content
stringlengths
23
1.05M
with AWS.Status; with AWS.Templates; with AWS.Services.Web_Block.Context; package @_Project_Name_@.Ajax is use AWS; use AWS.Services; procedure Onclick_Incr (Request : in Status.Data; Context : not null access Web_Block.Context.Object; Translations : in out Templates.Translate_Set); end @_Project_Name_@.Ajax;
with Text_IO; use Text_io; with Chebychev_Quadrature; with Ada.Numerics.Generic_Elementary_Functions; procedure cheby_quad_tst_1 is type Real is digits 15; package Maths is new Ada.Numerics.Generic_Elementary_Functions (Real); use Maths; No_Gauss_Pts : constant Positive := 2**16; package Quad is new Chebychev_Quadrature (Real, No_Gauss_Pts, Cos, Sin); use Quad; package rio is new Float_io(Real); use rio; X_First, X_Last, True_Area, True_Error : Real; Area : Real := 0.0; X_gauss : Gauss_Values; F_val : Function_Values; procedure Pause (s1,s2,s3,s4,s5,s6,s7,s8 : string := "") is Continue : Character := ' '; begin new_line; if S1 /= "" then put_line (S1); end if; if S2 /= "" then put_line (S2); end if; if S3 /= "" then put_line (S3); end if; if S4 /= "" then put_line (S4); end if; if S5 /= "" then put_line (S5); end if; if S6 /= "" then put_line (S6); end if; if S7 /= "" then put_line (S7); end if; if S8 /= "" then put_line (S8); end if; dialog: loop begin New_Line; Put ("Type a character to continue: "); Get_Immediate (Continue); exit dialog; exception when others => null; end; end loop dialog; new_line; end pause; begin X_First := 0.1; X_Last := 0.1777; New_Line; Pause ("Test Chebychev quadrature on sinusoids."); Sin_Test: for Pow in 1..30 loop Find_Gauss_Nodes (X_First, X_Last, X_gauss); for I in Gauss_Index loop F_val(I) := Sin (X_gauss(I)); end loop; Get_Integral(F_val, X_First, X_Last, Area); True_Area := -Cos(X_Last) + Cos(X_First); True_Error := Area - True_Area; new_line(1); put ("True_Error: "); put(True_Error); X_Last := X_Last + 1.7; end loop Sin_Test; X_First := -1.3; X_Last := -0.7777; New_Line; Pause ("Test Chebychev quadrature on the Exp function."); Exp_Test: for Pow in 1..30 loop --X_Last := X_Last + 3.7; X_First := X_First - 1.7; Find_Gauss_Nodes (X_First, X_Last, X_gauss); for I in Gauss_Index loop F_val(I) := Exp (X_gauss(I)); end loop; Get_Integral(F_val, X_First, X_Last, Area); True_Area := Exp (X_Last) - Exp (X_First); True_Error := (Area - True_Area) / Area; new_line(1); put ("True_Error: "); put(True_Error); end loop Exp_Test; X_First := -1.3; X_Last := -0.7777; New_Line; Pause ("Second test of Chebychev quadrature on the Exp function."); Exp2_Test: for Pow in 1..30 loop X_Last := X_Last + 1.7; --X_First := X_First - 4.7; Find_Gauss_Nodes (X_First, X_Last, X_gauss); for I in Gauss_Index loop F_val(I) := Exp (X_gauss(I)); end loop; Get_Integral(F_val, X_First, X_Last, Area); True_Area := Exp (X_Last) - Exp (X_First); True_Error := (Area - True_Area) / Area; new_line(1); put ("True_Error: "); put(True_Error); end loop Exp2_Test; X_First := 0.3; X_Last := 0.7777; new_line(2); New_Line; Pause ("Test Chebychev quadrature on the Log function."); Log_Test: for Pow in 1..30 loop X_First := X_First / 1.2; Find_Gauss_Nodes (X_First, X_Last, X_gauss); for I in Gauss_Index loop F_val(I) := 1.0 / (X_gauss(I)); end loop; Get_Integral(F_val, X_First, X_Last, Area); True_Area := Log (X_Last) - Log (X_First); True_Error := (Area - True_Area) / Area; new_line(1); put ("True_Error: "); put(True_Error); end loop Log_Test; X_First := 1.0; X_Last := 2.7; new_line(2); New_Line; Pause ("Second test of Chebychev quadrature on the Log function."); Log2_Test: for Pow in 1..30 loop X_Last := X_Last + 2.0; Find_Gauss_Nodes (X_First, X_Last, X_gauss); for I in Gauss_Index loop F_val(I) := 1.0 / (X_gauss(I)); end loop; Get_Integral(F_val, X_First, X_Last, Area); True_Area := Log (X_Last) - Log (X_First); True_Error := (Area - True_Area) / Area; new_line(1); put ("True_Error: "); put(True_Error); end loop Log2_Test; end cheby_quad_tst_1;
-- Copyright 2016-2019 NXP -- All rights reserved.SPDX-License-Identifier: BSD-3-Clause -- This spec has been automatically generated from LPC55S6x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package NXP_SVD.FLASH is pragma Preelaborate; --------------- -- Registers -- --------------- -- event register type EVENT_Register is record -- Write-only. When bit is set, the controller and flash are reset. RST : Boolean := False; -- Write-only. When bit is set, the controller wakes up from whatever -- low power or powerdown mode was active. WAKEUP : Boolean := False; -- Write-only. When bit is set, a running program/erase command is -- aborted. ABORT_k : Boolean := False; -- unspecified Reserved_3_31 : HAL.UInt29 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EVENT_Register use record RST at 0 range 0 .. 0; WAKEUP at 0 range 1 .. 1; ABORT_k at 0 range 2 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; subtype STARTA_STARTA_Field is HAL.UInt18; -- start (or only) address for next flash command type STARTA_Register is record -- Address / Start address for commands that take an address (range) as -- a parameter. STARTA : STARTA_STARTA_Field := 16#0#; -- unspecified Reserved_18_31 : HAL.UInt14 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for STARTA_Register use record STARTA at 0 range 0 .. 17; Reserved_18_31 at 0 range 18 .. 31; end record; subtype STOPA_STOPA_Field is HAL.UInt18; -- end address for next flash command, if command operates on address -- ranges type STOPA_Register is record -- Stop address for commands that take an address range as a parameter -- (the word specified by STOPA is included in the address range). STOPA : STOPA_STOPA_Field := 16#0#; -- unspecified Reserved_18_31 : HAL.UInt14 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for STOPA_Register use record STOPA at 0 range 0 .. 17; Reserved_18_31 at 0 range 18 .. 31; end record; -- data register, word 0-7; Memory data, or command parameter, or command result. -- data register, word 0-7; Memory data, or command parameter, or command -- result. type DATAW_Registers is array (0 .. 3) of HAL.UInt32 with Volatile; -- Clear interrupt enable bits type INT_CLR_ENABLE_Register is record -- Write-only. When a CLR_ENABLE bit is written to 1, the corresponding -- INT_ENABLE bit is cleared. FAIL : Boolean := False; -- Write-only. When a CLR_ENABLE bit is written to 1, the corresponding -- INT_ENABLE bit is cleared. ERR : Boolean := False; -- Write-only. When a CLR_ENABLE bit is written to 1, the corresponding -- INT_ENABLE bit is cleared. DONE : Boolean := False; -- Write-only. When a CLR_ENABLE bit is written to 1, the corresponding -- INT_ENABLE bit is cleared. ECC_ERR : Boolean := False; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for INT_CLR_ENABLE_Register use record FAIL at 0 range 0 .. 0; ERR at 0 range 1 .. 1; DONE at 0 range 2 .. 2; ECC_ERR at 0 range 3 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; -- Set interrupt enable bits type INT_SET_ENABLE_Register is record -- Write-only. When a SET_ENABLE bit is written to 1, the corresponding -- INT_ENABLE bit is set. FAIL : Boolean := False; -- Write-only. When a SET_ENABLE bit is written to 1, the corresponding -- INT_ENABLE bit is set. ERR : Boolean := False; -- Write-only. When a SET_ENABLE bit is written to 1, the corresponding -- INT_ENABLE bit is set. DONE : Boolean := False; -- Write-only. When a SET_ENABLE bit is written to 1, the corresponding -- INT_ENABLE bit is set. ECC_ERR : Boolean := False; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for INT_SET_ENABLE_Register use record FAIL at 0 range 0 .. 0; ERR at 0 range 1 .. 1; DONE at 0 range 2 .. 2; ECC_ERR at 0 range 3 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; -- Interrupt status bits type INT_STATUS_Register is record -- Read-only. This status bit is set if execution of a (legal) command -- failed. FAIL : Boolean; -- Read-only. This status bit is set if execution of an illegal command -- is detected. ERR : Boolean; -- Read-only. This status bit is set at the end of command execution. DONE : Boolean; -- Read-only. This status bit is set if, during a memory read operation -- (either a user-requested read, or a speculative read, or reads -- performed by a controller command), a correctable or uncorrectable -- error is detected by ECC decoding logic. ECC_ERR : Boolean; -- unspecified Reserved_4_31 : HAL.UInt28; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for INT_STATUS_Register use record FAIL at 0 range 0 .. 0; ERR at 0 range 1 .. 1; DONE at 0 range 2 .. 2; ECC_ERR at 0 range 3 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; -- Interrupt enable bits type INT_ENABLE_Register is record -- Read-only. If an INT_ENABLE bit is set, an interrupt request will be -- generated if the corresponding INT_STATUS bit is high. FAIL : Boolean; -- Read-only. If an INT_ENABLE bit is set, an interrupt request will be -- generated if the corresponding INT_STATUS bit is high. ERR : Boolean; -- Read-only. If an INT_ENABLE bit is set, an interrupt request will be -- generated if the corresponding INT_STATUS bit is high. DONE : Boolean; -- Read-only. If an INT_ENABLE bit is set, an interrupt request will be -- generated if the corresponding INT_STATUS bit is high. ECC_ERR : Boolean; -- unspecified Reserved_4_31 : HAL.UInt28; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for INT_ENABLE_Register use record FAIL at 0 range 0 .. 0; ERR at 0 range 1 .. 1; DONE at 0 range 2 .. 2; ECC_ERR at 0 range 3 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; -- Clear interrupt status bits type INT_CLR_STATUS_Register is record -- Write-only. When a CLR_STATUS bit is written to 1, the corresponding -- INT_STATUS bit is cleared. FAIL : Boolean := False; -- Write-only. When a CLR_STATUS bit is written to 1, the corresponding -- INT_STATUS bit is cleared. ERR : Boolean := False; -- Write-only. When a CLR_STATUS bit is written to 1, the corresponding -- INT_STATUS bit is cleared. DONE : Boolean := False; -- Write-only. When a CLR_STATUS bit is written to 1, the corresponding -- INT_STATUS bit is cleared. ECC_ERR : Boolean := False; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for INT_CLR_STATUS_Register use record FAIL at 0 range 0 .. 0; ERR at 0 range 1 .. 1; DONE at 0 range 2 .. 2; ECC_ERR at 0 range 3 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; -- Set interrupt status bits type INT_SET_STATUS_Register is record -- Write-only. When a SET_STATUS bit is written to 1, the corresponding -- INT_STATUS bit is set. FAIL : Boolean := False; -- Write-only. When a SET_STATUS bit is written to 1, the corresponding -- INT_STATUS bit is set. ERR : Boolean := False; -- Write-only. When a SET_STATUS bit is written to 1, the corresponding -- INT_STATUS bit is set. DONE : Boolean := False; -- Write-only. When a SET_STATUS bit is written to 1, the corresponding -- INT_STATUS bit is set. ECC_ERR : Boolean := False; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for INT_SET_STATUS_Register use record FAIL at 0 range 0 .. 0; ERR at 0 range 1 .. 1; DONE at 0 range 2 .. 2; ECC_ERR at 0 range 3 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; subtype MODULE_ID_APERTURE_Field is HAL.UInt8; subtype MODULE_ID_MINOR_REV_Field is HAL.UInt4; subtype MODULE_ID_MAJOR_REV_Field is HAL.UInt4; subtype MODULE_ID_ID_Field is HAL.UInt16; -- Controller+Memory module identification type MODULE_ID_Register is record -- Read-only. Aperture i. APERTURE : MODULE_ID_APERTURE_Field; -- Read-only. Minor revision i. MINOR_REV : MODULE_ID_MINOR_REV_Field; -- Read-only. Major revision i. MAJOR_REV : MODULE_ID_MAJOR_REV_Field; -- Read-only. Identifier. ID : MODULE_ID_ID_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MODULE_ID_Register use record APERTURE at 0 range 0 .. 7; MINOR_REV at 0 range 8 .. 11; MAJOR_REV at 0 range 12 .. 15; ID at 0 range 16 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- FLASH type FLASH_Peripheral is record -- command register CMD : aliased HAL.UInt32; -- event register EVENT : aliased EVENT_Register; -- start (or only) address for next flash command STARTA : aliased STARTA_Register; -- end address for next flash command, if command operates on address -- ranges STOPA : aliased STOPA_Register; -- data register, word 0-7; Memory data, or command parameter, or -- command result. DATAW : aliased DATAW_Registers; -- Clear interrupt enable bits INT_CLR_ENABLE : aliased INT_CLR_ENABLE_Register; -- Set interrupt enable bits INT_SET_ENABLE : aliased INT_SET_ENABLE_Register; -- Interrupt status bits INT_STATUS : aliased INT_STATUS_Register; -- Interrupt enable bits INT_ENABLE : aliased INT_ENABLE_Register; -- Clear interrupt status bits INT_CLR_STATUS : aliased INT_CLR_STATUS_Register; -- Set interrupt status bits INT_SET_STATUS : aliased INT_SET_STATUS_Register; -- Controller+Memory module identification MODULE_ID : aliased MODULE_ID_Register; end record with Volatile; for FLASH_Peripheral use record CMD at 16#0# range 0 .. 31; EVENT at 16#4# range 0 .. 31; STARTA at 16#10# range 0 .. 31; STOPA at 16#14# range 0 .. 31; DATAW at 16#80# range 0 .. 127; INT_CLR_ENABLE at 16#FD8# range 0 .. 31; INT_SET_ENABLE at 16#FDC# range 0 .. 31; INT_STATUS at 16#FE0# range 0 .. 31; INT_ENABLE at 16#FE4# range 0 .. 31; INT_CLR_STATUS at 16#FE8# range 0 .. 31; INT_SET_STATUS at 16#FEC# range 0 .. 31; MODULE_ID at 16#FFC# range 0 .. 31; end record; -- FLASH FLASH_Periph : aliased FLASH_Peripheral with Import, Address => System'To_Address (16#40034000#); end NXP_SVD.FLASH;
with ada.unchecked_Deallocation; package body openGL.Model is --------- --- Forge -- procedure define (Self : out Item) is null; procedure deallocate is new ada.unchecked_Deallocation (Geometry.views, access_Geometry_views); procedure destroy (Self : in out Item) is begin if Self.opaque_Geometries /= null then for i in Self.opaque_Geometries'Range loop Geometry.free (Self.opaque_Geometries (i)); end loop; deallocate (Self.opaque_Geometries); end if; if Self.lucid_Geometries /= null then for i in Self.lucid_Geometries'Range loop Geometry.free (Self.lucid_Geometries (i)); end loop; deallocate (Self.lucid_Geometries); end if; end destroy; procedure free (Self : in out View) is procedure deallocate is new ada.unchecked_Deallocation (Model.item'Class, Model.view); begin Self.destroy; deallocate (Self); end free; -------------- --- Attributes -- function Id (Self : in Item'Class) return Model_Id is begin return Self.Id; end Id; procedure Id_is (Self : in out Item'Class; Now : in Model_Id) is begin Self.Id := Now; end Id_is; procedure set_Bounds (Self : in out Item) is begin Self.Bounds := null_Bounds; if Self.opaque_Geometries /= null then for Each of Self.opaque_Geometries.all loop Self.Bounds.Box := Self.Bounds.Box or Each.Bounds.Box; Self.Bounds.Ball := Real'Max (Self.Bounds.Ball, Each.Bounds.Ball); end loop; end if; if Self.lucid_Geometries /= null then for Each of Self.lucid_Geometries.all loop Self.Bounds.Box := Self.Bounds.Box or Each.Bounds.Box; Self.Bounds.Ball := Real'Max (Self.Bounds.Ball, Each.Bounds.Ball); end loop; end if; end set_Bounds; procedure create_GL_Geometries (Self : in out Item'Class; Textures : access Texture.name_Map_of_texture'Class; Fonts : in Font.font_id_Map_of_font) is all_Geometries : constant Geometry.views := Self.to_GL_Geometries (Textures, Fonts); opaque_Faces : Geometry.views (1 .. all_Geometries'Length); opaque_Count : Index_t := 0; lucid_Faces : Geometry.views (1 .. all_Geometries'Length); lucid_Count : Index_t := 0; begin Self.Bounds := null_Bounds; -- Separate lucid and opaque geometries. -- for i in all_Geometries'Range loop if all_Geometries (i).is_Transparent then lucid_Count := lucid_Count + 1; lucid_Faces (lucid_Count) := all_Geometries (i); else opaque_Count := opaque_Count + 1; opaque_Faces (opaque_Count) := all_Geometries (i); end if; Self.Bounds.Box := Self.Bounds.Box or all_Geometries (i).Bounds.Box; Self.Bounds.Ball:= Real'Max (Self.Bounds.Ball, all_Geometries (i).Bounds.Ball); end loop; -- Free any existing geometries. -- if Self.opaque_Geometries /= null then for i in Self.opaque_Geometries'Range loop Geometry.free (Self.opaque_Geometries (i)); end loop; deallocate (Self.opaque_Geometries); end if; if Self.lucid_Geometries /= null then for i in Self.lucid_Geometries'Range loop Geometry.free (Self.lucid_Geometries (i)); end loop; deallocate (Self.lucid_Geometries); end if; -- Create new gemometries. -- Self.opaque_Geometries := new Geometry.views' (opaque_Faces (1 .. opaque_Count)); Self. lucid_Geometries := new Geometry.views' ( lucid_Faces (1 .. lucid_Count)); Self.needs_Rebuild := False; end create_GL_Geometries; function is_Modified (Self : in Item) return Boolean is pragma unreferenced (Self); begin return False; end is_Modified; function Bounds (Self : in Item) return openGL.Bounds is begin return Self.Bounds; end Bounds; function opaque_Geometries (Self : in Item) return access_Geometry_views is begin return Self.opaque_Geometries; end opaque_Geometries; function lucid_Geometries (Self : in Item) return access_Geometry_views is begin return Self.lucid_Geometries; end lucid_Geometries; function needs_Rebuild (Self : in Item) return Boolean is begin return Boolean (Self.needs_Rebuild); end needs_Rebuild; procedure needs_Rebuild (Self : in out Item) is begin Self.needs_Rebuild := True; end needs_Rebuild; end openGL.Model;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ -- Behavior is a specification of how its context classifier changes state -- over time. This specification may be either a definition of possible -- behavior execution or emergent behavior, or a selective illustration of an -- interesting subset of possible executions. The latter form is typically -- used for capturing examples, such as a trace of a particular execution. -- -- A behavior owns zero or more parameter sets. ------------------------------------------------------------------------------ limited with AMF.UML.Behavioral_Features; limited with AMF.UML.Behaviored_Classifiers; limited with AMF.UML.Behaviors.Collections; with AMF.UML.Classes; limited with AMF.UML.Constraints.Collections; limited with AMF.UML.Parameter_Sets.Collections; limited with AMF.UML.Parameters.Collections; package AMF.UML.Behaviors is pragma Preelaborate; type UML_Behavior is limited interface and AMF.UML.Classes.UML_Class; type UML_Behavior_Access is access all UML_Behavior'Class; for UML_Behavior_Access'Storage_Size use 0; not overriding function Get_Context (Self : not null access constant UML_Behavior) return AMF.UML.Behaviored_Classifiers.UML_Behaviored_Classifier_Access is abstract; -- Getter of Behavior::context. -- -- The classifier that is the context for the execution of the behavior. -- If the behavior is owned by a BehavioredClassifier, that classifier is -- the context. Otherwise, the context is the first BehavioredClassifier -- reached by following the chain of owner relationships. For example, -- following this algorithm, the context of an entry action in a state -- machine is the classifier that owns the state machine. The features of -- the context classifier as well as the elements visible to the context -- classifier are visible to the behavior. not overriding function Get_Is_Reentrant (Self : not null access constant UML_Behavior) return Boolean is abstract; -- Getter of Behavior::isReentrant. -- -- Tells whether the behavior can be invoked while it is still executing -- from a previous invocation. not overriding procedure Set_Is_Reentrant (Self : not null access UML_Behavior; To : Boolean) is abstract; -- Setter of Behavior::isReentrant. -- -- Tells whether the behavior can be invoked while it is still executing -- from a previous invocation. not overriding function Get_Owned_Parameter (Self : not null access constant UML_Behavior) return AMF.UML.Parameters.Collections.Ordered_Set_Of_UML_Parameter is abstract; -- Getter of Behavior::ownedParameter. -- -- References a list of parameters to the behavior which describes the -- order and type of arguments that can be given when the behavior is -- invoked and of the values which will be returned when the behavior -- completes its execution. not overriding function Get_Owned_Parameter_Set (Self : not null access constant UML_Behavior) return AMF.UML.Parameter_Sets.Collections.Set_Of_UML_Parameter_Set is abstract; -- Getter of Behavior::ownedParameterSet. -- -- The ParameterSets owned by this Behavior. not overriding function Get_Postcondition (Self : not null access constant UML_Behavior) return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint is abstract; -- Getter of Behavior::postcondition. -- -- An optional set of Constraints specifying what is fulfilled after the -- execution of the behavior is completed, if its precondition was -- fulfilled before its invocation. not overriding function Get_Precondition (Self : not null access constant UML_Behavior) return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint is abstract; -- Getter of Behavior::precondition. -- -- An optional set of Constraints specifying what must be fulfilled when -- the behavior is invoked. not overriding function Get_Redefined_Behavior (Self : not null access constant UML_Behavior) return AMF.UML.Behaviors.Collections.Set_Of_UML_Behavior is abstract; -- Getter of Behavior::redefinedBehavior. -- -- References a behavior that this behavior redefines. A subtype of -- Behavior may redefine any other subtype of Behavior. If the behavior -- implements a behavioral feature, it replaces the redefined behavior. If -- the behavior is a classifier behavior, it extends the redefined -- behavior. not overriding function Get_Specification (Self : not null access constant UML_Behavior) return AMF.UML.Behavioral_Features.UML_Behavioral_Feature_Access is abstract; -- Getter of Behavior::specification. -- -- Designates a behavioral feature that the behavior implements. The -- behavioral feature must be owned by the classifier that owns the -- behavior or be inherited by it. The parameters of the behavioral -- feature and the implementing behavior must match. A behavior does not -- need to have a specification, in which case it either is the classifer -- behavior of a BehavioredClassifier or it can only be invoked by another -- behavior of the classifier. not overriding procedure Set_Specification (Self : not null access UML_Behavior; To : AMF.UML.Behavioral_Features.UML_Behavioral_Feature_Access) is abstract; -- Setter of Behavior::specification. -- -- Designates a behavioral feature that the behavior implements. The -- behavioral feature must be owned by the classifier that owns the -- behavior or be inherited by it. The parameters of the behavioral -- feature and the implementing behavior must match. A behavior does not -- need to have a specification, in which case it either is the classifer -- behavior of a BehavioredClassifier or it can only be invoked by another -- behavior of the classifier. not overriding function Context (Self : not null access constant UML_Behavior) return AMF.UML.Behaviored_Classifiers.UML_Behaviored_Classifier_Access is abstract; -- Operation Behavior::context. -- -- Missing derivation for Behavior::/context : BehavioredClassifier end AMF.UML.Behaviors;
with Ada.Exception_Identification.From_Here; with System.Address_To_Named_Access_Conversions; with System.UTF_Conversions.From_8_To_16; with System.UTF_Conversions.From_16_To_8; with C.winnls; with C.winnt; package body System.Native_Text_IO is use Ada.Exception_Identification.From_Here; use type Ada.Streams.Stream_Element_Offset; use type C.signed_int; -- C.windef.WINBOOL use type C.windef.DWORD; use type C.windef.WORD; use type C.winnt.SHORT; use type C.winnt.WCHAR; package LPSTR_Conv is new Address_To_Named_Access_Conversions (C.char, C.winnt.LPSTR); function Processed_Input_Is_Enabled (Handle : Handle_Type) return Boolean; function Processed_Input_Is_Enabled (Handle : Handle_Type) return Boolean is Mode : aliased C.windef.DWORD; begin return C.wincon.GetConsoleMode (Handle, Mode'Access) /= C.windef.FALSE and then (Mode and C.wincon.ENABLE_PROCESSED_INPUT) /= 0; end Processed_Input_Is_Enabled; procedure Read_Buffer_Trailing_From_Terminal ( Handle : Handle_Type; Buffer : in out Buffer_Type; Out_Last : out Integer; -- no error since a leading data is existing Leading : C.winnt.WCHAR); procedure Read_Buffer_Trailing_From_Terminal ( Handle : Handle_Type; Buffer : in out Buffer_Type; Out_Last : out Integer; Leading : C.winnt.WCHAR) is Wide_Buffer : Wide_String (1 .. 2); Wide_Buffer_As_C : C.winnt.WCHAR_array (0 .. 1); for Wide_Buffer_As_C'Address use Wide_Buffer'Address; Wide_Buffer_Length : Natural; Read_Size : aliased C.windef.DWORD; UTF_16_Seq : Natural; Sequence_Status : UTF_Conversions.Sequence_Status_Type; -- ignore begin Wide_Buffer_As_C (0) := Leading; if Wide_Buffer_As_C (0) = C.winnt.WCHAR'Val (0) then Out_Last := 0; -- no data else Wide_Buffer_Length := 1; UTF_Conversions.UTF_16_Sequence ( Wide_Character'Val (C.winnt.WCHAR'Pos (Wide_Buffer_As_C (0))), UTF_16_Seq, Sequence_Status); if UTF_16_Seq = 2 and then C.wincon.ReadConsoleW ( hConsoleInput => Handle, lpBuffer => C.windef.LPVOID (Wide_Buffer_As_C (1)'Address), nNumberOfCharsToRead => 1, lpNumberOfCharsRead => Read_Size'Access, lpReserved => C.windef.LPVOID (Null_Address)) /= C.windef.FALSE and then Read_Size > 0 then Wide_Buffer_Length := Wide_Buffer_Length + Natural (Read_Size); end if; UTF_Conversions.From_16_To_8.Convert ( Wide_Buffer (1 .. Wide_Buffer_Length), Buffer, Out_Last); end if; end Read_Buffer_Trailing_From_Terminal; procedure GetConsoleScreenBufferInfo ( ConsoleOutput : C.winnt.HANDLE; ConsoleScreenBufferInfo : access C.wincon.CONSOLE_SCREEN_BUFFER_INFO); procedure GetConsoleScreenBufferInfo ( ConsoleOutput : C.winnt.HANDLE; ConsoleScreenBufferInfo : access C.wincon.CONSOLE_SCREEN_BUFFER_INFO) is begin if C.wincon.GetConsoleScreenBufferInfo ( ConsoleOutput, ConsoleScreenBufferInfo) = C.windef.FALSE then Raise_Exception (Device_Error'Identity); end if; end GetConsoleScreenBufferInfo; procedure SetConsoleScreenBufferSize_With_Adjusting ( ConsoleOutput : C.winnt.HANDLE; Size : C.wincon.COORD; Current : C.winnt.HANDLE); procedure SetConsoleScreenBufferSize_With_Adjusting ( ConsoleOutput : C.winnt.HANDLE; Size : C.wincon.COORD; Current : C.winnt.HANDLE) is Info, Old_Info : aliased C.wincon.CONSOLE_SCREEN_BUFFER_INFO; Old_Size : C.wincon.COORD; Rect : aliased C.wincon.SMALL_RECT; begin -- resize viewport to smaller than current window GetConsoleScreenBufferInfo (Current, Old_Info'Access); Old_Size.X := Old_Info.srWindow.Right - Old_Info.srWindow.Left + 1; Old_Size.Y := Old_Info.srWindow.Bottom - Old_Info.srWindow.Top + 1; if Size.X < Old_Size.X or else Size.Y < Old_Size.Y then Rect.Left := 0; Rect.Top := 0; Rect.Right := C.winnt.SHORT'Min (Size.X, Old_Size.X) - 1; Rect.Bottom := C.winnt.SHORT'Min (Size.Y, Old_Size.Y) - 1; if C.wincon.SetConsoleWindowInfo (ConsoleOutput, 1, Rect'Access) = C.windef.FALSE then Raise_Exception (Layout_Error'Identity); end if; end if; -- resize screen buffer if C.wincon.SetConsoleScreenBufferSize (ConsoleOutput, Size) = C.windef.FALSE then Raise_Exception (Layout_Error'Identity); -- Size is too large end if; -- maximize viewport GetConsoleScreenBufferInfo (ConsoleOutput, Info'Access); Rect.Left := 0; Rect.Top := 0; Rect.Right := Info.dwMaximumWindowSize.X - 1; Rect.Bottom := Info.dwMaximumWindowSize.Y - 1; if C.wincon.SetConsoleWindowInfo (ConsoleOutput, 1, Rect'Access) = C.windef.FALSE then Raise_Exception (Device_Error'Identity); end if; end SetConsoleScreenBufferSize_With_Adjusting; -- implementation procedure To_UTF_8 ( Buffer : aliased DBCS_Buffer_Type; Last : Natural; Out_Buffer : out Buffer_Type; Out_Last : out Natural) is Wide_Buffer : Wide_String (1 .. 2); Wide_Buffer_As_C : C.winnt.WCHAR_array (0 .. 1); for Wide_Buffer_As_C'Address use Wide_Buffer'Address; Wide_Buffer_Length : C.signed_int; DBCS_Seq : Natural; begin DBCS_Seq := 1 -- leading byte + Boolean'Pos ( C.winnls.IsDBCSLeadByte ( C.windef.BYTE'(Character'Pos (Buffer (1)))) /= C.windef.FALSE); if Last = DBCS_Seq then Wide_Buffer_Length := C.winnls.MultiByteToWideChar ( C.winnls.CP_ACP, 0, LPSTR_Conv.To_Pointer (Buffer (1)'Address), C.signed_int (Last), Wide_Buffer_As_C (0)'Access, 2); UTF_Conversions.From_16_To_8.Convert ( Wide_Buffer (1 .. Natural (Wide_Buffer_Length)), Out_Buffer, Out_Last); else Out_Last := 0; end if; end To_UTF_8; procedure To_DBCS ( Buffer : Buffer_Type; Last : Natural; Out_Buffer : aliased out DBCS_Buffer_Type; Out_Last : out Natural) is Wide_Buffer : Wide_String (1 .. 2); Wide_Buffer_Last : Natural; Wide_Buffer_As_C : C.winnt.WCHAR_array (0 .. 1); for Wide_Buffer_As_C'Address use Wide_Buffer'Address; Out_Length : C.signed_int; begin UTF_Conversions.From_8_To_16.Convert ( Buffer (1 .. Last), Wide_Buffer, Wide_Buffer_Last); Out_Length := C.winnls.WideCharToMultiByte ( C.winnls.CP_ACP, 0, Wide_Buffer_As_C (0)'Access, C.signed_int (Wide_Buffer_Last), LPSTR_Conv.To_Pointer (Out_Buffer (1)'Address), Out_Buffer'Length, null, null); if Out_Length = 0 then Out_Buffer (1) := '?'; Out_Last := 1; else Out_Last := Natural (Out_Length); end if; end To_DBCS; procedure Terminal_Get ( Handle : Handle_Type; Item : Address; Length : Ada.Streams.Stream_Element_Offset; Out_Length : out Ada.Streams.Stream_Element_Offset) is pragma Unreferenced (Length); Buffer : Buffer_Type; for Buffer'Address use Item; Wide_Buffer : C.winnt.WCHAR_array (0 .. 1); Read_Size : aliased C.windef.DWORD; begin if C.wincon.ReadConsole ( hConsoleInput => Handle, lpBuffer => C.windef.LPVOID (Wide_Buffer (0)'Address), nNumberOfCharsToRead => 1, lpNumberOfCharsRead => Read_Size'Access, lpReserved => C.windef.LPVOID (Null_Address)) = C.windef.FALSE then Out_Length := -1; -- error elsif Read_Size = 0 or else ( Wide_Buffer (0) = C.winnt.WCHAR'Val (16#1A#) -- Control+Z and then Processed_Input_Is_Enabled (Handle)) then Out_Length := 0; -- no data else Read_Buffer_Trailing_From_Terminal ( Handle, Buffer, Natural (Out_Length), Wide_Buffer (0)); end if; end Terminal_Get; procedure Terminal_Get_Immediate ( Handle : Handle_Type; Item : Address; Length : Ada.Streams.Stream_Element_Offset; Out_Length : out Ada.Streams.Stream_Element_Offset) is pragma Unreferenced (Length); Buffer : Buffer_Type; for Buffer'Address use Item; Event_Count : aliased C.windef.DWORD; Read_Size : aliased C.windef.DWORD; Event : aliased C.wincon.INPUT_RECORD; begin if C.wincon.GetNumberOfConsoleInputEvents (Handle, Event_Count'Access) = C.windef.FALSE then Out_Length := -1; -- error elsif Event_Count = 0 then Out_Length := 0; -- no data elsif C.wincon.ReadConsoleInput ( hConsoleInput => Handle, lpBuffer => Event'Access, nLength => 1, lpNumberOfEventsRead => Read_Size'Access) = C.windef.FALSE then Out_Length := -1; -- error elsif Read_Size = 0 or else Event.EventType /= C.wincon.KEY_EVENT or else Event.Event.KeyEvent.bKeyDown = C.windef.FALSE then Out_Length := 0; -- no data else Read_Buffer_Trailing_From_Terminal ( Handle, Buffer, Natural (Out_Length), Event.Event.KeyEvent.uChar.UnicodeChar); end if; end Terminal_Get_Immediate; procedure Terminal_Put ( Handle : Handle_Type; Item : Address; Length : Ada.Streams.Stream_Element_Offset; Out_Length : out Ada.Streams.Stream_Element_Offset) is Buffer : Buffer_Type; for Buffer'Address use Item; Wide_Buffer : Wide_String (1 .. 2); Wide_Buffer_Last : Natural; Written : aliased C.windef.DWORD; begin UTF_Conversions.From_8_To_16.Convert ( Buffer (1 .. Natural (Length)), Wide_Buffer, Wide_Buffer_Last); if C.wincon.WriteConsoleW ( hConsoleOutput => Handle, lpBuffer => C.windef.LPCVOID (Wide_Buffer (1)'Address), nNumberOfCharsToWrite => C.windef.DWORD (Wide_Buffer_Last), lpNumberOfCharsWritten => Written'Access, lpReserved => C.windef.LPVOID (Null_Address)) = C.windef.FALSE then Out_Length := -1; -- error else Out_Length := Ada.Streams.Stream_Element_Offset (Written); end if; end Terminal_Put; procedure Terminal_Size ( Handle : Handle_Type; Line_Length, Page_Length : out Natural) is Info : aliased C.wincon.CONSOLE_SCREEN_BUFFER_INFO; begin GetConsoleScreenBufferInfo (Handle, Info'Access); Line_Length := Natural (Info.dwSize.X); Page_Length := Natural (Info.dwSize.Y); end Terminal_Size; procedure Set_Terminal_Size ( Handle : Handle_Type; Line_Length, Page_Length : Natural) is begin SetConsoleScreenBufferSize_With_Adjusting ( Handle, C.wincon.COORD'( X => C.winnt.SHORT (Line_Length), Y => C.winnt.SHORT (Page_Length)), Handle); end Set_Terminal_Size; procedure Terminal_View ( Handle : Handle_Type; Left, Top : out Positive; Right, Bottom : out Natural) is Info : aliased C.wincon.CONSOLE_SCREEN_BUFFER_INFO; begin GetConsoleScreenBufferInfo (Handle, Info'Access); Left := Positive (Info.srWindow.Left + 1); Top := Positive (Info.srWindow.Top + 1); Right := Natural (Info.srWindow.Right + 1); Bottom := Natural (Info.srWindow.Bottom + 1); end Terminal_View; procedure Terminal_Position ( Handle : Handle_Type; Col, Line : out Positive) is Info : aliased C.wincon.CONSOLE_SCREEN_BUFFER_INFO; begin GetConsoleScreenBufferInfo (Handle, Info'Access); Col := Positive (Info.dwCursorPosition.X + 1); Line := Positive (Info.dwCursorPosition.Y + 1); end Terminal_Position; procedure Set_Terminal_Position ( Handle : Handle_Type; Col, Line : Positive) is begin if C.wincon.SetConsoleCursorPosition ( Handle, C.wincon.COORD'( X => C.winnt.SHORT (Col) - 1, Y => C.winnt.SHORT (Line) - 1)) = C.windef.FALSE then Raise_Exception (Layout_Error'Identity); end if; end Set_Terminal_Position; procedure Set_Terminal_Col ( Handle : Handle_Type; To : Positive) is Col, Line : Positive; begin Terminal_Position (Handle, Col, Line); Set_Terminal_Position (Handle, To, Line); end Set_Terminal_Col; procedure Terminal_Clear ( Handle : Handle_Type) is Info : aliased C.wincon.CONSOLE_SCREEN_BUFFER_INFO; begin GetConsoleScreenBufferInfo ( Handle, Info'Access); declare Clear_Char_Info : constant C.wincon.CHAR_INFO := ( Char => ( Unchecked_Tag => 0, UnicodeChar => C.winnt.WCHAR'Val (16#20#)), Attributes => Info.wAttributes); Buffer : aliased constant array (0 .. Info.dwSize.Y - 1, 0 .. Info.dwSize.X - 1) of aliased C.wincon.CHAR_INFO := (others => (others => Clear_Char_Info)); Region : aliased C.wincon.SMALL_RECT; begin Region.Left := 0; Region.Top := 0; Region.Right := Info.dwSize.X - 1; Region.Bottom := Info.dwSize.Y - 1; if C.wincon.WriteConsoleOutputW ( hConsoleOutput => Handle, lpBuffer => Buffer (0, 0)'Access, dwBufferSize => Info.dwSize, dwBufferCoord => (X => 0, Y => 0), lpWriteRegion => Region'Access) = C.windef.FALSE then Raise_Exception (Device_Error'Identity); end if; end; if C.wincon.SetConsoleCursorPosition (Handle, (X => 0, Y => 0)) = C.windef.FALSE then Raise_Exception (Device_Error'Identity); end if; end Terminal_Clear; procedure Set_Non_Canonical_Mode ( Handle : Handle_Type; Wait : Boolean; Saved_Settings : aliased out Setting) is pragma Unreferenced (Wait); begin -- get and unset line-input mode if C.wincon.GetConsoleMode (Handle, Saved_Settings'Access) = C.windef.FALSE or else C.wincon.SetConsoleMode ( Handle, Saved_Settings and not ( C.wincon.ENABLE_ECHO_INPUT or C.wincon.ENABLE_LINE_INPUT)) = C.windef.FALSE then Raise_Exception (Device_Error'Identity); end if; end Set_Non_Canonical_Mode; procedure Restore ( Handle : Handle_Type; Settings : aliased Setting) is begin if C.wincon.SetConsoleMode (Handle, Settings) = C.windef.FALSE then Raise_Exception (Device_Error'Identity); end if; end Restore; procedure Set_Terminal_Attributes ( Handle : Handle_Type; Attributes : C.windef.WORD) is begin if C.wincon.SetConsoleTextAttribute (Handle, Attributes) = C.windef.FALSE then Raise_Exception (Device_Error'Identity); end if; end Set_Terminal_Attributes; procedure Save_State (Handle : Handle_Type; To_State : out Output_State) is Info : aliased C.wincon.CONSOLE_SCREEN_BUFFER_INFO; begin if C.wincon.GetConsoleScreenBufferInfo (Handle, Info'Access) = C.windef.FALSE then Raise_Exception (Device_Error'Identity); end if; To_State.Position := Info.dwCursorPosition; To_State.Attributes := Info.wAttributes; end Save_State; procedure Reset_State (Handle : Handle_Type; From_State : Output_State) is begin Set_Terminal_Attributes (Handle, From_State.Attributes); Set_Terminal_Position (Handle, Col => Integer (From_State.Position.X + 1), Line => Integer (From_State.Position.Y + 1)); end Reset_State; end System.Native_Text_IO;
-- Some USB Device controllers require the address to be set earlier than -- the standard calls for. That is, before the set_address setup request -- is acknoledged with a Zero-Lenght-Packet. with USB_Testing; use USB_Testing; with USB_Testing.UDC_Stub; use USB_Testing.UDC_Stub; with USB_Testing.UDC_Scenarios; with HAL; use HAL; procedure Main is Scenario : aliased constant UDC_Stub.Stub_Scenario := UDC_Scenarios.Enumeration (Verbose => False) & UDC_Scenarios.Set_Address (Verbose => True); RX_Data : aliased constant UInt8_Array := (0 .. 1 => 0); begin USB_Testing.UDC_Scenarios.Basic_UDC_Test (Scenario, RX_Data, Early_Address => True); end Main;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ E L I M -- -- -- -- B o d y -- -- -- -- Copyright (C) 1997-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 Einfo; use Einfo; with Errout; use Errout; with Lib; use Lib; with Namet; use Namet; with Nlists; use Nlists; with Opt; use Opt; with Sem; use Sem; with Sem_Aux; use Sem_Aux; with Sem_Prag; use Sem_Prag; with Sem_Util; use Sem_Util; with Sinput; use Sinput; with Sinfo; use Sinfo; with Snames; use Snames; with Stand; use Stand; with Stringt; use Stringt; with Table; with GNAT.HTable; use GNAT.HTable; package body Sem_Elim is No_Elimination : Boolean; -- Set True if no Eliminate pragmas active --------------------- -- Data Structures -- --------------------- -- A single pragma Eliminate is represented by the following record type Elim_Data; type Access_Elim_Data is access Elim_Data; type Names is array (Nat range <>) of Name_Id; -- Type used to represent set of names. Used for names in Unit_Name -- and also the set of names in Argument_Types. type Access_Names is access Names; type Elim_Data is record Unit_Name : Access_Names; -- Unit name, broken down into a set of names (e.g. A.B.C is -- represented as Name_Id values for A, B, C in sequence). Entity_Name : Name_Id; -- Entity name if Entity parameter if present. If no Entity parameter -- was supplied, then Entity_Node is set to Empty, and the Entity_Name -- field contains the last identifier name in the Unit_Name. Entity_Scope : Access_Names; -- Static scope of the entity within the compilation unit represented by -- Unit_Name. Entity_Node : Node_Id; -- Save node of entity argument, for posting error messages. Set -- to Empty if there is no entity argument. Parameter_Types : Access_Names; -- Set to set of names given for parameter types. If no parameter -- types argument is present, this argument is set to null. Result_Type : Name_Id; -- Result type name if Result_Types parameter present, No_Name if not Source_Location : Name_Id; -- String describing the source location of subprogram defining name if -- Source_Location parameter present, No_Name if not Hash_Link : Access_Elim_Data; -- Link for hash table use Homonym : Access_Elim_Data; -- Pointer to next entry with same key Prag : Node_Id; -- Node_Id for Eliminate pragma end record; ---------------- -- Hash_Table -- ---------------- -- Setup hash table using the Entity_Name field as the hash key subtype Element is Elim_Data; subtype Elmt_Ptr is Access_Elim_Data; subtype Key is Name_Id; type Header_Num is range 0 .. 1023; Null_Ptr : constant Elmt_Ptr := null; ---------------------- -- Hash_Subprograms -- ---------------------- package Hash_Subprograms is function Equal (F1, F2 : Key) return Boolean; pragma Inline (Equal); function Get_Key (E : Elmt_Ptr) return Key; pragma Inline (Get_Key); function Hash (F : Key) return Header_Num; pragma Inline (Hash); function Next (E : Elmt_Ptr) return Elmt_Ptr; pragma Inline (Next); procedure Set_Next (E : Elmt_Ptr; Next : Elmt_Ptr); pragma Inline (Set_Next); end Hash_Subprograms; package body Hash_Subprograms is ----------- -- Equal -- ----------- function Equal (F1, F2 : Key) return Boolean is begin return F1 = F2; end Equal; ------------- -- Get_Key -- ------------- function Get_Key (E : Elmt_Ptr) return Key is begin return E.Entity_Name; end Get_Key; ---------- -- Hash -- ---------- function Hash (F : Key) return Header_Num is begin return Header_Num (Int (F) mod 1024); end Hash; ---------- -- Next -- ---------- function Next (E : Elmt_Ptr) return Elmt_Ptr is begin return E.Hash_Link; end Next; -------------- -- Set_Next -- -------------- procedure Set_Next (E : Elmt_Ptr; Next : Elmt_Ptr) is begin E.Hash_Link := Next; end Set_Next; end Hash_Subprograms; ------------ -- Tables -- ------------ -- The following table records the data for each pragma, using the -- entity name as the hash key for retrieval. Entries in this table -- are set by Process_Eliminate_Pragma and read by Check_Eliminated. package Elim_Hash_Table is new Static_HTable ( Header_Num => Header_Num, Element => Element, Elmt_Ptr => Elmt_Ptr, Null_Ptr => Null_Ptr, Set_Next => Hash_Subprograms.Set_Next, Next => Hash_Subprograms.Next, Key => Key, Get_Key => Hash_Subprograms.Get_Key, Hash => Hash_Subprograms.Hash, Equal => Hash_Subprograms.Equal); -- The following table records entities for subprograms that are -- eliminated, and corresponding eliminate pragmas that caused the -- elimination. Entries in this table are set by Check_Eliminated -- and read by Eliminate_Error_Msg. type Elim_Entity_Entry is record Prag : Node_Id; Subp : Entity_Id; end record; package Elim_Entities is new Table.Table ( Table_Component_Type => Elim_Entity_Entry, Table_Index_Type => Name_Id'Base, Table_Low_Bound => First_Name_Id, Table_Initial => 50, Table_Increment => 200, Table_Name => "Elim_Entries"); ---------------------- -- Check_Eliminated -- ---------------------- procedure Check_Eliminated (E : Entity_Id) is Elmt : Access_Elim_Data; Scop : Entity_Id; Form : Entity_Id; Up : Nat; begin if No_Elimination then return; -- Elimination of objects and types is not implemented yet elsif Ekind (E) not in Subprogram_Kind then return; end if; -- Loop through homonyms for this key Elmt := Elim_Hash_Table.Get (Chars (E)); while Elmt /= null loop Check_Homonyms : declare procedure Set_Eliminated; -- Set current subprogram entity as eliminated -------------------- -- Set_Eliminated -- -------------------- procedure Set_Eliminated is Overridden : Entity_Id; begin if Is_Dispatching_Operation (E) then -- If an overriding dispatching primitive is eliminated then -- its parent must have been eliminated. If the parent is an -- inherited operation, check the operation that it renames, -- because flag Eliminated is only set on source operations. Overridden := Overridden_Operation (E); if Present (Overridden) and then not Comes_From_Source (Overridden) and then Present (Alias (Overridden)) then Overridden := Alias (Overridden); end if; if Present (Overridden) and then not Is_Eliminated (Overridden) and then not Is_Abstract_Subprogram (Overridden) then Error_Msg_Name_1 := Chars (E); Error_Msg_N ("cannot eliminate subprogram %", E); return; end if; end if; Set_Is_Eliminated (E); Elim_Entities.Append ((Prag => Elmt.Prag, Subp => E)); end Set_Eliminated; -- Start of processing for Check_Homonyms begin -- First we check that the name of the entity matches if Elmt.Entity_Name /= Chars (E) then goto Continue; end if; -- Find enclosing unit, and verify that its name and those of its -- parents match. Scop := Cunit_Entity (Current_Sem_Unit); -- Now see if compilation unit matches Up := Elmt.Unit_Name'Last; -- If we are within a subunit, the name in the pragma has been -- parsed as a child unit, but the current compilation unit is in -- fact the parent in which the subunit is embedded. We must skip -- the first name which is that of the subunit to match the pragma -- specification. Body may be that of a package or subprogram. declare Par : Node_Id; begin Par := Parent (E); while Present (Par) loop if Nkind (Par) = N_Subunit then if Chars (Defining_Entity (Proper_Body (Par))) = Elmt.Unit_Name (Up) then Up := Up - 1; exit; else goto Continue; end if; end if; Par := Parent (Par); end loop; end; for J in reverse Elmt.Unit_Name'First .. Up loop if Elmt.Unit_Name (J) /= Chars (Scop) then goto Continue; end if; Scop := Scope (Scop); if Scop /= Standard_Standard and then J = 1 then goto Continue; end if; end loop; if Scop /= Standard_Standard then goto Continue; end if; if Present (Elmt.Entity_Node) and then Elmt.Entity_Scope /= null then -- Check that names of enclosing scopes match. Skip blocks and -- wrapper package of subprogram instances, which do not appear -- in the pragma. Scop := Scope (E); for J in reverse Elmt.Entity_Scope'Range loop while Ekind (Scop) = E_Block or else (Ekind (Scop) = E_Package and then Is_Wrapper_Package (Scop)) loop Scop := Scope (Scop); end loop; if Elmt.Entity_Scope (J) /= Chars (Scop) then if Ekind (Scop) /= E_Protected_Type or else Comes_From_Source (Scop) then goto Continue; -- For simple protected declarations, retrieve the source -- name of the object, which appeared in the Eliminate -- pragma. else declare Decl : constant Node_Id := Original_Node (Parent (Scop)); begin if Elmt.Entity_Scope (J) /= Chars (Defining_Identifier (Decl)) then if J > 0 then null; end if; goto Continue; end if; end; end if; end if; Scop := Scope (Scop); end loop; end if; -- If given entity is a library level subprogram and pragma had a -- single parameter, a match. if Is_Compilation_Unit (E) and then Is_Subprogram (E) and then No (Elmt.Entity_Node) then Set_Eliminated; return; -- Check for case of type or object with two parameter case elsif (Is_Type (E) or else Is_Object (E)) and then Elmt.Result_Type = No_Name and then Elmt.Parameter_Types = null then Set_Eliminated; return; -- Check for case of subprogram elsif Ekind (E) in E_Function | E_Procedure then -- If Source_Location present, then see if it matches if Elmt.Source_Location /= No_Name then Get_Name_String (Elmt.Source_Location); declare Sloc_Trace : constant String := Name_Buffer (1 .. Name_Len); Idx : Natural := Sloc_Trace'First; -- Index in Sloc_Trace, if equals to 0, then we have -- completely traversed Sloc_Trace Last : constant Natural := Sloc_Trace'Last; P : Source_Ptr; Sindex : Source_File_Index; function File_Name_Match return Boolean; -- This function is supposed to be called when Idx points -- to the beginning of the new file name, and Name_Buffer -- is set to contain the name of the proper source file -- from the chain corresponding to the Sloc of E. First -- it checks that these two files have the same name. If -- this check is successful, moves Idx to point to the -- beginning of the column number. function Line_Num_Match return Boolean; -- This function is supposed to be called when Idx points -- to the beginning of the column number, and P is -- set to point to the proper Sloc the chain -- corresponding to the Sloc of E. First it checks that -- the line number Idx points on and the line number -- corresponding to P are the same. If this check is -- successful, moves Idx to point to the beginning of -- the next file name in Sloc_Trace. If there is no file -- name any more, Idx is set to 0. function Different_Trace_Lengths return Boolean; -- From Idx and P, defines if there are in both traces -- more element(s) in the instantiation chains. Returns -- False if one trace contains more element(s), but -- another does not. If both traces contains more -- elements (that is, the function returns False), moves -- P ahead in the chain corresponding to E, recomputes -- Sindex and sets the name of the corresponding file in -- Name_Buffer function Skip_Spaces return Natural; -- If Sloc_Trace (Idx) is not space character, returns -- Idx. Otherwise returns the index of the nearest -- non-space character in Sloc_Trace to the right of Idx. -- Returns 0 if there is no such character. ----------------------------- -- Different_Trace_Lengths -- ----------------------------- function Different_Trace_Lengths return Boolean is begin P := Instantiation (Sindex); if (P = No_Location and then Idx /= 0) or else (P /= No_Location and then Idx = 0) then return True; else if P /= No_Location then Sindex := Get_Source_File_Index (P); Get_Name_String (File_Name (Sindex)); end if; return False; end if; end Different_Trace_Lengths; --------------------- -- File_Name_Match -- --------------------- function File_Name_Match return Boolean is Tmp_Idx : Natural; End_Idx : Natural; begin if Idx = 0 then return False; end if; -- Find first colon. If no colon, then return False. -- If there is a colon, Tmp_Idx is set to point just -- before the colon. Tmp_Idx := Idx - 1; loop if Tmp_Idx >= Last then return False; elsif Sloc_Trace (Tmp_Idx + 1) = ':' then exit; else Tmp_Idx := Tmp_Idx + 1; end if; end loop; -- Find last non-space before this colon. If there is -- no space character before this colon, then return -- False. Otherwise, End_Idx is set to point to this -- non-space character. End_Idx := Tmp_Idx; loop if End_Idx < Idx then return False; elsif Sloc_Trace (End_Idx) /= ' ' then exit; else End_Idx := End_Idx - 1; end if; end loop; -- Now see if file name matches what is in Name_Buffer -- and if so, step Idx past it and return True. If the -- name does not match, return False. if Sloc_Trace (Idx .. End_Idx) = Name_Buffer (1 .. Name_Len) then Idx := Tmp_Idx + 2; Idx := Skip_Spaces; return True; else return False; end if; end File_Name_Match; -------------------- -- Line_Num_Match -- -------------------- function Line_Num_Match return Boolean is N : Nat := 0; begin if Idx = 0 then return False; end if; while Idx <= Last and then Sloc_Trace (Idx) in '0' .. '9' loop N := N * 10 + (Character'Pos (Sloc_Trace (Idx)) - Character'Pos ('0')); Idx := Idx + 1; end loop; if Get_Physical_Line_Number (P) = Physical_Line_Number (N) then while Idx <= Last and then Sloc_Trace (Idx) /= '[' loop Idx := Idx + 1; end loop; if Idx <= Last then pragma Assert (Sloc_Trace (Idx) = '['); Idx := Idx + 1; Idx := Skip_Spaces; else Idx := 0; end if; return True; else return False; end if; end Line_Num_Match; ----------------- -- Skip_Spaces -- ----------------- function Skip_Spaces return Natural is Res : Natural; begin Res := Idx; while Sloc_Trace (Res) = ' ' loop Res := Res + 1; if Res > Last then Res := 0; exit; end if; end loop; return Res; end Skip_Spaces; begin P := Sloc (E); Sindex := Get_Source_File_Index (P); Get_Name_String (File_Name (Sindex)); Idx := Skip_Spaces; while Idx > 0 loop if not File_Name_Match then goto Continue; elsif not Line_Num_Match then goto Continue; end if; if Different_Trace_Lengths then goto Continue; end if; end loop; end; end if; -- If we have a Result_Type, then we must have a function with -- the proper result type. if Elmt.Result_Type /= No_Name then if Ekind (E) /= E_Function or else Chars (Etype (E)) /= Elmt.Result_Type then goto Continue; end if; end if; -- If we have Parameter_Types, they must match if Elmt.Parameter_Types /= null then Form := First_Formal (E); if No (Form) and then Elmt.Parameter_Types'Length = 1 and then Elmt.Parameter_Types (1) = No_Name then -- Parameterless procedure matches null; elsif Elmt.Parameter_Types = null then goto Continue; else for J in Elmt.Parameter_Types'Range loop if No (Form) or else Chars (Etype (Form)) /= Elmt.Parameter_Types (J) then goto Continue; else Next_Formal (Form); end if; end loop; if Present (Form) then goto Continue; end if; end if; end if; -- If we fall through, this is match Set_Eliminated; return; end if; end Check_Homonyms; <<Continue>> Elmt := Elmt.Homonym; end loop; return; end Check_Eliminated; ------------------------------------- -- Check_For_Eliminated_Subprogram -- ------------------------------------- procedure Check_For_Eliminated_Subprogram (N : Node_Id; S : Entity_Id) is Ultimate_Subp : constant Entity_Id := Ultimate_Alias (S); Enclosing_Subp : Entity_Id; begin -- No check needed within a default expression for a formal, since this -- is not really a use, and the expression (a call or attribute) may -- never be used if the enclosing subprogram is itself eliminated. if In_Spec_Expression then return; end if; if Is_Eliminated (Ultimate_Subp) and then not Inside_A_Generic and then not Is_Generic_Unit (Cunit_Entity (Current_Sem_Unit)) then Enclosing_Subp := Current_Subprogram; while Present (Enclosing_Subp) loop if Is_Eliminated (Enclosing_Subp) then return; end if; Enclosing_Subp := Enclosing_Subprogram (Enclosing_Subp); end loop; -- Emit error, unless we are within an instance body and the expander -- is disabled, indicating an instance within an enclosing generic. -- In an instance, the ultimate alias is an internal entity, so place -- the message on the original subprogram. if In_Instance_Body and then not Expander_Active then null; elsif Comes_From_Source (Ultimate_Subp) then Eliminate_Error_Msg (N, Ultimate_Subp); else Eliminate_Error_Msg (N, S); end if; end if; end Check_For_Eliminated_Subprogram; ------------------------- -- Eliminate_Error_Msg -- ------------------------- procedure Eliminate_Error_Msg (N : Node_Id; E : Entity_Id) is begin for J in Elim_Entities.First .. Elim_Entities.Last loop if E = Elim_Entities.Table (J).Subp then Error_Msg_Sloc := Sloc (Elim_Entities.Table (J).Prag); Error_Msg_NE ("cannot reference subprogram & eliminated #", N, E); return; end if; end loop; -- If this is an internal operation generated for a protected operation, -- its name does not match the source name, so just report the error. if not Comes_From_Source (E) and then Present (First_Entity (E)) and then Is_Concurrent_Record_Type (Etype (First_Entity (E))) then Error_Msg_NE ("cannot reference eliminated protected subprogram", N, E); -- Otherwise should not fall through, entry should be in table else Error_Msg_NE ("subprogram& is called but its alias is eliminated", N, E); -- raise Program_Error; end if; end Eliminate_Error_Msg; ---------------- -- Initialize -- ---------------- procedure Initialize is begin Elim_Hash_Table.Reset; Elim_Entities.Init; No_Elimination := True; end Initialize; ------------------------------ -- Process_Eliminate_Pragma -- ------------------------------ procedure Process_Eliminate_Pragma (Pragma_Node : Node_Id; Arg_Unit_Name : Node_Id; Arg_Entity : Node_Id; Arg_Parameter_Types : Node_Id; Arg_Result_Type : Node_Id; Arg_Source_Location : Node_Id) is Data : constant Access_Elim_Data := new Elim_Data; -- Build result data here Elmt : Access_Elim_Data; Num_Names : Nat := 0; -- Number of names in unit name Lit : Node_Id; Arg_Ent : Entity_Id; Arg_Uname : Node_Id; function OK_Selected_Component (N : Node_Id) return Boolean; -- Test if N is a selected component with all identifiers, or a selected -- component whose selector is an operator symbol. As a side effect -- if result is True, sets Num_Names to the number of names present -- (identifiers, and operator if any). --------------------------- -- OK_Selected_Component -- --------------------------- function OK_Selected_Component (N : Node_Id) return Boolean is begin if Nkind (N) = N_Identifier or else Nkind (N) = N_Operator_Symbol then Num_Names := Num_Names + 1; return True; elsif Nkind (N) = N_Selected_Component then return OK_Selected_Component (Prefix (N)) and then OK_Selected_Component (Selector_Name (N)); else return False; end if; end OK_Selected_Component; -- Start of processing for Process_Eliminate_Pragma begin Data.Prag := Pragma_Node; Error_Msg_Name_1 := Name_Eliminate; -- Process Unit_Name argument if Nkind (Arg_Unit_Name) = N_Identifier then Data.Unit_Name := new Names'(1 => Chars (Arg_Unit_Name)); Num_Names := 1; elsif OK_Selected_Component (Arg_Unit_Name) then Data.Unit_Name := new Names (1 .. Num_Names); Arg_Uname := Arg_Unit_Name; for J in reverse 2 .. Num_Names loop Data.Unit_Name (J) := Chars (Selector_Name (Arg_Uname)); Arg_Uname := Prefix (Arg_Uname); end loop; Data.Unit_Name (1) := Chars (Arg_Uname); else Error_Msg_N ("wrong form for Unit_Name parameter of pragma%", Arg_Unit_Name); return; end if; -- Process Entity argument if Present (Arg_Entity) then Num_Names := 0; if Nkind (Arg_Entity) = N_Identifier or else Nkind (Arg_Entity) = N_Operator_Symbol then Data.Entity_Name := Chars (Arg_Entity); Data.Entity_Node := Arg_Entity; Data.Entity_Scope := null; elsif OK_Selected_Component (Arg_Entity) then Data.Entity_Scope := new Names (1 .. Num_Names - 1); Data.Entity_Name := Chars (Selector_Name (Arg_Entity)); Data.Entity_Node := Arg_Entity; Arg_Ent := Prefix (Arg_Entity); for J in reverse 2 .. Num_Names - 1 loop Data.Entity_Scope (J) := Chars (Selector_Name (Arg_Ent)); Arg_Ent := Prefix (Arg_Ent); end loop; Data.Entity_Scope (1) := Chars (Arg_Ent); elsif Is_Config_Static_String (Arg_Entity) then Data.Entity_Name := Name_Find; Data.Entity_Node := Arg_Entity; else return; end if; else Data.Entity_Node := Empty; Data.Entity_Name := Data.Unit_Name (Num_Names); end if; -- Process Parameter_Types argument if Present (Arg_Parameter_Types) then -- Here for aggregate case if Nkind (Arg_Parameter_Types) = N_Aggregate then Data.Parameter_Types := new Names (1 .. List_Length (Expressions (Arg_Parameter_Types))); Lit := First (Expressions (Arg_Parameter_Types)); for J in Data.Parameter_Types'Range loop if Is_Config_Static_String (Lit) then Data.Parameter_Types (J) := Name_Find; Next (Lit); else return; end if; end loop; -- Otherwise we must have case of one name, which looks like a -- parenthesized literal rather than an aggregate. elsif Paren_Count (Arg_Parameter_Types) /= 1 then Error_Msg_N ("wrong form for argument of pragma Eliminate", Arg_Parameter_Types); return; elsif Is_Config_Static_String (Arg_Parameter_Types) then String_To_Name_Buffer (Strval (Arg_Parameter_Types)); if Name_Len = 0 then -- Parameterless procedure Data.Parameter_Types := new Names'(1 => No_Name); else Data.Parameter_Types := new Names'(1 => Name_Find); end if; else return; end if; end if; -- Process Result_Types argument if Present (Arg_Result_Type) then if Is_Config_Static_String (Arg_Result_Type) then Data.Result_Type := Name_Find; else return; end if; -- Here if no Result_Types argument else Data.Result_Type := No_Name; end if; -- Process Source_Location argument if Present (Arg_Source_Location) then if Is_Config_Static_String (Arg_Source_Location) then Data.Source_Location := Name_Find; else return; end if; else Data.Source_Location := No_Name; end if; Elmt := Elim_Hash_Table.Get (Hash_Subprograms.Get_Key (Data)); -- If we already have an entry with this same key, then link -- it into the chain of entries for this key. if Elmt /= null then Data.Homonym := Elmt.Homonym; Elmt.Homonym := Data; -- Otherwise create a new entry else Elim_Hash_Table.Set (Data); end if; No_Elimination := False; end Process_Eliminate_Pragma; end Sem_Elim;
with Ada.Numerics, Ada.Numerics.Elementary_Functions; package body PolyPaver.Floats is function Eps_Abs return Float is begin return 0.5**126; end Eps_Abs; function Eps_Rel return Float is begin return 0.5**22; end Eps_Rel; function Pi return Float is begin return Ada.Numerics.Pi; end Pi; function Add (X,Y : Float) return Float is begin return X+Y; end Add; function Subtract (X,Y : Float) return Float is begin return X-Y; end Subtract; function Multiply (X,Y : Float) return Float is begin return X*Y; end Multiply; function Divide (X,Y : Float) return Float is begin return X/Y; end Divide; function Square (X : Float) return Float is begin return X*X; end Square; function Sqrt (X : Float) return Float is begin return Ada.Numerics.Elementary_Functions.Sqrt(X); end Sqrt; function Exp (X : Float) return Float is begin return Ada.Numerics.Elementary_Functions.Exp(X); end Exp; function Sin (X : Float) return Float is begin return Ada.Numerics.Elementary_Functions.Sin(X); end Sin; function Cos (X : Float) return Float is begin return Ada.Numerics.Elementary_Functions.Cos(X); end Cos; end PolyPaver.Floats;
with Ada.Text_IO; with Ada.Strings.Unbounded; with DataBatch; with MathUtils; package CSV is type Reader is tagged limited private; function open(path: in String; separator: in Character := ',') return Reader; function hasNext(r: in Reader) return Boolean; function next(r: in out Reader) return MathUtils.Vector; private type Reader is tagged limited record handle: Ada.Text_IO.File_Type; nextLine: Ada.Strings.Unbounded.Unbounded_String; hasMore: Boolean := False; end record; end CSV;
with Zstandard.Functions.Streaming_Decompression; use Zstandard.Functions; with Ada.Command_line; use Ada.Command_Line; with Ada.Directories; use Ada.Directories; with Ada.Text_IO; use Ada.Text_IO; with Ada.Exceptions; use Ada.Exceptions; with Ada.Streams.Stream_IO; use Ada.Streams; procedure Demo_Ada is begin if Argument_Count /= 1 then Put_Line ("Zstandard version: " & Zstd_Version); Put_Line ("usage:"); Put_Line (Command_Name & " <path/to/file.zst>"); return; end if; declare path2file : String renames Argument (1); namelen : constant Natural := path2file'Length; nlast : constant Natural := path2file'Last; begin if not Exists (path2file) then Put_Line ("File '" & path2file & "' does not exist, aborting."); return; else if namelen < 5 or else path2file (nlast - 3 .. nlast) /= ".zst" then Put_Line ("File name doesn't have the .zst extension, aborting."); return; end if; end if; end; declare type Real4 is digits 4; path2file : String renames Argument (1); src_file : Stream_IO.File_Type; mech : Streaming_Decompression.Decompressor; complete : Boolean := False; plaintext : Streaming_Decompression.Output_Data_Container; last_one : Natural; sum : Natural := 0; begin Stream_IO.Open (File => src_file, Mode => Stream_IO.In_File, Name => path2file); mech.Initialize (input_stream => Stream_IO.Stream (src_file)); loop exit when complete; mech.Decompress_Data (complete => complete, output_data => plaintext, last_element => last_one); if last_one > 0 then declare message : String (1 .. last_one); begin for z in message'Range loop message (z) := Character'val (plaintext (Stream_Element_Offset (z))); end loop; Put (message); sum := sum + last_one; end; end if; end loop; Stream_IO.Close (src_file); Put_Line ("total length:" & sum'Img); exception when Error : others => Put_Line (Exception_Information(Error)); if Stream_IO.Is_Open (src_file) then Stream_IO.Close (src_file); end if; end; end Demo_Ada;
with ada.text_io; use ada.text_io; procedure fast_fibo is -- We work with biggest natural integers in a 64 bits machine type Big_Int is mod 2**64; -- We provide an index type for accessing the fibonacci sequence terms type Index is new Big_Int; -- fibo is a generic function that needs a modulus type since it will return -- the n'th term of the fibonacci sequence modulus this type (use Big_Int to get the -- expected behaviour in this particular task) generic type ring_element is mod <>; with function "*" (a, b : ring_element) return ring_element is <>; function fibo (n : Index) return ring_element; function fibo (n : Index) return ring_element is type matrix is array (1 .. 2, 1 .. 2) of ring_element; -- f is the matrix you apply to a column containing (F_n, F_{n+1}) to get -- the next one containing (F_{n+1},F_{n+2}) -- could be a more general matrix (given as a generic parameter) to deal with -- other linear sequences of order 2 f : constant matrix := (1 => (0, 1), 2 => (1, 1)); function "*" (a, b : matrix) return matrix is (1 => (a(1,1)*b(1,1)+a(1,2)*b(2,1), a(1,1)*b(1,2)+a(1,2)*b(2,2)), 2 => (a(2,1)*b(1,1)+a(2,2)*b(2,1), a(2,1)*b(1,2)+a(2,2)*b(2,2))); function square (m : matrix) return matrix is (m * m); -- Fast_Pow could be non recursive but it doesn't really matter since -- the number of calls is bounded up by the size (in bits) of Big_Int (e.g 64) function fast_pow (m : matrix; n : Index) return matrix is (if n = 0 then (1 => (1, 0), 2 => (0, 1)) -- = identity matrix elsif n mod 2 = 0 then square (fast_pow (m, n / 2)) else m * square (fast_pow (m, n / 2))); begin return fast_pow (f, n)(2, 1); end fibo; function Big_Int_Fibo is new fibo (Big_Int); begin -- calculate instantly F_n with n=10^15 (modulus 2^64 ) put_line (Big_Int_Fibo (10**15)'img); end fast_fibo;
-- part of OpenGLAda, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" with Glfw.Windows.Clipboard; with Glfw.Monitors; with Glfw.Input; procedure Glfw_Test.Clipboard is type My_Window is new Glfw.Windows.Window with null record; overriding procedure Init (Object : not null access My_Window; Width, Height : Glfw.Size; Title : String; Monitor : Glfw.Monitors.Monitor := Glfw.Monitors.No_Monitor; Share : access Glfw.Windows.Window'Class := null); overriding procedure Focus_Changed (Object : not null access My_Window; Focused : Boolean); procedure Init (Object : not null access My_Window; Width, Height : Glfw.Size; Title : String; Monitor : Glfw.Monitors.Monitor := Glfw.Monitors.No_Monitor; Share : access Glfw.Windows.Window'Class := null) is Upcast : constant Glfw.Windows.Window_Reference := Glfw.Windows.Window (Object.all)'Access; begin Upcast.Init (Width, Height, Title, Monitor, Share); Glfw.Windows.Clipboard.Set (Object, "Unfocus to change clipboard contents to window title"); Object.Enable_Callback (Glfw.Windows.Callbacks.Focus); end Init; procedure Focus_Changed (Object : not null access My_Window; Focused : Boolean) is begin if Focused then Object.Set_Title (Glfw.Windows.Clipboard.Get (Object)); else Glfw.Windows.Clipboard.Set (Object, Glfw.Windows.Clipboard.Get (Object) & " | focus lost"); end if; end Focus_Changed; W : aliased My_Window; begin Glfw.Init; Enable_Print_Errors; W'Access.Init (640, 480, ""); while not W'Access.Should_Close loop Glfw.Input.Wait_For_Events; end loop; Glfw.Shutdown; end Glfw_Test.Clipboard;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Web API Definition -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014-2015, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This package provides binding to interface Node. ------------------------------------------------------------------------------ limited with WebAPI.DOM.Documents; limited with WebAPI.DOM.Elements; with WebAPI.DOM.Event_Targets; limited with WebAPI.DOM.Node_Lists; package WebAPI.DOM.Nodes is pragma Preelaborate; type Node is limited interface and WebAPI.DOM.Event_Targets.Event_Target; type Node_Access is access all Node'Class with Storage_Size => 0; -- XXX Not binded yet: -- const unsigned short ELEMENT_NODE = 1; -- const unsigned short ATTRIBUTE_NODE = 2; // historical -- const unsigned short TEXT_NODE = 3; -- const unsigned short CDATA_SECTION_NODE = 4; // historical -- const unsigned short ENTITY_REFERENCE_NODE = 5; // historical -- const unsigned short ENTITY_NODE = 6; // historical -- const unsigned short PROCESSING_INSTRUCTION_NODE = 7; -- const unsigned short COMMENT_NODE = 8; -- const unsigned short DOCUMENT_NODE = 9; -- const unsigned short DOCUMENT_TYPE_NODE = 10; -- const unsigned short DOCUMENT_FRAGMENT_NODE = 11; -- const unsigned short NOTATION_NODE = 12; // historical -- readonly attribute unsigned short nodeType; not overriding function Get_Node_Name (Self : not null access constant Node) return WebAPI.DOM_String is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "nodeName"; -- Returns a string appropriate for the type of node, as follows: -- -- Element -- Its tagName attribute value. -- Text -- "#text". -- ProcessingInstruction -- Its target. -- Comment -- "#comment". -- Document -- "#document". -- DocumentType -- Its name. -- DocumentFragment -- "#document-fragment". not overriding function Get_Base_URI (Self : not null access constant Node) return WebAPI.DOM_String is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "baseURI"; -- Returns the base URL. not overriding function Get_Owner_Document (Self : not null access constant Node) return WebAPI.DOM.Documents.Document_Access is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "ownerDocument"; -- Returns the node document. -- -- Returns null for documents. not overriding function Get_Parent_Node (Self : not null access constant Node) return WebAPI.DOM.Nodes.Node_Access is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "parentNode"; -- Returns the parent. not overriding function Get_Parent_Element (Self : not null access constant Node) return WebAPI.DOM.Elements.Element_Access is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "parentElement"; -- Returns the parent element. not overriding function Has_Child_Nodes (Self : not null access constant Node) return Boolean is abstract with Import => True, Convention => JavaScript_Method, Link_Name => "hasChildNodes"; -- Returns whether node has children. not overriding function Get_Child_Nodes (Self : not null access constant Node) return WebAPI.DOM.Node_Lists.Node_List is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "childNodes"; -- Returns the children. not overriding function Get_First_Child (Self : not null access constant Node) return WebAPI.DOM.Nodes.Node_Access is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "firstChild"; -- Returns the first child. not overriding function Get_Last_Child (Self : not null access constant Node) return WebAPI.DOM.Nodes.Node_Access is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "lastChild"; -- Returns the last child. not overriding function Get_Previous_Sibling (Self : not null access constant Node) return WebAPI.DOM.Nodes.Node_Access is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "previousSibling"; -- Returns the previous sibling. not overriding function Get_Next_Sibling (Self : not null access constant Node) return WebAPI.DOM.Nodes.Node_Access is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "nextSibling"; -- Returns the next sibling. not overriding function Get_Node_Value (Self : not null access constant Node) return WebAPI.DOM_String is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "nodeValue"; -- The nodeValue attribute must return the following, depending on the -- context object: -- -- Text -- Comment -- ProcessingInstruction -- -- The context object's data. -- -- Any other node -- -- Null. not overriding procedure Set_Node_Value (Self : not null access Node; To : WebAPI.DOM_String) is abstract with Import => True, Convention => JavaScript_Property_Setter, Link_Name => "nodeValue"; -- The nodeValue attribute must, on setting, if the new value is null, act -- as if it was the empty string instead, and then do as described below, -- depending on the context object: -- -- Text -- Comment -- ProcessingInstruction -- -- Replace data with node context object, offset 0, count length -- attribute value, and data new value. -- -- Any other node -- -- Do nothing. not overriding function Get_Text_Content (Self : not null access constant Node) return WebAPI.DOM_String is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "textContent"; -- The textContent attribute must return the following, depending on the -- context object: -- -- DocumentFragment -- Element -- -- The concatenation of data of all the Text node descendants of the -- context object, in tree order. -- -- Text -- ProcessingInstruction -- Comment -- -- The context object's data. -- -- Any other node -- -- Null. not overriding procedure Set_Text_Content (Self : not null access Node; To : WebAPI.DOM_String) is abstract with Import => True, Convention => JavaScript_Property_Setter, Link_Name => "textContent"; -- The textContent attribute must, on setting, if the new value is null, -- act as if it was the empty string instead, and then do as described -- below, depending on the context object: -- -- DocumentFragment -- Element -- -- 1. Let node be null. -- -- 2. If new value is not the empty string, set node to a new Text node -- whose data is new value. -- -- 3. Replace all with node within the context object. -- -- Text -- ProcessingInstruction -- Comment -- -- Replace data with node context object, offset 0, count length -- attribute value, and data new value. -- -- Any other node -- -- Do nothing. not overriding procedure Normalize (Self : not null access Node) is abstract with Import => True, Convention => JavaScript_Method, Link_Name => "normalize"; -- Removes empty Text nodes and concatenates the data of remaining -- contiguous Text nodes into the first of their nodes. not overriding function Clone_Node (Self : not null access Node; Deep : Boolean := False) return not null WebAPI.DOM.Nodes.Node_Access is abstract with Import => True, Convention => JavaScript_Method, Link_Name => "cloneNode"; -- Returns a copy of node. If deep is true, the copy also includes the -- node's descendants. not overriding function Is_Equal_Node (Self : not null access constant Node; Other : access Node'Class) return Boolean is abstract with Import => True, Convention => JavaScript_Method, Link_Name => "isEqualNode"; -- Returns whether node and other have the same properties. -- XXX Not bindied yet: -- const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01; -- const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02; -- const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04; -- const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08; -- const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10; -- const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; -- unsigned short compareDocumentPosition(Node other); not overriding function Contains (Self : not null access constant Node; Other : access Node'Class) return Boolean is abstract with Import => True, Convention => JavaScript_Method, Link_Name => "contains"; -- Returns true if other is an inclusive descendant of node, and false -- otherwise. not overriding function Lookup_Prefix (Self : not null access constant Node; Namespace_URI : WebAPI.DOM_String) return WebAPI.DOM_String is abstract with Import => True, Convention => JavaScript_Method, Link_Name => "lookupPrefix"; -- The lookupPrefix(namespace) method must run these steps: -- -- 1. If namespace is null or the empty string, return null. -- -- 2. Otherwise it depends on the context object: -- -- Element -- -- Return the result of locating a namespace prefix for the node -- using namespace. -- -- Document -- -- Return the result of locating a namespace prefix for its document -- element, if that is not null, and null otherwise. -- -- DocumentType -- DocumentFragment -- -- Return null. -- -- Any other node -- -- Return the result of locating a namespace prefix for its parent -- element, or if that is null, null. not overriding function Lookup_Namespace_URI (Self : not null access constant Node; Prefix : WebAPI.DOM_String) return WebAPI.DOM_String is abstract with Import => True, Convention => JavaScript_Method, Link_Name => "lookupNamespaceURI"; -- The lookupNamespaceURI(prefix) method must run these steps: -- -- 1. If prefix is the empty string, set it to null. -- -- 2. Return the result of running locate a namespace for the context -- object using prefix. not overriding function Is_Default_Namespace (Self : not null access constant Node; Namespace_URI : WebAPI.DOM_String) return Boolean is abstract with Import => True, Convention => JavaScript_Method, Link_Name => "isDefaultNamespace"; -- The isDefaultNamespace(namespace) method must run these steps: -- -- 1. If namespace is the empty string, set it to null. -- -- 2. Let defaultNamespace be the result of running locate a namespace for -- the context object using null. -- -- 3. Return true if defaultNamespace is the same as namespace, and false -- otherwise. not overriding function Insert_Before (Self : not null access Node; Node : not null access WebAPI.DOM.Nodes.Node'Class; Child : access WebAPI.DOM.Nodes.Node'Class) return WebAPI.DOM.Nodes.Node_Access is abstract with Import => True, Convention => JavaScript_Method, Link_Name => "insertBefore"; procedure Insert_Before (Self : not null access Node'Class; Node : not null access WebAPI.DOM.Nodes.Node'Class; Child : access WebAPI.DOM.Nodes.Node'Class) with Import => True, Convention => JavaScript_Method, Link_Name => "insertBefore"; -- The insertBefore(node, child) method must return the result of -- pre-inserting node into the context object before child. not overriding function Append_Child (Self : not null access Node; Node : not null access WebAPI.DOM.Nodes.Node'Class) return Node_Access is abstract with Import => True, Convention => JavaScript_Method, Link_Name => "appendChild"; procedure Append_Child (Self : not null access Node'Class; Node : not null access WebAPI.DOM.Nodes.Node'Class) with Import => True, Convention => JavaScript_Method, Link_Name => "appendChild"; -- The appendChild(node) method must return the result of appending node to -- the context object. not overriding function Replace_Child (Self : not null access Node; Node : not null access WebAPI.DOM.Nodes.Node'Class; Child : not null access WebAPI.DOM.Nodes.Node'Class) return WebAPI.DOM.Nodes.Node_Access is abstract with Import => True, Convention => JavaScript_Method, Link_Name => "replaceChild"; procedure Replace_Child (Self : not null access Node'Class; Node : not null access WebAPI.DOM.Nodes.Node'Class; Child : not null access WebAPI.DOM.Nodes.Node'Class) with Import => True, Convention => JavaScript_Method, Link_Name => "replaceChild"; -- The replaceChild(node, child) method must return the result of replacing -- child with node within the context object. not overriding function Remove_Child (Self : not null access Node; Node : not null access WebAPI.DOM.Nodes.Node'Class) return Node_Access is abstract with Import => True, Convention => JavaScript_Method, Link_Name => "removeChild"; procedure Remove_Child (Self : not null access Node'Class; Node : not null access WebAPI.DOM.Nodes.Node'Class) with Import => True, Convention => JavaScript_Method, Link_Name => "removeChild"; -- The removeChild(child) method must return the result of pre-removing -- child from the context object. end WebAPI.DOM.Nodes;
-- { dg-do compile } -- { dg-options "-O" } with Ada.Strings; with Ada.Strings.Fixed; procedure String_Slice2 is package ASF renames Ada.Strings.Fixed; Delete_String : String(1..10); Source_String2 : String(1..12) := "abcdefghijkl"; begin Delete_String := Source_String2(1..10); ASF.Delete(Source => Delete_String, From => 6, Through => Delete_String'Last, Justify => Ada.Strings.Left, Pad => 'x'); end;
with One; procedure Two is X : Integer := 1; begin One (X); pragma Assert (X=2); end Two;
-- generic_example -- An example of the use of parse_args with generic option types -- Copyright (c) 2015, James Humphry -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -- PERFORMANCE OF THIS SOFTWARE. with Parse_Args; use Parse_Args; with Ada.Text_IO; use Ada.Text_IO; with Generic_Example_Options; use Generic_Example_Options; procedure Generic_Example is AP : Argument_Parser; begin AP.Add_Option(Make_Boolean_Option(False), "help", 'h', Usage => "Display this help text"); AP.Add_Option(Compass_Option.Make_Option, "compass", 'c', Usage => "A compass point (North (default), South, East or West)"); AP.Add_Option(Even_Option.Make_Option, "even", 'e', Usage => "An even natural number (default 0)"); AP.Add_Option(Float_Option.Make_Option, "float", 'f', Usage => "A floating-point number (default 0.0)"); AP.Add_Option(Float_Array_Option.Make_Option, "float-array", 'g', Usage => "An array of floating-point numbers"); AP.Set_Prologue("A demonstration of the Parse_Args library with generic types."); AP.Parse_Command_Line; if AP.Parse_Success and then AP.Boolean_Value("help") then AP.Usage; elsif AP.Parse_Success then Put_Line("Compass point specified: " & Compass'Image(Compass_Option.Value(AP, "compass"))); Put_Line("Even number specified: " & Natural'Image(Even_Option.Value(AP, "even"))); Put_Line("Floating-point number specified: " & Float'Image(Float_Option.Value(AP, "float"))); if Float_Array_Option.Value(AP, "float-array") /= null then Put_Line("Floating-point number array: "); for I of Float_Array_Option.Value(AP, "float-array").all loop Put(Float'Image(I) & ", "); end loop; else Put_Line("No floating-point array specified."); end if; else Put_Line("Error while parsing command-line arguments: " & AP.Parse_Message); end if; end Generic_Example;
----------------------------------------------------------------------- -- jobs-tests -- Unit tests for AWA jobs -- 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 Util.Test_Caller; with AWA.Jobs.Modules; with AWA.Jobs.Services.Tests; package body AWA.Jobs.Modules.Tests is package Caller is new Util.Test_Caller (Test, "Jobs.Modules"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test AWA.Jobs.Modules.Register", Test_Register'Access); end Add_Tests; -- ------------------------------ -- Test the job factory. -- ------------------------------ procedure Test_Register (T : in out Test) is M : AWA.Jobs.Modules.Job_Module; begin M.Register (Definition => Services.Tests.Test_Definition.Factory); Util.Tests.Assert_Equals (T, 1, Integer (M.Factory.Length), "Invalid factory length"); M.Register (Definition => Services.Tests.Work_1_Definition.Factory); Util.Tests.Assert_Equals (T, 2, Integer (M.Factory.Length), "Invalid factory length"); M.Register (Definition => Services.Tests.Work_2_Definition.Factory); Util.Tests.Assert_Equals (T, 3, Integer (M.Factory.Length), "Invalid factory length"); end Test_Register; end AWA.Jobs.Modules.Tests;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014-2017, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Ada.Strings.Unbounded; with AWS.Attachments; with AWS.Headers.Values; with AWS.Messages; with AWS.Parameters; with AWS.Server; with AWS.URL; with League.IRIs; with Servlet.HTTP_Cookies; with Servlet.HTTP_Parameters.AWS_Parameters; package body Matreshka.Servlet_AWS_Requests is -------------- -- Finalize -- -------------- procedure Finalize (Self : in out AWS_Servlet_Request'Class) is begin null; end Finalize; ---------------- -- Get_Cookie -- ---------------- overriding function Get_Cookies (Self : AWS_Servlet_Request) return Servlet.HTTP_Cookie_Sets.Cookie_Set is begin if Self.Data.Cookies_Computed then -- Reuse cookies when they was computed. return Self.Data.Cookies; end if; -- Compute cookies. declare Headers : constant AWS.Headers.List := AWS.Status.Header (Self.Request); Cookies : constant String := AWS.Headers.Get_Values (Headers, AWS.Messages.Cookie_Token); Set : constant AWS.Headers.Values.Set := AWS.Headers.Values.Split (Cookies); Cookie : Servlet.HTTP_Cookies.Cookie; begin Self.Data.Cookies_Computed := True; for J in Set'Range loop Servlet.HTTP_Cookies.Initialize (Cookie, League.Strings.From_UTF_8_String (Ada.Strings.Unbounded.To_String (Set (J).Name)), League.Strings.From_UTF_8_String (AWS.URL.Decode (Ada.Strings.Unbounded.To_String (Set (J).Value)))); -- AWS.URL.Decode is used here for compatibility with AWS.Cookies. Self.Data.Cookies.Append (Cookie); end loop; return Self.Data.Cookies; end; end Get_Cookies; ----------------- -- Get_Headers -- ----------------- overriding function Get_Headers (Self : AWS_Servlet_Request; Name : League.Strings.Universal_String) return League.String_Vectors.Universal_String_Vector is N : constant String := Name.To_UTF_8_String; Headers : constant AWS.Headers.List := AWS.Status.Header (Self.Request); Result : League.String_Vectors.Universal_String_Vector; begin for J in 1 .. AWS.Headers.Count (Headers, N) loop Result.Append (League.Strings.From_UTF_8_String (AWS.Headers.Get (Headers, N, J))); end loop; return Result; end Get_Headers; ---------------------- -- Get_Input_Stream -- ---------------------- overriding function Get_Input_Stream (Self : AWS_Servlet_Request) return not null access Ada.Streams.Root_Stream_Type'Class is begin -- XXX Should it be done before starting of request processing? if not AWS.Status.Is_Body_Uploaded (Self.Request) then AWS.Server.Get_Message_Body; end if; return Self.Body_Stream'Unrestricted_Access; end Get_Input_Stream; ---------------- -- Get_Method -- ---------------- overriding function Get_Method (Self : AWS_Servlet_Request) return Servlet.HTTP_Requests.HTTP_Method is begin case AWS.Status.Method (Self.Request) is when AWS.Status.OPTIONS => return Servlet.HTTP_Requests.Options; when AWS.Status.GET => return Servlet.HTTP_Requests.Get; when AWS.Status.HEAD => return Servlet.HTTP_Requests.Head; when AWS.Status.POST => return Servlet.HTTP_Requests.Post; when AWS.Status.PUT => return Servlet.HTTP_Requests.Put; when AWS.Status.DELETE => return Servlet.HTTP_Requests.Delete; when AWS.Status.TRACE => return Servlet.HTTP_Requests.Trace; when AWS.Status.CONNECT => return Servlet.HTTP_Requests.Connect; when AWS.Status.EXTENSION_METHOD => raise Program_Error; end case; end Get_Method; ------------------------- -- Get_Parameter_Names -- ------------------------- overriding function Get_Parameter_Names (Self : AWS_Servlet_Request) return League.String_Vectors.Universal_String_Vector is Names : constant AWS.Parameters.VString_Array := AWS.Parameters.Get_Names (AWS.Status.Parameters (Self.Request)); Result : League.String_Vectors.Universal_String_Vector; begin for Name of Names loop Result.Append (League.Strings.From_UTF_8_String (Ada.Strings.Unbounded.To_String (Name))); end loop; return Result; end Get_Parameter_Names; -------------------------- -- Get_Parameter_Values -- -------------------------- overriding function Get_Parameter_Values (Self : AWS_Servlet_Request; Name : League.Strings.Universal_String) return Servlet.HTTP_Parameter_Vectors.HTTP_Parameter_Vector is N : constant String := Name.To_UTF_8_String; Result : Servlet.HTTP_Parameter_Vectors.HTTP_Parameter_Vector; procedure Process_Attachment_Element (Attachment : AWS.Attachments.Element; Index : Positive; Quit : in out Boolean); -- Process each attachment element. -------------------------------- -- Process_Attachment_Element -- -------------------------------- procedure Process_Attachment_Element (Attachment : AWS.Attachments.Element; Index : Positive; Quit : in out Boolean) is Headers : constant AWS.Headers.List := AWS.Attachments.Headers (Attachment); begin if AWS.Headers.Exist (Headers, AWS.Messages.Content_Disposition_Token) and then AWS.Headers.Values.Search (AWS.Headers.Get (Headers, AWS.Messages.Content_Disposition_Token), "name") = N then Result.Append (Servlet.HTTP_Parameters.AWS_Parameters.Create (Attachment)); end if; end Process_Attachment_Element; procedure Process_Attachments is new AWS.Attachments.For_Every_Attachment (Process_Attachment_Element); begin Process_Attachments (AWS.Status.Attachments (Self.Request)); return Result; end Get_Parameter_Values; -------------------------- -- Get_Parameter_Values -- -------------------------- overriding function Get_Parameter_Values (Self : AWS_Servlet_Request; Name : League.Strings.Universal_String) return League.String_Vectors.Universal_String_Vector is Values : constant AWS.Parameters.VString_Array := AWS.Parameters.Get_Values (AWS.Status.Parameters (Self.Request), Name.To_UTF_8_String); Result : League.String_Vectors.Universal_String_Vector; begin for Value of Values loop Result.Append (League.Strings.From_UTF_8_String (Ada.Strings.Unbounded.To_String (Value))); end loop; return Result; end Get_Parameter_Values; ------------------------- -- Get_Upgrade_Handler -- ------------------------- function Get_Upgrade_Handler (Self : AWS_Servlet_Request'Class) return Servlet.HTTP_Upgrade_Handlers.HTTP_Upgrade_Handler_Access is begin return Self.Data.Upgrade; end Get_Upgrade_Handler; ---------------- -- Initialize -- ---------------- procedure Initialize (Self : in out AWS_Servlet_Request'Class; Data : AWS.Status.Data) is use type League.String_Vectors.Universal_String_Vector; Headers : constant AWS.Headers.List := AWS.Status.Header (Data); AWS_URI : constant AWS.URL.Object := AWS.Status.URI (Data); Protocol : constant String := AWS.URL.Protocol_Name (AWS_URI); URI_Text : constant String := AWS.Status.URI (Data); Path : League.String_Vectors.Universal_String_Vector := League.Strings.From_UTF_8_String (URI_Text).Split ('/', League.Strings.Skip_Empty); -- XXX HTTP protocol uses some protocol specific escaping sequnces, they -- should be handled here. -- XXX Use of UTF-8 to encode URI by AWS should be checked. Host : League.Strings.Universal_String; Delimiter : Natural; URL : League.IRIs.IRI; begin -- Add empty string at the end of constructed path when URI text ends -- with '/' character to distinguish requests of directory or its -- contents. if URI_Text (URI_Text'Last) = '/' then Path.Append (League.Strings.Empty_Universal_String); end if; -- Reconstruct request's URL. URL.Set_Scheme (League.Strings.From_UTF_8_String (Protocol)); if AWS.Headers.Exist (Headers, AWS.Messages.Host_Token) then -- When 'Host' header exists use its content to specify host and port -- components of original URL. Host := League.Strings.From_UTF_8_String (AWS.Headers.Get (Headers, AWS.Messages.Host_Token)); Delimiter := Host.Index (':'); if Delimiter /= 0 then URL.Set_Host (Host.Head_To (Delimiter - 1)); URL.Set_Port (Integer'Wide_Wide_Value (Host.Tail_From (Delimiter + 1).To_Wide_Wide_String)); else URL.Set_Host (Host); -- Default port was used by client. It depends from protocol. if Protocol = "http" then URL.Set_Port (80); elsif Protocol = "https" then URL.Set_Port (443); else raise Program_Error; end if; end if; else -- Otherwise (with old HTTP 1.0 client) fallback to host:port data -- provided by AWS. As of AWS 3.1 this is address of socket where AWS -- accepts connections, so it is incorrect in case of work in -- internal network behind proxy/load balancer. URL.Set_Host (League.Strings.From_UTF_8_String (AWS.URL.Host (AWS_URI))); URL.Set_Port (AWS.URL.Port (AWS_URI)); end if; URL.Set_Absolute_Path (Path); -- Initialize object. Matreshka.Servlet_HTTP_Requests.Initialize (Self, URL); Self.Request := Data; Self.Data := Self.Data_Storage'Unchecked_Access; end Initialize; ------------------------ -- Is_Async_Supported -- ------------------------ overriding function Is_Async_Supported (Self : not null access AWS_Servlet_Request) return Boolean is pragma Unreferenced (Self); begin -- AWS doesn't support asynchronous processing of requests. return False; end Is_Async_Supported; ---------- -- Read -- ---------- overriding procedure Read (Self : in out Body_Stream_Type; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset) is begin AWS.Status.Read_Body (Self.Request.Request, Item, Last); end Read; ------------- -- Upgrade -- ------------- overriding procedure Upgrade (Self : AWS_Servlet_Request; Handler : not null Servlet.HTTP_Upgrade_Handlers.HTTP_Upgrade_Handler_Access) is begin Self.Data.Upgrade := Handler; end Upgrade; ----------- -- Write -- ----------- overriding procedure Write (Self : in out Body_Stream_Type; Item : Ada.Streams.Stream_Element_Array) is begin raise Program_Error with "Servlet input stream doesn't allow write operations"; end Write; end Matreshka.Servlet_AWS_Requests;
-- ----------------------------------------------------------------- -- -- AdaSDL_Framebuffer -- -- Copyright (C) 2001 A.M.F.Vargas -- -- Antonio M. F. Vargas -- -- Ponta Delgada - Azores - Portugal -- -- http://www.adapower.net/~avargas -- -- E-mail: avargas@adapower.net -- -- ----------------------------------------------------------------- -- -- -- -- This library 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 library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public -- -- License along with this library; if not, write to the -- -- Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- -- Boston, MA 02111-1307, USA. -- -- -- -- As a special exception, if other files instantiate generics from -- -- this unit, or you link this unit with other files to produce an -- -- executable, this unit does not by itself cause the resulting -- -- executable to be covered by the GNU General Public License. This -- -- exception does not however invalidate any other reasons why the -- -- executable file might be covered by the GNU Public License. -- -- ----------------------------------------------------------------- -- -- ########################################################################## -- ### These are new extensions to the SDL API in order to improve the -- ### Ada code and to isolate the pointer arithmetic inside the library. -- ########################################################################## with Lib_C; package body SDL_Framebuffer_Generics is -- =========================================================== -- Go_XY_Generic -- =========================================================== function Go_XY_Generic ( Surface : Vd.Surface_ptr; X : Natural; Y : Natural) return Uint_Ptrs.Object_Pointer is use Uint_PtrOps; use Uint_Ptrs; begin if X < Natural (Surface.h) and Y < Natural (Surface.w) then return Uint_Ptrs.Object_Pointer ( Uint_PtrOps.Pointer (Uint_Ptrs.To_Pointer (Surface.pixels)) + C.ptrdiff_t ( Y * Natural (Surface.pitch) / Natural (Surface.format.BytesPerPixel) + X)); else return Uint_Ptrs.Object_Pointer ( Uint_PtrOps.Pointer (Uint_Ptrs.To_Pointer (Surface.pixels))); end if; end Go_XY_Generic; -- =========================================================== -- Go_XY_Unchecked_Generic -- =========================================================== function Go_XY_Unchecked_Generic ( Surface : Vd.Surface_ptr; X : Natural; Y : Natural) return Uint_Ptrs.Object_Pointer is use Uint_PtrOps; use Uint_Ptrs; begin return Uint_Ptrs.Object_Pointer ( Uint_PtrOps.Pointer (Uint_Ptrs.To_Pointer (Surface.pixels)) + C.ptrdiff_t ( Y * Natural (Surface.pitch) / Natural (Surface.format.BytesPerPixel) + X)); end Go_XY_Unchecked_Generic; -- =========================================================== -- Get_Framebuffer_Generic -- =========================================================== function Get_Framebuffer_Generic ( Surface : Vd.Surface_ptr) return Uint_Ptrs.Object_Pointer is begin return Uint_Ptrs.To_Pointer (Surface.pixels); end Get_Framebuffer_Generic; -- =========================================================== -- Goto_Line_Generic -- =========================================================== function Goto_Line_Generic ( Surface : Vd.Surface_ptr; Line_Num : Natural) return Uint_Ptrs.Object_Pointer is use Uint_PtrOps; use type C.int; begin if Line_Num > Natural (Surface.h - 1) then return Uint_Ptrs.Object_Pointer ( Uint_PtrOps.Pointer (Uint_Ptrs.To_Pointer (Surface.pixels)) + C.ptrdiff_t (Line_Num * Natural (Surface.pitch))); else return Uint_Ptrs.Object_Pointer ( Uint_PtrOps.Pointer (Uint_Ptrs.To_Pointer (Surface.pixels))); end if; end Goto_Line_Generic; -- =================================================================== -- Goto_Line_Unchecked_Generic -- =================================================================== function Goto_Line_Unchecked_Generic ( Surface : Vd.Surface_ptr; Line_Num : Natural) return Uint_Ptrs.Object_Pointer is use Uint_PtrOps; begin return Uint_Ptrs.Object_Pointer ( Uint_PtrOps.Pointer (Uint_Ptrs.To_Pointer (Surface.pixels)) + C.ptrdiff_t (Line_Num * Natural (Surface.pitch))); end Goto_Line_Unchecked_Generic; -- =========================================================== -- Goto_Line_End_Unchecked_Generic -- =========================================================== function Goto_Line_End_Unchecked_Generic ( Surface : Vd.Surface_ptr; Line_Num : Natural) return Uint_Ptrs.Object_Pointer is use Uint_PtrOps; use type C.int; begin return Uint_Ptrs.Object_Pointer ( Uint_PtrOps.Pointer (Uint_Ptrs.To_Pointer (Surface.pixels)) + C.ptrdiff_t (Line_Num * Natural (Surface.pitch) + Natural (Surface.w - 1))); end Goto_Line_End_Unchecked_Generic; -- =========================================================== -- Goto_Line_End_Generic -- =========================================================== function Goto_Line_End_Generic ( Surface : Vd.Surface_ptr; Line_Num : Natural) return Uint_Ptrs.Object_Pointer is use Uint_PtrOps; use type C.int; begin if Line_Num < Natural (Surface.h - 1) then return Uint_Ptrs.Object_Pointer ( Uint_PtrOps.Pointer (Uint_Ptrs.To_Pointer (Surface.pixels)) + C.ptrdiff_t (Line_Num * Natural (Surface.pitch) + Natural (Surface.w - 1))); else return Uint_Ptrs.Object_Pointer ( Uint_PtrOps.Pointer (Uint_Ptrs.To_Pointer (Surface.pixels)) + C.ptrdiff_t (Natural (Surface.w - 1))); end if; end Goto_Line_End_Generic; -- =========================================================== -- Next_Line_Unchecked_Generic -- =========================================================== function Next_Line_Unchecked_Generic ( Surface : Vd.Surface_ptr; Actual : Uint_Ptrs.Object_Pointer) return Uint_Ptrs.Object_Pointer is use Uint_PtrOps; begin return Uint_Ptrs.Object_Pointer ( Uint_PtrOps.Pointer (Actual) + C.ptrdiff_t (Surface.pitch)); end Next_Line_Unchecked_Generic; -- =========================================================== -- Prev_Line_Unchecked_Generic -- =========================================================== function Prev_Line_Unchecked_Generic ( Surface : Vd.Surface_ptr; Actual : Uint_Ptrs.Object_Pointer) return Uint_Ptrs.Object_Pointer is use Uint_PtrOps; begin return Uint_Ptrs.Object_Pointer ( Uint_PtrOps.Pointer (Actual) - C.ptrdiff_t (Surface.pitch)); end Prev_Line_Unchecked_Generic; -- =========================================================== -- Go_Right_Unchecked_Generic -- =========================================================== function Go_Right_Unchecked_Generic ( Actual : Uint_Ptrs.Object_Pointer; Displacement : Natural) return Uint_Ptrs.Object_Pointer is use Uint_PtrOps; begin return Uint_Ptrs.Object_Pointer ( Uint_PtrOps.Pointer (Actual) + C.ptrdiff_t (Displacement)); end Go_Right_Unchecked_Generic; -- =========================================================== -- Go_Left_Unchecked_Generic -- =========================================================== function Go_Left_Unchecked_Generic ( Actual : Uint_Ptrs.Object_Pointer; Displacement : Natural) return Uint_Ptrs.Object_Pointer is use Uint_PtrOps; begin return Uint_Ptrs.Object_Pointer ( Uint_PtrOps.Pointer (Actual) - C.ptrdiff_t (Displacement)); end Go_Left_Unchecked_Generic; -- =========================================================== -- Go_Up_Unchecked_Generic -- =========================================================== function Go_Up_Unchecked_Generic ( Surface : Vd.Surface_ptr; Actual : Uint_Ptrs.Object_Pointer; Displacement : Natural) return Uint_Ptrs.Object_Pointer is use Uint_PtrOps; begin return Uint_Ptrs.Object_Pointer ( Uint_PtrOps.Pointer (Actual) - C.ptrdiff_t (Uint16 (Displacement) * Surface.pitch)); end Go_Up_Unchecked_Generic; -- =========================================================== -- Go_Down_Unchecked_Generic -- =========================================================== function Go_Down_Unchecked_Generic ( Surface : Vd.Surface_ptr; Actual : Uint_Ptrs.Object_Pointer; Displacement : Natural) return Uint_Ptrs.Object_Pointer is use Uint_PtrOps; begin return Uint_Ptrs.Object_Pointer ( Uint_PtrOps.Pointer (Actual) + C.ptrdiff_t (Uint16 (Displacement) * Surface.pitch)); end Go_Down_Unchecked_Generic; -- =========================================================== -- Paint_Line_Generic -- =========================================================== procedure Paint_Line_Generic ( Surface : Vd.Surface_ptr; Line_Num : Natural; Color : C.int) is Line_Begin : Uint_Ptrs.Object_Pointer; begin Line_Begin := Goto_Line (Surface, Line_Num); Lib_C.memset ( Uint_Ptrs.To_Address (Line_Begin), Color, -- Surface.w * Surface.format.BytesPerPixel); C.size_t (Surface.pitch)); end Paint_Line_Generic; -- =========================================================== -- Paint_Line_Unchecked_Generic -- =========================================================== procedure Paint_Line_Unchecked_Generic ( Surface : Vd.Surface_ptr; Line_Begin : Uint_Ptrs.Object_Pointer; Color : C.int) is begin Lib_C.memset ( Uint_Ptrs.To_Address (Line_Begin), Color, -- Surface.w * Surface.format.BytesPerPixel); C.size_t (Surface.pitch)); end Paint_Line_Unchecked_Generic; -- =========================================================== function MapRGB_Generic ( format : Vd.PixelFormat_ptr; r : Uint8; g : Uint8; b : Uint8) return Element_Type is begin return Element_Type (Vd.MapRGB (format, r, g, b)); end MapRGB_Generic; -- =========================================================== end SDL_Framebuffer_Generics;
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2020, Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- -- SDL.TTFs -------------------------------------------------------------------------------------------------------------------- with Interfaces.C.Strings; with SDL.Error; package body SDL.TTFs is use type C.char_array; use type C.int; function Initialise return Boolean is function TTF_Init return C.int with Import => True, Convention => C, External_Name => "TTF_Init"; Result : C.int := TTF_Init; begin return (Result = Success); end Initialise; overriding procedure Finalize (Self : in out Fonts) is procedure TTF_Close_Font (Font : in Fonts_Ref) with Import => True, Convention => C, External_Name => "TTF_CloseFont"; procedure TTF_Quit with Import => True, Convention => C, External_Name => "TTF_Quit"; begin if Self.Internal /= null then if Self.Source_Freed = False then TTF_Close_Font (Self.Internal); end if; Self.Internal := null; TTF_Quit; end if; end Finalize; function Style (Self : in Fonts) return Font_Styles is function TTF_Get_Font_Style (Font : in Fonts_Ref) return Font_Styles with Import => True, Convention => C, External_Name => "TTF_GetFontStyle"; begin return TTF_Get_Font_Style (Self.Internal); end Style; procedure Set_Style (Self : in out Fonts; Now : in Font_Styles) is procedure TTF_Set_Font_Style (Font : in Fonts_Ref; Now : in Font_Styles) with Import => True, Convention => C, External_Name => "TTF_SetFontStyle"; begin TTF_Set_Font_Style (Self.Internal, Now); end Set_Style; function Outline (Self : in Fonts) return Font_Outlines is function TTF_Get_Font_Outline (Font : in Fonts_Ref) return Font_Outlines with Import => True, Convention => C, External_Name => "TTF_GetFontOutline"; begin return TTF_Get_Font_Outline (Self.Internal); end Outline; procedure Set_Outline (Self : in out Fonts; Now : in Font_Outlines := Outlines_Off) is procedure TTF_Set_Font_Outline (Font : in Fonts_Ref; Now : in Font_Outlines) with Import => True, Convention => C, External_Name => "TTF_SetFontOutline"; begin TTF_Set_Font_Outline (Self.Internal, Now); end Set_Outline; function Hinting (Self : in Fonts) return Font_Hints is function TTF_Get_Font_Hinting (Font : in Fonts_Ref) return Font_Hints with Import => True, Convention => C, External_Name => "TTF_GetFontHinting"; begin return TTF_Get_Font_Hinting (Self.Internal); end Hinting; procedure Set_Hinting (Self : in out Fonts; Now : in Font_Hints := Normal) is procedure TTF_Set_Font_Hinting (Font : in Fonts_Ref; Now : in Font_Hints) with Import => True, Convention => C, External_Name => "TTF_SetFontHinting"; begin TTF_Set_Font_Hinting (Self.Internal, Now); end Set_Hinting; function Kerning (Self : in Fonts) return Boolean is function TTF_Get_Font_Kerning (Font : in Fonts_Ref) return C.int with Import => True, Convention => C, External_Name => "TTF_GetFontKerning"; Enabled : C.int := TTF_Get_Font_Kerning (Self.Internal); begin return (if Enabled = 0 then False else True); end Kerning; procedure Set_Kerning (Self : in out Fonts; Now : in Boolean) is procedure TTF_Set_Font_Kerning (Font : in Fonts_Ref; Now : in C.int) with Import => True, Convention => C, External_Name => "TTF_SetFontKerning"; begin TTF_Set_Font_Kerning (Font => Self.Internal, Now => (if Now = True then 1 else 0)); end Set_Kerning; function Height (Self : in Fonts) return Font_Measurements is function TTF_Font_Height (Font : in Fonts_Ref) return Font_Measurements with Import => True, Convention => C, External_Name => "TTF_FontHeight"; begin return TTF_Font_Height (Self.Internal); end Height; function Ascent (Self : in Fonts) return Font_Measurements is function TTF_Font_Ascent (Font : in Fonts_Ref) return Font_Measurements with Import => True, Convention => C, External_Name => "TTF_FontAscent"; begin return TTF_Font_Ascent (Self.Internal); end Ascent; function Descent (Self : in Fonts) return Font_Measurements is function TTF_Font_Descent (Font : in Fonts_Ref) return Font_Measurements with Import => True, Convention => C, External_Name => "TTF_FontDescent"; begin return TTF_Font_Descent (Self.Internal); end Descent; function Line_Skip (Self : in Fonts) return Font_Measurements is function TTF_Font_Line_Skip (Font : in Fonts_Ref) return Font_Measurements with Import => True, Convention => C, External_Name => "TTF_FontLineSkip"; begin return TTF_Font_Line_Skip (Self.Internal); end Line_Skip; function Faces (Self : in Fonts) return Font_Faces is function TTF_Font_Faces (Font : in Fonts_Ref) return Font_Faces with Import => True, Convention => C, External_Name => "TTF_FontFaces"; begin return TTF_Font_Faces (Self.Internal); end Faces; function Is_Face_Fixed_Width (Self : in Fonts) return Boolean is function TTF_Font_Face_Is_Fixed_Width (Font : in Fonts_Ref) return C.int with Import => True, Convention => C, External_Name => "TTF_FontFaceIsFixedWidth"; Result : C.int := TTF_Font_Face_Is_Fixed_Width (Self.Internal); begin return (if Result > 0 then True else False); end Is_Face_Fixed_Width; function Face_Family_Name (Self : in Fonts) return String is function TTF_Font_Face_Family_Name (Font : in Fonts_Ref) return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "TTF_FontFaceFamilyName"; begin return C.Strings.Value (TTF_Font_Face_Family_Name (Self.Internal)); end Face_Family_Name; function Face_Style_Name (Self : in Fonts) return String is function TTF_Font_Face_Style_Name (Font : in Fonts_Ref) return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "TTF_FontFaceStyleName"; begin return C.Strings.Value (TTF_Font_Face_Style_Name (Self.Internal)); end Face_Style_Name; function Size_Latin_1 (Self : in Fonts; Text : in String) return SDL.Sizes is function TTF_Size_Text (Font : in Fonts_Ref; Text : in C.Strings.chars_ptr; W : out Dimension; H : out Dimension) return C.int with Import => True, Convention => C, External_Name => "TTF_SizeText"; Size : SDL.Sizes := SDL.Zero_Size; C_Text : C.Strings.chars_ptr := C.Strings.New_String (Text); Result : C.int := TTF_Size_Text (Self.Internal, C_Text, Size.Width, Size.Height); begin C.Strings.Free (C_Text); return Size; end Size_Latin_1; function Size_UTF_8 (Self : in Fonts; Text : in UTF_Strings.UTF_8_String) return SDL.Sizes is function TTF_Size_UTF_8 (Font : in Fonts_Ref; Text : in C.Strings.chars_ptr; W : out Dimension; H : out Dimension) return C.int with Import => True, Convention => C, External_Name => "TTF_SizeUTF8"; Size : SDL.Sizes := SDL.Zero_Size; C_Text : C.Strings.chars_ptr := C.Strings.New_String (Text); Result : C.int := TTF_Size_UTF_8 (Self.Internal, C_Text, Size.Width, Size.Height); begin return Size; end Size_UTF_8; function Make_Surface_From_Pointer (S : in Video.Surfaces.Internal_Surface_Pointer; Owns : in Boolean := False) return Video.Surfaces.Surface with Import => True, Convention => Ada; function Render_Solid (Self : in Fonts; Text : in String; Colour : in SDL.Video.Palettes.Colour) return SDL.Video.Surfaces.Surface is function TTF_Render_Text_Solid (Font : in Fonts_Ref; Text : in C.Strings.chars_ptr; Colour : in SDL.Video.Palettes.Colour) return Video.Surfaces.Internal_Surface_Pointer with Import => True, Convention => C, External_Name => "TTF_RenderText_Solid"; C_Text : C.Strings.chars_ptr := C.Strings.New_String (Text); begin return S : SDL.Video.Surfaces.Surface := Make_Surface_From_Pointer (S => TTF_Render_Text_Solid (Self.Internal, C_Text, Colour), Owns => True) do C.Strings.Free (C_Text); end return; end Render_Solid; function Render_Shaded (Self : in Fonts; Text : in String; Colour : in SDL.Video.Palettes.Colour; Background_Colour : in SDL.Video.Palettes.Colour) return SDL.Video.Surfaces.Surface is function TTF_Render_Text_Shaded (Font : in Fonts_Ref; Text : in C.Strings.chars_ptr; Colour : in SDL.Video.Palettes.Colour; Background_Colour : in SDL.Video.Palettes.Colour) return Video.Surfaces.Internal_Surface_Pointer with Import => True, Convention => C, External_Name => "TTF_RenderText_Shaded"; C_Text : C.Strings.chars_ptr := C.Strings.New_String (Text); begin return S : SDL.Video.Surfaces.Surface := Make_Surface_From_Pointer (S => TTF_Render_Text_Shaded (Self.Internal, C_Text, Colour, Background_Colour), Owns => True) do C.Strings.Free (C_Text); end return; end Render_Shaded; function Render_Blended (Self : in Fonts; Text : in String; Colour : in SDL.Video.Palettes.Colour) return SDL.Video.Surfaces.Surface is function TTF_Render_Text_Blended (Font : in Fonts_Ref; Text : in C.Strings.chars_ptr; Colour : in SDL.Video.Palettes.Colour) return Video.Surfaces.Internal_Surface_Pointer with Import => True, Convention => C, External_Name => "TTF_RenderText_Blended"; C_Text : C.Strings.chars_ptr := C.Strings.New_String (Text); begin return S : SDL.Video.Surfaces.Surface := Make_Surface_From_Pointer (S => TTF_Render_Text_Blended (Self.Internal, C_Text, Colour), Owns => True) do C.Strings.Free (C_Text); end return; end Render_Blended; end SDL.TTFs;
-- 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. pragma Ada_2012; with Ada.Text_IO; use Ada.Text_IO; with AUnit.Assertions; with Ada.Directories; use Ada.Directories; with Ada.Streams; use Ada.Streams; with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Unchecked_Conversion; with DNSCatcher.DNS; use DNSCatcher.DNS; with DNSCatcher.Types; use DNSCatcher.Types; with DNSCatcher.Utils; use DNSCatcher.Utils; with DNSCatcher.DNS.Processor.Packet; use DNSCatcher.DNS.Processor.Packet; with DNSCatcher.DNS.Processor.RData; use DNSCatcher.DNS.Processor.RData; with DNSCatcher.DNS.Processor.RData.SOA_Parser; use DNSCatcher.DNS.Processor.RData.SOA_Parser; with Interfaces.C.Extensions; use Interfaces.C.Extensions; package body Test_Packet_Parser is procedure Set_Up_Case (T : in out Packet_Parser_Test) is begin T.Capture_Config.Local_Listen_Port := 53; T.Capture_Config.Upstream_DNS_Server := To_Unbounded_String ("4.2.2.2"); T.Capture_Config.Upstream_DNS_Server_Port := 53; -- Configure the logger T.Capture_Config.Logger_Config.Log_Level := DEBUG; T.Capture_Config.Logger_Config.Use_Color := True; T.Logger_Task.Initialize (T.Capture_Config.Logger_Config); T.Logger_Task.Start; end Set_Up_Case; procedure Tear_Down_Case (T : in out Packet_Parser_Test) is begin T.Logger_Task.Stop; end Tear_Down_Case; -------------------- -- Register_Tests -- -------------------- procedure Register_Tests (T : in out Packet_Parser_Test) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, Test_Parse_A_Record'Access, "Parse A Record"); Register_Routine (T, Test_Parse_SOA_Record'Access, "Parse SOA Record"); Register_Routine (T, Test_Parse_CNAME_Record'Access, "Parse CName Record"); Register_Routine (T, Test_Parse_NS_Record'Access, "Parse NS Record"); Register_Routine (T, Test_Parse_PTR_Record'Access, "Parse PTR Record"); Register_Routine (T, Test_Parse_OPT_Record'Access, "Parse OPT Record"); end Register_Tests; ---------- -- Name -- ---------- pragma Warnings (Off, "formal parameter ""T"" is not referenced"); function Name (T : Packet_Parser_Test) return Message_String is begin return Format ("Packet Parser Test"); end Name; --------------------- -- Test_Simple_Add -- --------------------- function Load_Binary_DNS_Dump (File : String) return Raw_Packet_Record_Ptr is Input_File : Stream_IO.File_Type; Input_Stream : Stream_Access; Packet_Size : Stream_Element_Offset; Read_Packet : Stream_Element_Offset; Full_Packet : Stream_Element_Array_Ptr; Inbound_Packet : constant Raw_Packet_Record_Ptr := new Raw_Packet_Record; begin Ada.Streams.Stream_IO.Open (Input_File, In_File, File); -- We need to load and convert the header seperately because Ada sizing -- doesn't account for Pack correct. Input_Stream := Ada.Streams.Stream_IO.Stream (Input_File); -- Load in the A record and try to parse it Packet_Size := Stream_Element_Offset (Size (File)); Full_Packet := new Stream_Element_Array (1 .. Packet_Size); Input_Stream.Read (Full_Packet.all, Read_Packet); Inbound_Packet.Raw_Data.Header := SEA_To_DNS_Packet_Header (Full_Packet (Full_Packet'First .. DNS_PACKET_HEADER_SIZE)); Inbound_Packet.Raw_Data.Data := new Stream_Element_Array (1 .. Packet_Size - DNS_PACKET_HEADER_SIZE); Inbound_Packet.Raw_Data.Data.all := Full_Packet (DNS_PACKET_HEADER_SIZE + 1 .. Packet_Size); Free_Stream_Element_Array_Ptr (Full_Packet); Close (Input_File); return Inbound_Packet; end Load_Binary_DNS_Dump; procedure Test_Parse_A_Record (T : in out Test_Cases.Test_Case'Class) is Logger_Packet : DNSCatcher.Utils.Logger.Logger_Message_Packet_Ptr; Parsed_Packet : Parsed_DNS_Packet_Ptr; Inbound_Packet : Raw_Packet_Record_Ptr := new Raw_Packet_Record; Question : Parsed_DNS_Question; Answer : Parsed_RData_Access; begin Logger_Packet := new Logger_Message_Packet; Inbound_Packet := Load_Binary_DNS_Dump ("./tests/data/udp_a_record.bin"); Parsed_Packet := Packet_Parser (Logger_Packet, Inbound_Packet); Logger_Queue.Add_Packet (Logger_Packet); -- Verify the data we got from the packet matches what we expect AUnit.Assertions.Assert ((Integer (Parsed_Packet.Header.Question_Count) = Integer (Parsed_Packet.Questions.Length)), "Question Count Mismatch!"); -- Verify the question section Question := Parsed_Packet.Questions (1); AUnit.Assertions.Assert (To_String (Question.QName), "apple.com", "Incorrect QNAME on decode!"); AUnit.Assertions.Assert ((Question.QType = DNSCatcher.DNS.A), "Incorrect QTYPE on decode!"); AUnit.Assertions.Assert ((Question.QClass = DNSCatcher.DNS.INternet), "Incorrect QCLASS on decode!"); -- Verify the response section AUnit.Assertions.Assert ((Integer (Parsed_Packet.Header.Answer_Record_Count) = Integer (Parsed_Packet.Answer.Length)), "Answer Count Mismatch!"); Answer := Parsed_Packet.Answer.Element (1); AUnit.Assertions.Assert (To_String (Answer.RName), "apple.com", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.A), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3190), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "17.172.224.47", "RData is incorrect"); Answer := Parsed_Packet.Answer.Element (2); AUnit.Assertions.Assert (To_String (Answer.RName), "apple.com", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.A), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3190), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "17.178.96.59", "RData is incorrect"); Answer := Parsed_Packet.Answer.Element (3); AUnit.Assertions.Assert (To_String (Answer.RName), "apple.com", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.A), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3190), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "17.142.160.59", "RData is incorrect"); Free_Raw_Packet_Record_Ptr (Inbound_Packet); Free_Parsed_DNS_Packet (Parsed_Packet); end Test_Parse_A_Record; -- Tests if we can parse an SOA record procedure Test_Parse_SOA_Record (T : in out Test_Cases.Test_Case'Class) is Logger_Packet : DNSCatcher.Utils.Logger.Logger_Message_Packet_Ptr; Parsed_Packet : Parsed_DNS_Packet_Ptr; Inbound_Packet : Raw_Packet_Record_Ptr := new Raw_Packet_Record; Question : Parsed_DNS_Question; Answer : Parsed_RData_Access; SOA_Record : Parsed_SOA_RData_Access; function To_Parsed_SOA_RData is new Ada.Unchecked_Conversion (Source => Parsed_RData_Access, Target => Parsed_SOA_RData_Access); begin Logger_Packet := new Logger_Message_Packet; Inbound_Packet := Load_Binary_DNS_Dump ("./tests/data/udp_soa_record.bin"); Parsed_Packet := Packet_Parser (Logger_Packet, Inbound_Packet); Logger_Queue.Add_Packet (Logger_Packet); -- Verify the question section Question := Parsed_Packet.Questions (1); AUnit.Assertions.Assert (To_String (Question.QName), "casadevall.pro", "Incorrect QNAME on decode!"); AUnit.Assertions.Assert ((Question.QType = DNSCatcher.DNS.SOA), "Incorrect QTYPE on decode!"); AUnit.Assertions.Assert ((Question.QClass = DNSCatcher.DNS.INternet), "Incorrect QCLASS on decode!"); -- Verify the response section AUnit.Assertions.Assert ((Integer (Parsed_Packet.Header.Answer_Record_Count) = Integer (Parsed_Packet.Answer.Length)), "Answer Count Mismatch!"); Answer := Parsed_Packet.Answer.Element (1); SOA_Record := To_Parsed_SOA_RData (Answer); AUnit.Assertions.Assert (To_String (SOA_Record.Primary_Nameserver), "ns1.casadevall.pro", "Incorrect decode on primary nameserver"); AUnit.Assertions.Assert (To_String (SOA_Record.Responsible_Contact), "casadevall.pro", "Incorrect decode on responsible contact"); AUnit.Assertions.Assert ((Integer (SOA_Record.Serial) = 2018082638), "Incorrect Serial"); AUnit.Assertions.Assert ((Integer (SOA_Record.Refresh) = 300), "Incorrect Refresh"); AUnit.Assertions.Assert ((Integer (SOA_Record.Retry) = 14400), "Incorrect Refresh"); AUnit.Assertions.Assert ((Integer (SOA_Record.Expire) = 2419200), "Incorrect Expire"); AUnit.Assertions.Assert ((Integer (SOA_Record.Minimum) = 1800), "Incorrect Expire"); Free_Raw_Packet_Record_Ptr (Inbound_Packet); Free_Parsed_DNS_Packet (Parsed_Packet); end Test_Parse_SOA_Record; -- Tests if we can parse an CNAME record procedure Test_Parse_CNAME_Record (T : in out Test_Cases.Test_Case'Class) is Logger_Packet : DNSCatcher.Utils.Logger.Logger_Message_Packet_Ptr; Parsed_Packet : Parsed_DNS_Packet_Ptr; Inbound_Packet : Raw_Packet_Record_Ptr := new Raw_Packet_Record; Question : Parsed_DNS_Question; Answer : Parsed_RData_Access; begin Logger_Packet := new Logger_Message_Packet; Inbound_Packet := Load_Binary_DNS_Dump ("./tests/data/udp_cname_record.bin"); Parsed_Packet := Packet_Parser (Logger_Packet, Inbound_Packet); Logger_Queue.Add_Packet (Logger_Packet); -- Verify the question section Question := Parsed_Packet.Questions (1); AUnit.Assertions.Assert (To_String (Question.QName), "mail.casadevall.pro", "Incorrect QNAME on decode!"); AUnit.Assertions.Assert ((Question.QType = DNSCatcher.DNS.CNAME), "Incorrect QTYPE on decode!"); AUnit.Assertions.Assert ((Question.QClass = DNSCatcher.DNS.INternet), "Incorrect QCLASS on decode!"); AUnit.Assertions.Assert ((Integer (Parsed_Packet.Header.Answer_Record_Count) = Integer (Parsed_Packet.Answer.Length)), "Answer Count Mismatch!"); Answer := Parsed_Packet.Answer.Element (1); AUnit.Assertions.Assert (To_String (Answer.RName), "mail.casadevall.pro", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.CNAME), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3600), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "pathfinder.casadevall.pro", "RData is incorrect"); Free_Raw_Packet_Record_Ptr (Inbound_Packet); Free_Parsed_DNS_Packet (Parsed_Packet); end Test_Parse_CNAME_Record; procedure Test_Parse_NS_Record (T : in out Test_Cases.Test_Case'Class) is Logger_Packet : DNSCatcher.Utils.Logger.Logger_Message_Packet_Ptr; Parsed_Packet : Parsed_DNS_Packet_Ptr; Inbound_Packet : Raw_Packet_Record_Ptr := new Raw_Packet_Record; Question : Parsed_DNS_Question; Answer : Parsed_RData_Access; begin Logger_Packet := new Logger_Message_Packet; Inbound_Packet := Load_Binary_DNS_Dump ("./tests/data/udp_ns_record.bin"); Parsed_Packet := Packet_Parser (Logger_Packet, Inbound_Packet); Logger_Queue.Add_Packet (Logger_Packet); -- Verify the question section Question := Parsed_Packet.Questions (1); AUnit.Assertions.Assert (To_String (Question.QName), "casadevall.pro", "Incorrect QNAME on decode!"); AUnit.Assertions.Assert ((Question.QType = DNSCatcher.DNS.NS), "Incorrect QTYPE on decode!"); AUnit.Assertions.Assert ((Question.QClass = DNSCatcher.DNS.INternet), "Incorrect QCLASS on decode!"); AUnit.Assertions.Assert ((Integer (Parsed_Packet.Header.Answer_Record_Count) = Integer (Parsed_Packet.Answer.Length)), "Answer Count Mismatch!"); Answer := Parsed_Packet.Answer.Element (1); AUnit.Assertions.Assert (To_String (Answer.RName), "casadevall.pro", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.NS), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3600), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "ns5.linode.com", "RData is incorrect"); Answer := Parsed_Packet.Answer.Element (2); AUnit.Assertions.Assert (To_String (Answer.RName), "casadevall.pro", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.NS), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3600), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "ns2.linode.com", "RData is incorrect"); Answer := Parsed_Packet.Answer.Element (3); AUnit.Assertions.Assert (To_String (Answer.RName), "casadevall.pro", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.NS), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3600), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "ns1.casadevall.pro", "RData is incorrect"); Answer := Parsed_Packet.Answer.Element (4); AUnit.Assertions.Assert (To_String (Answer.RName), "casadevall.pro", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.NS), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3600), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "ns3.linode.com", "RData is incorrect"); Answer := Parsed_Packet.Answer.Element (5); AUnit.Assertions.Assert (To_String (Answer.RName), "casadevall.pro", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.NS), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3600), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "ns1.linode.com", "RData is incorrect"); Answer := Parsed_Packet.Answer.Element (6); AUnit.Assertions.Assert (To_String (Answer.RName), "casadevall.pro", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.NS), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3600), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "ns4.linode.com", "RData is incorrect"); Free_Raw_Packet_Record_Ptr (Inbound_Packet); Free_Parsed_DNS_Packet (Parsed_Packet); end Test_Parse_NS_Record; -- Tests if we can parse an PTR record procedure Test_Parse_PTR_Record (T : in out Test_Cases.Test_Case'Class) is Logger_Packet : DNSCatcher.Utils.Logger.Logger_Message_Packet_Ptr; Parsed_Packet : Parsed_DNS_Packet_Ptr; Inbound_Packet : Raw_Packet_Record_Ptr := new Raw_Packet_Record; Question : Parsed_DNS_Question; Answer : Parsed_RData_Access; begin Logger_Packet := new Logger_Message_Packet; Inbound_Packet := Load_Binary_DNS_Dump ("./tests/data/udp_ptr_record.bin"); Parsed_Packet := Packet_Parser (Logger_Packet, Inbound_Packet); Logger_Queue.Add_Packet (Logger_Packet); -- Verify the question section Question := Parsed_Packet.Questions (1); AUnit.Assertions.Assert (To_String (Question.QName), "193.112.33.45.in-addr.arpa", "Incorrect QNAME on decode!"); AUnit.Assertions.Assert ((Question.QType = DNSCatcher.DNS.PTR), "Incorrect QTYPE on decode!"); AUnit.Assertions.Assert ((Question.QClass = DNSCatcher.DNS.INternet), "Incorrect QCLASS on decode!"); AUnit.Assertions.Assert ((Integer (Parsed_Packet.Header.Answer_Record_Count) = Integer (Parsed_Packet.Answer.Length)), "Answer Count Mismatch!"); Answer := Parsed_Packet.Answer.Element (1); AUnit.Assertions.Assert (To_String (Answer.RName), "193.112.33.45.in-addr.arpa", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.PTR), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 86400), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "pathfinder.casadevall.pro", "RData is incorrect"); Free_Raw_Packet_Record_Ptr (Inbound_Packet); Free_Parsed_DNS_Packet (Parsed_Packet); end Test_Parse_PTR_Record; -- Tests if we can parse an OPT record procedure Test_Parse_OPT_Record (T : in out Test_Cases.Test_Case'Class) is Logger_Packet : DNSCatcher.Utils.Logger.Logger_Message_Packet_Ptr; Parsed_Packet : Parsed_DNS_Packet_Ptr; Inbound_Packet : Raw_Packet_Record_Ptr := new Raw_Packet_Record; Question : Parsed_DNS_Question; Answer : Parsed_RData_Access; begin Logger_Packet := new Logger_Message_Packet; Inbound_Packet := Load_Binary_DNS_Dump ("./tests/data/udp_client_opt_record.bin"); Parsed_Packet := Packet_Parser (Logger_Packet, Inbound_Packet); Logger_Queue.Add_Packet (Logger_Packet); -- Verify the question section (this was a request for a DNSKEY on the -- root) Question := Parsed_Packet.Questions (1); AUnit.Assertions.Assert (To_String (Question.QName), "", "Incorrect QNAME on decode!"); AUnit.Assertions.Assert ((Question.QType = DNSCatcher.DNS.DNSKEY), "Incorrect QTYPE on decode!"); AUnit.Assertions.Assert ((Question.QClass = DNSCatcher.DNS.INternet), "Incorrect QCLASS on decode!"); Put_Line (Parsed_Packet.Header.Additional_Record_Count'Image); Put_Line (Parsed_Packet.Additional.Length'Image); AUnit.Assertions.Assert ((Integer (Parsed_Packet.Header.Additional_Record_Count) = Integer (Parsed_Packet.Additional.Length)), "Additional Count Mismatch!"); Answer := Parsed_Packet.Additional.Element (1); AUnit.Assertions.Assert (To_String (Answer.RName), "", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.OPT), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 0), "Incorrect TTL!"); Free_Raw_Packet_Record_Ptr (Inbound_Packet); Free_Parsed_DNS_Packet (Parsed_Packet); end Test_Parse_OPT_Record; end Test_Packet_Parser;
with Datos, Ada.Text_Io; use Datos, Ada.Text_Io; procedure Eliminar_Primera_Aparicion ( L : in out Lista; Num : in Integer ) is -- Pre: -- Post: se ha eliminado de L la primera aparicion de Num -- en caso de que no aparezca se escribira un mensaje begin end Eliminar_Primera_Aparicion;
with AUnit; use AUnit; with AUnit.Test_Suites; with AUnit.Run; with AUnit.Reporter.Text; with GNAT.OS_Lib; with Ada.Text_IO; with Testsuite.Encode; with Testsuite.Decode; with Testsuite.Encode_Decode; procedure Tests is Failures : Natural := 0; begin for Kind in Testsuite.Encode.Encoder_Kind loop declare Suite : aliased AUnit.Test_Suites.Test_Suite; function Get_Suite return AUnit.Test_Suites.Access_Test_Suite is (Suite'Unchecked_Access); function Runner is new AUnit.Run.Test_Runner_With_Status (Get_Suite); Reporter : AUnit.Reporter.Text.Text_Reporter; begin Ada.Text_IO.New_Line; Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line ("Testing " & Kind'Img & " encoder:"); Testsuite.Encode.Set_Encoder_Kind (Kind); Testsuite.Encode.Add_Tests (Suite); Reporter.Set_Use_ANSI_Colors (True); if Runner (Reporter, (Global_Timer => True, Test_Case_Timer => True, Report_Successes => True, others => <>)) /= AUnit.Success then Failures := Failures + 1; end if; end; end loop; for Kind in Testsuite.Decode.Decoder_Kind loop declare Suite : aliased AUnit.Test_Suites.Test_Suite; function Get_Suite return AUnit.Test_Suites.Access_Test_Suite is (Suite'Unchecked_Access); function Runner is new AUnit.Run.Test_Runner_With_Status (Get_Suite); Reporter : AUnit.Reporter.Text.Text_Reporter; begin Ada.Text_IO.New_Line; Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line ("Testing " & Kind'Img & " decoder:"); Testsuite.Decode.Set_Decoder_Kind (Kind); Testsuite.Decode.Add_Tests (Suite); Reporter.Set_Use_ANSI_Colors (True); if Runner (Reporter, (Global_Timer => True, Test_Case_Timer => True, Report_Successes => True, others => <>)) /= AUnit.Success then Failures := Failures + 1; end if; end; end loop; for D_Kind in Testsuite.Decode.Decoder_Kind loop for E_Kind in Testsuite.Encode.Encoder_Kind loop declare Suite : aliased AUnit.Test_Suites.Test_Suite; function Get_Suite return AUnit.Test_Suites.Access_Test_Suite is (Suite'Unchecked_Access); function Runner is new AUnit.Run.Test_Runner_With_Status (Get_Suite); Reporter : AUnit.Reporter.Text.Text_Reporter; begin Ada.Text_IO.New_Line; Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line ("Testing " & E_Kind'Img & " encoder" & " with " & D_Kind'Img & " decoder"); Testsuite.Encode_Decode.Set_Kinds (E_Kind, D_Kind); Testsuite.Encode_Decode.Add_Tests (Suite); Reporter.Set_Use_ANSI_Colors (True); if Runner (Reporter, (Global_Timer => True, Test_Case_Timer => True, Report_Successes => True, others => <>)) /= AUnit.Success then Failures := Failures + 1; end if; end; end loop; end loop; if Failures /= 0 then GNAT.OS_Lib.OS_Exit (1); end if; end Tests;
with AUnit.Assertions; use AUnit.Assertions; with ACO.Utils.DS.Generic_Collection; with ACO.Utils.DS.Generic_Collection.Sorted; package body Generic_Collection_Test is pragma Assertion_Policy (Check); type Item_Type is new Character; subtype Test_Items is Item_Type range 'a' .. 'z'; package Collection_Pack is new ACO.Utils.DS.Generic_Collection (Item_Type => Item_Type, "=" => "="); Max_Size : constant := Test_Items'Pos(Test_Items'Last) - Test_Items'Pos(Test_Items'First) + 1; subtype Collection is Collection_Pack.Collection (Max_Size); package Sorted is type T is record Char : Character; Id : Natural; end record; function "=" (L : T; R : T) return Boolean is (L.Char = R.Char); package Collection_Pack is new ACO.Utils.DS.Generic_Collection (Item_Type => T, "=" => "="); function "<" (L : T; R : T) return Boolean is (L.Char < R.Char); package Pack is new Collection_Pack.Sorted ("<" => "<"); Max_Size : constant := 10; subtype Collection is Pack.Sorted_Collection (Max_Size); end Sorted; function Name (T : Test) return AUnit.Message_String is pragma Unreferenced (T); begin return AUnit.Format ("Data Structures: Generic (Sorted) Collection Test"); end Name; procedure Init_Test is C : Collection; begin Assert (C.Is_Empty, "Collection is not initially empty"); Assert (C.Length = 0, "Collection has not initially the length zero"); Assert (not C.Is_Full, "Collection is initially full"); Assert (C.Available = Max_Size, "Nof availables in collection incorrect"); for I in 1 .. C.Max_Size loop Assert (not C.Is_Valid_Index (I), "Empty collection has valid index"); end loop; end Init_Test; procedure Fill_And_Empty is C : Collection; L : Natural := 0; Loc : Natural; begin C.Clear; for I in Test_Items'Range loop C.Append (I); L := L + 1; Assert (C.Length = L, "Length incorrect"); Assert (C.Available = C.Max_Size - L, "Available incorrect"); Assert (C.Is_Valid_Index (L), "Index of added item invalid"); Assert (not C.Is_Valid_Index (L + 1), "Index of not added item valid"); Assert (C.Item_At (L) = I, "Added item incorrect"); Assert (C.Last = I, "Appended item not the last one"); Assert (C.First = Test_Items'First, "First item not the first added"); Assert (not C.Is_Empty, "Collection is empty after adding items"); Assert (C.Location (I) = L, "Location of added item incorrect"); end loop; Assert (C.Is_Full, "Collection not full after filling it"); for I in Test_Items'Range loop Loc := C.Location (I); C.Remove (Loc); L := L - 1; Assert (C.Length = L, "Length incorrect"); Assert (C.Available = C.Max_Size - L, "Available incorrect"); if not C.Is_Empty then Assert (C.Is_Valid_Index (Loc), "Front index invalid after removing front item"); Assert (C.First = Test_Items'Succ (I), "Item after removed not set as front item"); Assert (C.Last = Test_Items'Last, "Last item not kept"); else Assert (not C.Is_Valid_Index (Loc), "Front index valid when collection is empty"); end if; end loop; Assert (C.Is_Empty, "Not empty after removing all items"); end Fill_And_Empty; type Result (L : Natural) is record Description : String (1 .. L); Status : Boolean; end record; function Failed (Description : String) return Result is (Result'(L => Description'Length, Description => Description, Status => False)); function Success return Result is (Result'(L => 0, Description => "", Status => True)); type State_Array is array (Positive range <>) of Item_Type; function Check (C : in Collection'Class; State : in State_Array) return Result is First : Item_Type renames State (State'First); Last : Item_Type renames State (State'Last); Length : constant Natural := State'Length; begin if not (C.First = First) then return Failed ("First item incorrect"); end if; if not (C.Last = Last) then return Failed ("Last item incorrect"); end if; if not (C.Length = Length) then return Failed ("Incorrect length"); end if; if not (C.Available = C.Max_Size - Length) then return Failed ("Available incorrect"); end if; if not (if C.Length = 0 then C.Is_Empty else not C.Is_Empty) then return Failed ("Empty flag not consistent with length " & "Length =" & C.Length'Img & "=> Is_Empty = " & C.Is_Empty'Img); end if; if not (if C.Length = C.Max_Size then C.Is_Full else not C.Is_Full) then return Failed ("Full flag not consistent with length " & "Length =" & C.Length'Img & "=> Is_Full = " & C.Is_Full'Img); end if; for Index in 1 .. C.Max_Size loop if Index <= C.Length then if not (C.Is_Valid_Index (Index)) then return Failed ("Valid index reported as invalid"); end if; else if C.Is_Valid_Index (Index) then return Failed ("Invalid index reported as valid"); end if; end if; end loop; for Index in 1 .. C.Length loop if not (State (Index) = C.Item_At (Index)) then return Failed ("Item at index" & Index'Img & " does not match"); end if; end loop; return Success; end Check; procedure Insert is C : Collection; begin C.Insert ('a'); -- Insert front to empty declare S : constant Result := Check (C, (1 => 'a')); begin Assert (S.Status, S.Description); end; C.Insert ('b'); -- Insert front to non-empty declare S : constant Result := Check (C, ('b', 'a')); begin Assert (S.Status, S.Description); end; C.Clear; C.Insert ('a', Before => 1); -- Directed insert front to empty declare S : constant Result := Check (C, (1 => 'a')); begin Assert (S.Status, S.Description); end; C.Insert ('b', Before => 1); -- Directed insert front to non-empty declare S : constant Result := Check (C, ('b', 'a')); begin Assert (S.Status, S.Description); end; C.Insert ('c', Before => 2); -- Directed insert middle to non-empty declare S : constant Result := Check (C, ('b', 'c', 'a')); begin Assert (S.Status, S.Description); end; end Insert; procedure Append is C : Collection; begin C.Append ('a'); -- Append last to empty declare S : constant Result := Check (C, (1 => 'a')); begin Assert (S.Status, S.Description); end; C.Append ('b'); -- Append last to non-empty declare S : constant Result := Check (C, ('a', 'b')); begin Assert (S.Status, S.Description); end; C.Clear; C.Append ('a', After => 1); -- Directed append last to empty declare S : constant Result := Check (C, (1 => 'a')); begin Assert (S.Status, S.Description); end; C.Append ('b', After => 1); -- Directed append last to non-empty declare S : constant Result := Check (C, ('a', 'b')); begin Assert (S.Status, S.Description); end; C.Append ('c', After => 1); -- Directed append middle to non-empty declare S : constant Result := Check (C, ('a', 'c', 'b')); begin Assert (S.Status, S.Description); end; end Append; procedure Remove is C : Collection; begin C.Append ('a'); C.Append ('b'); C.Append ('c'); C.Append ('d'); C.Remove (2); -- Remove from middle declare S : constant Result := Check (C, ('a', 'c', 'd')); begin Assert (S.Status, S.Description); end; C.Remove (1); -- Remove from front declare S : constant Result := Check (C, ('c', 'd')); begin Assert (S.Status, S.Description); end; C.Remove (2); -- Remove from back declare S : constant Result := Check (C, (1 => 'c')); begin Assert (S.Status, S.Description); end; C.Remove (1); -- Remove last Assert (C.Is_Empty, "Not empty after removing last item"); end Remove; procedure Location is C : Collection; begin Assert (C.Location ('a') = Collection_Pack.No_Index, "Found in empty"); C.Append ('a'); -- a Assert (C.Location ('a') = 1, "Did not find location for size 1"); C.Append ('b'); -- ab Assert (C.Location ('b') = 2, "Did not find location for last"); C.Append ('c'); -- abc Assert (C.Location ('b') = 2, "Did not find location for middle"); C.Append ('c'); -- abcc Assert (C.Location ('c') = 3, "Did not find location for first duplicate"); end Location; procedure Replace is C : Collection; begin C.Append ('a'); C.Replace (1, 'b'); declare S : constant Result := Check (C, (1 => 'b')); begin Assert (S.Status, S.Description); end; C.Append ('c'); C.Replace (1, 'd'); declare S : constant Result := Check (C, ('d', 'c')); begin Assert (S.Status, S.Description); end; C.Replace (2, 'e'); declare S : constant Result := Check (C, ('d', 'e')); begin Assert (S.Status, S.Description); end; C.Append ('f'); C.Replace (2, 'g'); declare S : constant Result := Check (C, ('d', 'g', 'f')); begin Assert (S.Status, S.Description); end; end Replace; procedure Insert_Sorted is use type Sorted.T; C : Sorted.Collection; begin C.Insert (('a', 1)); -- a1 C.Insert (('c', 1)); -- a1c1 C.Insert (('b', 1)); -- a1b1c1 C.Insert (('b', 2)); -- a1b2b1c1 Assert (C.Item_At (1) = ('a', 1), ""); Assert (C.Item_At (2) = ('b', 2), ""); Assert (C.Item_At (3) = ('b', 1), ""); Assert (C.Item_At (4) = ('c', 1), ""); C.Clear; C.Insert (('a', 1)); -- a1 C.Insert (('c', 1), Before => 1); -- a1c1 C.Insert (('c', 2), Before => 2); -- a1c2c1 C.Insert (('c', 3), Before => 3); -- a1c2c3c1 Assert (C.Item_At (1) = ('a', 1), ""); Assert (C.Item_At (2) = ('c', 2), ""); Assert (C.Item_At (3) = ('c', 3), ""); Assert (C.Item_At (4) = ('c', 1), ""); end Insert_Sorted; procedure Append_Sorted is use type Sorted.T; C : Sorted.Collection; begin C.Append (('b', 1)); -- b1 C.Append (('a', 1)); -- a1b1 C.Append (('a', 2)); -- a1a2b1 C.Append (('a', 3)); -- a1a2a3b1 Assert (C.Item_At (1) = ('a', 1), ""); Assert (C.Item_At (2) = ('a', 2), ""); Assert (C.Item_At (3) = ('a', 3), ""); Assert (C.Item_At (4) = ('b', 1), ""); C.Clear; C.Append (('b', 1)); -- b1 C.Append (('a', 1), After => 1); -- a1b1 C.Append (('a', 2), After => 2); -- a1a2b1 C.Append (('a', 3), After => 1); -- a1a3a2b1 Assert (C.Item_At (1) = ('a', 1), ""); Assert (C.Item_At (2) = ('a', 3), ""); Assert (C.Item_At (3) = ('a', 2), ""); Assert (C.Item_At (4) = ('b', 1), ""); end Append_Sorted; procedure Replace_Sorted is use type Sorted.T; C : Sorted.Collection; begin C.Append (('b', 1)); C.Append (('c', 1)); C.Append (('c', 2)); C.Append (('c', 3)); C.Append (('d', 1)); -- b1 c1 c2 c3 d1 C.Replace (3, ('b', 0)); -- b1 b0 c1 c3 d1 Assert (C.Item_At (1) = ('b', 1), ""); Assert (C.Item_At (2) = ('b', 0), ""); Assert (C.Item_At (3) = ('c', 1), ""); Assert (C.Item_At (4) = ('c', 3), ""); Assert (C.Item_At (5) = ('d', 1), ""); C.Replace (3, ('d', 0)); -- b1 b0 c3 d0 d1 Assert (C.Item_At (1) = ('b', 1), ""); Assert (C.Item_At (2) = ('b', 0), ""); Assert (C.Item_At (3) = ('c', 3), ""); Assert (C.Item_At (4) = ('d', 0), ""); Assert (C.Item_At (5) = ('d', 1), ""); C.Replace (3, ('c', 0)); -- b1 b0 c0 d0 d1 Assert (C.Item_At (1) = ('b', 1), ""); Assert (C.Item_At (2) = ('b', 0), ""); Assert (C.Item_At (3) = ('c', 0), ""); Assert (C.Item_At (4) = ('d', 0), ""); Assert (C.Item_At (5) = ('d', 1), ""); end Replace_Sorted; procedure First_Empty is C : Collection; Tmp : Item_Type; pragma Unreferenced (Tmp); begin C.Clear; Tmp := C.First; end First_Empty; procedure Last_Empty is C : Collection; Tmp : Item_Type; pragma Unreferenced (Tmp); begin C.Clear; Tmp := C.Last; end Last_Empty; procedure Item_At_Empty is C : Collection; Tmp : Item_Type; pragma Unreferenced (Tmp); begin C.Clear; Tmp := C.Item_At (1); end Item_At_Empty; procedure Remove_Empty is C : Collection; begin C.Clear; C.Remove (1); end Remove_Empty; procedure Replace_Empty is C : Collection; begin C.Clear; C.Replace (1, 'x'); end Replace_Empty; procedure Fill (C : in out Collection) is begin while not C.Is_Full loop C.Append ('X'); end loop; end Fill; procedure Insert_Full is C : Collection; begin Fill (C); C.Insert ('X'); end Insert_Full; procedure Insert_Before_Full is C : Collection; begin Fill (C); C.Insert ('X', Before => 1); end Insert_Before_Full; procedure Append_Full is C : Collection; begin Fill (C); C.Append ('X'); end Append_Full; procedure Append_After_Full is C : Collection; begin Fill (C); C.Append ('X', After => 1); end Append_After_Full; procedure Preconditions is begin Assert_Exception (First_Empty'Access, "Expected an exception when accessing first item for empty"); Assert_Exception (Last_Empty'Access, "Expected an exception when accessing last item for empty"); Assert_Exception (Item_At_Empty'Access, "Expected an exception when accessing item for empty"); Assert_Exception (Remove_Empty'Access, "Expected an exception when removing item for empty"); Assert_Exception (Replace_Empty'Access, "Expected an exception when replacing item for empty"); Assert_Exception (Insert_Full'Access, "Expected an exception when inserting item to full"); Assert_Exception (Insert_Before_Full'Access, "Expected an exception when inserting item to full"); Assert_Exception (Append_Full'Access, "Expected an exception when appending item to full"); Assert_Exception (Append_After_Full'Access, "Expected an exception when appending item to full"); end Preconditions; procedure Run_Test (T : in out Test) is pragma Unreferenced (T); begin Init_Test; Fill_And_Empty; Insert; Append; Remove; Location; Replace; Preconditions; Insert_Sorted; Append_Sorted; Replace_Sorted; end Run_Test; end Generic_Collection_Test;
with Ada.Containers.Vectors; With Ada.Strings.Unbounded; package Util is -- TODO separate further into specialized packages? -- TODO make child package of Iictl? Verbose : Boolean := False; -- TODO make private or something. Util.Set_Verbose? use type Ada.Strings.Unbounded.Unbounded_String; package Unbounded_String_Vectors is new Ada.Containers.Vectors (Element_Type => Ada.Strings.Unbounded.Unbounded_String, Index_Type => Natural); type Unbounded_String_Vector is new Unbounded_String_Vectors.Vector with null record; procedure Verbose_Print (Msg : String); function Is_Fifo_Up (Srv_Path : in String) return Boolean; -- TODO rename Is_Fifo_Down? Avoid double negatives function Is_Integral (Text : String) return Boolean; -- TODO package util? end Util;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ package AMF.Internals.Tables.UML_Metamodel.Links is procedure Initialize; private procedure Initialize_1; procedure Initialize_2; procedure Initialize_3; procedure Initialize_4; procedure Initialize_5; procedure Initialize_6; procedure Initialize_7; procedure Initialize_8; procedure Initialize_9; procedure Initialize_10; procedure Initialize_11; procedure Initialize_12; procedure Initialize_13; procedure Initialize_14; procedure Initialize_15; procedure Initialize_16; procedure Initialize_17; procedure Initialize_18; procedure Initialize_19; procedure Initialize_20; procedure Initialize_21; procedure Initialize_22; procedure Initialize_23; procedure Initialize_24; procedure Initialize_25; procedure Initialize_26; procedure Initialize_27; procedure Initialize_28; procedure Initialize_29; procedure Initialize_30; procedure Initialize_31; procedure Initialize_32; procedure Initialize_33; procedure Initialize_34; procedure Initialize_35; procedure Initialize_36; procedure Initialize_37; procedure Initialize_38; procedure Initialize_39; procedure Initialize_40; procedure Initialize_41; procedure Initialize_42; procedure Initialize_43; procedure Initialize_44; procedure Initialize_45; procedure Initialize_46; procedure Initialize_47; procedure Initialize_48; procedure Initialize_49; procedure Initialize_50; procedure Initialize_51; procedure Initialize_52; procedure Initialize_53; procedure Initialize_54; procedure Initialize_55; procedure Initialize_56; procedure Initialize_57; procedure Initialize_58; procedure Initialize_59; procedure Initialize_60; procedure Initialize_61; procedure Initialize_62; procedure Initialize_63; procedure Initialize_64; procedure Initialize_65; procedure Initialize_66; procedure Initialize_67; procedure Initialize_68; procedure Initialize_69; procedure Initialize_70; procedure Initialize_71; procedure Initialize_72; procedure Initialize_73; procedure Initialize_74; procedure Initialize_75; procedure Initialize_76; procedure Initialize_77; procedure Initialize_78; procedure Initialize_79; procedure Initialize_80; procedure Initialize_81; procedure Initialize_82; procedure Initialize_83; procedure Initialize_84; procedure Initialize_85; procedure Initialize_86; procedure Initialize_87; procedure Initialize_88; procedure Initialize_89; procedure Initialize_90; procedure Initialize_91; procedure Initialize_92; procedure Initialize_93; procedure Initialize_94; procedure Initialize_95; procedure Initialize_96; procedure Initialize_97; procedure Initialize_98; procedure Initialize_99; procedure Initialize_100; procedure Initialize_101; procedure Initialize_102; procedure Initialize_103; procedure Initialize_104; procedure Initialize_105; procedure Initialize_106; procedure Initialize_107; procedure Initialize_108; procedure Initialize_109; procedure Initialize_110; procedure Initialize_111; procedure Initialize_112; procedure Initialize_113; procedure Initialize_114; procedure Initialize_115; procedure Initialize_116; procedure Initialize_117; procedure Initialize_118; procedure Initialize_119; procedure Initialize_120; procedure Initialize_121; procedure Initialize_122; procedure Initialize_123; procedure Initialize_124; procedure Initialize_125; procedure Initialize_126; procedure Initialize_127; procedure Initialize_128; procedure Initialize_129; procedure Initialize_130; procedure Initialize_131; procedure Initialize_132; procedure Initialize_133; procedure Initialize_134; procedure Initialize_135; procedure Initialize_136; procedure Initialize_137; procedure Initialize_138; procedure Initialize_139; procedure Initialize_140; procedure Initialize_141; procedure Initialize_142; procedure Initialize_143; procedure Initialize_144; procedure Initialize_145; procedure Initialize_146; procedure Initialize_147; procedure Initialize_148; procedure Initialize_149; procedure Initialize_150; procedure Initialize_151; procedure Initialize_152; procedure Initialize_153; procedure Initialize_154; procedure Initialize_155; procedure Initialize_156; procedure Initialize_157; procedure Initialize_158; procedure Initialize_159; procedure Initialize_160; procedure Initialize_161; procedure Initialize_162; procedure Initialize_163; procedure Initialize_164; procedure Initialize_165; procedure Initialize_166; procedure Initialize_167; procedure Initialize_168; procedure Initialize_169; procedure Initialize_170; procedure Initialize_171; procedure Initialize_172; procedure Initialize_173; procedure Initialize_174; procedure Initialize_175; procedure Initialize_176; procedure Initialize_177; procedure Initialize_178; procedure Initialize_179; procedure Initialize_180; procedure Initialize_181; procedure Initialize_182; procedure Initialize_183; procedure Initialize_184; procedure Initialize_185; procedure Initialize_186; procedure Initialize_187; procedure Initialize_188; procedure Initialize_189; procedure Initialize_190; procedure Initialize_191; procedure Initialize_192; procedure Initialize_193; procedure Initialize_194; procedure Initialize_195; procedure Initialize_196; procedure Initialize_197; procedure Initialize_198; procedure Initialize_199; procedure Initialize_200; procedure Initialize_201; procedure Initialize_202; procedure Initialize_203; procedure Initialize_204; procedure Initialize_205; procedure Initialize_206; procedure Initialize_207; procedure Initialize_208; procedure Initialize_209; procedure Initialize_210; procedure Initialize_211; procedure Initialize_212; procedure Initialize_213; procedure Initialize_214; procedure Initialize_215; procedure Initialize_216; procedure Initialize_217; procedure Initialize_218; procedure Initialize_219; procedure Initialize_220; procedure Initialize_221; procedure Initialize_222; procedure Initialize_223; procedure Initialize_224; procedure Initialize_225; procedure Initialize_226; procedure Initialize_227; procedure Initialize_228; procedure Initialize_229; procedure Initialize_230; procedure Initialize_231; procedure Initialize_232; procedure Initialize_233; procedure Initialize_234; procedure Initialize_235; procedure Initialize_236; procedure Initialize_237; procedure Initialize_238; procedure Initialize_239; procedure Initialize_240; procedure Initialize_241; procedure Initialize_242; procedure Initialize_243; procedure Initialize_244; procedure Initialize_245; procedure Initialize_246; procedure Initialize_247; procedure Initialize_248; procedure Initialize_249; procedure Initialize_250; procedure Initialize_251; procedure Initialize_252; procedure Initialize_253; procedure Initialize_254; procedure Initialize_255; procedure Initialize_256; procedure Initialize_257; procedure Initialize_258; procedure Initialize_259; procedure Initialize_260; procedure Initialize_261; procedure Initialize_262; procedure Initialize_263; procedure Initialize_264; procedure Initialize_265; procedure Initialize_266; procedure Initialize_267; procedure Initialize_268; procedure Initialize_269; procedure Initialize_270; procedure Initialize_271; procedure Initialize_272; procedure Initialize_273; procedure Initialize_274; procedure Initialize_275; procedure Initialize_276; procedure Initialize_277; procedure Initialize_278; procedure Initialize_279; procedure Initialize_280; procedure Initialize_281; procedure Initialize_282; procedure Initialize_283; procedure Initialize_284; procedure Initialize_285; procedure Initialize_286; procedure Initialize_287; procedure Initialize_288; procedure Initialize_289; procedure Initialize_290; procedure Initialize_291; procedure Initialize_292; procedure Initialize_293; procedure Initialize_294; procedure Initialize_295; procedure Initialize_296; procedure Initialize_297; procedure Initialize_298; procedure Initialize_299; procedure Initialize_300; procedure Initialize_301; procedure Initialize_302; procedure Initialize_303; procedure Initialize_304; procedure Initialize_305; procedure Initialize_306; procedure Initialize_307; procedure Initialize_308; procedure Initialize_309; procedure Initialize_310; procedure Initialize_311; procedure Initialize_312; procedure Initialize_313; procedure Initialize_314; procedure Initialize_315; procedure Initialize_316; procedure Initialize_317; procedure Initialize_318; procedure Initialize_319; procedure Initialize_320; procedure Initialize_321; procedure Initialize_322; procedure Initialize_323; procedure Initialize_324; procedure Initialize_325; procedure Initialize_326; procedure Initialize_327; procedure Initialize_328; procedure Initialize_329; procedure Initialize_330; procedure Initialize_331; procedure Initialize_332; procedure Initialize_333; procedure Initialize_334; procedure Initialize_335; procedure Initialize_336; procedure Initialize_337; procedure Initialize_338; procedure Initialize_339; procedure Initialize_340; procedure Initialize_341; procedure Initialize_342; procedure Initialize_343; procedure Initialize_344; procedure Initialize_345; procedure Initialize_346; procedure Initialize_347; procedure Initialize_348; procedure Initialize_349; procedure Initialize_350; procedure Initialize_351; procedure Initialize_352; procedure Initialize_353; procedure Initialize_354; procedure Initialize_355; procedure Initialize_356; procedure Initialize_357; procedure Initialize_358; procedure Initialize_359; procedure Initialize_360; procedure Initialize_361; procedure Initialize_362; procedure Initialize_363; procedure Initialize_364; procedure Initialize_365; procedure Initialize_366; procedure Initialize_367; procedure Initialize_368; procedure Initialize_369; procedure Initialize_370; procedure Initialize_371; procedure Initialize_372; procedure Initialize_373; procedure Initialize_374; procedure Initialize_375; procedure Initialize_376; procedure Initialize_377; procedure Initialize_378; procedure Initialize_379; procedure Initialize_380; procedure Initialize_381; procedure Initialize_382; procedure Initialize_383; procedure Initialize_384; procedure Initialize_385; procedure Initialize_386; procedure Initialize_387; procedure Initialize_388; procedure Initialize_389; procedure Initialize_390; procedure Initialize_391; procedure Initialize_392; procedure Initialize_393; procedure Initialize_394; procedure Initialize_395; procedure Initialize_396; procedure Initialize_397; procedure Initialize_398; procedure Initialize_399; procedure Initialize_400; procedure Initialize_401; procedure Initialize_402; procedure Initialize_403; procedure Initialize_404; procedure Initialize_405; procedure Initialize_406; procedure Initialize_407; procedure Initialize_408; procedure Initialize_409; procedure Initialize_410; procedure Initialize_411; procedure Initialize_412; procedure Initialize_413; procedure Initialize_414; procedure Initialize_415; procedure Initialize_416; procedure Initialize_417; procedure Initialize_418; procedure Initialize_419; procedure Initialize_420; procedure Initialize_421; procedure Initialize_422; procedure Initialize_423; procedure Initialize_424; procedure Initialize_425; procedure Initialize_426; procedure Initialize_427; procedure Initialize_428; procedure Initialize_429; procedure Initialize_430; procedure Initialize_431; procedure Initialize_432; procedure Initialize_433; procedure Initialize_434; procedure Initialize_435; procedure Initialize_436; procedure Initialize_437; procedure Initialize_438; procedure Initialize_439; procedure Initialize_440; procedure Initialize_441; procedure Initialize_442; procedure Initialize_443; procedure Initialize_444; procedure Initialize_445; procedure Initialize_446; procedure Initialize_447; procedure Initialize_448; procedure Initialize_449; procedure Initialize_450; procedure Initialize_451; procedure Initialize_452; procedure Initialize_453; procedure Initialize_454; procedure Initialize_455; procedure Initialize_456; procedure Initialize_457; procedure Initialize_458; procedure Initialize_459; procedure Initialize_460; procedure Initialize_461; procedure Initialize_462; procedure Initialize_463; procedure Initialize_464; procedure Initialize_465; procedure Initialize_466; procedure Initialize_467; procedure Initialize_468; procedure Initialize_469; procedure Initialize_470; procedure Initialize_471; procedure Initialize_472; procedure Initialize_473; procedure Initialize_474; procedure Initialize_475; procedure Initialize_476; procedure Initialize_477; procedure Initialize_478; procedure Initialize_479; procedure Initialize_480; procedure Initialize_481; procedure Initialize_482; procedure Initialize_483; procedure Initialize_484; procedure Initialize_485; procedure Initialize_486; procedure Initialize_487; procedure Initialize_488; procedure Initialize_489; procedure Initialize_490; procedure Initialize_491; procedure Initialize_492; procedure Initialize_493; procedure Initialize_494; procedure Initialize_495; procedure Initialize_496; procedure Initialize_497; procedure Initialize_498; procedure Initialize_499; procedure Initialize_500; procedure Initialize_501; procedure Initialize_502; procedure Initialize_503; procedure Initialize_504; procedure Initialize_505; procedure Initialize_506; procedure Initialize_507; procedure Initialize_508; procedure Initialize_509; procedure Initialize_510; procedure Initialize_511; procedure Initialize_512; procedure Initialize_513; procedure Initialize_514; procedure Initialize_515; procedure Initialize_516; procedure Initialize_517; procedure Initialize_518; procedure Initialize_519; procedure Initialize_520; procedure Initialize_521; procedure Initialize_522; procedure Initialize_523; procedure Initialize_524; procedure Initialize_525; procedure Initialize_526; procedure Initialize_527; procedure Initialize_528; procedure Initialize_529; procedure Initialize_530; procedure Initialize_531; procedure Initialize_532; procedure Initialize_533; procedure Initialize_534; procedure Initialize_535; procedure Initialize_536; procedure Initialize_537; procedure Initialize_538; procedure Initialize_539; procedure Initialize_540; procedure Initialize_541; procedure Initialize_542; procedure Initialize_543; procedure Initialize_544; procedure Initialize_545; procedure Initialize_546; procedure Initialize_547; procedure Initialize_548; procedure Initialize_549; procedure Initialize_550; procedure Initialize_551; procedure Initialize_552; procedure Initialize_553; procedure Initialize_554; procedure Initialize_555; procedure Initialize_556; procedure Initialize_557; procedure Initialize_558; procedure Initialize_559; procedure Initialize_560; procedure Initialize_561; procedure Initialize_562; procedure Initialize_563; procedure Initialize_564; procedure Initialize_565; procedure Initialize_566; procedure Initialize_567; procedure Initialize_568; procedure Initialize_569; procedure Initialize_570; procedure Initialize_571; procedure Initialize_572; procedure Initialize_573; procedure Initialize_574; procedure Initialize_575; procedure Initialize_576; procedure Initialize_577; procedure Initialize_578; procedure Initialize_579; procedure Initialize_580; procedure Initialize_581; procedure Initialize_582; procedure Initialize_583; procedure Initialize_584; procedure Initialize_585; procedure Initialize_586; procedure Initialize_587; procedure Initialize_588; procedure Initialize_589; procedure Initialize_590; procedure Initialize_591; procedure Initialize_592; procedure Initialize_593; procedure Initialize_594; procedure Initialize_595; procedure Initialize_596; procedure Initialize_597; procedure Initialize_598; procedure Initialize_599; procedure Initialize_600; procedure Initialize_601; procedure Initialize_602; procedure Initialize_603; procedure Initialize_604; procedure Initialize_605; procedure Initialize_606; procedure Initialize_607; procedure Initialize_608; procedure Initialize_609; procedure Initialize_610; procedure Initialize_611; procedure Initialize_612; procedure Initialize_613; procedure Initialize_614; procedure Initialize_615; procedure Initialize_616; procedure Initialize_617; procedure Initialize_618; procedure Initialize_619; procedure Initialize_620; procedure Initialize_621; procedure Initialize_622; procedure Initialize_623; procedure Initialize_624; procedure Initialize_625; procedure Initialize_626; procedure Initialize_627; procedure Initialize_628; procedure Initialize_629; procedure Initialize_630; procedure Initialize_631; procedure Initialize_632; procedure Initialize_633; procedure Initialize_634; procedure Initialize_635; procedure Initialize_636; procedure Initialize_637; procedure Initialize_638; procedure Initialize_639; procedure Initialize_640; procedure Initialize_641; procedure Initialize_642; procedure Initialize_643; procedure Initialize_644; procedure Initialize_645; procedure Initialize_646; procedure Initialize_647; procedure Initialize_648; procedure Initialize_649; procedure Initialize_650; procedure Initialize_651; procedure Initialize_652; procedure Initialize_653; procedure Initialize_654; procedure Initialize_655; procedure Initialize_656; procedure Initialize_657; procedure Initialize_658; procedure Initialize_659; procedure Initialize_660; procedure Initialize_661; procedure Initialize_662; procedure Initialize_663; procedure Initialize_664; procedure Initialize_665; procedure Initialize_666; procedure Initialize_667; procedure Initialize_668; procedure Initialize_669; procedure Initialize_670; procedure Initialize_671; procedure Initialize_672; procedure Initialize_673; procedure Initialize_674; procedure Initialize_675; procedure Initialize_676; procedure Initialize_677; procedure Initialize_678; procedure Initialize_679; procedure Initialize_680; procedure Initialize_681; procedure Initialize_682; procedure Initialize_683; procedure Initialize_684; procedure Initialize_685; procedure Initialize_686; procedure Initialize_687; procedure Initialize_688; procedure Initialize_689; procedure Initialize_690; procedure Initialize_691; procedure Initialize_692; procedure Initialize_693; procedure Initialize_694; procedure Initialize_695; procedure Initialize_696; procedure Initialize_697; procedure Initialize_698; procedure Initialize_699; procedure Initialize_700; procedure Initialize_701; procedure Initialize_702; procedure Initialize_703; procedure Initialize_704; procedure Initialize_705; procedure Initialize_706; procedure Initialize_707; procedure Initialize_708; procedure Initialize_709; procedure Initialize_710; procedure Initialize_711; procedure Initialize_712; procedure Initialize_713; procedure Initialize_714; procedure Initialize_715; procedure Initialize_716; procedure Initialize_717; procedure Initialize_718; procedure Initialize_719; procedure Initialize_720; procedure Initialize_721; procedure Initialize_722; procedure Initialize_723; procedure Initialize_724; procedure Initialize_725; procedure Initialize_726; procedure Initialize_727; procedure Initialize_728; procedure Initialize_729; procedure Initialize_730; procedure Initialize_731; procedure Initialize_732; procedure Initialize_733; procedure Initialize_734; procedure Initialize_735; procedure Initialize_736; procedure Initialize_737; procedure Initialize_738; procedure Initialize_739; procedure Initialize_740; procedure Initialize_741; procedure Initialize_742; procedure Initialize_743; procedure Initialize_744; procedure Initialize_745; procedure Initialize_746; procedure Initialize_747; procedure Initialize_748; procedure Initialize_749; procedure Initialize_750; procedure Initialize_751; procedure Initialize_752; procedure Initialize_753; procedure Initialize_754; procedure Initialize_755; procedure Initialize_756; procedure Initialize_757; procedure Initialize_758; procedure Initialize_759; procedure Initialize_760; procedure Initialize_761; procedure Initialize_762; procedure Initialize_763; procedure Initialize_764; procedure Initialize_765; procedure Initialize_766; procedure Initialize_767; procedure Initialize_768; procedure Initialize_769; procedure Initialize_770; procedure Initialize_771; procedure Initialize_772; procedure Initialize_773; procedure Initialize_774; procedure Initialize_775; procedure Initialize_776; procedure Initialize_777; procedure Initialize_778; procedure Initialize_779; procedure Initialize_780; procedure Initialize_781; procedure Initialize_782; procedure Initialize_783; procedure Initialize_784; procedure Initialize_785; procedure Initialize_786; procedure Initialize_787; procedure Initialize_788; procedure Initialize_789; procedure Initialize_790; procedure Initialize_791; procedure Initialize_792; procedure Initialize_793; procedure Initialize_794; procedure Initialize_795; procedure Initialize_796; procedure Initialize_797; procedure Initialize_798; procedure Initialize_799; procedure Initialize_800; procedure Initialize_801; procedure Initialize_802; procedure Initialize_803; procedure Initialize_804; procedure Initialize_805; procedure Initialize_806; procedure Initialize_807; procedure Initialize_808; procedure Initialize_809; procedure Initialize_810; procedure Initialize_811; procedure Initialize_812; procedure Initialize_813; procedure Initialize_814; procedure Initialize_815; procedure Initialize_816; procedure Initialize_817; procedure Initialize_818; procedure Initialize_819; procedure Initialize_820; procedure Initialize_821; procedure Initialize_822; procedure Initialize_823; procedure Initialize_824; procedure Initialize_825; procedure Initialize_826; procedure Initialize_827; procedure Initialize_828; procedure Initialize_829; procedure Initialize_830; procedure Initialize_831; procedure Initialize_832; procedure Initialize_833; procedure Initialize_834; procedure Initialize_835; procedure Initialize_836; procedure Initialize_837; procedure Initialize_838; procedure Initialize_839; procedure Initialize_840; procedure Initialize_841; procedure Initialize_842; procedure Initialize_843; procedure Initialize_844; procedure Initialize_845; procedure Initialize_846; procedure Initialize_847; procedure Initialize_848; procedure Initialize_849; procedure Initialize_850; procedure Initialize_851; procedure Initialize_852; procedure Initialize_853; procedure Initialize_854; procedure Initialize_855; procedure Initialize_856; procedure Initialize_857; procedure Initialize_858; procedure Initialize_859; procedure Initialize_860; procedure Initialize_861; procedure Initialize_862; procedure Initialize_863; procedure Initialize_864; procedure Initialize_865; procedure Initialize_866; procedure Initialize_867; procedure Initialize_868; procedure Initialize_869; procedure Initialize_870; procedure Initialize_871; procedure Initialize_872; procedure Initialize_873; procedure Initialize_874; procedure Initialize_875; procedure Initialize_876; procedure Initialize_877; procedure Initialize_878; procedure Initialize_879; procedure Initialize_880; procedure Initialize_881; procedure Initialize_882; procedure Initialize_883; procedure Initialize_884; procedure Initialize_885; procedure Initialize_886; procedure Initialize_887; procedure Initialize_888; procedure Initialize_889; procedure Initialize_890; procedure Initialize_891; procedure Initialize_892; procedure Initialize_893; procedure Initialize_894; procedure Initialize_895; procedure Initialize_896; procedure Initialize_897; procedure Initialize_898; procedure Initialize_899; procedure Initialize_900; procedure Initialize_901; procedure Initialize_902; procedure Initialize_903; procedure Initialize_904; procedure Initialize_905; procedure Initialize_906; procedure Initialize_907; procedure Initialize_908; procedure Initialize_909; procedure Initialize_910; procedure Initialize_911; procedure Initialize_912; procedure Initialize_913; procedure Initialize_914; procedure Initialize_915; procedure Initialize_916; procedure Initialize_917; procedure Initialize_918; procedure Initialize_919; procedure Initialize_920; procedure Initialize_921; procedure Initialize_922; procedure Initialize_923; procedure Initialize_924; procedure Initialize_925; procedure Initialize_926; procedure Initialize_927; procedure Initialize_928; procedure Initialize_929; procedure Initialize_930; procedure Initialize_931; procedure Initialize_932; procedure Initialize_933; procedure Initialize_934; procedure Initialize_935; procedure Initialize_936; procedure Initialize_937; procedure Initialize_938; procedure Initialize_939; procedure Initialize_940; procedure Initialize_941; procedure Initialize_942; procedure Initialize_943; procedure Initialize_944; procedure Initialize_945; procedure Initialize_946; procedure Initialize_947; procedure Initialize_948; procedure Initialize_949; procedure Initialize_950; procedure Initialize_951; procedure Initialize_952; procedure Initialize_953; procedure Initialize_954; procedure Initialize_955; procedure Initialize_956; procedure Initialize_957; procedure Initialize_958; procedure Initialize_959; procedure Initialize_960; procedure Initialize_961; procedure Initialize_962; procedure Initialize_963; procedure Initialize_964; procedure Initialize_965; procedure Initialize_966; procedure Initialize_967; procedure Initialize_968; procedure Initialize_969; procedure Initialize_970; procedure Initialize_971; procedure Initialize_972; procedure Initialize_973; procedure Initialize_974; procedure Initialize_975; procedure Initialize_976; procedure Initialize_977; procedure Initialize_978; procedure Initialize_979; procedure Initialize_980; procedure Initialize_981; procedure Initialize_982; procedure Initialize_983; procedure Initialize_984; procedure Initialize_985; procedure Initialize_986; procedure Initialize_987; procedure Initialize_988; procedure Initialize_989; procedure Initialize_990; procedure Initialize_991; procedure Initialize_992; procedure Initialize_993; procedure Initialize_994; procedure Initialize_995; procedure Initialize_996; procedure Initialize_997; procedure Initialize_998; procedure Initialize_999; procedure Initialize_1000; procedure Initialize_1001; procedure Initialize_1002; procedure Initialize_1003; procedure Initialize_1004; procedure Initialize_1005; procedure Initialize_1006; procedure Initialize_1007; procedure Initialize_1008; procedure Initialize_1009; procedure Initialize_1010; procedure Initialize_1011; procedure Initialize_1012; procedure Initialize_1013; procedure Initialize_1014; procedure Initialize_1015; procedure Initialize_1016; procedure Initialize_1017; procedure Initialize_1018; procedure Initialize_1019; procedure Initialize_1020; procedure Initialize_1021; procedure Initialize_1022; procedure Initialize_1023; procedure Initialize_1024; procedure Initialize_1025; procedure Initialize_1026; procedure Initialize_1027; procedure Initialize_1028; procedure Initialize_1029; procedure Initialize_1030; procedure Initialize_1031; procedure Initialize_1032; procedure Initialize_1033; procedure Initialize_1034; procedure Initialize_1035; procedure Initialize_1036; procedure Initialize_1037; procedure Initialize_1038; procedure Initialize_1039; procedure Initialize_1040; procedure Initialize_1041; procedure Initialize_1042; procedure Initialize_1043; procedure Initialize_1044; procedure Initialize_1045; procedure Initialize_1046; procedure Initialize_1047; procedure Initialize_1048; procedure Initialize_1049; procedure Initialize_1050; procedure Initialize_1051; procedure Initialize_1052; procedure Initialize_1053; procedure Initialize_1054; procedure Initialize_1055; procedure Initialize_1056; procedure Initialize_1057; procedure Initialize_1058; procedure Initialize_1059; procedure Initialize_1060; procedure Initialize_1061; procedure Initialize_1062; procedure Initialize_1063; procedure Initialize_1064; procedure Initialize_1065; procedure Initialize_1066; procedure Initialize_1067; procedure Initialize_1068; procedure Initialize_1069; procedure Initialize_1070; procedure Initialize_1071; procedure Initialize_1072; procedure Initialize_1073; procedure Initialize_1074; procedure Initialize_1075; procedure Initialize_1076; procedure Initialize_1077; procedure Initialize_1078; procedure Initialize_1079; procedure Initialize_1080; procedure Initialize_1081; procedure Initialize_1082; procedure Initialize_1083; procedure Initialize_1084; procedure Initialize_1085; procedure Initialize_1086; procedure Initialize_1087; procedure Initialize_1088; procedure Initialize_1089; procedure Initialize_1090; procedure Initialize_1091; procedure Initialize_1092; procedure Initialize_1093; procedure Initialize_1094; procedure Initialize_1095; procedure Initialize_1096; procedure Initialize_1097; procedure Initialize_1098; procedure Initialize_1099; procedure Initialize_1100; procedure Initialize_1101; procedure Initialize_1102; procedure Initialize_1103; procedure Initialize_1104; procedure Initialize_1105; procedure Initialize_1106; procedure Initialize_1107; procedure Initialize_1108; procedure Initialize_1109; procedure Initialize_1110; procedure Initialize_1111; procedure Initialize_1112; procedure Initialize_1113; procedure Initialize_1114; procedure Initialize_1115; procedure Initialize_1116; procedure Initialize_1117; procedure Initialize_1118; procedure Initialize_1119; procedure Initialize_1120; procedure Initialize_1121; procedure Initialize_1122; procedure Initialize_1123; procedure Initialize_1124; procedure Initialize_1125; procedure Initialize_1126; procedure Initialize_1127; procedure Initialize_1128; procedure Initialize_1129; procedure Initialize_1130; procedure Initialize_1131; procedure Initialize_1132; procedure Initialize_1133; procedure Initialize_1134; procedure Initialize_1135; procedure Initialize_1136; procedure Initialize_1137; procedure Initialize_1138; procedure Initialize_1139; procedure Initialize_1140; procedure Initialize_1141; procedure Initialize_1142; procedure Initialize_1143; procedure Initialize_1144; procedure Initialize_1145; procedure Initialize_1146; procedure Initialize_1147; procedure Initialize_1148; procedure Initialize_1149; procedure Initialize_1150; procedure Initialize_1151; procedure Initialize_1152; procedure Initialize_1153; procedure Initialize_1154; procedure Initialize_1155; procedure Initialize_1156; procedure Initialize_1157; procedure Initialize_1158; procedure Initialize_1159; procedure Initialize_1160; procedure Initialize_1161; procedure Initialize_1162; procedure Initialize_1163; procedure Initialize_1164; procedure Initialize_1165; procedure Initialize_1166; procedure Initialize_1167; procedure Initialize_1168; procedure Initialize_1169; procedure Initialize_1170; procedure Initialize_1171; procedure Initialize_1172; procedure Initialize_1173; procedure Initialize_1174; procedure Initialize_1175; procedure Initialize_1176; procedure Initialize_1177; procedure Initialize_1178; procedure Initialize_1179; procedure Initialize_1180; procedure Initialize_1181; procedure Initialize_1182; procedure Initialize_1183; procedure Initialize_1184; procedure Initialize_1185; procedure Initialize_1186; procedure Initialize_1187; procedure Initialize_1188; procedure Initialize_1189; procedure Initialize_1190; procedure Initialize_1191; procedure Initialize_1192; procedure Initialize_1193; procedure Initialize_1194; procedure Initialize_1195; procedure Initialize_1196; procedure Initialize_1197; procedure Initialize_1198; procedure Initialize_1199; procedure Initialize_1200; procedure Initialize_1201; procedure Initialize_1202; procedure Initialize_1203; procedure Initialize_1204; procedure Initialize_1205; procedure Initialize_1206; procedure Initialize_1207; procedure Initialize_1208; procedure Initialize_1209; procedure Initialize_1210; procedure Initialize_1211; procedure Initialize_1212; procedure Initialize_1213; procedure Initialize_1214; procedure Initialize_1215; procedure Initialize_1216; procedure Initialize_1217; procedure Initialize_1218; procedure Initialize_1219; procedure Initialize_1220; procedure Initialize_1221; procedure Initialize_1222; procedure Initialize_1223; procedure Initialize_1224; procedure Initialize_1225; procedure Initialize_1226; procedure Initialize_1227; procedure Initialize_1228; procedure Initialize_1229; procedure Initialize_1230; procedure Initialize_1231; procedure Initialize_1232; procedure Initialize_1233; procedure Initialize_1234; procedure Initialize_1235; procedure Initialize_1236; procedure Initialize_1237; procedure Initialize_1238; procedure Initialize_1239; procedure Initialize_1240; procedure Initialize_1241; procedure Initialize_1242; procedure Initialize_1243; procedure Initialize_1244; procedure Initialize_1245; procedure Initialize_1246; procedure Initialize_1247; procedure Initialize_1248; procedure Initialize_1249; procedure Initialize_1250; procedure Initialize_1251; procedure Initialize_1252; procedure Initialize_1253; procedure Initialize_1254; procedure Initialize_1255; procedure Initialize_1256; procedure Initialize_1257; procedure Initialize_1258; procedure Initialize_1259; procedure Initialize_1260; procedure Initialize_1261; procedure Initialize_1262; procedure Initialize_1263; procedure Initialize_1264; procedure Initialize_1265; procedure Initialize_1266; procedure Initialize_1267; procedure Initialize_1268; procedure Initialize_1269; procedure Initialize_1270; procedure Initialize_1271; procedure Initialize_1272; procedure Initialize_1273; procedure Initialize_1274; procedure Initialize_1275; procedure Initialize_1276; procedure Initialize_1277; procedure Initialize_1278; procedure Initialize_1279; procedure Initialize_1280; procedure Initialize_1281; procedure Initialize_1282; procedure Initialize_1283; procedure Initialize_1284; procedure Initialize_1285; procedure Initialize_1286; procedure Initialize_1287; procedure Initialize_1288; procedure Initialize_1289; procedure Initialize_1290; procedure Initialize_1291; procedure Initialize_1292; procedure Initialize_1293; procedure Initialize_1294; procedure Initialize_1295; procedure Initialize_1296; procedure Initialize_1297; procedure Initialize_1298; procedure Initialize_1299; procedure Initialize_1300; procedure Initialize_1301; procedure Initialize_1302; procedure Initialize_1303; procedure Initialize_1304; procedure Initialize_1305; procedure Initialize_1306; procedure Initialize_1307; procedure Initialize_1308; procedure Initialize_1309; procedure Initialize_1310; procedure Initialize_1311; procedure Initialize_1312; procedure Initialize_1313; procedure Initialize_1314; procedure Initialize_1315; procedure Initialize_1316; procedure Initialize_1317; procedure Initialize_1318; procedure Initialize_1319; procedure Initialize_1320; procedure Initialize_1321; procedure Initialize_1322; procedure Initialize_1323; procedure Initialize_1324; procedure Initialize_1325; procedure Initialize_1326; procedure Initialize_1327; procedure Initialize_1328; procedure Initialize_1329; procedure Initialize_1330; procedure Initialize_1331; procedure Initialize_1332; procedure Initialize_1333; procedure Initialize_1334; procedure Initialize_1335; procedure Initialize_1336; procedure Initialize_1337; procedure Initialize_1338; procedure Initialize_1339; procedure Initialize_1340; procedure Initialize_1341; procedure Initialize_1342; procedure Initialize_1343; procedure Initialize_1344; procedure Initialize_1345; procedure Initialize_1346; procedure Initialize_1347; procedure Initialize_1348; procedure Initialize_1349; procedure Initialize_1350; procedure Initialize_1351; procedure Initialize_1352; procedure Initialize_1353; procedure Initialize_1354; procedure Initialize_1355; procedure Initialize_1356; procedure Initialize_1357; procedure Initialize_1358; procedure Initialize_1359; procedure Initialize_1360; procedure Initialize_1361; procedure Initialize_1362; procedure Initialize_1363; procedure Initialize_1364; procedure Initialize_1365; procedure Initialize_1366; procedure Initialize_1367; procedure Initialize_1368; procedure Initialize_1369; procedure Initialize_1370; procedure Initialize_1371; procedure Initialize_1372; procedure Initialize_1373; procedure Initialize_1374; procedure Initialize_1375; procedure Initialize_1376; procedure Initialize_1377; procedure Initialize_1378; procedure Initialize_1379; procedure Initialize_1380; procedure Initialize_1381; procedure Initialize_1382; procedure Initialize_1383; procedure Initialize_1384; procedure Initialize_1385; procedure Initialize_1386; procedure Initialize_1387; procedure Initialize_1388; procedure Initialize_1389; procedure Initialize_1390; procedure Initialize_1391; procedure Initialize_1392; procedure Initialize_1393; procedure Initialize_1394; procedure Initialize_1395; procedure Initialize_1396; procedure Initialize_1397; procedure Initialize_1398; procedure Initialize_1399; procedure Initialize_1400; procedure Initialize_1401; procedure Initialize_1402; procedure Initialize_1403; procedure Initialize_1404; procedure Initialize_1405; procedure Initialize_1406; procedure Initialize_1407; procedure Initialize_1408; procedure Initialize_1409; procedure Initialize_1410; procedure Initialize_1411; procedure Initialize_1412; procedure Initialize_1413; procedure Initialize_1414; procedure Initialize_1415; procedure Initialize_1416; procedure Initialize_1417; procedure Initialize_1418; procedure Initialize_1419; procedure Initialize_1420; procedure Initialize_1421; procedure Initialize_1422; procedure Initialize_1423; procedure Initialize_1424; procedure Initialize_1425; procedure Initialize_1426; procedure Initialize_1427; procedure Initialize_1428; procedure Initialize_1429; procedure Initialize_1430; procedure Initialize_1431; procedure Initialize_1432; procedure Initialize_1433; procedure Initialize_1434; procedure Initialize_1435; procedure Initialize_1436; procedure Initialize_1437; procedure Initialize_1438; procedure Initialize_1439; procedure Initialize_1440; procedure Initialize_1441; procedure Initialize_1442; procedure Initialize_1443; procedure Initialize_1444; procedure Initialize_1445; procedure Initialize_1446; procedure Initialize_1447; procedure Initialize_1448; procedure Initialize_1449; procedure Initialize_1450; procedure Initialize_1451; procedure Initialize_1452; procedure Initialize_1453; procedure Initialize_1454; procedure Initialize_1455; procedure Initialize_1456; procedure Initialize_1457; procedure Initialize_1458; procedure Initialize_1459; procedure Initialize_1460; procedure Initialize_1461; procedure Initialize_1462; procedure Initialize_1463; procedure Initialize_1464; procedure Initialize_1465; procedure Initialize_1466; procedure Initialize_1467; procedure Initialize_1468; procedure Initialize_1469; procedure Initialize_1470; procedure Initialize_1471; procedure Initialize_1472; procedure Initialize_1473; procedure Initialize_1474; procedure Initialize_1475; procedure Initialize_1476; procedure Initialize_1477; procedure Initialize_1478; procedure Initialize_1479; procedure Initialize_1480; procedure Initialize_1481; procedure Initialize_1482; procedure Initialize_1483; procedure Initialize_1484; procedure Initialize_1485; procedure Initialize_1486; procedure Initialize_1487; procedure Initialize_1488; procedure Initialize_1489; procedure Initialize_1490; procedure Initialize_1491; procedure Initialize_1492; procedure Initialize_1493; procedure Initialize_1494; procedure Initialize_1495; procedure Initialize_1496; procedure Initialize_1497; procedure Initialize_1498; procedure Initialize_1499; procedure Initialize_1500; procedure Initialize_1501; procedure Initialize_1502; procedure Initialize_1503; procedure Initialize_1504; procedure Initialize_1505; procedure Initialize_1506; procedure Initialize_1507; procedure Initialize_1508; procedure Initialize_1509; procedure Initialize_1510; procedure Initialize_1511; procedure Initialize_1512; procedure Initialize_1513; procedure Initialize_1514; procedure Initialize_1515; procedure Initialize_1516; procedure Initialize_1517; procedure Initialize_1518; procedure Initialize_1519; procedure Initialize_1520; procedure Initialize_1521; procedure Initialize_1522; procedure Initialize_1523; procedure Initialize_1524; procedure Initialize_1525; procedure Initialize_1526; procedure Initialize_1527; procedure Initialize_1528; procedure Initialize_1529; procedure Initialize_1530; procedure Initialize_1531; procedure Initialize_1532; procedure Initialize_1533; procedure Initialize_1534; procedure Initialize_1535; procedure Initialize_1536; procedure Initialize_1537; procedure Initialize_1538; procedure Initialize_1539; procedure Initialize_1540; procedure Initialize_1541; procedure Initialize_1542; procedure Initialize_1543; procedure Initialize_1544; procedure Initialize_1545; procedure Initialize_1546; procedure Initialize_1547; procedure Initialize_1548; procedure Initialize_1549; procedure Initialize_1550; procedure Initialize_1551; procedure Initialize_1552; procedure Initialize_1553; procedure Initialize_1554; procedure Initialize_1555; procedure Initialize_1556; procedure Initialize_1557; procedure Initialize_1558; procedure Initialize_1559; procedure Initialize_1560; procedure Initialize_1561; procedure Initialize_1562; procedure Initialize_1563; procedure Initialize_1564; procedure Initialize_1565; procedure Initialize_1566; procedure Initialize_1567; procedure Initialize_1568; procedure Initialize_1569; procedure Initialize_1570; procedure Initialize_1571; procedure Initialize_1572; procedure Initialize_1573; procedure Initialize_1574; procedure Initialize_1575; procedure Initialize_1576; procedure Initialize_1577; procedure Initialize_1578; procedure Initialize_1579; procedure Initialize_1580; procedure Initialize_1581; procedure Initialize_1582; procedure Initialize_1583; procedure Initialize_1584; procedure Initialize_1585; procedure Initialize_1586; procedure Initialize_1587; procedure Initialize_1588; procedure Initialize_1589; procedure Initialize_1590; procedure Initialize_1591; procedure Initialize_1592; procedure Initialize_1593; procedure Initialize_1594; procedure Initialize_1595; procedure Initialize_1596; procedure Initialize_1597; procedure Initialize_1598; procedure Initialize_1599; procedure Initialize_1600; procedure Initialize_1601; procedure Initialize_1602; procedure Initialize_1603; procedure Initialize_1604; procedure Initialize_1605; procedure Initialize_1606; procedure Initialize_1607; procedure Initialize_1608; procedure Initialize_1609; procedure Initialize_1610; procedure Initialize_1611; procedure Initialize_1612; procedure Initialize_1613; procedure Initialize_1614; procedure Initialize_1615; procedure Initialize_1616; procedure Initialize_1617; procedure Initialize_1618; procedure Initialize_1619; procedure Initialize_1620; procedure Initialize_1621; procedure Initialize_1622; procedure Initialize_1623; procedure Initialize_1624; procedure Initialize_1625; procedure Initialize_1626; procedure Initialize_1627; procedure Initialize_1628; procedure Initialize_1629; procedure Initialize_1630; procedure Initialize_1631; procedure Initialize_1632; procedure Initialize_1633; procedure Initialize_1634; procedure Initialize_1635; procedure Initialize_1636; procedure Initialize_1637; procedure Initialize_1638; procedure Initialize_1639; procedure Initialize_1640; procedure Initialize_1641; procedure Initialize_1642; procedure Initialize_1643; procedure Initialize_1644; procedure Initialize_1645; procedure Initialize_1646; procedure Initialize_1647; procedure Initialize_1648; procedure Initialize_1649; procedure Initialize_1650; procedure Initialize_1651; procedure Initialize_1652; procedure Initialize_1653; procedure Initialize_1654; procedure Initialize_1655; procedure Initialize_1656; procedure Initialize_1657; procedure Initialize_1658; procedure Initialize_1659; procedure Initialize_1660; procedure Initialize_1661; procedure Initialize_1662; procedure Initialize_1663; procedure Initialize_1664; procedure Initialize_1665; procedure Initialize_1666; procedure Initialize_1667; procedure Initialize_1668; procedure Initialize_1669; procedure Initialize_1670; procedure Initialize_1671; procedure Initialize_1672; procedure Initialize_1673; procedure Initialize_1674; procedure Initialize_1675; procedure Initialize_1676; procedure Initialize_1677; procedure Initialize_1678; procedure Initialize_1679; procedure Initialize_1680; procedure Initialize_1681; procedure Initialize_1682; procedure Initialize_1683; procedure Initialize_1684; procedure Initialize_1685; procedure Initialize_1686; procedure Initialize_1687; procedure Initialize_1688; procedure Initialize_1689; procedure Initialize_1690; procedure Initialize_1691; procedure Initialize_1692; procedure Initialize_1693; procedure Initialize_1694; procedure Initialize_1695; procedure Initialize_1696; procedure Initialize_1697; procedure Initialize_1698; procedure Initialize_1699; procedure Initialize_1700; procedure Initialize_1701; procedure Initialize_1702; procedure Initialize_1703; procedure Initialize_1704; procedure Initialize_1705; procedure Initialize_1706; procedure Initialize_1707; procedure Initialize_1708; procedure Initialize_1709; procedure Initialize_1710; procedure Initialize_1711; procedure Initialize_1712; procedure Initialize_1713; procedure Initialize_1714; procedure Initialize_1715; procedure Initialize_1716; procedure Initialize_1717; procedure Initialize_1718; procedure Initialize_1719; procedure Initialize_1720; procedure Initialize_1721; procedure Initialize_1722; procedure Initialize_1723; procedure Initialize_1724; procedure Initialize_1725; procedure Initialize_1726; procedure Initialize_1727; procedure Initialize_1728; procedure Initialize_1729; procedure Initialize_1730; procedure Initialize_1731; procedure Initialize_1732; procedure Initialize_1733; procedure Initialize_1734; procedure Initialize_1735; procedure Initialize_1736; procedure Initialize_1737; procedure Initialize_1738; procedure Initialize_1739; procedure Initialize_1740; procedure Initialize_1741; procedure Initialize_1742; procedure Initialize_1743; procedure Initialize_1744; procedure Initialize_1745; procedure Initialize_1746; procedure Initialize_1747; procedure Initialize_1748; procedure Initialize_1749; procedure Initialize_1750; procedure Initialize_1751; procedure Initialize_1752; procedure Initialize_1753; procedure Initialize_1754; procedure Initialize_1755; procedure Initialize_1756; procedure Initialize_1757; procedure Initialize_1758; procedure Initialize_1759; procedure Initialize_1760; procedure Initialize_1761; procedure Initialize_1762; procedure Initialize_1763; procedure Initialize_1764; procedure Initialize_1765; procedure Initialize_1766; procedure Initialize_1767; procedure Initialize_1768; procedure Initialize_1769; procedure Initialize_1770; procedure Initialize_1771; procedure Initialize_1772; procedure Initialize_1773; procedure Initialize_1774; procedure Initialize_1775; procedure Initialize_1776; procedure Initialize_1777; procedure Initialize_1778; procedure Initialize_1779; procedure Initialize_1780; procedure Initialize_1781; procedure Initialize_1782; procedure Initialize_1783; procedure Initialize_1784; procedure Initialize_1785; procedure Initialize_1786; procedure Initialize_1787; procedure Initialize_1788; procedure Initialize_1789; procedure Initialize_1790; procedure Initialize_1791; procedure Initialize_1792; procedure Initialize_1793; procedure Initialize_1794; procedure Initialize_1795; procedure Initialize_1796; procedure Initialize_1797; procedure Initialize_1798; procedure Initialize_1799; procedure Initialize_1800; procedure Initialize_1801; procedure Initialize_1802; procedure Initialize_1803; procedure Initialize_1804; procedure Initialize_1805; procedure Initialize_1806; procedure Initialize_1807; procedure Initialize_1808; procedure Initialize_1809; procedure Initialize_1810; procedure Initialize_1811; procedure Initialize_1812; procedure Initialize_1813; procedure Initialize_1814; procedure Initialize_1815; procedure Initialize_1816; procedure Initialize_1817; procedure Initialize_1818; procedure Initialize_1819; procedure Initialize_1820; procedure Initialize_1821; procedure Initialize_1822; procedure Initialize_1823; procedure Initialize_1824; procedure Initialize_1825; procedure Initialize_1826; procedure Initialize_1827; procedure Initialize_1828; procedure Initialize_1829; procedure Initialize_1830; procedure Initialize_1831; procedure Initialize_1832; procedure Initialize_1833; procedure Initialize_1834; procedure Initialize_1835; procedure Initialize_1836; procedure Initialize_1837; procedure Initialize_1838; procedure Initialize_1839; procedure Initialize_1840; procedure Initialize_1841; procedure Initialize_1842; procedure Initialize_1843; procedure Initialize_1844; procedure Initialize_1845; procedure Initialize_1846; procedure Initialize_1847; procedure Initialize_1848; procedure Initialize_1849; procedure Initialize_1850; procedure Initialize_1851; procedure Initialize_1852; procedure Initialize_1853; procedure Initialize_1854; procedure Initialize_1855; procedure Initialize_1856; procedure Initialize_1857; procedure Initialize_1858; procedure Initialize_1859; procedure Initialize_1860; procedure Initialize_1861; procedure Initialize_1862; procedure Initialize_1863; procedure Initialize_1864; procedure Initialize_1865; procedure Initialize_1866; procedure Initialize_1867; procedure Initialize_1868; procedure Initialize_1869; procedure Initialize_1870; procedure Initialize_1871; procedure Initialize_1872; procedure Initialize_1873; procedure Initialize_1874; procedure Initialize_1875; procedure Initialize_1876; procedure Initialize_1877; procedure Initialize_1878; procedure Initialize_1879; procedure Initialize_1880; procedure Initialize_1881; procedure Initialize_1882; procedure Initialize_1883; procedure Initialize_1884; procedure Initialize_1885; procedure Initialize_1886; procedure Initialize_1887; procedure Initialize_1888; procedure Initialize_1889; procedure Initialize_1890; procedure Initialize_1891; procedure Initialize_1892; procedure Initialize_1893; procedure Initialize_1894; procedure Initialize_1895; procedure Initialize_1896; procedure Initialize_1897; procedure Initialize_1898; procedure Initialize_1899; procedure Initialize_1900; procedure Initialize_1901; procedure Initialize_1902; procedure Initialize_1903; procedure Initialize_1904; procedure Initialize_1905; procedure Initialize_1906; procedure Initialize_1907; procedure Initialize_1908; procedure Initialize_1909; procedure Initialize_1910; procedure Initialize_1911; procedure Initialize_1912; procedure Initialize_1913; procedure Initialize_1914; procedure Initialize_1915; procedure Initialize_1916; procedure Initialize_1917; procedure Initialize_1918; procedure Initialize_1919; procedure Initialize_1920; procedure Initialize_1921; procedure Initialize_1922; procedure Initialize_1923; procedure Initialize_1924; procedure Initialize_1925; procedure Initialize_1926; procedure Initialize_1927; procedure Initialize_1928; procedure Initialize_1929; procedure Initialize_1930; procedure Initialize_1931; procedure Initialize_1932; procedure Initialize_1933; procedure Initialize_1934; procedure Initialize_1935; procedure Initialize_1936; procedure Initialize_1937; procedure Initialize_1938; procedure Initialize_1939; procedure Initialize_1940; procedure Initialize_1941; procedure Initialize_1942; procedure Initialize_1943; procedure Initialize_1944; procedure Initialize_1945; procedure Initialize_1946; procedure Initialize_1947; procedure Initialize_1948; procedure Initialize_1949; procedure Initialize_1950; procedure Initialize_1951; procedure Initialize_1952; procedure Initialize_1953; procedure Initialize_1954; procedure Initialize_1955; procedure Initialize_1956; procedure Initialize_1957; procedure Initialize_1958; procedure Initialize_1959; procedure Initialize_1960; procedure Initialize_1961; procedure Initialize_1962; procedure Initialize_1963; procedure Initialize_1964; procedure Initialize_1965; procedure Initialize_1966; procedure Initialize_1967; procedure Initialize_1968; procedure Initialize_1969; procedure Initialize_1970; procedure Initialize_1971; procedure Initialize_1972; procedure Initialize_1973; procedure Initialize_1974; procedure Initialize_1975; procedure Initialize_1976; procedure Initialize_1977; procedure Initialize_1978; procedure Initialize_1979; procedure Initialize_1980; procedure Initialize_1981; procedure Initialize_1982; procedure Initialize_1983; procedure Initialize_1984; procedure Initialize_1985; procedure Initialize_1986; procedure Initialize_1987; procedure Initialize_1988; procedure Initialize_1989; procedure Initialize_1990; procedure Initialize_1991; procedure Initialize_1992; procedure Initialize_1993; procedure Initialize_1994; procedure Initialize_1995; procedure Initialize_1996; procedure Initialize_1997; procedure Initialize_1998; procedure Initialize_1999; procedure Initialize_2000; procedure Initialize_2001; procedure Initialize_2002; procedure Initialize_2003; procedure Initialize_2004; procedure Initialize_2005; procedure Initialize_2006; procedure Initialize_2007; procedure Initialize_2008; procedure Initialize_2009; procedure Initialize_2010; procedure Initialize_2011; procedure Initialize_2012; procedure Initialize_2013; procedure Initialize_2014; procedure Initialize_2015; procedure Initialize_2016; procedure Initialize_2017; procedure Initialize_2018; procedure Initialize_2019; procedure Initialize_2020; procedure Initialize_2021; procedure Initialize_2022; procedure Initialize_2023; procedure Initialize_2024; procedure Initialize_2025; procedure Initialize_2026; procedure Initialize_2027; procedure Initialize_2028; procedure Initialize_2029; procedure Initialize_2030; procedure Initialize_2031; procedure Initialize_2032; procedure Initialize_2033; procedure Initialize_2034; procedure Initialize_2035; procedure Initialize_2036; procedure Initialize_2037; procedure Initialize_2038; procedure Initialize_2039; procedure Initialize_2040; procedure Initialize_2041; procedure Initialize_2042; procedure Initialize_2043; procedure Initialize_2044; procedure Initialize_2045; procedure Initialize_2046; procedure Initialize_2047; procedure Initialize_2048; procedure Initialize_2049; procedure Initialize_2050; procedure Initialize_2051; procedure Initialize_2052; procedure Initialize_2053; procedure Initialize_2054; procedure Initialize_2055; procedure Initialize_2056; procedure Initialize_2057; procedure Initialize_2058; procedure Initialize_2059; procedure Initialize_2060; procedure Initialize_2061; procedure Initialize_2062; procedure Initialize_2063; procedure Initialize_2064; procedure Initialize_2065; procedure Initialize_2066; procedure Initialize_2067; procedure Initialize_2068; procedure Initialize_2069; procedure Initialize_2070; procedure Initialize_2071; procedure Initialize_2072; procedure Initialize_2073; procedure Initialize_2074; procedure Initialize_2075; procedure Initialize_2076; procedure Initialize_2077; procedure Initialize_2078; procedure Initialize_2079; procedure Initialize_2080; procedure Initialize_2081; procedure Initialize_2082; procedure Initialize_2083; procedure Initialize_2084; procedure Initialize_2085; procedure Initialize_2086; procedure Initialize_2087; procedure Initialize_2088; procedure Initialize_2089; procedure Initialize_2090; procedure Initialize_2091; procedure Initialize_2092; procedure Initialize_2093; procedure Initialize_2094; procedure Initialize_2095; procedure Initialize_2096; procedure Initialize_2097; procedure Initialize_2098; procedure Initialize_2099; procedure Initialize_2100; procedure Initialize_2101; procedure Initialize_2102; procedure Initialize_2103; procedure Initialize_2104; procedure Initialize_2105; procedure Initialize_2106; procedure Initialize_2107; procedure Initialize_2108; procedure Initialize_2109; procedure Initialize_2110; procedure Initialize_2111; procedure Initialize_2112; procedure Initialize_2113; procedure Initialize_2114; procedure Initialize_2115; procedure Initialize_2116; procedure Initialize_2117; procedure Initialize_2118; procedure Initialize_2119; procedure Initialize_2120; procedure Initialize_2121; procedure Initialize_2122; procedure Initialize_2123; procedure Initialize_2124; procedure Initialize_2125; procedure Initialize_2126; procedure Initialize_2127; procedure Initialize_2128; procedure Initialize_2129; procedure Initialize_2130; procedure Initialize_2131; procedure Initialize_2132; procedure Initialize_2133; procedure Initialize_2134; procedure Initialize_2135; procedure Initialize_2136; procedure Initialize_2137; procedure Initialize_2138; procedure Initialize_2139; procedure Initialize_2140; procedure Initialize_2141; procedure Initialize_2142; procedure Initialize_2143; procedure Initialize_2144; procedure Initialize_2145; procedure Initialize_2146; procedure Initialize_2147; procedure Initialize_2148; procedure Initialize_2149; procedure Initialize_2150; procedure Initialize_2151; procedure Initialize_2152; procedure Initialize_2153; procedure Initialize_2154; procedure Initialize_2155; procedure Initialize_2156; procedure Initialize_2157; procedure Initialize_2158; procedure Initialize_2159; procedure Initialize_2160; procedure Initialize_2161; procedure Initialize_2162; procedure Initialize_2163; procedure Initialize_2164; procedure Initialize_2165; procedure Initialize_2166; procedure Initialize_2167; procedure Initialize_2168; procedure Initialize_2169; procedure Initialize_2170; procedure Initialize_2171; procedure Initialize_2172; procedure Initialize_2173; procedure Initialize_2174; procedure Initialize_2175; procedure Initialize_2176; procedure Initialize_2177; procedure Initialize_2178; procedure Initialize_2179; procedure Initialize_2180; procedure Initialize_2181; procedure Initialize_2182; procedure Initialize_2183; procedure Initialize_2184; procedure Initialize_2185; procedure Initialize_2186; procedure Initialize_2187; procedure Initialize_2188; procedure Initialize_2189; procedure Initialize_2190; procedure Initialize_2191; procedure Initialize_2192; procedure Initialize_2193; procedure Initialize_2194; procedure Initialize_2195; procedure Initialize_2196; procedure Initialize_2197; procedure Initialize_2198; procedure Initialize_2199; procedure Initialize_2200; procedure Initialize_2201; procedure Initialize_2202; procedure Initialize_2203; procedure Initialize_2204; procedure Initialize_2205; procedure Initialize_2206; procedure Initialize_2207; procedure Initialize_2208; procedure Initialize_2209; procedure Initialize_2210; procedure Initialize_2211; procedure Initialize_2212; procedure Initialize_2213; procedure Initialize_2214; procedure Initialize_2215; procedure Initialize_2216; procedure Initialize_2217; procedure Initialize_2218; procedure Initialize_2219; procedure Initialize_2220; procedure Initialize_2221; procedure Initialize_2222; procedure Initialize_2223; procedure Initialize_2224; procedure Initialize_2225; procedure Initialize_2226; procedure Initialize_2227; procedure Initialize_2228; procedure Initialize_2229; procedure Initialize_2230; procedure Initialize_2231; procedure Initialize_2232; procedure Initialize_2233; procedure Initialize_2234; procedure Initialize_2235; procedure Initialize_2236; procedure Initialize_2237; procedure Initialize_2238; procedure Initialize_2239; procedure Initialize_2240; procedure Initialize_2241; procedure Initialize_2242; procedure Initialize_2243; procedure Initialize_2244; procedure Initialize_2245; procedure Initialize_2246; procedure Initialize_2247; procedure Initialize_2248; procedure Initialize_2249; procedure Initialize_2250; procedure Initialize_2251; procedure Initialize_2252; procedure Initialize_2253; procedure Initialize_2254; procedure Initialize_2255; procedure Initialize_2256; procedure Initialize_2257; procedure Initialize_2258; procedure Initialize_2259; procedure Initialize_2260; procedure Initialize_2261; procedure Initialize_2262; procedure Initialize_2263; procedure Initialize_2264; procedure Initialize_2265; procedure Initialize_2266; procedure Initialize_2267; procedure Initialize_2268; procedure Initialize_2269; procedure Initialize_2270; procedure Initialize_2271; procedure Initialize_2272; procedure Initialize_2273; procedure Initialize_2274; procedure Initialize_2275; procedure Initialize_2276; procedure Initialize_2277; procedure Initialize_2278; procedure Initialize_2279; procedure Initialize_2280; procedure Initialize_2281; procedure Initialize_2282; procedure Initialize_2283; procedure Initialize_2284; procedure Initialize_2285; procedure Initialize_2286; procedure Initialize_2287; procedure Initialize_2288; procedure Initialize_2289; procedure Initialize_2290; procedure Initialize_2291; procedure Initialize_2292; procedure Initialize_2293; procedure Initialize_2294; procedure Initialize_2295; procedure Initialize_2296; procedure Initialize_2297; procedure Initialize_2298; procedure Initialize_2299; procedure Initialize_2300; procedure Initialize_2301; procedure Initialize_2302; procedure Initialize_2303; procedure Initialize_2304; procedure Initialize_2305; procedure Initialize_2306; procedure Initialize_2307; procedure Initialize_2308; procedure Initialize_2309; procedure Initialize_2310; procedure Initialize_2311; procedure Initialize_2312; procedure Initialize_2313; procedure Initialize_2314; procedure Initialize_2315; procedure Initialize_2316; procedure Initialize_2317; procedure Initialize_2318; procedure Initialize_2319; procedure Initialize_2320; procedure Initialize_2321; procedure Initialize_2322; procedure Initialize_2323; procedure Initialize_2324; procedure Initialize_2325; procedure Initialize_2326; procedure Initialize_2327; procedure Initialize_2328; procedure Initialize_2329; procedure Initialize_2330; procedure Initialize_2331; procedure Initialize_2332; procedure Initialize_2333; procedure Initialize_2334; procedure Initialize_2335; procedure Initialize_2336; procedure Initialize_2337; procedure Initialize_2338; procedure Initialize_2339; procedure Initialize_2340; procedure Initialize_2341; procedure Initialize_2342; procedure Initialize_2343; procedure Initialize_2344; procedure Initialize_2345; procedure Initialize_2346; procedure Initialize_2347; procedure Initialize_2348; procedure Initialize_2349; procedure Initialize_2350; procedure Initialize_2351; procedure Initialize_2352; procedure Initialize_2353; procedure Initialize_2354; procedure Initialize_2355; procedure Initialize_2356; procedure Initialize_2357; procedure Initialize_2358; procedure Initialize_2359; procedure Initialize_2360; procedure Initialize_2361; procedure Initialize_2362; procedure Initialize_2363; procedure Initialize_2364; procedure Initialize_2365; procedure Initialize_2366; procedure Initialize_2367; procedure Initialize_2368; procedure Initialize_2369; procedure Initialize_2370; procedure Initialize_2371; procedure Initialize_2372; procedure Initialize_2373; procedure Initialize_2374; procedure Initialize_2375; procedure Initialize_2376; procedure Initialize_2377; procedure Initialize_2378; procedure Initialize_2379; procedure Initialize_2380; procedure Initialize_2381; procedure Initialize_2382; procedure Initialize_2383; procedure Initialize_2384; procedure Initialize_2385; procedure Initialize_2386; procedure Initialize_2387; procedure Initialize_2388; procedure Initialize_2389; procedure Initialize_2390; procedure Initialize_2391; procedure Initialize_2392; procedure Initialize_2393; procedure Initialize_2394; procedure Initialize_2395; procedure Initialize_2396; procedure Initialize_2397; procedure Initialize_2398; procedure Initialize_2399; procedure Initialize_2400; procedure Initialize_2401; procedure Initialize_2402; procedure Initialize_2403; procedure Initialize_2404; procedure Initialize_2405; procedure Initialize_2406; procedure Initialize_2407; procedure Initialize_2408; procedure Initialize_2409; procedure Initialize_2410; procedure Initialize_2411; procedure Initialize_2412; procedure Initialize_2413; procedure Initialize_2414; procedure Initialize_2415; procedure Initialize_2416; procedure Initialize_2417; procedure Initialize_2418; procedure Initialize_2419; procedure Initialize_2420; procedure Initialize_2421; procedure Initialize_2422; procedure Initialize_2423; procedure Initialize_2424; procedure Initialize_2425; procedure Initialize_2426; procedure Initialize_2427; procedure Initialize_2428; procedure Initialize_2429; procedure Initialize_2430; procedure Initialize_2431; procedure Initialize_2432; procedure Initialize_2433; procedure Initialize_2434; procedure Initialize_2435; procedure Initialize_2436; procedure Initialize_2437; procedure Initialize_2438; procedure Initialize_2439; procedure Initialize_2440; procedure Initialize_2441; procedure Initialize_2442; procedure Initialize_2443; procedure Initialize_2444; procedure Initialize_2445; procedure Initialize_2446; procedure Initialize_2447; procedure Initialize_2448; procedure Initialize_2449; procedure Initialize_2450; procedure Initialize_2451; procedure Initialize_2452; procedure Initialize_2453; procedure Initialize_2454; procedure Initialize_2455; procedure Initialize_2456; procedure Initialize_2457; procedure Initialize_2458; procedure Initialize_2459; procedure Initialize_2460; procedure Initialize_2461; procedure Initialize_2462; procedure Initialize_2463; procedure Initialize_2464; procedure Initialize_2465; procedure Initialize_2466; procedure Initialize_2467; procedure Initialize_2468; procedure Initialize_2469; procedure Initialize_2470; procedure Initialize_2471; procedure Initialize_2472; procedure Initialize_2473; procedure Initialize_2474; procedure Initialize_2475; procedure Initialize_2476; procedure Initialize_2477; procedure Initialize_2478; procedure Initialize_2479; procedure Initialize_2480; procedure Initialize_2481; procedure Initialize_2482; procedure Initialize_2483; procedure Initialize_2484; procedure Initialize_2485; procedure Initialize_2486; procedure Initialize_2487; procedure Initialize_2488; procedure Initialize_2489; procedure Initialize_2490; procedure Initialize_2491; procedure Initialize_2492; procedure Initialize_2493; procedure Initialize_2494; procedure Initialize_2495; procedure Initialize_2496; procedure Initialize_2497; procedure Initialize_2498; procedure Initialize_2499; procedure Initialize_2500; procedure Initialize_2501; procedure Initialize_2502; procedure Initialize_2503; procedure Initialize_2504; procedure Initialize_2505; procedure Initialize_2506; procedure Initialize_2507; procedure Initialize_2508; procedure Initialize_2509; procedure Initialize_2510; procedure Initialize_2511; procedure Initialize_2512; procedure Initialize_2513; procedure Initialize_2514; procedure Initialize_2515; procedure Initialize_2516; procedure Initialize_2517; procedure Initialize_2518; procedure Initialize_2519; procedure Initialize_2520; procedure Initialize_2521; procedure Initialize_2522; procedure Initialize_2523; procedure Initialize_2524; procedure Initialize_2525; procedure Initialize_2526; procedure Initialize_2527; procedure Initialize_2528; procedure Initialize_2529; procedure Initialize_2530; procedure Initialize_2531; procedure Initialize_2532; procedure Initialize_2533; procedure Initialize_2534; procedure Initialize_2535; procedure Initialize_2536; procedure Initialize_2537; procedure Initialize_2538; procedure Initialize_2539; procedure Initialize_2540; procedure Initialize_2541; procedure Initialize_2542; procedure Initialize_2543; procedure Initialize_2544; procedure Initialize_2545; procedure Initialize_2546; procedure Initialize_2547; procedure Initialize_2548; procedure Initialize_2549; procedure Initialize_2550; procedure Initialize_2551; procedure Initialize_2552; procedure Initialize_2553; procedure Initialize_2554; procedure Initialize_2555; procedure Initialize_2556; procedure Initialize_2557; procedure Initialize_2558; procedure Initialize_2559; procedure Initialize_2560; procedure Initialize_2561; procedure Initialize_2562; procedure Initialize_2563; procedure Initialize_2564; procedure Initialize_2565; procedure Initialize_2566; procedure Initialize_2567; procedure Initialize_2568; procedure Initialize_2569; procedure Initialize_2570; procedure Initialize_2571; procedure Initialize_2572; procedure Initialize_2573; procedure Initialize_2574; procedure Initialize_2575; procedure Initialize_2576; procedure Initialize_2577; procedure Initialize_2578; procedure Initialize_2579; procedure Initialize_2580; procedure Initialize_2581; procedure Initialize_2582; procedure Initialize_2583; procedure Initialize_2584; procedure Initialize_2585; procedure Initialize_2586; procedure Initialize_2587; procedure Initialize_2588; procedure Initialize_2589; procedure Initialize_2590; procedure Initialize_2591; procedure Initialize_2592; procedure Initialize_2593; procedure Initialize_2594; procedure Initialize_2595; procedure Initialize_2596; procedure Initialize_2597; procedure Initialize_2598; procedure Initialize_2599; procedure Initialize_2600; procedure Initialize_2601; procedure Initialize_2602; procedure Initialize_2603; procedure Initialize_2604; procedure Initialize_2605; procedure Initialize_2606; procedure Initialize_2607; procedure Initialize_2608; procedure Initialize_2609; procedure Initialize_2610; procedure Initialize_2611; procedure Initialize_2612; procedure Initialize_2613; procedure Initialize_2614; procedure Initialize_2615; procedure Initialize_2616; procedure Initialize_2617; procedure Initialize_2618; procedure Initialize_2619; procedure Initialize_2620; procedure Initialize_2621; procedure Initialize_2622; procedure Initialize_2623; procedure Initialize_2624; procedure Initialize_2625; procedure Initialize_2626; procedure Initialize_2627; procedure Initialize_2628; procedure Initialize_2629; procedure Initialize_2630; procedure Initialize_2631; procedure Initialize_2632; procedure Initialize_2633; procedure Initialize_2634; procedure Initialize_2635; procedure Initialize_2636; procedure Initialize_2637; procedure Initialize_2638; procedure Initialize_2639; procedure Initialize_2640; procedure Initialize_2641; procedure Initialize_2642; procedure Initialize_2643; procedure Initialize_2644; procedure Initialize_2645; procedure Initialize_2646; procedure Initialize_2647; procedure Initialize_2648; procedure Initialize_2649; procedure Initialize_2650; procedure Initialize_2651; procedure Initialize_2652; procedure Initialize_2653; procedure Initialize_2654; procedure Initialize_2655; procedure Initialize_2656; procedure Initialize_2657; procedure Initialize_2658; procedure Initialize_2659; procedure Initialize_2660; procedure Initialize_2661; procedure Initialize_2662; procedure Initialize_2663; procedure Initialize_2664; procedure Initialize_2665; procedure Initialize_2666; procedure Initialize_2667; procedure Initialize_2668; procedure Initialize_2669; procedure Initialize_2670; procedure Initialize_2671; procedure Initialize_2672; procedure Initialize_2673; procedure Initialize_2674; procedure Initialize_2675; procedure Initialize_2676; procedure Initialize_2677; procedure Initialize_2678; procedure Initialize_2679; procedure Initialize_2680; procedure Initialize_2681; procedure Initialize_2682; procedure Initialize_2683; procedure Initialize_2684; procedure Initialize_2685; procedure Initialize_2686; procedure Initialize_2687; procedure Initialize_2688; procedure Initialize_2689; procedure Initialize_2690; procedure Initialize_2691; procedure Initialize_2692; procedure Initialize_2693; procedure Initialize_2694; procedure Initialize_2695; procedure Initialize_2696; procedure Initialize_2697; procedure Initialize_2698; procedure Initialize_2699; procedure Initialize_2700; procedure Initialize_2701; procedure Initialize_2702; procedure Initialize_2703; procedure Initialize_2704; procedure Initialize_2705; procedure Initialize_2706; procedure Initialize_2707; procedure Initialize_2708; procedure Initialize_2709; procedure Initialize_2710; procedure Initialize_2711; procedure Initialize_2712; procedure Initialize_2713; procedure Initialize_2714; procedure Initialize_2715; procedure Initialize_2716; procedure Initialize_2717; procedure Initialize_2718; procedure Initialize_2719; procedure Initialize_2720; procedure Initialize_2721; procedure Initialize_2722; procedure Initialize_2723; procedure Initialize_2724; procedure Initialize_2725; procedure Initialize_2726; procedure Initialize_2727; procedure Initialize_2728; procedure Initialize_2729; procedure Initialize_2730; procedure Initialize_2731; procedure Initialize_2732; procedure Initialize_2733; procedure Initialize_2734; procedure Initialize_2735; procedure Initialize_2736; procedure Initialize_2737; procedure Initialize_2738; procedure Initialize_2739; procedure Initialize_2740; procedure Initialize_2741; procedure Initialize_2742; procedure Initialize_2743; procedure Initialize_2744; procedure Initialize_2745; procedure Initialize_2746; procedure Initialize_2747; procedure Initialize_2748; procedure Initialize_2749; procedure Initialize_2750; procedure Initialize_2751; procedure Initialize_2752; procedure Initialize_2753; procedure Initialize_2754; procedure Initialize_2755; procedure Initialize_2756; procedure Initialize_2757; procedure Initialize_2758; procedure Initialize_2759; procedure Initialize_2760; procedure Initialize_2761; procedure Initialize_2762; procedure Initialize_2763; procedure Initialize_2764; procedure Initialize_2765; procedure Initialize_2766; procedure Initialize_2767; procedure Initialize_2768; procedure Initialize_2769; procedure Initialize_2770; procedure Initialize_2771; procedure Initialize_2772; procedure Initialize_2773; procedure Initialize_2774; procedure Initialize_2775; procedure Initialize_2776; procedure Initialize_2777; procedure Initialize_2778; procedure Initialize_2779; procedure Initialize_2780; procedure Initialize_2781; procedure Initialize_2782; procedure Initialize_2783; procedure Initialize_2784; procedure Initialize_2785; procedure Initialize_2786; procedure Initialize_2787; procedure Initialize_2788; procedure Initialize_2789; procedure Initialize_2790; procedure Initialize_2791; procedure Initialize_2792; procedure Initialize_2793; procedure Initialize_2794; procedure Initialize_2795; procedure Initialize_2796; procedure Initialize_2797; procedure Initialize_2798; procedure Initialize_2799; procedure Initialize_2800; procedure Initialize_2801; procedure Initialize_2802; procedure Initialize_2803; procedure Initialize_2804; procedure Initialize_2805; procedure Initialize_2806; procedure Initialize_2807; procedure Initialize_2808; procedure Initialize_2809; procedure Initialize_2810; procedure Initialize_2811; procedure Initialize_2812; procedure Initialize_2813; procedure Initialize_2814; procedure Initialize_2815; procedure Initialize_2816; procedure Initialize_2817; procedure Initialize_2818; procedure Initialize_2819; procedure Initialize_2820; procedure Initialize_2821; procedure Initialize_2822; procedure Initialize_2823; procedure Initialize_2824; procedure Initialize_2825; procedure Initialize_2826; procedure Initialize_2827; procedure Initialize_2828; procedure Initialize_2829; procedure Initialize_2830; procedure Initialize_2831; procedure Initialize_2832; procedure Initialize_2833; procedure Initialize_2834; procedure Initialize_2835; procedure Initialize_2836; procedure Initialize_2837; procedure Initialize_2838; procedure Initialize_2839; procedure Initialize_2840; procedure Initialize_2841; procedure Initialize_2842; procedure Initialize_2843; procedure Initialize_2844; procedure Initialize_2845; procedure Initialize_2846; procedure Initialize_2847; procedure Initialize_2848; procedure Initialize_2849; procedure Initialize_2850; procedure Initialize_2851; procedure Initialize_2852; procedure Initialize_2853; procedure Initialize_2854; procedure Initialize_2855; procedure Initialize_2856; procedure Initialize_2857; procedure Initialize_2858; procedure Initialize_2859; procedure Initialize_2860; procedure Initialize_2861; procedure Initialize_2862; procedure Initialize_2863; procedure Initialize_2864; procedure Initialize_2865; procedure Initialize_2866; procedure Initialize_2867; procedure Initialize_2868; procedure Initialize_2869; procedure Initialize_2870; procedure Initialize_2871; procedure Initialize_2872; procedure Initialize_2873; procedure Initialize_2874; procedure Initialize_2875; procedure Initialize_2876; procedure Initialize_2877; procedure Initialize_2878; procedure Initialize_2879; procedure Initialize_2880; procedure Initialize_2881; procedure Initialize_2882; procedure Initialize_2883; procedure Initialize_2884; procedure Initialize_2885; procedure Initialize_2886; procedure Initialize_2887; procedure Initialize_2888; procedure Initialize_2889; procedure Initialize_2890; procedure Initialize_2891; procedure Initialize_2892; procedure Initialize_2893; procedure Initialize_2894; procedure Initialize_2895; procedure Initialize_2896; procedure Initialize_2897; procedure Initialize_2898; procedure Initialize_2899; procedure Initialize_2900; procedure Initialize_2901; procedure Initialize_2902; procedure Initialize_2903; procedure Initialize_2904; procedure Initialize_2905; procedure Initialize_2906; procedure Initialize_2907; procedure Initialize_2908; procedure Initialize_2909; procedure Initialize_2910; procedure Initialize_2911; procedure Initialize_2912; procedure Initialize_2913; procedure Initialize_2914; procedure Initialize_2915; procedure Initialize_2916; procedure Initialize_2917; procedure Initialize_2918; procedure Initialize_2919; procedure Initialize_2920; procedure Initialize_2921; procedure Initialize_2922; procedure Initialize_2923; procedure Initialize_2924; procedure Initialize_2925; procedure Initialize_2926; procedure Initialize_2927; procedure Initialize_2928; procedure Initialize_2929; procedure Initialize_2930; procedure Initialize_2931; procedure Initialize_2932; procedure Initialize_2933; procedure Initialize_2934; procedure Initialize_2935; procedure Initialize_2936; procedure Initialize_2937; procedure Initialize_2938; procedure Initialize_2939; procedure Initialize_2940; procedure Initialize_2941; procedure Initialize_2942; procedure Initialize_2943; procedure Initialize_2944; procedure Initialize_2945; procedure Initialize_2946; procedure Initialize_2947; procedure Initialize_2948; procedure Initialize_2949; procedure Initialize_2950; procedure Initialize_2951; procedure Initialize_2952; procedure Initialize_2953; procedure Initialize_2954; procedure Initialize_2955; procedure Initialize_2956; procedure Initialize_2957; procedure Initialize_2958; procedure Initialize_2959; procedure Initialize_2960; procedure Initialize_2961; procedure Initialize_2962; procedure Initialize_2963; procedure Initialize_2964; procedure Initialize_2965; procedure Initialize_2966; procedure Initialize_2967; procedure Initialize_2968; procedure Initialize_2969; procedure Initialize_2970; procedure Initialize_2971; procedure Initialize_2972; procedure Initialize_2973; procedure Initialize_2974; procedure Initialize_2975; procedure Initialize_2976; procedure Initialize_2977; procedure Initialize_2978; procedure Initialize_2979; procedure Initialize_2980; procedure Initialize_2981; procedure Initialize_2982; procedure Initialize_2983; procedure Initialize_2984; procedure Initialize_2985; procedure Initialize_2986; procedure Initialize_2987; procedure Initialize_2988; procedure Initialize_2989; procedure Initialize_2990; procedure Initialize_2991; procedure Initialize_2992; procedure Initialize_2993; procedure Initialize_2994; procedure Initialize_2995; procedure Initialize_2996; procedure Initialize_2997; procedure Initialize_2998; procedure Initialize_2999; procedure Initialize_3000; procedure Initialize_3001; procedure Initialize_3002; procedure Initialize_3003; procedure Initialize_3004; procedure Initialize_3005; procedure Initialize_3006; procedure Initialize_3007; procedure Initialize_3008; procedure Initialize_3009; procedure Initialize_3010; procedure Initialize_3011; procedure Initialize_3012; procedure Initialize_3013; procedure Initialize_3014; procedure Initialize_3015; procedure Initialize_3016; procedure Initialize_3017; procedure Initialize_3018; procedure Initialize_3019; procedure Initialize_3020; procedure Initialize_3021; procedure Initialize_3022; procedure Initialize_3023; procedure Initialize_3024; procedure Initialize_3025; procedure Initialize_3026; procedure Initialize_3027; procedure Initialize_3028; procedure Initialize_3029; procedure Initialize_3030; procedure Initialize_3031; procedure Initialize_3032; procedure Initialize_3033; procedure Initialize_3034; procedure Initialize_3035; procedure Initialize_3036; procedure Initialize_3037; procedure Initialize_3038; procedure Initialize_3039; procedure Initialize_3040; procedure Initialize_3041; procedure Initialize_3042; procedure Initialize_3043; procedure Initialize_3044; procedure Initialize_3045; procedure Initialize_3046; procedure Initialize_3047; procedure Initialize_3048; procedure Initialize_3049; procedure Initialize_3050; procedure Initialize_3051; procedure Initialize_3052; procedure Initialize_3053; procedure Initialize_3054; procedure Initialize_3055; procedure Initialize_3056; procedure Initialize_3057; procedure Initialize_3058; procedure Initialize_3059; procedure Initialize_3060; procedure Initialize_3061; procedure Initialize_3062; procedure Initialize_3063; procedure Initialize_3064; procedure Initialize_3065; procedure Initialize_3066; procedure Initialize_3067; procedure Initialize_3068; procedure Initialize_3069; procedure Initialize_3070; procedure Initialize_3071; procedure Initialize_3072; procedure Initialize_3073; procedure Initialize_3074; procedure Initialize_3075; procedure Initialize_3076; procedure Initialize_3077; procedure Initialize_3078; procedure Initialize_3079; procedure Initialize_3080; procedure Initialize_3081; procedure Initialize_3082; procedure Initialize_3083; procedure Initialize_3084; procedure Initialize_3085; procedure Initialize_3086; procedure Initialize_3087; procedure Initialize_3088; procedure Initialize_3089; procedure Initialize_3090; procedure Initialize_3091; procedure Initialize_3092; procedure Initialize_3093; procedure Initialize_3094; procedure Initialize_3095; procedure Initialize_3096; procedure Initialize_3097; procedure Initialize_3098; procedure Initialize_3099; procedure Initialize_3100; procedure Initialize_3101; procedure Initialize_3102; procedure Initialize_3103; procedure Initialize_3104; procedure Initialize_3105; procedure Initialize_3106; procedure Initialize_3107; procedure Initialize_3108; procedure Initialize_3109; procedure Initialize_3110; procedure Initialize_3111; procedure Initialize_3112; procedure Initialize_3113; procedure Initialize_3114; procedure Initialize_3115; procedure Initialize_3116; procedure Initialize_3117; procedure Initialize_3118; procedure Initialize_3119; procedure Initialize_3120; procedure Initialize_3121; procedure Initialize_3122; procedure Initialize_3123; procedure Initialize_3124; procedure Initialize_3125; procedure Initialize_3126; procedure Initialize_3127; procedure Initialize_3128; procedure Initialize_3129; procedure Initialize_3130; procedure Initialize_3131; procedure Initialize_3132; procedure Initialize_3133; procedure Initialize_3134; procedure Initialize_3135; procedure Initialize_3136; procedure Initialize_3137; procedure Initialize_3138; procedure Initialize_3139; procedure Initialize_3140; procedure Initialize_3141; procedure Initialize_3142; procedure Initialize_3143; procedure Initialize_3144; procedure Initialize_3145; procedure Initialize_3146; procedure Initialize_3147; procedure Initialize_3148; procedure Initialize_3149; procedure Initialize_3150; procedure Initialize_3151; procedure Initialize_3152; procedure Initialize_3153; procedure Initialize_3154; procedure Initialize_3155; procedure Initialize_3156; procedure Initialize_3157; procedure Initialize_3158; procedure Initialize_3159; procedure Initialize_3160; procedure Initialize_3161; procedure Initialize_3162; procedure Initialize_3163; procedure Initialize_3164; procedure Initialize_3165; procedure Initialize_3166; procedure Initialize_3167; procedure Initialize_3168; procedure Initialize_3169; procedure Initialize_3170; procedure Initialize_3171; procedure Initialize_3172; procedure Initialize_3173; procedure Initialize_3174; procedure Initialize_3175; procedure Initialize_3176; procedure Initialize_3177; procedure Initialize_3178; procedure Initialize_3179; procedure Initialize_3180; procedure Initialize_3181; procedure Initialize_3182; procedure Initialize_3183; procedure Initialize_3184; procedure Initialize_3185; procedure Initialize_3186; procedure Initialize_3187; procedure Initialize_3188; procedure Initialize_3189; procedure Initialize_3190; procedure Initialize_3191; procedure Initialize_3192; procedure Initialize_3193; procedure Initialize_3194; procedure Initialize_3195; procedure Initialize_3196; procedure Initialize_3197; procedure Initialize_3198; procedure Initialize_3199; procedure Initialize_3200; procedure Initialize_3201; procedure Initialize_3202; procedure Initialize_3203; procedure Initialize_3204; procedure Initialize_3205; procedure Initialize_3206; procedure Initialize_3207; procedure Initialize_3208; procedure Initialize_3209; procedure Initialize_3210; procedure Initialize_3211; procedure Initialize_3212; procedure Initialize_3213; procedure Initialize_3214; procedure Initialize_3215; procedure Initialize_3216; procedure Initialize_3217; procedure Initialize_3218; procedure Initialize_3219; procedure Initialize_3220; procedure Initialize_3221; procedure Initialize_3222; procedure Initialize_3223; procedure Initialize_3224; procedure Initialize_3225; procedure Initialize_3226; procedure Initialize_3227; procedure Initialize_3228; procedure Initialize_3229; procedure Initialize_3230; procedure Initialize_3231; procedure Initialize_3232; procedure Initialize_3233; procedure Initialize_3234; procedure Initialize_3235; procedure Initialize_3236; procedure Initialize_3237; procedure Initialize_3238; procedure Initialize_3239; procedure Initialize_3240; procedure Initialize_3241; procedure Initialize_3242; procedure Initialize_3243; procedure Initialize_3244; procedure Initialize_3245; procedure Initialize_3246; procedure Initialize_3247; procedure Initialize_3248; procedure Initialize_3249; procedure Initialize_3250; procedure Initialize_3251; procedure Initialize_3252; procedure Initialize_3253; procedure Initialize_3254; procedure Initialize_3255; procedure Initialize_3256; procedure Initialize_3257; procedure Initialize_3258; procedure Initialize_3259; procedure Initialize_3260; procedure Initialize_3261; procedure Initialize_3262; procedure Initialize_3263; procedure Initialize_3264; procedure Initialize_3265; procedure Initialize_3266; procedure Initialize_3267; procedure Initialize_3268; procedure Initialize_3269; procedure Initialize_3270; procedure Initialize_3271; procedure Initialize_3272; procedure Initialize_3273; procedure Initialize_3274; procedure Initialize_3275; procedure Initialize_3276; procedure Initialize_3277; procedure Initialize_3278; procedure Initialize_3279; procedure Initialize_3280; procedure Initialize_3281; procedure Initialize_3282; procedure Initialize_3283; procedure Initialize_3284; procedure Initialize_3285; procedure Initialize_3286; procedure Initialize_3287; procedure Initialize_3288; procedure Initialize_3289; procedure Initialize_3290; procedure Initialize_3291; procedure Initialize_3292; procedure Initialize_3293; procedure Initialize_3294; procedure Initialize_3295; procedure Initialize_3296; procedure Initialize_3297; procedure Initialize_3298; procedure Initialize_3299; procedure Initialize_3300; procedure Initialize_3301; procedure Initialize_3302; procedure Initialize_3303; procedure Initialize_3304; procedure Initialize_3305; procedure Initialize_3306; procedure Initialize_3307; procedure Initialize_3308; procedure Initialize_3309; procedure Initialize_3310; procedure Initialize_3311; procedure Initialize_3312; procedure Initialize_3313; procedure Initialize_3314; procedure Initialize_3315; procedure Initialize_3316; procedure Initialize_3317; procedure Initialize_3318; procedure Initialize_3319; procedure Initialize_3320; procedure Initialize_3321; procedure Initialize_3322; procedure Initialize_3323; procedure Initialize_3324; procedure Initialize_3325; procedure Initialize_3326; procedure Initialize_3327; procedure Initialize_3328; procedure Initialize_3329; procedure Initialize_3330; procedure Initialize_3331; procedure Initialize_3332; procedure Initialize_3333; procedure Initialize_3334; procedure Initialize_3335; procedure Initialize_3336; procedure Initialize_3337; procedure Initialize_3338; procedure Initialize_3339; procedure Initialize_3340; procedure Initialize_3341; procedure Initialize_3342; procedure Initialize_3343; procedure Initialize_3344; procedure Initialize_3345; procedure Initialize_3346; procedure Initialize_3347; procedure Initialize_3348; procedure Initialize_3349; procedure Initialize_3350; procedure Initialize_3351; procedure Initialize_3352; procedure Initialize_3353; procedure Initialize_3354; procedure Initialize_3355; procedure Initialize_3356; procedure Initialize_3357; procedure Initialize_3358; procedure Initialize_3359; procedure Initialize_3360; procedure Initialize_3361; procedure Initialize_3362; procedure Initialize_3363; procedure Initialize_3364; procedure Initialize_3365; procedure Initialize_3366; procedure Initialize_3367; procedure Initialize_3368; procedure Initialize_3369; procedure Initialize_3370; procedure Initialize_3371; procedure Initialize_3372; procedure Initialize_3373; procedure Initialize_3374; procedure Initialize_3375; procedure Initialize_3376; procedure Initialize_3377; procedure Initialize_3378; procedure Initialize_3379; procedure Initialize_3380; procedure Initialize_3381; procedure Initialize_3382; procedure Initialize_3383; procedure Initialize_3384; procedure Initialize_3385; procedure Initialize_3386; procedure Initialize_3387; procedure Initialize_3388; procedure Initialize_3389; procedure Initialize_3390; procedure Initialize_3391; procedure Initialize_3392; procedure Initialize_3393; procedure Initialize_3394; procedure Initialize_3395; procedure Initialize_3396; procedure Initialize_3397; procedure Initialize_3398; procedure Initialize_3399; procedure Initialize_3400; procedure Initialize_3401; procedure Initialize_3402; procedure Initialize_3403; procedure Initialize_3404; procedure Initialize_3405; procedure Initialize_3406; procedure Initialize_3407; procedure Initialize_3408; procedure Initialize_3409; procedure Initialize_3410; procedure Initialize_3411; procedure Initialize_3412; procedure Initialize_3413; procedure Initialize_3414; procedure Initialize_3415; procedure Initialize_3416; procedure Initialize_3417; procedure Initialize_3418; procedure Initialize_3419; procedure Initialize_3420; procedure Initialize_3421; procedure Initialize_3422; procedure Initialize_3423; procedure Initialize_3424; procedure Initialize_3425; procedure Initialize_3426; procedure Initialize_3427; procedure Initialize_3428; procedure Initialize_3429; procedure Initialize_3430; procedure Initialize_3431; procedure Initialize_3432; procedure Initialize_3433; procedure Initialize_3434; procedure Initialize_3435; procedure Initialize_3436; procedure Initialize_3437; procedure Initialize_3438; procedure Initialize_3439; procedure Initialize_3440; procedure Initialize_3441; procedure Initialize_3442; procedure Initialize_3443; procedure Initialize_3444; procedure Initialize_3445; procedure Initialize_3446; procedure Initialize_3447; procedure Initialize_3448; procedure Initialize_3449; procedure Initialize_3450; procedure Initialize_3451; procedure Initialize_3452; procedure Initialize_3453; procedure Initialize_3454; procedure Initialize_3455; procedure Initialize_3456; procedure Initialize_3457; procedure Initialize_3458; procedure Initialize_3459; procedure Initialize_3460; procedure Initialize_3461; procedure Initialize_3462; procedure Initialize_3463; procedure Initialize_3464; procedure Initialize_3465; procedure Initialize_3466; procedure Initialize_3467; procedure Initialize_3468; procedure Initialize_3469; procedure Initialize_3470; procedure Initialize_3471; procedure Initialize_3472; procedure Initialize_3473; procedure Initialize_3474; procedure Initialize_3475; procedure Initialize_3476; procedure Initialize_3477; procedure Initialize_3478; procedure Initialize_3479; procedure Initialize_3480; procedure Initialize_3481; procedure Initialize_3482; procedure Initialize_3483; procedure Initialize_3484; procedure Initialize_3485; procedure Initialize_3486; procedure Initialize_3487; procedure Initialize_3488; procedure Initialize_3489; procedure Initialize_3490; procedure Initialize_3491; procedure Initialize_3492; procedure Initialize_3493; procedure Initialize_3494; procedure Initialize_3495; procedure Initialize_3496; procedure Initialize_3497; procedure Initialize_3498; procedure Initialize_3499; procedure Initialize_3500; procedure Initialize_3501; procedure Initialize_3502; procedure Initialize_3503; procedure Initialize_3504; procedure Initialize_3505; procedure Initialize_3506; procedure Initialize_3507; procedure Initialize_3508; procedure Initialize_3509; procedure Initialize_3510; procedure Initialize_3511; procedure Initialize_3512; procedure Initialize_3513; procedure Initialize_3514; procedure Initialize_3515; procedure Initialize_3516; procedure Initialize_3517; procedure Initialize_3518; procedure Initialize_3519; procedure Initialize_3520; procedure Initialize_3521; procedure Initialize_3522; procedure Initialize_3523; procedure Initialize_3524; procedure Initialize_3525; procedure Initialize_3526; procedure Initialize_3527; procedure Initialize_3528; procedure Initialize_3529; procedure Initialize_3530; procedure Initialize_3531; procedure Initialize_3532; procedure Initialize_3533; procedure Initialize_3534; procedure Initialize_3535; procedure Initialize_3536; procedure Initialize_3537; procedure Initialize_3538; procedure Initialize_3539; procedure Initialize_3540; procedure Initialize_3541; procedure Initialize_3542; procedure Initialize_3543; procedure Initialize_3544; procedure Initialize_3545; procedure Initialize_3546; procedure Initialize_3547; procedure Initialize_3548; procedure Initialize_3549; procedure Initialize_3550; procedure Initialize_3551; procedure Initialize_3552; procedure Initialize_3553; procedure Initialize_3554; procedure Initialize_3555; procedure Initialize_3556; procedure Initialize_3557; procedure Initialize_3558; procedure Initialize_3559; procedure Initialize_3560; procedure Initialize_3561; procedure Initialize_3562; procedure Initialize_3563; procedure Initialize_3564; procedure Initialize_3565; procedure Initialize_3566; procedure Initialize_3567; procedure Initialize_3568; procedure Initialize_3569; procedure Initialize_3570; procedure Initialize_3571; procedure Initialize_3572; procedure Initialize_3573; procedure Initialize_3574; procedure Initialize_3575; procedure Initialize_3576; procedure Initialize_3577; procedure Initialize_3578; procedure Initialize_3579; procedure Initialize_3580; procedure Initialize_3581; procedure Initialize_3582; procedure Initialize_3583; procedure Initialize_3584; procedure Initialize_3585; procedure Initialize_3586; procedure Initialize_3587; procedure Initialize_3588; procedure Initialize_3589; procedure Initialize_3590; procedure Initialize_3591; procedure Initialize_3592; procedure Initialize_3593; procedure Initialize_3594; procedure Initialize_3595; procedure Initialize_3596; procedure Initialize_3597; procedure Initialize_3598; procedure Initialize_3599; procedure Initialize_3600; procedure Initialize_3601; procedure Initialize_3602; procedure Initialize_3603; procedure Initialize_3604; procedure Initialize_3605; procedure Initialize_3606; procedure Initialize_3607; procedure Initialize_3608; procedure Initialize_3609; procedure Initialize_3610; procedure Initialize_3611; procedure Initialize_3612; procedure Initialize_3613; procedure Initialize_3614; procedure Initialize_3615; procedure Initialize_3616; procedure Initialize_3617; procedure Initialize_3618; procedure Initialize_3619; procedure Initialize_3620; procedure Initialize_3621; procedure Initialize_3622; procedure Initialize_3623; procedure Initialize_3624; procedure Initialize_3625; procedure Initialize_3626; procedure Initialize_3627; procedure Initialize_3628; procedure Initialize_3629; procedure Initialize_3630; procedure Initialize_3631; procedure Initialize_3632; procedure Initialize_3633; procedure Initialize_3634; procedure Initialize_3635; procedure Initialize_3636; procedure Initialize_3637; procedure Initialize_3638; procedure Initialize_3639; procedure Initialize_3640; procedure Initialize_3641; procedure Initialize_3642; procedure Initialize_3643; procedure Initialize_3644; procedure Initialize_3645; procedure Initialize_3646; procedure Initialize_3647; procedure Initialize_3648; procedure Initialize_3649; procedure Initialize_3650; procedure Initialize_3651; procedure Initialize_3652; procedure Initialize_3653; procedure Initialize_3654; procedure Initialize_3655; procedure Initialize_3656; procedure Initialize_3657; procedure Initialize_3658; procedure Initialize_3659; procedure Initialize_3660; procedure Initialize_3661; procedure Initialize_3662; procedure Initialize_3663; procedure Initialize_3664; procedure Initialize_3665; procedure Initialize_3666; procedure Initialize_3667; procedure Initialize_3668; procedure Initialize_3669; procedure Initialize_3670; procedure Initialize_3671; procedure Initialize_3672; procedure Initialize_3673; procedure Initialize_3674; procedure Initialize_3675; procedure Initialize_3676; procedure Initialize_3677; procedure Initialize_3678; procedure Initialize_3679; procedure Initialize_3680; procedure Initialize_3681; procedure Initialize_3682; procedure Initialize_3683; procedure Initialize_3684; procedure Initialize_3685; procedure Initialize_3686; procedure Initialize_3687; procedure Initialize_3688; procedure Initialize_3689; procedure Initialize_3690; procedure Initialize_3691; procedure Initialize_3692; procedure Initialize_3693; procedure Initialize_3694; procedure Initialize_3695; procedure Initialize_3696; procedure Initialize_3697; procedure Initialize_3698; procedure Initialize_3699; procedure Initialize_3700; procedure Initialize_3701; procedure Initialize_3702; procedure Initialize_3703; procedure Initialize_3704; procedure Initialize_3705; procedure Initialize_3706; procedure Initialize_3707; procedure Initialize_3708; procedure Initialize_3709; procedure Initialize_3710; procedure Initialize_3711; procedure Initialize_3712; procedure Initialize_3713; procedure Initialize_3714; procedure Initialize_3715; procedure Initialize_3716; procedure Initialize_3717; procedure Initialize_3718; procedure Initialize_3719; procedure Initialize_3720; procedure Initialize_3721; procedure Initialize_3722; procedure Initialize_3723; procedure Initialize_3724; procedure Initialize_3725; procedure Initialize_3726; procedure Initialize_3727; procedure Initialize_3728; procedure Initialize_3729; procedure Initialize_3730; procedure Initialize_3731; procedure Initialize_3732; procedure Initialize_3733; procedure Initialize_3734; procedure Initialize_3735; procedure Initialize_3736; procedure Initialize_3737; procedure Initialize_3738; procedure Initialize_3739; procedure Initialize_3740; procedure Initialize_3741; procedure Initialize_3742; procedure Initialize_3743; procedure Initialize_3744; procedure Initialize_3745; procedure Initialize_3746; procedure Initialize_3747; procedure Initialize_3748; procedure Initialize_3749; procedure Initialize_3750; procedure Initialize_3751; procedure Initialize_3752; procedure Initialize_3753; procedure Initialize_3754; procedure Initialize_3755; procedure Initialize_3756; procedure Initialize_3757; procedure Initialize_3758; procedure Initialize_3759; procedure Initialize_3760; procedure Initialize_3761; procedure Initialize_3762; procedure Initialize_3763; procedure Initialize_3764; procedure Initialize_3765; procedure Initialize_3766; procedure Initialize_3767; procedure Initialize_3768; procedure Initialize_3769; procedure Initialize_3770; procedure Initialize_3771; procedure Initialize_3772; procedure Initialize_3773; procedure Initialize_3774; procedure Initialize_3775; procedure Initialize_3776; procedure Initialize_3777; procedure Initialize_3778; procedure Initialize_3779; procedure Initialize_3780; procedure Initialize_3781; procedure Initialize_3782; procedure Initialize_3783; procedure Initialize_3784; procedure Initialize_3785; procedure Initialize_3786; procedure Initialize_3787; procedure Initialize_3788; procedure Initialize_3789; procedure Initialize_3790; procedure Initialize_3791; procedure Initialize_3792; procedure Initialize_3793; procedure Initialize_3794; procedure Initialize_3795; procedure Initialize_3796; procedure Initialize_3797; procedure Initialize_3798; procedure Initialize_3799; procedure Initialize_3800; procedure Initialize_3801; procedure Initialize_3802; procedure Initialize_3803; procedure Initialize_3804; procedure Initialize_3805; procedure Initialize_3806; procedure Initialize_3807; procedure Initialize_3808; procedure Initialize_3809; procedure Initialize_3810; procedure Initialize_3811; procedure Initialize_3812; procedure Initialize_3813; procedure Initialize_3814; procedure Initialize_3815; procedure Initialize_3816; procedure Initialize_3817; procedure Initialize_3818; procedure Initialize_3819; procedure Initialize_3820; procedure Initialize_3821; procedure Initialize_3822; procedure Initialize_3823; procedure Initialize_3824; procedure Initialize_3825; procedure Initialize_3826; procedure Initialize_3827; procedure Initialize_3828; procedure Initialize_3829; procedure Initialize_3830; procedure Initialize_3831; procedure Initialize_3832; procedure Initialize_3833; procedure Initialize_3834; procedure Initialize_3835; procedure Initialize_3836; procedure Initialize_3837; procedure Initialize_3838; procedure Initialize_3839; procedure Initialize_3840; procedure Initialize_3841; procedure Initialize_3842; procedure Initialize_3843; procedure Initialize_3844; procedure Initialize_3845; procedure Initialize_3846; procedure Initialize_3847; procedure Initialize_3848; procedure Initialize_3849; procedure Initialize_3850; procedure Initialize_3851; procedure Initialize_3852; procedure Initialize_3853; procedure Initialize_3854; procedure Initialize_3855; procedure Initialize_3856; procedure Initialize_3857; procedure Initialize_3858; procedure Initialize_3859; procedure Initialize_3860; procedure Initialize_3861; procedure Initialize_3862; procedure Initialize_3863; procedure Initialize_3864; procedure Initialize_3865; procedure Initialize_3866; procedure Initialize_3867; procedure Initialize_3868; procedure Initialize_3869; procedure Initialize_3870; procedure Initialize_3871; procedure Initialize_3872; procedure Initialize_3873; procedure Initialize_3874; procedure Initialize_3875; procedure Initialize_3876; procedure Initialize_3877; procedure Initialize_3878; procedure Initialize_3879; procedure Initialize_3880; procedure Initialize_3881; procedure Initialize_3882; procedure Initialize_3883; procedure Initialize_3884; procedure Initialize_3885; procedure Initialize_3886; procedure Initialize_3887; procedure Initialize_3888; procedure Initialize_3889; procedure Initialize_3890; procedure Initialize_3891; procedure Initialize_3892; procedure Initialize_3893; procedure Initialize_3894; procedure Initialize_3895; procedure Initialize_3896; procedure Initialize_3897; procedure Initialize_3898; procedure Initialize_3899; procedure Initialize_3900; procedure Initialize_3901; procedure Initialize_3902; procedure Initialize_3903; procedure Initialize_3904; procedure Initialize_3905; procedure Initialize_3906; procedure Initialize_3907; procedure Initialize_3908; procedure Initialize_3909; procedure Initialize_3910; procedure Initialize_3911; procedure Initialize_3912; procedure Initialize_3913; procedure Initialize_3914; procedure Initialize_3915; procedure Initialize_3916; procedure Initialize_3917; procedure Initialize_3918; procedure Initialize_3919; procedure Initialize_3920; procedure Initialize_3921; procedure Initialize_3922; procedure Initialize_3923; procedure Initialize_3924; procedure Initialize_3925; procedure Initialize_3926; procedure Initialize_3927; procedure Initialize_3928; procedure Initialize_3929; procedure Initialize_3930; procedure Initialize_3931; procedure Initialize_3932; procedure Initialize_3933; procedure Initialize_3934; procedure Initialize_3935; procedure Initialize_3936; procedure Initialize_3937; procedure Initialize_3938; procedure Initialize_3939; procedure Initialize_3940; procedure Initialize_3941; procedure Initialize_3942; procedure Initialize_3943; procedure Initialize_3944; procedure Initialize_3945; procedure Initialize_3946; procedure Initialize_3947; procedure Initialize_3948; procedure Initialize_3949; procedure Initialize_3950; procedure Initialize_3951; procedure Initialize_3952; procedure Initialize_3953; procedure Initialize_3954; procedure Initialize_3955; procedure Initialize_3956; procedure Initialize_3957; procedure Initialize_3958; procedure Initialize_3959; procedure Initialize_3960; procedure Initialize_3961; procedure Initialize_3962; procedure Initialize_3963; procedure Initialize_3964; procedure Initialize_3965; procedure Initialize_3966; procedure Initialize_3967; procedure Initialize_3968; procedure Initialize_3969; procedure Initialize_3970; procedure Initialize_3971; procedure Initialize_3972; procedure Initialize_3973; procedure Initialize_3974; procedure Initialize_3975; procedure Initialize_3976; procedure Initialize_3977; procedure Initialize_3978; procedure Initialize_3979; procedure Initialize_3980; procedure Initialize_3981; procedure Initialize_3982; procedure Initialize_3983; procedure Initialize_3984; procedure Initialize_3985; procedure Initialize_3986; procedure Initialize_3987; procedure Initialize_3988; procedure Initialize_3989; procedure Initialize_3990; procedure Initialize_3991; procedure Initialize_3992; procedure Initialize_3993; procedure Initialize_3994; procedure Initialize_3995; procedure Initialize_3996; procedure Initialize_3997; procedure Initialize_3998; procedure Initialize_3999; procedure Initialize_4000; procedure Initialize_4001; procedure Initialize_4002; procedure Initialize_4003; procedure Initialize_4004; procedure Initialize_4005; procedure Initialize_4006; procedure Initialize_4007; procedure Initialize_4008; procedure Initialize_4009; procedure Initialize_4010; procedure Initialize_4011; procedure Initialize_4012; procedure Initialize_4013; procedure Initialize_4014; procedure Initialize_4015; procedure Initialize_4016; procedure Initialize_4017; procedure Initialize_4018; procedure Initialize_4019; procedure Initialize_4020; procedure Initialize_4021; procedure Initialize_4022; procedure Initialize_4023; procedure Initialize_4024; procedure Initialize_4025; procedure Initialize_4026; procedure Initialize_4027; procedure Initialize_4028; procedure Initialize_4029; procedure Initialize_4030; procedure Initialize_4031; procedure Initialize_4032; procedure Initialize_4033; procedure Initialize_4034; procedure Initialize_4035; procedure Initialize_4036; procedure Initialize_4037; procedure Initialize_4038; procedure Initialize_4039; procedure Initialize_4040; procedure Initialize_4041; procedure Initialize_4042; procedure Initialize_4043; procedure Initialize_4044; procedure Initialize_4045; procedure Initialize_4046; procedure Initialize_4047; procedure Initialize_4048; procedure Initialize_4049; procedure Initialize_4050; procedure Initialize_4051; procedure Initialize_4052; procedure Initialize_4053; procedure Initialize_4054; procedure Initialize_4055; procedure Initialize_4056; procedure Initialize_4057; procedure Initialize_4058; procedure Initialize_4059; procedure Initialize_4060; procedure Initialize_4061; procedure Initialize_4062; procedure Initialize_4063; procedure Initialize_4064; procedure Initialize_4065; procedure Initialize_4066; procedure Initialize_4067; procedure Initialize_4068; procedure Initialize_4069; procedure Initialize_4070; procedure Initialize_4071; procedure Initialize_4072; procedure Initialize_4073; procedure Initialize_4074; procedure Initialize_4075; procedure Initialize_4076; procedure Initialize_4077; procedure Initialize_4078; procedure Initialize_4079; procedure Initialize_4080; procedure Initialize_4081; procedure Initialize_4082; procedure Initialize_4083; procedure Initialize_4084; procedure Initialize_4085; procedure Initialize_4086; procedure Initialize_4087; procedure Initialize_4088; procedure Initialize_4089; procedure Initialize_4090; procedure Initialize_4091; procedure Initialize_4092; procedure Initialize_4093; procedure Initialize_4094; procedure Initialize_4095; procedure Initialize_4096; procedure Initialize_4097; procedure Initialize_4098; procedure Initialize_4099; procedure Initialize_4100; procedure Initialize_4101; procedure Initialize_4102; procedure Initialize_4103; procedure Initialize_4104; procedure Initialize_4105; procedure Initialize_4106; procedure Initialize_4107; procedure Initialize_4108; procedure Initialize_4109; procedure Initialize_4110; procedure Initialize_4111; procedure Initialize_4112; procedure Initialize_4113; procedure Initialize_4114; procedure Initialize_4115; procedure Initialize_4116; procedure Initialize_4117; procedure Initialize_4118; procedure Initialize_4119; procedure Initialize_4120; procedure Initialize_4121; procedure Initialize_4122; procedure Initialize_4123; procedure Initialize_4124; procedure Initialize_4125; procedure Initialize_4126; procedure Initialize_4127; procedure Initialize_4128; procedure Initialize_4129; procedure Initialize_4130; procedure Initialize_4131; procedure Initialize_4132; procedure Initialize_4133; procedure Initialize_4134; procedure Initialize_4135; procedure Initialize_4136; procedure Initialize_4137; procedure Initialize_4138; procedure Initialize_4139; procedure Initialize_4140; procedure Initialize_4141; procedure Initialize_4142; procedure Initialize_4143; procedure Initialize_4144; procedure Initialize_4145; procedure Initialize_4146; procedure Initialize_4147; procedure Initialize_4148; procedure Initialize_4149; procedure Initialize_4150; procedure Initialize_4151; procedure Initialize_4152; procedure Initialize_4153; procedure Initialize_4154; procedure Initialize_4155; procedure Initialize_4156; procedure Initialize_4157; procedure Initialize_4158; procedure Initialize_4159; procedure Initialize_4160; procedure Initialize_4161; procedure Initialize_4162; procedure Initialize_4163; procedure Initialize_4164; procedure Initialize_4165; procedure Initialize_4166; procedure Initialize_4167; procedure Initialize_4168; procedure Initialize_4169; procedure Initialize_4170; procedure Initialize_4171; procedure Initialize_4172; procedure Initialize_4173; procedure Initialize_4174; procedure Initialize_4175; procedure Initialize_4176; procedure Initialize_4177; procedure Initialize_4178; procedure Initialize_4179; procedure Initialize_4180; procedure Initialize_4181; procedure Initialize_4182; procedure Initialize_4183; procedure Initialize_4184; procedure Initialize_4185; procedure Initialize_4186; procedure Initialize_4187; procedure Initialize_4188; procedure Initialize_4189; procedure Initialize_4190; procedure Initialize_4191; procedure Initialize_4192; procedure Initialize_4193; procedure Initialize_4194; procedure Initialize_4195; procedure Initialize_4196; procedure Initialize_4197; procedure Initialize_4198; procedure Initialize_4199; procedure Initialize_4200; procedure Initialize_4201; procedure Initialize_4202; procedure Initialize_4203; procedure Initialize_4204; procedure Initialize_4205; procedure Initialize_4206; procedure Initialize_4207; procedure Initialize_4208; procedure Initialize_4209; procedure Initialize_4210; procedure Initialize_4211; procedure Initialize_4212; procedure Initialize_4213; procedure Initialize_4214; procedure Initialize_4215; procedure Initialize_4216; procedure Initialize_4217; procedure Initialize_4218; procedure Initialize_4219; procedure Initialize_4220; procedure Initialize_4221; procedure Initialize_4222; procedure Initialize_4223; procedure Initialize_4224; procedure Initialize_4225; procedure Initialize_4226; procedure Initialize_4227; procedure Initialize_4228; procedure Initialize_4229; procedure Initialize_4230; procedure Initialize_4231; procedure Initialize_4232; procedure Initialize_4233; procedure Initialize_4234; procedure Initialize_4235; procedure Initialize_4236; procedure Initialize_4237; procedure Initialize_4238; procedure Initialize_4239; procedure Initialize_4240; procedure Initialize_4241; procedure Initialize_4242; procedure Initialize_4243; procedure Initialize_4244; procedure Initialize_4245; procedure Initialize_4246; procedure Initialize_4247; procedure Initialize_4248; procedure Initialize_4249; procedure Initialize_4250; procedure Initialize_4251; procedure Initialize_4252; procedure Initialize_4253; procedure Initialize_4254; procedure Initialize_4255; procedure Initialize_4256; procedure Initialize_4257; procedure Initialize_4258; procedure Initialize_4259; procedure Initialize_4260; procedure Initialize_4261; procedure Initialize_4262; procedure Initialize_4263; procedure Initialize_4264; procedure Initialize_4265; procedure Initialize_4266; procedure Initialize_4267; procedure Initialize_4268; procedure Initialize_4269; procedure Initialize_4270; procedure Initialize_4271; procedure Initialize_4272; procedure Initialize_4273; procedure Initialize_4274; procedure Initialize_4275; procedure Initialize_4276; procedure Initialize_4277; procedure Initialize_4278; procedure Initialize_4279; procedure Initialize_4280; procedure Initialize_4281; procedure Initialize_4282; procedure Initialize_4283; procedure Initialize_4284; procedure Initialize_4285; procedure Initialize_4286; procedure Initialize_4287; procedure Initialize_4288; procedure Initialize_4289; procedure Initialize_4290; procedure Initialize_4291; procedure Initialize_4292; procedure Initialize_4293; procedure Initialize_4294; procedure Initialize_4295; procedure Initialize_4296; procedure Initialize_4297; procedure Initialize_4298; procedure Initialize_4299; procedure Initialize_4300; procedure Initialize_4301; procedure Initialize_4302; procedure Initialize_4303; procedure Initialize_4304; procedure Initialize_4305; procedure Initialize_4306; procedure Initialize_4307; procedure Initialize_4308; procedure Initialize_4309; procedure Initialize_4310; procedure Initialize_4311; procedure Initialize_4312; procedure Initialize_4313; procedure Initialize_4314; procedure Initialize_4315; procedure Initialize_4316; procedure Initialize_4317; procedure Initialize_4318; procedure Initialize_4319; procedure Initialize_4320; procedure Initialize_4321; procedure Initialize_4322; procedure Initialize_4323; procedure Initialize_4324; procedure Initialize_4325; procedure Initialize_4326; procedure Initialize_4327; procedure Initialize_4328; procedure Initialize_4329; procedure Initialize_4330; procedure Initialize_4331; procedure Initialize_4332; procedure Initialize_4333; procedure Initialize_4334; procedure Initialize_4335; procedure Initialize_4336; procedure Initialize_4337; procedure Initialize_4338; procedure Initialize_4339; procedure Initialize_4340; procedure Initialize_4341; procedure Initialize_4342; procedure Initialize_4343; procedure Initialize_4344; procedure Initialize_4345; procedure Initialize_4346; procedure Initialize_4347; procedure Initialize_4348; procedure Initialize_4349; procedure Initialize_4350; procedure Initialize_4351; procedure Initialize_4352; procedure Initialize_4353; procedure Initialize_4354; procedure Initialize_4355; procedure Initialize_4356; procedure Initialize_4357; procedure Initialize_4358; procedure Initialize_4359; procedure Initialize_4360; procedure Initialize_4361; procedure Initialize_4362; procedure Initialize_4363; procedure Initialize_4364; procedure Initialize_4365; procedure Initialize_4366; procedure Initialize_4367; procedure Initialize_4368; procedure Initialize_4369; procedure Initialize_4370; procedure Initialize_4371; procedure Initialize_4372; procedure Initialize_4373; procedure Initialize_4374; procedure Initialize_4375; procedure Initialize_4376; procedure Initialize_4377; procedure Initialize_4378; procedure Initialize_4379; procedure Initialize_4380; procedure Initialize_4381; procedure Initialize_4382; procedure Initialize_4383; procedure Initialize_4384; procedure Initialize_4385; procedure Initialize_4386; procedure Initialize_4387; procedure Initialize_4388; procedure Initialize_4389; procedure Initialize_4390; procedure Initialize_4391; procedure Initialize_4392; procedure Initialize_4393; procedure Initialize_4394; procedure Initialize_4395; procedure Initialize_4396; procedure Initialize_4397; procedure Initialize_4398; procedure Initialize_4399; procedure Initialize_4400; procedure Initialize_4401; procedure Initialize_4402; procedure Initialize_4403; procedure Initialize_4404; procedure Initialize_4405; procedure Initialize_4406; procedure Initialize_4407; procedure Initialize_4408; procedure Initialize_4409; procedure Initialize_4410; procedure Initialize_4411; procedure Initialize_4412; procedure Initialize_4413; procedure Initialize_4414; procedure Initialize_4415; procedure Initialize_4416; procedure Initialize_4417; procedure Initialize_4418; procedure Initialize_4419; procedure Initialize_4420; procedure Initialize_4421; procedure Initialize_4422; procedure Initialize_4423; procedure Initialize_4424; procedure Initialize_4425; procedure Initialize_4426; procedure Initialize_4427; procedure Initialize_4428; procedure Initialize_4429; procedure Initialize_4430; procedure Initialize_4431; procedure Initialize_4432; procedure Initialize_4433; procedure Initialize_4434; procedure Initialize_4435; procedure Initialize_4436; procedure Initialize_4437; procedure Initialize_4438; procedure Initialize_4439; procedure Initialize_4440; procedure Initialize_4441; procedure Initialize_4442; procedure Initialize_4443; procedure Initialize_4444; procedure Initialize_4445; procedure Initialize_4446; procedure Initialize_4447; procedure Initialize_4448; procedure Initialize_4449; procedure Initialize_4450; procedure Initialize_4451; procedure Initialize_4452; procedure Initialize_4453; procedure Initialize_4454; procedure Initialize_4455; procedure Initialize_4456; procedure Initialize_4457; procedure Initialize_4458; procedure Initialize_4459; procedure Initialize_4460; procedure Initialize_4461; procedure Initialize_4462; procedure Initialize_4463; procedure Initialize_4464; procedure Initialize_4465; procedure Initialize_4466; procedure Initialize_4467; procedure Initialize_4468; procedure Initialize_4469; procedure Initialize_4470; procedure Initialize_4471; procedure Initialize_4472; procedure Initialize_4473; procedure Initialize_4474; procedure Initialize_4475; procedure Initialize_4476; procedure Initialize_4477; procedure Initialize_4478; procedure Initialize_4479; procedure Initialize_4480; procedure Initialize_4481; procedure Initialize_4482; procedure Initialize_4483; procedure Initialize_4484; procedure Initialize_4485; procedure Initialize_4486; procedure Initialize_4487; procedure Initialize_4488; procedure Initialize_4489; procedure Initialize_4490; procedure Initialize_4491; procedure Initialize_4492; procedure Initialize_4493; procedure Initialize_4494; procedure Initialize_4495; procedure Initialize_4496; procedure Initialize_4497; procedure Initialize_4498; procedure Initialize_4499; procedure Initialize_4500; procedure Initialize_4501; procedure Initialize_4502; procedure Initialize_4503; procedure Initialize_4504; procedure Initialize_4505; procedure Initialize_4506; procedure Initialize_4507; procedure Initialize_4508; procedure Initialize_4509; procedure Initialize_4510; procedure Initialize_4511; procedure Initialize_4512; procedure Initialize_4513; procedure Initialize_4514; procedure Initialize_4515; procedure Initialize_4516; procedure Initialize_4517; procedure Initialize_4518; procedure Initialize_4519; procedure Initialize_4520; procedure Initialize_4521; procedure Initialize_4522; procedure Initialize_4523; procedure Initialize_4524; procedure Initialize_4525; procedure Initialize_4526; procedure Initialize_4527; procedure Initialize_4528; procedure Initialize_4529; procedure Initialize_4530; procedure Initialize_4531; procedure Initialize_4532; procedure Initialize_4533; procedure Initialize_4534; procedure Initialize_4535; procedure Initialize_4536; procedure Initialize_4537; procedure Initialize_4538; procedure Initialize_4539; procedure Initialize_4540; procedure Initialize_4541; procedure Initialize_4542; procedure Initialize_4543; procedure Initialize_4544; procedure Initialize_4545; procedure Initialize_4546; procedure Initialize_4547; procedure Initialize_4548; procedure Initialize_4549; procedure Initialize_4550; procedure Initialize_4551; procedure Initialize_4552; procedure Initialize_4553; procedure Initialize_4554; procedure Initialize_4555; procedure Initialize_4556; procedure Initialize_4557; procedure Initialize_4558; procedure Initialize_4559; procedure Initialize_4560; procedure Initialize_4561; procedure Initialize_4562; procedure Initialize_4563; procedure Initialize_4564; procedure Initialize_4565; procedure Initialize_4566; procedure Initialize_4567; procedure Initialize_4568; procedure Initialize_4569; procedure Initialize_4570; procedure Initialize_4571; procedure Initialize_4572; procedure Initialize_4573; procedure Initialize_4574; procedure Initialize_4575; procedure Initialize_4576; procedure Initialize_4577; procedure Initialize_4578; procedure Initialize_4579; procedure Initialize_4580; procedure Initialize_4581; procedure Initialize_4582; procedure Initialize_4583; procedure Initialize_4584; procedure Initialize_4585; procedure Initialize_4586; procedure Initialize_4587; procedure Initialize_4588; procedure Initialize_4589; procedure Initialize_4590; procedure Initialize_4591; procedure Initialize_4592; procedure Initialize_4593; procedure Initialize_4594; procedure Initialize_4595; procedure Initialize_4596; procedure Initialize_4597; procedure Initialize_4598; procedure Initialize_4599; procedure Initialize_4600; procedure Initialize_4601; procedure Initialize_4602; procedure Initialize_4603; procedure Initialize_4604; procedure Initialize_4605; procedure Initialize_4606; procedure Initialize_4607; procedure Initialize_4608; procedure Initialize_4609; procedure Initialize_4610; procedure Initialize_4611; procedure Initialize_4612; procedure Initialize_4613; procedure Initialize_4614; procedure Initialize_4615; procedure Initialize_4616; procedure Initialize_4617; procedure Initialize_4618; procedure Initialize_4619; procedure Initialize_4620; procedure Initialize_4621; procedure Initialize_4622; procedure Initialize_4623; procedure Initialize_4624; procedure Initialize_4625; procedure Initialize_4626; procedure Initialize_4627; procedure Initialize_4628; procedure Initialize_4629; procedure Initialize_4630; procedure Initialize_4631; procedure Initialize_4632; procedure Initialize_4633; procedure Initialize_4634; procedure Initialize_4635; procedure Initialize_4636; procedure Initialize_4637; procedure Initialize_4638; procedure Initialize_4639; procedure Initialize_4640; procedure Initialize_4641; procedure Initialize_4642; procedure Initialize_4643; procedure Initialize_4644; procedure Initialize_4645; procedure Initialize_4646; procedure Initialize_4647; procedure Initialize_4648; procedure Initialize_4649; procedure Initialize_4650; procedure Initialize_4651; procedure Initialize_4652; procedure Initialize_4653; procedure Initialize_4654; procedure Initialize_4655; procedure Initialize_4656; procedure Initialize_4657; procedure Initialize_4658; procedure Initialize_4659; procedure Initialize_4660; procedure Initialize_4661; procedure Initialize_4662; procedure Initialize_4663; procedure Initialize_4664; procedure Initialize_4665; procedure Initialize_4666; procedure Initialize_4667; procedure Initialize_4668; procedure Initialize_4669; procedure Initialize_4670; procedure Initialize_4671; procedure Initialize_4672; procedure Initialize_4673; procedure Initialize_4674; procedure Initialize_4675; procedure Initialize_4676; procedure Initialize_4677; procedure Initialize_4678; procedure Initialize_4679; procedure Initialize_4680; procedure Initialize_4681; procedure Initialize_4682; procedure Initialize_4683; procedure Initialize_4684; procedure Initialize_4685; procedure Initialize_4686; procedure Initialize_4687; procedure Initialize_4688; procedure Initialize_4689; procedure Initialize_4690; procedure Initialize_4691; procedure Initialize_4692; procedure Initialize_4693; procedure Initialize_4694; procedure Initialize_4695; procedure Initialize_4696; procedure Initialize_4697; procedure Initialize_4698; procedure Initialize_4699; procedure Initialize_4700; procedure Initialize_4701; procedure Initialize_4702; procedure Initialize_4703; procedure Initialize_4704; procedure Initialize_4705; procedure Initialize_4706; procedure Initialize_4707; procedure Initialize_4708; procedure Initialize_4709; procedure Initialize_4710; procedure Initialize_4711; procedure Initialize_4712; procedure Initialize_4713; procedure Initialize_4714; procedure Initialize_4715; procedure Initialize_4716; procedure Initialize_4717; procedure Initialize_4718; procedure Initialize_4719; procedure Initialize_4720; procedure Initialize_4721; procedure Initialize_4722; procedure Initialize_4723; procedure Initialize_4724; procedure Initialize_4725; procedure Initialize_4726; procedure Initialize_4727; procedure Initialize_4728; procedure Initialize_4729; procedure Initialize_4730; procedure Initialize_4731; procedure Initialize_4732; procedure Initialize_4733; procedure Initialize_4734; procedure Initialize_4735; procedure Initialize_4736; procedure Initialize_4737; procedure Initialize_4738; procedure Initialize_4739; procedure Initialize_4740; procedure Initialize_4741; procedure Initialize_4742; procedure Initialize_4743; procedure Initialize_4744; procedure Initialize_4745; procedure Initialize_4746; procedure Initialize_4747; procedure Initialize_4748; procedure Initialize_4749; procedure Initialize_4750; procedure Initialize_4751; procedure Initialize_4752; procedure Initialize_4753; procedure Initialize_4754; procedure Initialize_4755; procedure Initialize_4756; procedure Initialize_4757; procedure Initialize_4758; procedure Initialize_4759; procedure Initialize_4760; procedure Initialize_4761; procedure Initialize_4762; procedure Initialize_4763; procedure Initialize_4764; procedure Initialize_4765; procedure Initialize_4766; procedure Initialize_4767; procedure Initialize_4768; procedure Initialize_4769; procedure Initialize_4770; procedure Initialize_4771; procedure Initialize_4772; procedure Initialize_4773; procedure Initialize_4774; procedure Initialize_4775; procedure Initialize_4776; procedure Initialize_4777; procedure Initialize_4778; procedure Initialize_4779; procedure Initialize_4780; procedure Initialize_4781; procedure Initialize_4782; procedure Initialize_4783; procedure Initialize_4784; procedure Initialize_4785; procedure Initialize_4786; procedure Initialize_4787; procedure Initialize_4788; procedure Initialize_4789; procedure Initialize_4790; procedure Initialize_4791; procedure Initialize_4792; procedure Initialize_4793; procedure Initialize_4794; procedure Initialize_4795; procedure Initialize_4796; procedure Initialize_4797; procedure Initialize_4798; procedure Initialize_4799; procedure Initialize_4800; procedure Initialize_4801; procedure Initialize_4802; procedure Initialize_4803; procedure Initialize_4804; procedure Initialize_4805; procedure Initialize_4806; procedure Initialize_4807; procedure Initialize_4808; procedure Initialize_4809; procedure Initialize_4810; procedure Initialize_4811; procedure Initialize_4812; procedure Initialize_4813; procedure Initialize_4814; procedure Initialize_4815; procedure Initialize_4816; procedure Initialize_4817; procedure Initialize_4818; procedure Initialize_4819; procedure Initialize_4820; procedure Initialize_4821; procedure Initialize_4822; procedure Initialize_4823; procedure Initialize_4824; procedure Initialize_4825; procedure Initialize_4826; procedure Initialize_4827; procedure Initialize_4828; procedure Initialize_4829; end AMF.Internals.Tables.UML_Metamodel.Links;
with Interfaces; use Interfaces; package avtas.lmcp.types is -- C/C++ compatible integer types type UInt16_t is new Interfaces.Unsigned_16; type UInt32_t is new Interfaces.Unsigned_32; type Int16_t is new Interfaces.Integer_16; type Int32_t is new Interfaces.Integer_32; type Int64_t is new Interfaces.Integer_64; type Float_t is new Interfaces.IEEE_Float_32; type Double_t is new Interfaces.IEEE_Float_64; end avtas.lmcp.types;
with Ada.Text_IO; use Ada.Text_IO; package body Important_Dates with SPARK_Mode => On is function "=" (L, R : Date_T) return Boolean is (L.Year = R.Year and L.Month = R.Month and L.Day = R.Day); function ">=" (L, R : Date_T) return Boolean is (L.Year > R.Year or else (L.Year = R.Year and then (L.Month > R.Month or else (L.Month = R.Month and then L.Day >= R.Day)))); function ">=" (L, R : Event_T) return Boolean is (L.Date >= R.Date); --------------- -- Add_Event -- --------------- procedure Add_Event (Calendar : in out Calendar_T; Description : String; Date : Date_T) is Event : Event_T := (To_Unbounded_String (Description), Date); First : constant Index_T := Calendar.List'First; Last : constant Integer := First + Calendar.In_Use - 1; begin if Calendar.In_Use = 0 then Calendar.List (First) := Event; else declare Added : Boolean := False; begin for K in First .. Last loop if Calendar.List (K) >= Event then Calendar.List (K + 1 .. Last + 1) := Calendar.List (K .. Last); pragma Assert (K = First or else not (Calendar.List (K - 1) >= Event)); pragma Assert (K = First or else Event >= Calendar.List (K - 1)); pragma Assert (Calendar.List (K + 1) >= Event); Calendar.List (K) := Event; Added := True; pragma Assert (for all J in First .. Last + 1 => J = First or else Calendar.List (J) >= Calendar.List (J - 1)); exit; end if; pragma Loop_Invariant (for all J in First .. K => not (Calendar.List (J) >= Event)); end loop; if not Added then pragma Assert (Event >= Calendar.List (Last)); Calendar.List (Last + 1) := Event; pragma Assert (for all J in First .. Last + 1 => J = First or else Calendar.List (J) >= Calendar.List (J - 1)); end if; end; end if; Calendar.In_Use := Calendar.In_Use + 1; end Add_Event; ------------------ -- Remove_Event -- ------------------ procedure Remove_Event (Calendar : in out Calendar_T; Description : String; Date : Date_T) is Event : Event_T := (To_Unbounded_String (Description), Date); First : constant Index_T := Calendar.List'First; Last : constant Integer := First + Calendar.In_Use - 1; begin for K in First .. Last loop if Calendar.List (K) = Event then pragma Assert (K = First or else K = Last or else Calendar.List (K + 1) >= Calendar.List (K - 1)); Calendar.List (K .. Last - 1) := Calendar.List (K + 1 .. Last); pragma Assert (for all J in First .. Last - 1 => J = First or else Calendar.List (J) >= Calendar.List (J - 1)); Calendar.In_Use := Calendar.In_Use - 1; exit; end if; end loop; end Remove_Event; ------------------ -- Print_Events -- ------------------ procedure Print_Events (Calendar : Calendar_T; Number_Of_Events : Positive; Date : Date_T) is First : constant Index_T := Calendar.List'First; Last : constant Integer := First + Calendar.In_Use - 1; begin Outer_Loop : for K in First .. Last loop if Calendar.List (K).Date >= Date then for J in K .. Last loop exit when J - K + 1 > Number_Of_Events; Put (Calendar.List (J).Date.Year'Image & "-" & Calendar.List (J).Date.Month'Image & "-" & Calendar.List (J).Date.Day'Image); Set_Col (15); Put_Line (To_String (Calendar.List (J).Description)); end loop; exit Outer_Loop; end if; end loop Outer_Loop; end Print_Events; end Important_Dates;
------------------------------------------------------------------------------ -- File : Game_control.ads -- Description : Command set for games, based on GLUT -- Copyright (c) Gautier de Montmollin/Rod Kay 2007 ------------------------------------------------------------------------------ -- with GLOBE_3D; -- with GL; -- with Game_control; package GLUT.Devices is procedure Initialize; -- -- Sets up the GLUT mouse and keybaord devices. -- Keyboard -- type Key_set is array (Character) of Boolean; type Modifier_set is array (GLUT.Active_Shift .. GLUT.Active_Alt) of Boolean; type Special_set is array (1 .. 200) of Boolean; type Special_key_set is array (1 .. 128) of Boolean; type Keyboard is record normal_set : Key_set := (others => False); normal_set_mem : Key_set := (others => False); modif_set : Devices.Modifier_set := (others => False); special_set : Devices.Special_set := (others => False); special_set_mem : Devices.Special_key_set := (others => False); end record; type p_Keyboard is access all Keyboard; default_Keyboard : aliased Keyboard; function Strike_once (c : Character; kb : access Keyboard := default_Keyboard'Access) return Boolean; function Strike_once (special : Integer; kb : access Keyboard := default_Keyboard'Access) return Boolean; -- Mouse -- type mouse_button_Set is array (GLUT.LEFT_BUTTON .. GLUT.RIGHT_BUTTON) of Boolean; type Mouse is record oldx, oldy, mx, my : Integer := 0; button_state : mouse_button_Set := (others => False); end record; type p_Mouse is access all Mouse; default_Mouse : aliased Mouse; end GLUT.Devices;
with Ada.Numerics.Discrete_Random; with Ada.Text_IO; procedure Minesweeper is package IO renames Ada.Text_IO; package Nat_IO is new IO.Integer_IO (Natural); package Nat_RNG is new Ada.Numerics.Discrete_Random (Natural); type Stuff is (Empty, Mine); type Field is record Contents : Stuff := Empty; Opened : Boolean := False; Marked : Boolean := False; end record; type Grid is array (Positive range <>, Positive range <>) of Field; -- counts how many mines are in the surrounding fields function Mines_Nearby (Item : Grid; X, Y : Positive) return Natural is Result : Natural := 0; begin -- left of X:Y if X > Item'First (1) then -- above X-1:Y if Y > Item'First (2) then if Item (X - 1, Y - 1).Contents = Mine then Result := Result + 1; end if; end if; -- X-1:Y if Item (X - 1, Y).Contents = Mine then Result := Result + 1; end if; -- below X-1:Y if Y < Item'Last (2) then if Item (X - 1, Y + 1).Contents = Mine then Result := Result + 1; end if; end if; end if; -- above of X:Y if Y > Item'First (2) then if Item (X, Y - 1).Contents = Mine then Result := Result + 1; end if; end if; -- below of X:Y if Y < Item'Last (2) then if Item (X, Y + 1).Contents = Mine then Result := Result + 1; end if; end if; -- right of X:Y if X < Item'Last (1) then -- above X+1:Y if Y > Item'First (2) then if Item (X + 1, Y - 1).Contents = Mine then Result := Result + 1; end if; end if; -- X+1:Y if Item (X + 1, Y).Contents = Mine then Result := Result + 1; end if; -- below X+1:Y if Y < Item'Last (2) then if Item (X + 1, Y + 1).Contents = Mine then Result := Result + 1; end if; end if; end if; return Result; end Mines_Nearby; -- outputs the grid procedure Put (Item : Grid) is Mines : Natural := 0; begin IO.Put (" "); for X in Item'Range (1) loop Nat_IO.Put (Item => X, Width => 3); end loop; IO.New_Line; IO.Put (" +"); for X in Item'Range (1) loop IO.Put ("---"); end loop; IO.Put ('+'); IO.New_Line; for Y in Item'Range (2) loop Nat_IO.Put (Item => Y, Width => 3); IO.Put ('|'); for X in Item'Range (1) loop if Item (X, Y).Opened then if Item (X, Y).Contents = Empty then if Item (X, Y).Marked then IO.Put (" - "); else Mines := Mines_Nearby (Item, X, Y); if Mines > 0 then Nat_IO.Put (Item => Mines, Width => 2); IO.Put (' '); else IO.Put (" "); end if; end if; else if Item (X, Y).Marked then IO.Put (" + "); else IO.Put (" X "); end if; end if; elsif Item (X, Y).Marked then IO.Put (" ? "); else IO.Put (" . "); end if; end loop; IO.Put ('|'); IO.New_Line; end loop; IO.Put (" +"); for X in Item'Range (1) loop IO.Put ("---"); end loop; IO.Put ('+'); IO.New_Line; end Put; -- marks a field as possible bomb procedure Mark (Item : in out Grid; X, Y : in Positive) is begin if Item (X, Y).Opened then IO.Put_Line ("Field already open!"); else Item (X, Y).Marked := not Item (X, Y).Marked; end if; end Mark; -- clears a field and it's neighbours, if they don't have mines procedure Clear (Item : in out Grid; X, Y : in Positive; Killed : out Boolean) is -- clears the neighbours, if they don't have mines procedure Clear_Neighbours (The_X, The_Y : Positive) is begin -- mark current field opened Item (The_X, The_Y).Opened := True; -- only proceed if neighbours don't have mines if Mines_Nearby (Item, The_X, The_Y) = 0 then -- left of X:Y if The_X > Item'First (1) then -- above X-1:Y if The_Y > Item'First (2) then if not Item (The_X - 1, The_Y - 1).Opened and not Item (The_X - 1, The_Y - 1).Marked then Clear_Neighbours (The_X - 1, The_Y - 1); end if; end if; -- X-1:Y if not Item (The_X - 1, The_Y).Opened and not Item (The_X - 1, The_Y).Marked then Clear_Neighbours (The_X - 1, The_Y); end if; -- below X-1:Y if The_Y < Item'Last (2) then if not Item (The_X - 1, The_Y + 1).Opened and not Item (The_X - 1, The_Y + 1).Marked then Clear_Neighbours (The_X - 1, The_Y + 1); end if; end if; end if; -- above X:Y if The_Y > Item'First (2) then if not Item (The_X, The_Y - 1).Opened and not Item (The_X, The_Y - 1).Marked then Clear_Neighbours (The_X, The_Y - 1); end if; end if; -- below X:Y if The_Y < Item'Last (2) then if not Item (The_X, The_Y + 1).Opened and not Item (The_X, The_Y + 1).Marked then Clear_Neighbours (The_X, The_Y + 1); end if; end if; -- right of X:Y if The_X < Item'Last (1) then -- above X+1:Y if The_Y > Item'First (2) then if not Item (The_X + 1, The_Y - 1).Opened and not Item (The_X + 1, The_Y - 1).Marked then Clear_Neighbours (The_X + 1, The_Y - 1); end if; end if; -- X+1:Y if not Item (The_X + 1, The_Y).Opened and not Item (The_X + 1, The_Y).Marked then Clear_Neighbours (The_X + 1, The_Y); end if; -- below X+1:Y if The_Y < Item'Last (2) then if not Item (The_X + 1, The_Y + 1).Opened and not Item (The_X + 1, The_Y + 1).Marked then Clear_Neighbours (The_X + 1, The_Y + 1); end if; end if; end if; end if; end Clear_Neighbours; begin Killed := False; -- only clear closed and unmarked fields if Item (X, Y).Opened then IO.Put_Line ("Field already open!"); elsif Item (X, Y).Marked then IO.Put_Line ("Field already marked!"); else Killed := Item (X, Y).Contents = Mine; -- game over if killed, no need to clear if not Killed then Clear_Neighbours (X, Y); end if; end if; end Clear; -- marks all fields as open procedure Open_All (Item : in out Grid) is begin for X in Item'Range (1) loop for Y in Item'Range (2) loop Item (X, Y).Opened := True; end loop; end loop; end Open_All; -- counts the number of marks function Count_Marks (Item : Grid) return Natural is Result : Natural := 0; begin for X in Item'Range (1) loop for Y in Item'Range (2) loop if Item (X, Y).Marked then Result := Result + 1; end if; end loop; end loop; return Result; end Count_Marks; -- read and validate user input procedure Get_Coordinates (Max_X, Max_Y : Positive; X, Y : out Positive; Valid : out Boolean) is begin Valid := False; IO.Put ("X: "); Nat_IO.Get (X); IO.Put ("Y: "); Nat_IO.Get (Y); Valid := X > 0 and X <= Max_X and Y > 0 and Y <= Max_Y; exception when Constraint_Error => Valid := False; end Get_Coordinates; -- randomly place bombs procedure Set_Bombs (Item : in out Grid; Max_X, Max_Y, Count : Positive) is Generator : Nat_RNG.Generator; X, Y : Positive; begin Nat_RNG.Reset (Generator); for I in 1 .. Count loop Placement : loop X := Nat_RNG.Random (Generator) mod Max_X + 1; Y := Nat_RNG.Random (Generator) mod Max_Y + 1; -- redo placement if X:Y already full if Item (X, Y).Contents = Empty then Item (X, Y).Contents := Mine; exit Placement; end if; end loop Placement; end loop; end Set_Bombs; Width, Height : Positive; begin -- can be dynamically set Width := 6; Height := 4; declare The_Grid : Grid (1 .. Width, 1 .. Height); -- 20% bombs Bomb_Count : Positive := Width * Height * 20 / 100; Finished : Boolean := False; Action : Character; Chosen_X, Chosen_Y : Positive; Valid_Entry : Boolean; begin IO.Put ("Nr. Bombs: "); Nat_IO.Put (Item => Bomb_Count, Width => 0); IO.New_Line; Set_Bombs (Item => The_Grid, Max_X => Width, Max_Y => Height, Count => Bomb_Count); while not Finished and Count_Marks (The_Grid) /= Bomb_Count loop Put (The_Grid); IO.Put ("Input (c/m/r): "); IO.Get (Action); case Action is when 'c' | 'C' => Get_Coordinates (Max_X => Width, Max_Y => Height, X => Chosen_X, Y => Chosen_Y, Valid => Valid_Entry); if Valid_Entry then Clear (Item => The_Grid, X => Chosen_X, Y => Chosen_Y, Killed => Finished); if Finished then IO.Put_Line ("You stepped on a mine!"); end if; else IO.Put_Line ("Invalid input, retry!"); end if; when 'm' | 'M' => Get_Coordinates (Max_X => Width, Max_Y => Height, X => Chosen_X, Y => Chosen_Y, Valid => Valid_Entry); if Valid_Entry then Mark (Item => The_Grid, X => Chosen_X, Y => Chosen_Y); else IO.Put_Line ("Invalid input, retry!"); end if; when 'r' | 'R' => Finished := True; when others => IO.Put_Line ("Invalid input, retry!"); end case; end loop; Open_All (The_Grid); IO.Put_Line ("Solution: (+ = correctly marked, - = incorrectly marked)"); Put (The_Grid); end; end Minesweeper;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- M L I B . T G T -- -- -- -- S p e c -- -- -- -- Copyright (C) 2001-2005, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package provides a set of target dependent routines to build -- static, dynamic and shared libraries. -- There are several versions for the body of this package -- In the default version, libraries are not supported, so function -- Support_For_Libraries return None. with Prj; use Prj; package MLib.Tgt is type Library_Support is (None, Static_Only, Full); -- Support for Library Project File. -- - None: Library Project Files are not supported at all -- - Static_Only: Library Project Files are only supported for static -- libraries. -- - Full: Library Project Files are supported for static and dynamic -- (shared) libraries. function Support_For_Libraries return Library_Support; -- Indicates how building libraries by gnatmake is supported by the GNAT -- implementation for the platform. function Standalone_Library_Auto_Init_Is_Supported return Boolean; -- Indicates if when building a dynamic Standalone Library, -- automatic initialization is supported. If it is, then it is the default, -- unless attribute Library_Auto_Init has the value "false". function Archive_Builder return String; -- Returns the name of the archive builder program, usually "ar" function Archive_Builder_Options return String_List_Access; -- A list of options to invoke the Archive_Builder, usually "cr" for "ar" function Archive_Indexer return String; -- Returns the name of the program, if any, that generates an index to the -- contents of an archive, usually "ranlib". If there is no archive indexer -- to be used, returns an empty string. function Archive_Indexer_Options return String_List_Access; -- A list of options to invoke the Archive_Indexer, usually empty function Dynamic_Option return String; -- gcc option to create a dynamic library. -- For Unix, returns "-shared", for Windows returns "-mdll". function Libgnat return String; -- System dependent static GNAT library function Archive_Ext return String; -- System dependent static library extension, without leading dot. -- For Unix and Windows, return "a". function Object_Ext return String; -- System dependent object extension, without leadien dot. -- On Unix, returns "o". function DLL_Prefix return String; -- System dependent dynamic library prefix. -- On Windows, returns "". On other platforms, returns "lib". function DLL_Ext return String; -- System dependent dynamic library extension, without leading dot. -- On Windows, returns "dll". On Unix, usually returns "so", but not -- always, e.g. on HP-UX the extension for shared libraries is "sl". function PIC_Option return String; -- Position independent code option function Is_Object_Ext (Ext : String) return Boolean; -- Returns True iff Ext is an object file extension function Is_C_Ext (Ext : String) return Boolean; -- Returns True iff Ext is a C file extension function Is_Archive_Ext (Ext : String) return Boolean; -- Returns True iff Ext is an extension for a library procedure Build_Dynamic_Library (Ofiles : Argument_List; Foreign : Argument_List; Afiles : Argument_List; Options : Argument_List; Options_2 : Argument_List; Interfaces : Argument_List; Lib_Filename : String; Lib_Dir : String; Symbol_Data : Symbol_Record; Driver_Name : Name_Id := No_Name; Lib_Version : String := ""; Auto_Init : Boolean := False); -- Build a dynamic/relocatable library -- -- Ofiles is the list of all object files in the library -- -- Foreign is the list of non Ada object files (also included in Ofiles) -- -- Afiles is the list of ALI files for the Ada object files -- -- Options and Options_2 are lists of options to be passed to the tool -- (gcc or other) that effectively builds the dynamic library. Options -- are passed before the object files, Options_2 are passed after the -- object files. -- -- Interfaces is the list of ALI files for the interfaces of a SAL. -- It is empty if the library is not a SAL. -- -- Lib_Filename is the name of the library, without any prefix or -- extension. For example, on Unix, if Lib_Filename is "toto", the -- name of the library file will be "libtoto.so". -- -- Lib_Dir is the directory path where the library will be located -- -- For OSes that support symbolic links, Lib_Version, if non null, -- is the actual file name of the library. For example on Unix, if -- Lib_Filename is "toto" and Lib_Version is "libtoto.so.2.1", -- "libtoto.so" will be a symbolic link to "libtoto.so.2.1" which -- will be the actual library file. -- -- Symbol_Data is used for some patforms, including VMS, to generate -- the symbols to be exported by the library. -- -- Note: Depending on the OS, some of the parameters may not be taken -- into account. For example, on Linux, Foreign, Afiles Lib_Address and -- Relocatable are ignored. function Library_Exists_For (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean; -- Return True if the library file for a library project already exists. -- This function can only be called for library projects. function Library_File_Name_For (Project : Project_Id; In_Tree : Project_Tree_Ref) return Name_Id; -- Returns the file name of the library file of a library project. -- This function can only be called for library projects. end MLib.Tgt;
-- REST API Validation -- API to validate -- -- The version of the OpenAPI document: 1.0.0 -- Contact: Stephane.Carrez@gmail.com -- -- NOTE: This package is auto generated by OpenAPI-Generator 5.2.1-SNAPSHOT. -- https://openapi-generator.tech -- Do not edit the class manually. with TestAPI.Models; with Swagger.Clients; package TestAPI.Clients is pragma Style_Checks ("-mr"); type Client_Type is new Swagger.Clients.Client_Type with null record; -- -- Query an orchestrated service instance procedure Orch_Store (Client : in out Client_Type; Inline_Object_3Type : in TestAPI.Models.InlineObject3_Type); -- Create a ticket procedure Do_Create_Ticket (Client : in out Client_Type; Title : in Swagger.UString; Owner : in Swagger.Nullable_UString; Status : in Swagger.Nullable_UString; Description : in Swagger.Nullable_UString); -- Delete a ticket procedure Do_Delete_Ticket (Client : in out Client_Type; Tid : in Swagger.Long); -- List the tickets procedure Do_Head_Ticket (Client : in out Client_Type); -- Patch a ticket procedure Do_Patch_Ticket (Client : in out Client_Type; Tid : in Swagger.Long; Owner : in Swagger.Nullable_UString; Status : in Swagger.Nullable_UString; Title : in Swagger.Nullable_UString; Description : in Swagger.Nullable_UString; Result : out TestAPI.Models.Ticket_Type); -- Update a ticket procedure Do_Update_Ticket (Client : in out Client_Type; Tid : in Swagger.Long; Owner : in Swagger.Nullable_UString; Status : in Swagger.Nullable_UString; Title : in Swagger.Nullable_UString; Description : in Swagger.Nullable_UString; Result : out TestAPI.Models.Ticket_Type); -- Get a ticket -- Get a ticket procedure Do_Get_Ticket (Client : in out Client_Type; Tid : in Swagger.Long; Result : out TestAPI.Models.Ticket_Type); -- List the tickets -- List the tickets created for the project. procedure Do_List_Tickets (Client : in out Client_Type; Status : in Swagger.Nullable_UString; Owner : in Swagger.Nullable_UString; Result : out TestAPI.Models.Ticket_Type_Vectors.Vector); -- Get a ticket -- Get a ticket procedure Do_Options_Ticket (Client : in out Client_Type; Tid : in Swagger.Long; Result : out TestAPI.Models.Ticket_Type); end TestAPI.Clients;
------------------------------------------------------------------------------ -- Copyright (c) 2006-2013, Maxim Reznik -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * Neither the name of the Maxim Reznik, IE nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------ package Asis.Gela.Elements.Defs.Types is ----------------------- -- Derived_Type_Node -- ----------------------- type Derived_Type_Node is new Type_Definition_Node with private; type Derived_Type_Ptr is access all Derived_Type_Node; for Derived_Type_Ptr'Storage_Pool use Lists.Pool; function New_Derived_Type_Node (The_Context : ASIS.Context) return Derived_Type_Ptr; function Corresponding_Parent_Subtype (Element : Derived_Type_Node) return Asis.Declaration; procedure Set_Corresponding_Parent_Subtype (Element : in out Derived_Type_Node; Value : in Asis.Declaration); function Corresponding_Root_Type (Element : Derived_Type_Node) return Asis.Declaration; procedure Set_Corresponding_Root_Type (Element : in out Derived_Type_Node; Value : in Asis.Declaration); function Implicit_Inherited_Declarations (Element : Derived_Type_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Add_To_Implicit_Inherited_Declarations (Element : in out Derived_Type_Node; Item : in Asis.Element); function Implicit_Inherited_Subprograms (Element : Derived_Type_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Add_To_Implicit_Inherited_Subprograms (Element : in out Derived_Type_Node; Item : in Asis.Element); function Corresponding_Type_Structure (Element : Derived_Type_Node) return Asis.Declaration; procedure Set_Corresponding_Type_Structure (Element : in out Derived_Type_Node; Value : in Asis.Declaration); function Trait_Kind (Element : Derived_Type_Node) return Asis.Trait_Kinds; procedure Set_Trait_Kind (Element : in out Derived_Type_Node; Value : in Asis.Trait_Kinds); function Parent_Subtype_Indication (Element : Derived_Type_Node) return Asis.Subtype_Indication; procedure Set_Parent_Subtype_Indication (Element : in out Derived_Type_Node; Value : in Asis.Subtype_Indication); function Has_Limited (Element : Derived_Type_Node) return Boolean; procedure Set_Has_Limited (Element : in out Derived_Type_Node; Value : in Boolean); function Has_Abstract (Element : Derived_Type_Node) return Boolean; procedure Set_Has_Abstract (Element : in out Derived_Type_Node; Value : in Boolean); function Type_Definition_Kind (Element : Derived_Type_Node) return Asis.Type_Kinds; function Children (Element : access Derived_Type_Node) return Traverse_List; function Clone (Element : Derived_Type_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Derived_Type_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); ----------------------------------- -- Derived_Record_Extension_Node -- ----------------------------------- type Derived_Record_Extension_Node is new Derived_Type_Node with private; type Derived_Record_Extension_Ptr is access all Derived_Record_Extension_Node; for Derived_Record_Extension_Ptr'Storage_Pool use Lists.Pool; function New_Derived_Record_Extension_Node (The_Context : ASIS.Context) return Derived_Record_Extension_Ptr; function Progenitor_List (Element : Derived_Record_Extension_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Set_Progenitor_List (Element : in out Derived_Record_Extension_Node; Value : in Asis.Element); function Progenitor_List_List (Element : Derived_Record_Extension_Node) return Asis.Element; function Get_Record_Definition (Element : Derived_Record_Extension_Node) return Asis.Definition; procedure Set_Record_Definition (Element : in out Derived_Record_Extension_Node; Value : in Asis.Definition); function Type_Definition_Kind (Element : Derived_Record_Extension_Node) return Asis.Type_Kinds; function Children (Element : access Derived_Record_Extension_Node) return Traverse_List; function Clone (Element : Derived_Record_Extension_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Derived_Record_Extension_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); --------------------------- -- Enumeration_Type_Node -- --------------------------- type Enumeration_Type_Node is new Type_Definition_Node with private; type Enumeration_Type_Ptr is access all Enumeration_Type_Node; for Enumeration_Type_Ptr'Storage_Pool use Lists.Pool; function New_Enumeration_Type_Node (The_Context : ASIS.Context) return Enumeration_Type_Ptr; function Enumeration_Literal_Declarations (Element : Enumeration_Type_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Set_Enumeration_Literal_Declarations (Element : in out Enumeration_Type_Node; Value : in Asis.Element); function Enumeration_Literal_Declarations_List (Element : Enumeration_Type_Node) return Asis.Element; function Type_Definition_Kind (Element : Enumeration_Type_Node) return Asis.Type_Kinds; function Children (Element : access Enumeration_Type_Node) return Traverse_List; function Clone (Element : Enumeration_Type_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Enumeration_Type_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); ------------------------------ -- Signed_Integer_Type_Node -- ------------------------------ type Signed_Integer_Type_Node is new Type_Definition_Node with private; type Signed_Integer_Type_Ptr is access all Signed_Integer_Type_Node; for Signed_Integer_Type_Ptr'Storage_Pool use Lists.Pool; function New_Signed_Integer_Type_Node (The_Context : ASIS.Context) return Signed_Integer_Type_Ptr; function Integer_Constraint (Element : Signed_Integer_Type_Node) return Asis.Range_Constraint; procedure Set_Integer_Constraint (Element : in out Signed_Integer_Type_Node; Value : in Asis.Range_Constraint); function Type_Definition_Kind (Element : Signed_Integer_Type_Node) return Asis.Type_Kinds; function Children (Element : access Signed_Integer_Type_Node) return Traverse_List; function Clone (Element : Signed_Integer_Type_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Signed_Integer_Type_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); ----------------------- -- Modular_Type_Node -- ----------------------- type Modular_Type_Node is new Type_Definition_Node with private; type Modular_Type_Ptr is access all Modular_Type_Node; for Modular_Type_Ptr'Storage_Pool use Lists.Pool; function New_Modular_Type_Node (The_Context : ASIS.Context) return Modular_Type_Ptr; function Mod_Static_Expression (Element : Modular_Type_Node) return Asis.Expression; procedure Set_Mod_Static_Expression (Element : in out Modular_Type_Node; Value : in Asis.Expression); function Type_Definition_Kind (Element : Modular_Type_Node) return Asis.Type_Kinds; function Children (Element : access Modular_Type_Node) return Traverse_List; function Clone (Element : Modular_Type_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Modular_Type_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); -------------------- -- Root_Type_Node -- -------------------- type Root_Type_Node is new Type_Definition_Node with private; type Root_Type_Ptr is access all Root_Type_Node; for Root_Type_Ptr'Storage_Pool use Lists.Pool; function New_Root_Type_Node (The_Context : ASIS.Context) return Root_Type_Ptr; function Root_Type_Kind (Element : Root_Type_Node) return Asis.Root_Type_Kinds; procedure Set_Root_Type_Kind (Element : in out Root_Type_Node; Value : in Asis.Root_Type_Kinds); function Type_Definition_Kind (Element : Root_Type_Node) return Asis.Type_Kinds; function Clone (Element : Root_Type_Node; Parent : Asis.Element) return Asis.Element; ------------------------- -- Floating_Point_Node -- ------------------------- type Floating_Point_Node is new Type_Definition_Node with private; type Floating_Point_Ptr is access all Floating_Point_Node; for Floating_Point_Ptr'Storage_Pool use Lists.Pool; function New_Floating_Point_Node (The_Context : ASIS.Context) return Floating_Point_Ptr; function Digits_Expression (Element : Floating_Point_Node) return Asis.Expression; procedure Set_Digits_Expression (Element : in out Floating_Point_Node; Value : in Asis.Expression); function Real_Range_Constraint (Element : Floating_Point_Node) return Asis.Range_Constraint; procedure Set_Real_Range_Constraint (Element : in out Floating_Point_Node; Value : in Asis.Range_Constraint); function Type_Definition_Kind (Element : Floating_Point_Node) return Asis.Type_Kinds; function Children (Element : access Floating_Point_Node) return Traverse_List; function Clone (Element : Floating_Point_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Floating_Point_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); ------------------------------- -- Ordinary_Fixed_Point_Node -- ------------------------------- type Ordinary_Fixed_Point_Node is new Type_Definition_Node with private; type Ordinary_Fixed_Point_Ptr is access all Ordinary_Fixed_Point_Node; for Ordinary_Fixed_Point_Ptr'Storage_Pool use Lists.Pool; function New_Ordinary_Fixed_Point_Node (The_Context : ASIS.Context) return Ordinary_Fixed_Point_Ptr; function Delta_Expression (Element : Ordinary_Fixed_Point_Node) return Asis.Expression; procedure Set_Delta_Expression (Element : in out Ordinary_Fixed_Point_Node; Value : in Asis.Expression); function Real_Range_Constraint (Element : Ordinary_Fixed_Point_Node) return Asis.Range_Constraint; procedure Set_Real_Range_Constraint (Element : in out Ordinary_Fixed_Point_Node; Value : in Asis.Range_Constraint); function Type_Definition_Kind (Element : Ordinary_Fixed_Point_Node) return Asis.Type_Kinds; function Children (Element : access Ordinary_Fixed_Point_Node) return Traverse_List; function Clone (Element : Ordinary_Fixed_Point_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Ordinary_Fixed_Point_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); ------------------------------ -- Decimal_Fixed_Point_Node -- ------------------------------ type Decimal_Fixed_Point_Node is new Ordinary_Fixed_Point_Node with private; type Decimal_Fixed_Point_Ptr is access all Decimal_Fixed_Point_Node; for Decimal_Fixed_Point_Ptr'Storage_Pool use Lists.Pool; function New_Decimal_Fixed_Point_Node (The_Context : ASIS.Context) return Decimal_Fixed_Point_Ptr; function Digits_Expression (Element : Decimal_Fixed_Point_Node) return Asis.Expression; procedure Set_Digits_Expression (Element : in out Decimal_Fixed_Point_Node; Value : in Asis.Expression); function Type_Definition_Kind (Element : Decimal_Fixed_Point_Node) return Asis.Type_Kinds; function Children (Element : access Decimal_Fixed_Point_Node) return Traverse_List; function Clone (Element : Decimal_Fixed_Point_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Decimal_Fixed_Point_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); ------------------------------ -- Unconstrained_Array_Node -- ------------------------------ type Unconstrained_Array_Node is new Type_Definition_Node with private; type Unconstrained_Array_Ptr is access all Unconstrained_Array_Node; for Unconstrained_Array_Ptr'Storage_Pool use Lists.Pool; function New_Unconstrained_Array_Node (The_Context : ASIS.Context) return Unconstrained_Array_Ptr; function Index_Subtype_Definitions (Element : Unconstrained_Array_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Set_Index_Subtype_Definitions (Element : in out Unconstrained_Array_Node; Value : in Asis.Element); function Index_Subtype_Definitions_List (Element : Unconstrained_Array_Node) return Asis.Element; function Array_Component_Definition (Element : Unconstrained_Array_Node) return Asis.Component_Definition; procedure Set_Array_Component_Definition (Element : in out Unconstrained_Array_Node; Value : in Asis.Component_Definition); function Type_Definition_Kind (Element : Unconstrained_Array_Node) return Asis.Type_Kinds; function Children (Element : access Unconstrained_Array_Node) return Traverse_List; function Clone (Element : Unconstrained_Array_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Unconstrained_Array_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); ---------------------------- -- Constrained_Array_Node -- ---------------------------- type Constrained_Array_Node is new Type_Definition_Node with private; type Constrained_Array_Ptr is access all Constrained_Array_Node; for Constrained_Array_Ptr'Storage_Pool use Lists.Pool; function New_Constrained_Array_Node (The_Context : ASIS.Context) return Constrained_Array_Ptr; function Discrete_Subtype_Definitions (Element : Constrained_Array_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Set_Discrete_Subtype_Definitions (Element : in out Constrained_Array_Node; Value : in Asis.Element); function Discrete_Subtype_Definitions_List (Element : Constrained_Array_Node) return Asis.Element; function Array_Component_Definition (Element : Constrained_Array_Node) return Asis.Component_Definition; procedure Set_Array_Component_Definition (Element : in out Constrained_Array_Node; Value : in Asis.Component_Definition); function Type_Definition_Kind (Element : Constrained_Array_Node) return Asis.Type_Kinds; function Children (Element : access Constrained_Array_Node) return Traverse_List; function Clone (Element : Constrained_Array_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Constrained_Array_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); ---------------------- -- Record_Type_Node -- ---------------------- type Record_Type_Node is new Type_Definition_Node with private; type Record_Type_Ptr is access all Record_Type_Node; for Record_Type_Ptr'Storage_Pool use Lists.Pool; function New_Record_Type_Node (The_Context : ASIS.Context) return Record_Type_Ptr; function Trait_Kind (Element : Record_Type_Node) return Asis.Trait_Kinds; procedure Set_Trait_Kind (Element : in out Record_Type_Node; Value : in Asis.Trait_Kinds); function Get_Record_Definition (Element : Record_Type_Node) return Asis.Definition; procedure Set_Record_Definition (Element : in out Record_Type_Node; Value : in Asis.Definition); function Has_Limited (Element : Record_Type_Node) return Boolean; procedure Set_Has_Limited (Element : in out Record_Type_Node; Value : in Boolean); function Type_Definition_Kind (Element : Record_Type_Node) return Asis.Type_Kinds; function Children (Element : access Record_Type_Node) return Traverse_List; function Clone (Element : Record_Type_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Record_Type_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); ----------------------------- -- Tagged_Record_Type_Node -- ----------------------------- type Tagged_Record_Type_Node is new Record_Type_Node with private; type Tagged_Record_Type_Ptr is access all Tagged_Record_Type_Node; for Tagged_Record_Type_Ptr'Storage_Pool use Lists.Pool; function New_Tagged_Record_Type_Node (The_Context : ASIS.Context) return Tagged_Record_Type_Ptr; function Has_Abstract (Element : Tagged_Record_Type_Node) return Boolean; procedure Set_Has_Abstract (Element : in out Tagged_Record_Type_Node; Value : in Boolean); function Has_Tagged (Element : Tagged_Record_Type_Node) return Boolean; procedure Set_Has_Tagged (Element : in out Tagged_Record_Type_Node; Value : in Boolean); function Type_Definition_Kind (Element : Tagged_Record_Type_Node) return Asis.Type_Kinds; function Clone (Element : Tagged_Record_Type_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Tagged_Record_Type_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); ------------------------- -- Interface_Type_Node -- ------------------------- type Interface_Type_Node is new Type_Definition_Node with private; type Interface_Type_Ptr is access all Interface_Type_Node; for Interface_Type_Ptr'Storage_Pool use Lists.Pool; function New_Interface_Type_Node (The_Context : ASIS.Context) return Interface_Type_Ptr; function Interface_Kind (Element : Interface_Type_Node) return Asis.Interface_Kinds; procedure Set_Interface_Kind (Element : in out Interface_Type_Node; Value : in Asis.Interface_Kinds); function Has_Limited (Element : Interface_Type_Node) return Boolean; procedure Set_Has_Limited (Element : in out Interface_Type_Node; Value : in Boolean); function Has_Synchronized (Element : Interface_Type_Node) return Boolean; procedure Set_Has_Synchronized (Element : in out Interface_Type_Node; Value : in Boolean); function Has_Protected (Element : Interface_Type_Node) return Boolean; procedure Set_Has_Protected (Element : in out Interface_Type_Node; Value : in Boolean); function Has_Task (Element : Interface_Type_Node) return Boolean; procedure Set_Has_Task (Element : in out Interface_Type_Node; Value : in Boolean); function Progenitor_List (Element : Interface_Type_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Set_Progenitor_List (Element : in out Interface_Type_Node; Value : in Asis.Element); function Progenitor_List_List (Element : Interface_Type_Node) return Asis.Element; function Implicit_Inherited_Subprograms (Element : Interface_Type_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Add_To_Implicit_Inherited_Subprograms (Element : in out Interface_Type_Node; Item : in Asis.Element); function Type_Definition_Kind (Element : Interface_Type_Node) return Asis.Type_Kinds; function Children (Element : access Interface_Type_Node) return Traverse_List; function Clone (Element : Interface_Type_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Interface_Type_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); ---------------------- -- Access_Type_Node -- ---------------------- type Access_Type_Node is new Type_Definition_Node with private; type Access_Type_Ptr is access all Access_Type_Node; for Access_Type_Ptr'Storage_Pool use Lists.Pool; function New_Access_Type_Node (The_Context : ASIS.Context) return Access_Type_Ptr; function Access_Type_Kind (Element : Access_Type_Node) return Asis.Access_Type_Kinds; procedure Set_Access_Type_Kind (Element : in out Access_Type_Node; Value : in Asis.Access_Type_Kinds); function Get_Access_To_Object_Definition (Element : Access_Type_Node) return Asis.Subtype_Indication; procedure Set_Access_To_Object_Definition (Element : in out Access_Type_Node; Value : in Asis.Subtype_Indication); function Access_To_Subprogram_Parameter_Profile (Element : Access_Type_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Set_Access_To_Subprogram_Parameter_Profile (Element : in out Access_Type_Node; Value : in Asis.Element); function Access_To_Subprogram_Parameter_Profile_List (Element : Access_Type_Node) return Asis.Element; function Access_To_Function_Result_Subtype (Element : Access_Type_Node) return Asis.Definition; procedure Set_Access_To_Function_Result_Subtype (Element : in out Access_Type_Node; Value : in Asis.Definition); function Has_Null_Exclusion (Element : Access_Type_Node) return Boolean; procedure Set_Has_Null_Exclusion (Element : in out Access_Type_Node; Value : in Boolean); function Type_Definition_Kind (Element : Access_Type_Node) return Asis.Type_Kinds; function Children (Element : access Access_Type_Node) return Traverse_List; function Clone (Element : Access_Type_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Access_Type_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); private type Derived_Type_Node is new Type_Definition_Node with record Corresponding_Parent_Subtype : aliased Asis.Declaration; Corresponding_Root_Type : aliased Asis.Declaration; Implicit_Inherited_Declarations : aliased Secondary_Declaration_Lists.List_Node; Implicit_Inherited_Subprograms : aliased Secondary_Declaration_Lists.List_Node; Corresponding_Type_Structure : aliased Asis.Declaration; Trait_Kind : aliased Asis.Trait_Kinds := An_Ordinary_Trait; Parent_Subtype_Indication : aliased Asis.Subtype_Indication; Has_Limited : aliased Boolean := False; Has_Abstract : aliased Boolean := False; end record; type Derived_Record_Extension_Node is new Derived_Type_Node with record Progenitor_List : aliased Primary_Expression_Lists.List; Record_Definition : aliased Asis.Definition; end record; type Enumeration_Type_Node is new Type_Definition_Node with record Enumeration_Literal_Declarations : aliased Primary_Declaration_Lists.List; end record; type Signed_Integer_Type_Node is new Type_Definition_Node with record Integer_Constraint : aliased Asis.Range_Constraint; end record; type Modular_Type_Node is new Type_Definition_Node with record Mod_Static_Expression : aliased Asis.Expression; end record; type Root_Type_Node is new Type_Definition_Node with record Root_Type_Kind : aliased Asis.Root_Type_Kinds := Not_A_Root_Type_Definition; end record; type Floating_Point_Node is new Type_Definition_Node with record Digits_Expression : aliased Asis.Expression; Real_Range_Constraint : aliased Asis.Range_Constraint; end record; type Ordinary_Fixed_Point_Node is new Type_Definition_Node with record Delta_Expression : aliased Asis.Expression; Real_Range_Constraint : aliased Asis.Range_Constraint; end record; type Decimal_Fixed_Point_Node is new Ordinary_Fixed_Point_Node with record Digits_Expression : aliased Asis.Expression; end record; type Unconstrained_Array_Node is new Type_Definition_Node with record Index_Subtype_Definitions : aliased Primary_Identifier_Lists.List; Array_Component_Definition : aliased Asis.Component_Definition; end record; type Constrained_Array_Node is new Type_Definition_Node with record Discrete_Subtype_Definitions : aliased Primary_Definition_Lists.List; Array_Component_Definition : aliased Asis.Component_Definition; end record; type Record_Type_Node is new Type_Definition_Node with record Trait_Kind : aliased Asis.Trait_Kinds := An_Ordinary_Trait; Record_Definition : aliased Asis.Definition; Has_Limited : aliased Boolean := False; end record; type Tagged_Record_Type_Node is new Record_Type_Node with record Has_Abstract : aliased Boolean := False; Has_Tagged : aliased Boolean := False; end record; type Interface_Type_Node is new Type_Definition_Node with record Interface_Kind : aliased Asis.Interface_Kinds := Not_An_Interface; Has_Limited : aliased Boolean := False; Has_Synchronized : aliased Boolean := False; Has_Protected : aliased Boolean := False; Has_Task : aliased Boolean := False; Progenitor_List : aliased Primary_Expression_Lists.List; Implicit_Inherited_Subprograms : aliased Secondary_Declaration_Lists.List_Node; end record; type Access_Type_Node is new Type_Definition_Node with record Access_Type_Kind : aliased Asis.Access_Type_Kinds := A_Pool_Specific_Access_To_Variable; Access_To_Object_Definition : aliased Asis.Subtype_Indication; Access_To_Subprogram_Parameter_Profile : aliased Primary_Parameter_Lists.List; Access_To_Function_Result_Subtype : aliased Asis.Definition; Has_Null_Exclusion : aliased Boolean := False; end record; end Asis.Gela.Elements.Defs.Types;
-- { dg-do link } -- { dg-options "-largs -f -margs -flto" { target lto } } -- { dg-skip-if "missing linker support" { *-*-solaris2.* } } procedure Lto14 is begin null; end;
separate (Numerics.Sparse_Matrices) function Eye (N : in Pos) return Sparse_Matrix is Result : Sparse_Matrix; use Ada.Containers; begin Result.Format := CSC; Result.N_Row := N; Result.N_Col := N; Result.X := RV_Package.To_Vector (1.0, Count_Type (N)); Result.I.Reserve_Capacity (Count_Type (N)); Result.P.Reserve_Capacity (Count_Type (N + 1)); for I in 1 .. N loop Result.I.Append (I); Result.P.Append (I); end loop; Result.P.Append (N + 1); return Result; end Eye;
package Test_Utils.Abstract_Decoder is subtype Parent is Test_Utils.Abstract_Data_Processing; type Instance is abstract limited new Parent with private; type Acc is access all Instance; type Any_Acc is access all Instance'Class; procedure Receive (This : in out Instance; Data : Storage_Element) is abstract; -- This procedure is called when there is new data to process procedure Update (This : in out Instance) is abstract; -- This procedure is called regularely during test to let processing -- abstraction handle pending data, if any. procedure End_Of_Test (This : in out Instance) is abstract; -- This procedure is called at the end of the test, before collecting the -- output data frames. private type Instance is abstract limited new Parent with null record; end Test_Utils.Abstract_Decoder;
with Ada.Containers.Vectors; use Ada.Containers; procedure Vector_Example is package Vector_Pkg is new Vectors (Natural, Integer); use Vector_Pkg; V : Vector; begin V.Append (1); V.Append (2); V.Append (3); end Vector_Example;
-- CC1221B.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: -- FOR A FORMAL INTEGER TYPE, CHECK THAT THE FOLLOWING BASIC -- OPERATIONS ARE IMPLICITLY DECLARED AND ARE THEREFORE AVAILABLE -- WITHIN THE GENERIC UNIT: ATTRIBUTES 'FIRST, 'LAST, 'WIDTH, -- 'ADDRESS, AND 'SIZE. -- HISTORY: -- BCB 11/12/87 CREATED ORIGINAL TEST FROM SPLIT OF CC1221A.ADA. WITH SYSTEM; USE SYSTEM; WITH REPORT; USE REPORT; PROCEDURE CC1221B IS SUBTYPE SUBINT IS INTEGER RANGE -100 .. 100; SUBTYPE NOINT IS INTEGER RANGE 1 .. -1; TYPE NEWINT IS NEW INTEGER; TYPE INT IS RANGE -300 .. 300; SUBTYPE SINT1 IS INT RANGE INT (IDENT_INT (-4)) .. INT (IDENT_INT (4)); SUBTYPE SINT2 IS INT RANGE 16#E#E1 .. 2#1111_1111#; TYPE INT2 IS RANGE 0E8 .. 1E3; BEGIN TEST ( "CC1221B", "FOR A FORMAL INTEGER TYPE, CHECK THAT THE " & "FOLLOWING BASIC OPERATIONS ARE IMPLICITLY " & "DECLARED AND ARE THEREFORE AVAILABLE " & "WITHIN THE GENERIC UNIT: ATTRIBUTES 'FIRST, " & "'LAST, 'WIDTH, 'ADDRESS, AND 'SIZE"); DECLARE -- (B) CHECKS FOR BASIC OPERATIONS OF A DISCRETE TYPE. -- PART II. GENERIC TYPE T IS RANGE <>; F, L : T; W : INTEGER; PROCEDURE P (STR : STRING); PROCEDURE P (STR : STRING) IS I : INTEGER := F'SIZE; T1 : T; A : ADDRESS := T1'ADDRESS; BEGIN IF T'FIRST /= F THEN FAILED ( "INCORRECT VALUE FOR " & STR & "'FIRST" ); END IF; IF T'LAST /= L THEN FAILED ( "INCORRECT VALUE FOR " & STR & "'LAST" ); END IF; IF T'BASE'FIRST > T'FIRST THEN FAILED ( "INCORRECT RESULTS WITH " & STR & "'BASE'FIRST" ); END IF; IF T'BASE'LAST < T'LAST THEN FAILED ( "INCORRECT RESULTS WITH " & STR & "'BASE'LAST" ); END IF; IF T'WIDTH /= W THEN FAILED ( "INCORRECT VALUE FOR " & STR & "'WIDTH" ); END IF; IF T'BASE'WIDTH < T'WIDTH THEN FAILED ( "INCORRECT RESULTS WITH " & STR & "'BASE'WIDTH" ); END IF; END P; GENERIC TYPE T IS RANGE <>; PROCEDURE Q; PROCEDURE Q IS BEGIN IF T'FIRST /= 1 THEN FAILED ( "INCORRECT VALUE FOR NOINT'FIRST" ); END IF; IF T'LAST /= -1 THEN FAILED ( "INCORRECT VALUE FOR NOINT'LAST" ); END IF; IF T'BASE'FIRST > T'FIRST THEN FAILED ( "INCORRECT RESULTS WITH " & "NOINT'BASE'FIRST" ); END IF; IF T'BASE'LAST < T'LAST THEN FAILED ( "INCORRECT RESULTS WITH " & "NOINT'BASE'LAST" ); END IF; IF T'WIDTH /= 0 THEN FAILED ( "INCORRECT VALUE FOR " & "NOINT'WIDTH" ); END IF; IF T'BASE'WIDTH < T'WIDTH THEN FAILED ( "INCORRECT RESULTS WITH " & "NOINT'BASE'WIDTH" ); END IF; END Q; PROCEDURE P1 IS NEW P (INTEGER, INTEGER'FIRST, INTEGER'LAST, INTEGER'WIDTH); PROCEDURE P2 IS NEW P (SUBINT, -100, 100, 4); PROCEDURE P3 IS NEW P (NEWINT, NEWINT'FIRST, NEWINT'LAST, NEWINT'WIDTH); PROCEDURE P4 IS NEW P (SINT1, -4, 4, 2); PROCEDURE P5 IS NEW P (SINT2, 224, 255, 4); PROCEDURE P6 IS NEW P (INT2 , 0, 1000, 5); PROCEDURE Q1 IS NEW Q (NOINT); BEGIN P1 ( "INTEGER" ); P2 ( "SUBINT" ); P3 ( "NEWINT" ); P4 ( "SINT1" ); P5 ( "SINT2" ); P6 ( "INT2" ); Q1; END; -- (B). RESULT; END CC1221B;
-- Copyright (c) 2010 - 2018, Nordic Semiconductor ASA -- -- All rights reserved. -- -- 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, except as embedded into a Nordic -- Semiconductor ASA integrated circuit in a product or a software update for -- such product, 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 Nordic Semiconductor ASA nor the names of its -- contributors may be used to endorse or promote products derived from this -- software without specific prior written permission. -- -- 4. This software, with or without modification, must only be used with a -- Nordic Semiconductor ASA integrated circuit. -- -- 5. Any software provided in binary form under this license must not be reverse -- engineered, decompiled, modified and/or disassembled. -- -- THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS -- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE -- DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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 spec has been automatically generated from nrf52.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package NRF_SVD.POWER is pragma Preelaborate; --------------- -- Registers -- --------------- -- Write '1' to Enable interrupt for POFWARN event type INTENSET_POFWARN_Field is (-- Read: Disabled Disabled, -- Read: Enabled Enabled) with Size => 1; for INTENSET_POFWARN_Field use (Disabled => 0, Enabled => 1); -- Write '1' to Enable interrupt for POFWARN event type INTENSET_POFWARN_Field_1 is (-- Reset value for the field Intenset_Pofwarn_Field_Reset, -- Enable Set) with Size => 1; for INTENSET_POFWARN_Field_1 use (Intenset_Pofwarn_Field_Reset => 0, Set => 1); -- Write '1' to Enable interrupt for SLEEPENTER event type INTENSET_SLEEPENTER_Field is (-- Read: Disabled Disabled, -- Read: Enabled Enabled) with Size => 1; for INTENSET_SLEEPENTER_Field use (Disabled => 0, Enabled => 1); -- Write '1' to Enable interrupt for SLEEPENTER event type INTENSET_SLEEPENTER_Field_1 is (-- Reset value for the field Intenset_Sleepenter_Field_Reset, -- Enable Set) with Size => 1; for INTENSET_SLEEPENTER_Field_1 use (Intenset_Sleepenter_Field_Reset => 0, Set => 1); -- Write '1' to Enable interrupt for SLEEPEXIT event type INTENSET_SLEEPEXIT_Field is (-- Read: Disabled Disabled, -- Read: Enabled Enabled) with Size => 1; for INTENSET_SLEEPEXIT_Field use (Disabled => 0, Enabled => 1); -- Write '1' to Enable interrupt for SLEEPEXIT event type INTENSET_SLEEPEXIT_Field_1 is (-- Reset value for the field Intenset_Sleepexit_Field_Reset, -- Enable Set) with Size => 1; for INTENSET_SLEEPEXIT_Field_1 use (Intenset_Sleepexit_Field_Reset => 0, Set => 1); -- Enable interrupt type INTENSET_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- Write '1' to Enable interrupt for POFWARN event POFWARN : INTENSET_POFWARN_Field_1 := Intenset_Pofwarn_Field_Reset; -- unspecified Reserved_3_4 : HAL.UInt2 := 16#0#; -- Write '1' to Enable interrupt for SLEEPENTER event SLEEPENTER : INTENSET_SLEEPENTER_Field_1 := Intenset_Sleepenter_Field_Reset; -- Write '1' to Enable interrupt for SLEEPEXIT event SLEEPEXIT : INTENSET_SLEEPEXIT_Field_1 := Intenset_Sleepexit_Field_Reset; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INTENSET_Register use record Reserved_0_1 at 0 range 0 .. 1; POFWARN at 0 range 2 .. 2; Reserved_3_4 at 0 range 3 .. 4; SLEEPENTER at 0 range 5 .. 5; SLEEPEXIT at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; -- Write '1' to Disable interrupt for POFWARN event type INTENCLR_POFWARN_Field is (-- Read: Disabled Disabled, -- Read: Enabled Enabled) with Size => 1; for INTENCLR_POFWARN_Field use (Disabled => 0, Enabled => 1); -- Write '1' to Disable interrupt for POFWARN event type INTENCLR_POFWARN_Field_1 is (-- Reset value for the field Intenclr_Pofwarn_Field_Reset, -- Disable Clear) with Size => 1; for INTENCLR_POFWARN_Field_1 use (Intenclr_Pofwarn_Field_Reset => 0, Clear => 1); -- Write '1' to Disable interrupt for SLEEPENTER event type INTENCLR_SLEEPENTER_Field is (-- Read: Disabled Disabled, -- Read: Enabled Enabled) with Size => 1; for INTENCLR_SLEEPENTER_Field use (Disabled => 0, Enabled => 1); -- Write '1' to Disable interrupt for SLEEPENTER event type INTENCLR_SLEEPENTER_Field_1 is (-- Reset value for the field Intenclr_Sleepenter_Field_Reset, -- Disable Clear) with Size => 1; for INTENCLR_SLEEPENTER_Field_1 use (Intenclr_Sleepenter_Field_Reset => 0, Clear => 1); -- Write '1' to Disable interrupt for SLEEPEXIT event type INTENCLR_SLEEPEXIT_Field is (-- Read: Disabled Disabled, -- Read: Enabled Enabled) with Size => 1; for INTENCLR_SLEEPEXIT_Field use (Disabled => 0, Enabled => 1); -- Write '1' to Disable interrupt for SLEEPEXIT event type INTENCLR_SLEEPEXIT_Field_1 is (-- Reset value for the field Intenclr_Sleepexit_Field_Reset, -- Disable Clear) with Size => 1; for INTENCLR_SLEEPEXIT_Field_1 use (Intenclr_Sleepexit_Field_Reset => 0, Clear => 1); -- Disable interrupt type INTENCLR_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- Write '1' to Disable interrupt for POFWARN event POFWARN : INTENCLR_POFWARN_Field_1 := Intenclr_Pofwarn_Field_Reset; -- unspecified Reserved_3_4 : HAL.UInt2 := 16#0#; -- Write '1' to Disable interrupt for SLEEPENTER event SLEEPENTER : INTENCLR_SLEEPENTER_Field_1 := Intenclr_Sleepenter_Field_Reset; -- Write '1' to Disable interrupt for SLEEPEXIT event SLEEPEXIT : INTENCLR_SLEEPEXIT_Field_1 := Intenclr_Sleepexit_Field_Reset; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INTENCLR_Register use record Reserved_0_1 at 0 range 0 .. 1; POFWARN at 0 range 2 .. 2; Reserved_3_4 at 0 range 3 .. 4; SLEEPENTER at 0 range 5 .. 5; SLEEPEXIT at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; -- Reset from pin-reset detected type RESETREAS_RESETPIN_Field is (-- Not detected Notdetected, -- Detected Detected) with Size => 1; for RESETREAS_RESETPIN_Field use (Notdetected => 0, Detected => 1); -- Reset from watchdog detected type RESETREAS_DOG_Field is (-- Not detected Notdetected, -- Detected Detected) with Size => 1; for RESETREAS_DOG_Field use (Notdetected => 0, Detected => 1); -- Reset from soft reset detected type RESETREAS_SREQ_Field is (-- Not detected Notdetected, -- Detected Detected) with Size => 1; for RESETREAS_SREQ_Field use (Notdetected => 0, Detected => 1); -- Reset from CPU lock-up detected type RESETREAS_LOCKUP_Field is (-- Not detected Notdetected, -- Detected Detected) with Size => 1; for RESETREAS_LOCKUP_Field use (Notdetected => 0, Detected => 1); -- Reset due to wake up from System OFF mode when wakeup is triggered from -- DETECT signal from GPIO type RESETREAS_OFF_Field is (-- Not detected Notdetected, -- Detected Detected) with Size => 1; for RESETREAS_OFF_Field use (Notdetected => 0, Detected => 1); -- Reset due to wake up from System OFF mode when wakeup is triggered from -- ANADETECT signal from LPCOMP type RESETREAS_LPCOMP_Field is (-- Not detected Notdetected, -- Detected Detected) with Size => 1; for RESETREAS_LPCOMP_Field use (Notdetected => 0, Detected => 1); -- Reset due to wake up from System OFF mode when wakeup is triggered from -- entering into debug interface mode type RESETREAS_DIF_Field is (-- Not detected Notdetected, -- Detected Detected) with Size => 1; for RESETREAS_DIF_Field use (Notdetected => 0, Detected => 1); -- Reset due to wake up from System OFF mode by NFC field detect type RESETREAS_NFC_Field is (-- Not detected Notdetected, -- Detected Detected) with Size => 1; for RESETREAS_NFC_Field use (Notdetected => 0, Detected => 1); -- Reset reason type RESETREAS_Register is record -- Reset from pin-reset detected RESETPIN : RESETREAS_RESETPIN_Field := NRF_SVD.POWER.Notdetected; -- Reset from watchdog detected DOG : RESETREAS_DOG_Field := NRF_SVD.POWER.Notdetected; -- Reset from soft reset detected SREQ : RESETREAS_SREQ_Field := NRF_SVD.POWER.Notdetected; -- Reset from CPU lock-up detected LOCKUP : RESETREAS_LOCKUP_Field := NRF_SVD.POWER.Notdetected; -- unspecified Reserved_4_15 : HAL.UInt12 := 16#0#; -- Reset due to wake up from System OFF mode when wakeup is triggered -- from DETECT signal from GPIO OFF : RESETREAS_OFF_Field := NRF_SVD.POWER.Notdetected; -- Reset due to wake up from System OFF mode when wakeup is triggered -- from ANADETECT signal from LPCOMP LPCOMP : RESETREAS_LPCOMP_Field := NRF_SVD.POWER.Notdetected; -- Reset due to wake up from System OFF mode when wakeup is triggered -- from entering into debug interface mode DIF : RESETREAS_DIF_Field := NRF_SVD.POWER.Notdetected; -- Reset due to wake up from System OFF mode by NFC field detect NFC : RESETREAS_NFC_Field := NRF_SVD.POWER.Notdetected; -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for RESETREAS_Register use record RESETPIN at 0 range 0 .. 0; DOG at 0 range 1 .. 1; SREQ at 0 range 2 .. 2; LOCKUP at 0 range 3 .. 3; Reserved_4_15 at 0 range 4 .. 15; OFF at 0 range 16 .. 16; LPCOMP at 0 range 17 .. 17; DIF at 0 range 18 .. 18; NFC at 0 range 19 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; -- RAM block 0 is on or off/powering up type RAMSTATUS_RAMBLOCK0_Field is (-- Off Off, -- On On) with Size => 1; for RAMSTATUS_RAMBLOCK0_Field use (Off => 0, On => 1); -- RAMSTATUS_RAMBLOCK array type RAMSTATUS_RAMBLOCK_Field_Array is array (0 .. 3) of RAMSTATUS_RAMBLOCK0_Field with Component_Size => 1, Size => 4; -- Type definition for RAMSTATUS_RAMBLOCK type RAMSTATUS_RAMBLOCK_Field (As_Array : Boolean := False) is record case As_Array is when False => -- RAMBLOCK as a value Val : HAL.UInt4; when True => -- RAMBLOCK as an array Arr : RAMSTATUS_RAMBLOCK_Field_Array; end case; end record with Unchecked_Union, Size => 4; for RAMSTATUS_RAMBLOCK_Field use record Val at 0 range 0 .. 3; Arr at 0 range 0 .. 3; end record; -- Deprecated register - RAM status register type RAMSTATUS_Register is record -- Read-only. RAM block 0 is on or off/powering up RAMBLOCK : RAMSTATUS_RAMBLOCK_Field; -- unspecified Reserved_4_31 : HAL.UInt28; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for RAMSTATUS_Register use record RAMBLOCK at 0 range 0 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; -- Enable System OFF mode type SYSTEMOFF_SYSTEMOFF_Field is (-- Reset value for the field Systemoff_Systemoff_Field_Reset, -- Enable System OFF mode Enter) with Size => 1; for SYSTEMOFF_SYSTEMOFF_Field use (Systemoff_Systemoff_Field_Reset => 0, Enter => 1); -- System OFF register type SYSTEMOFF_Register is record -- Write-only. Enable System OFF mode SYSTEMOFF : SYSTEMOFF_SYSTEMOFF_Field := Systemoff_Systemoff_Field_Reset; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SYSTEMOFF_Register use record SYSTEMOFF at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- Enable or disable power failure comparator type POFCON_POF_Field is (-- Disable Disabled, -- Enable Enabled) with Size => 1; for POFCON_POF_Field use (Disabled => 0, Enabled => 1); -- Power failure comparator threshold setting type POFCON_THRESHOLD_Field is (-- Reset value for the field Pofcon_Threshold_Field_Reset, -- Set threshold to 1.7 V V17, -- Set threshold to 1.8 V V18, -- Set threshold to 1.9 V V19, -- Set threshold to 2.0 V V20, -- Set threshold to 2.1 V V21, -- Set threshold to 2.2 V V22, -- Set threshold to 2.3 V V23, -- Set threshold to 2.4 V V24, -- Set threshold to 2.5 V V25, -- Set threshold to 2.6 V V26, -- Set threshold to 2.7 V V27, -- Set threshold to 2.8 V V28) with Size => 4; for POFCON_THRESHOLD_Field use (Pofcon_Threshold_Field_Reset => 0, V17 => 4, V18 => 5, V19 => 6, V20 => 7, V21 => 8, V22 => 9, V23 => 10, V24 => 11, V25 => 12, V26 => 13, V27 => 14, V28 => 15); -- Power failure comparator configuration type POFCON_Register is record -- Enable or disable power failure comparator POF : POFCON_POF_Field := NRF_SVD.POWER.Disabled; -- Power failure comparator threshold setting THRESHOLD : POFCON_THRESHOLD_Field := Pofcon_Threshold_Field_Reset; -- unspecified Reserved_5_31 : HAL.UInt27 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for POFCON_Register use record POF at 0 range 0 .. 0; THRESHOLD at 0 range 1 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; subtype GPREGRET_GPREGRET_Field is HAL.UInt8; -- General purpose retention register type GPREGRET_Register is record -- General purpose retention register GPREGRET : GPREGRET_GPREGRET_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for GPREGRET_Register use record GPREGRET at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- Keep RAM block 0 on or off in system ON Mode type RAMON_ONRAM0_Field is (-- Off Ram0Off, -- On Ram0On) with Size => 1; for RAMON_ONRAM0_Field use (Ram0Off => 0, Ram0On => 1); -- Keep RAM block 1 on or off in system ON Mode type RAMON_ONRAM1_Field is (-- Off Ram1Off, -- On Ram1On) with Size => 1; for RAMON_ONRAM1_Field use (Ram1Off => 0, Ram1On => 1); -- Keep retention on RAM block 0 when RAM block is switched off type RAMON_OFFRAM0_Field is (-- Off Ram0Off, -- On Ram0On) with Size => 1; for RAMON_OFFRAM0_Field use (Ram0Off => 0, Ram0On => 1); -- Keep retention on RAM block 1 when RAM block is switched off type RAMON_OFFRAM1_Field is (-- Off Ram1Off, -- On Ram1On) with Size => 1; for RAMON_OFFRAM1_Field use (Ram1Off => 0, Ram1On => 1); -- Deprecated register - RAM on/off register (this register is retained) type RAMON_Register is record -- Keep RAM block 0 on or off in system ON Mode ONRAM0 : RAMON_ONRAM0_Field := NRF_SVD.POWER.Ram0On; -- Keep RAM block 1 on or off in system ON Mode ONRAM1 : RAMON_ONRAM1_Field := NRF_SVD.POWER.Ram1On; -- unspecified Reserved_2_15 : HAL.UInt14 := 16#0#; -- Keep retention on RAM block 0 when RAM block is switched off OFFRAM0 : RAMON_OFFRAM0_Field := NRF_SVD.POWER.Ram0Off; -- Keep retention on RAM block 1 when RAM block is switched off OFFRAM1 : RAMON_OFFRAM1_Field := NRF_SVD.POWER.Ram1Off; -- unspecified Reserved_18_31 : HAL.UInt14 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for RAMON_Register use record ONRAM0 at 0 range 0 .. 0; ONRAM1 at 0 range 1 .. 1; Reserved_2_15 at 0 range 2 .. 15; OFFRAM0 at 0 range 16 .. 16; OFFRAM1 at 0 range 17 .. 17; Reserved_18_31 at 0 range 18 .. 31; end record; -- Keep RAM block 2 on or off in system ON Mode type RAMONB_ONRAM2_Field is (-- Off Ram2Off, -- On Ram2On) with Size => 1; for RAMONB_ONRAM2_Field use (Ram2Off => 0, Ram2On => 1); -- Keep RAM block 3 on or off in system ON Mode type RAMONB_ONRAM3_Field is (-- Off Ram3Off, -- On Ram3On) with Size => 1; for RAMONB_ONRAM3_Field use (Ram3Off => 0, Ram3On => 1); -- Keep retention on RAM block 2 when RAM block is switched off type RAMONB_OFFRAM2_Field is (-- Off Ram2Off, -- On Ram2On) with Size => 1; for RAMONB_OFFRAM2_Field use (Ram2Off => 0, Ram2On => 1); -- Keep retention on RAM block 3 when RAM block is switched off type RAMONB_OFFRAM3_Field is (-- Off Ram3Off, -- On Ram3On) with Size => 1; for RAMONB_OFFRAM3_Field use (Ram3Off => 0, Ram3On => 1); -- Deprecated register - RAM on/off register (this register is retained) type RAMONB_Register is record -- Keep RAM block 2 on or off in system ON Mode ONRAM2 : RAMONB_ONRAM2_Field := NRF_SVD.POWER.Ram2On; -- Keep RAM block 3 on or off in system ON Mode ONRAM3 : RAMONB_ONRAM3_Field := NRF_SVD.POWER.Ram3On; -- unspecified Reserved_2_15 : HAL.UInt14 := 16#0#; -- Keep retention on RAM block 2 when RAM block is switched off OFFRAM2 : RAMONB_OFFRAM2_Field := NRF_SVD.POWER.Ram2Off; -- Keep retention on RAM block 3 when RAM block is switched off OFFRAM3 : RAMONB_OFFRAM3_Field := NRF_SVD.POWER.Ram3Off; -- unspecified Reserved_18_31 : HAL.UInt14 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for RAMONB_Register use record ONRAM2 at 0 range 0 .. 0; ONRAM3 at 0 range 1 .. 1; Reserved_2_15 at 0 range 2 .. 15; OFFRAM2 at 0 range 16 .. 16; OFFRAM3 at 0 range 17 .. 17; Reserved_18_31 at 0 range 18 .. 31; end record; -- Enable or disable DC/DC converter type DCDCEN_DCDCEN_Field is (-- Disable Disabled, -- Enable Enabled) with Size => 1; for DCDCEN_DCDCEN_Field use (Disabled => 0, Enabled => 1); -- DC/DC enable register type DCDCEN_Register is record -- Enable or disable DC/DC converter DCDCEN : DCDCEN_DCDCEN_Field := NRF_SVD.POWER.Disabled; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DCDCEN_Register use record DCDCEN at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; ----------------------------- -- RAM cluster's Registers -- ----------------------------- -- Keep RAM section S0 ON or OFF in System ON mode. type POWER_S0POWER_Field is (-- Off Off, -- On On) with Size => 1; for POWER_S0POWER_Field use (Off => 0, On => 1); -- Keep RAM section S1 ON or OFF in System ON mode. type POWER_S1POWER_Field is (-- Off Off, -- On On) with Size => 1; for POWER_S1POWER_Field use (Off => 0, On => 1); -- Keep retention on RAM section S0 when RAM section is in OFF type POWER_S0RETENTION_Field is (-- Off Off, -- On On) with Size => 1; for POWER_S0RETENTION_Field use (Off => 0, On => 1); -- Keep retention on RAM section S1 when RAM section is in OFF type POWER_S1RETENTION_Field is (-- Off Off, -- On On) with Size => 1; for POWER_S1RETENTION_Field use (Off => 0, On => 1); -- Description cluster[0]: RAM0 power control register type POWER_RAM_Register is record -- Keep RAM section S0 ON or OFF in System ON mode. S0POWER : POWER_S0POWER_Field := NRF_SVD.POWER.On; -- Keep RAM section S1 ON or OFF in System ON mode. S1POWER : POWER_S1POWER_Field := NRF_SVD.POWER.On; -- unspecified Reserved_2_15 : HAL.UInt14 := 16#3FFF#; -- Keep retention on RAM section S0 when RAM section is in OFF S0RETENTION : POWER_S0RETENTION_Field := NRF_SVD.POWER.Off; -- Keep retention on RAM section S1 when RAM section is in OFF S1RETENTION : POWER_S1RETENTION_Field := NRF_SVD.POWER.Off; -- unspecified Reserved_18_31 : HAL.UInt14 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for POWER_RAM_Register use record S0POWER at 0 range 0 .. 0; S1POWER at 0 range 1 .. 1; Reserved_2_15 at 0 range 2 .. 15; S0RETENTION at 0 range 16 .. 16; S1RETENTION at 0 range 17 .. 17; Reserved_18_31 at 0 range 18 .. 31; end record; -- Keep RAM section S0 of RAM0 on or off in System ON mode type POWERSET_S0POWER_Field is (-- On On) with Size => 1; for POWERSET_S0POWER_Field use (On => 1); -- Keep RAM section S1 of RAM0 on or off in System ON mode type POWERSET_S1POWER_Field is (-- On On) with Size => 1; for POWERSET_S1POWER_Field use (On => 1); -- Keep retention on RAM section S0 when RAM section is switched off type POWERSET_S0RETENTION_Field is (-- Reset value for the field Powerset_S0Retention_Field_Reset, -- On On) with Size => 1; for POWERSET_S0RETENTION_Field use (Powerset_S0Retention_Field_Reset => 0, On => 1); -- Keep retention on RAM section S1 when RAM section is switched off type POWERSET_S1RETENTION_Field is (-- Reset value for the field Powerset_S1Retention_Field_Reset, -- On On) with Size => 1; for POWERSET_S1RETENTION_Field use (Powerset_S1Retention_Field_Reset => 0, On => 1); -- Description cluster[0]: RAM0 power control set register type POWERSET_RAM_Register is record -- Write-only. Keep RAM section S0 of RAM0 on or off in System ON mode S0POWER : POWERSET_S0POWER_Field := NRF_SVD.POWER.On; -- Write-only. Keep RAM section S1 of RAM0 on or off in System ON mode S1POWER : POWERSET_S1POWER_Field := NRF_SVD.POWER.On; -- unspecified Reserved_2_15 : HAL.UInt14 := 16#3FFF#; -- Write-only. Keep retention on RAM section S0 when RAM section is -- switched off S0RETENTION : POWERSET_S0RETENTION_Field := Powerset_S0Retention_Field_Reset; -- Write-only. Keep retention on RAM section S1 when RAM section is -- switched off S1RETENTION : POWERSET_S1RETENTION_Field := Powerset_S1Retention_Field_Reset; -- unspecified Reserved_18_31 : HAL.UInt14 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for POWERSET_RAM_Register use record S0POWER at 0 range 0 .. 0; S1POWER at 0 range 1 .. 1; Reserved_2_15 at 0 range 2 .. 15; S0RETENTION at 0 range 16 .. 16; S1RETENTION at 0 range 17 .. 17; Reserved_18_31 at 0 range 18 .. 31; end record; -- Keep RAM section S0 of RAM0 on or off in System ON mode type POWERCLR_S0POWER_Field is (-- Off Off) with Size => 1; for POWERCLR_S0POWER_Field use (Off => 1); -- Keep RAM section S1 of RAM0 on or off in System ON mode type POWERCLR_S1POWER_Field is (-- Off Off) with Size => 1; for POWERCLR_S1POWER_Field use (Off => 1); -- Keep retention on RAM section S0 when RAM section is switched off type POWERCLR_S0RETENTION_Field is (-- Reset value for the field Powerclr_S0Retention_Field_Reset, -- Off Off) with Size => 1; for POWERCLR_S0RETENTION_Field use (Powerclr_S0Retention_Field_Reset => 0, Off => 1); -- Keep retention on RAM section S1 when RAM section is switched off type POWERCLR_S1RETENTION_Field is (-- Reset value for the field Powerclr_S1Retention_Field_Reset, -- Off Off) with Size => 1; for POWERCLR_S1RETENTION_Field use (Powerclr_S1Retention_Field_Reset => 0, Off => 1); -- Description cluster[0]: RAM0 power control clear register type POWERCLR_RAM_Register is record -- Write-only. Keep RAM section S0 of RAM0 on or off in System ON mode S0POWER : POWERCLR_S0POWER_Field := NRF_SVD.POWER.Off; -- Write-only. Keep RAM section S1 of RAM0 on or off in System ON mode S1POWER : POWERCLR_S1POWER_Field := NRF_SVD.POWER.Off; -- unspecified Reserved_2_15 : HAL.UInt14 := 16#3FFF#; -- Write-only. Keep retention on RAM section S0 when RAM section is -- switched off S0RETENTION : POWERCLR_S0RETENTION_Field := Powerclr_S0Retention_Field_Reset; -- Write-only. Keep retention on RAM section S1 when RAM section is -- switched off S1RETENTION : POWERCLR_S1RETENTION_Field := Powerclr_S1Retention_Field_Reset; -- unspecified Reserved_18_31 : HAL.UInt14 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for POWERCLR_RAM_Register use record S0POWER at 0 range 0 .. 0; S1POWER at 0 range 1 .. 1; Reserved_2_15 at 0 range 2 .. 15; S0RETENTION at 0 range 16 .. 16; S1RETENTION at 0 range 17 .. 17; Reserved_18_31 at 0 range 18 .. 31; end record; -- Unspecified type RAM_Cluster is record -- Description cluster[0]: RAM0 power control register POWER : aliased POWER_RAM_Register; -- Description cluster[0]: RAM0 power control set register POWERSET : aliased POWERSET_RAM_Register; -- Description cluster[0]: RAM0 power control clear register POWERCLR : aliased POWERCLR_RAM_Register; end record with Size => 96; for RAM_Cluster use record POWER at 16#0# range 0 .. 31; POWERSET at 16#4# range 0 .. 31; POWERCLR at 16#8# range 0 .. 31; end record; -- Unspecified type RAM_Clusters is array (0 .. 7) of RAM_Cluster; ----------------- -- Peripherals -- ----------------- -- Power control type POWER_Peripheral is record -- Enable constant latency mode TASKS_CONSTLAT : aliased HAL.UInt32; -- Enable low power mode (variable latency) TASKS_LOWPWR : aliased HAL.UInt32; -- Power failure warning EVENTS_POFWARN : aliased HAL.UInt32; -- CPU entered WFI/WFE sleep EVENTS_SLEEPENTER : aliased HAL.UInt32; -- CPU exited WFI/WFE sleep EVENTS_SLEEPEXIT : aliased HAL.UInt32; -- Enable interrupt INTENSET : aliased INTENSET_Register; -- Disable interrupt INTENCLR : aliased INTENCLR_Register; -- Reset reason RESETREAS : aliased RESETREAS_Register; -- Deprecated register - RAM status register RAMSTATUS : aliased RAMSTATUS_Register; -- System OFF register SYSTEMOFF : aliased SYSTEMOFF_Register; -- Power failure comparator configuration POFCON : aliased POFCON_Register; -- General purpose retention register GPREGRET : aliased GPREGRET_Register; -- General purpose retention register GPREGRET2 : aliased GPREGRET_Register; -- Deprecated register - RAM on/off register (this register is retained) RAMON : aliased RAMON_Register; -- Deprecated register - RAM on/off register (this register is retained) RAMONB : aliased RAMONB_Register; -- DC/DC enable register DCDCEN : aliased DCDCEN_Register; -- Unspecified RAM : aliased RAM_Clusters; end record with Volatile; for POWER_Peripheral use record TASKS_CONSTLAT at 16#78# range 0 .. 31; TASKS_LOWPWR at 16#7C# range 0 .. 31; EVENTS_POFWARN at 16#108# range 0 .. 31; EVENTS_SLEEPENTER at 16#114# range 0 .. 31; EVENTS_SLEEPEXIT at 16#118# range 0 .. 31; INTENSET at 16#304# range 0 .. 31; INTENCLR at 16#308# range 0 .. 31; RESETREAS at 16#400# range 0 .. 31; RAMSTATUS at 16#428# range 0 .. 31; SYSTEMOFF at 16#500# range 0 .. 31; POFCON at 16#510# range 0 .. 31; GPREGRET at 16#51C# range 0 .. 31; GPREGRET2 at 16#520# range 0 .. 31; RAMON at 16#524# range 0 .. 31; RAMONB at 16#554# range 0 .. 31; DCDCEN at 16#578# range 0 .. 31; RAM at 16#900# range 0 .. 767; end record; -- Power control POWER_Periph : aliased POWER_Peripheral with Import, Address => POWER_Base; end NRF_SVD.POWER;
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- package Program.Storage_Pools.Instance is Pool : aliased Storage_Pool; Pool_Access : constant Storage_Pool_Access := Pool'Access with Export, External_Name => "pool_access"; end Program.Storage_Pools.Instance;
generic type T is private; package Prot2_Pkg2 is type Id is private; procedure Create (B : out Id); procedure Delete (B : in out Id); private type Rec; type Id is access Rec; end Prot2_Pkg2;
pragma Style_Checks (Off); -- This spec has been automatically generated from STM32G474xx.svd pragma Restrictions (No_Elaboration_Code); with HAL; with System; package STM32_SVD.TAMP is pragma Preelaborate; --------------- -- Registers -- --------------- -- control register 1 type CR1_Register is record -- TAMP1E TAMP1E : Boolean := False; -- TAMP2E TAMP2E : Boolean := False; -- TAMP2E TAMP3E : Boolean := False; -- unspecified Reserved_3_17 : HAL.UInt15 := 16#6000#; -- ITAMP3E ITAMP3E : Boolean := True; -- ITAMP4E ITAMP4E : Boolean := True; -- ITAMP5E ITAMP5E : Boolean := True; -- ITAMP6E ITAMP6E : Boolean := True; -- unspecified Reserved_22_31 : HAL.UInt10 := 16#3FF#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CR1_Register use record TAMP1E at 0 range 0 .. 0; TAMP2E at 0 range 1 .. 1; TAMP3E at 0 range 2 .. 2; Reserved_3_17 at 0 range 3 .. 17; ITAMP3E at 0 range 18 .. 18; ITAMP4E at 0 range 19 .. 19; ITAMP5E at 0 range 20 .. 20; ITAMP6E at 0 range 21 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; -- control register 2 type CR2_Register is record -- TAMP1NOER TAMP1NOER : Boolean := False; -- TAMP2NOER TAMP2NOER : Boolean := False; -- TAMP3NOER TAMP3NOER : Boolean := False; -- unspecified Reserved_3_15 : HAL.UInt13 := 16#0#; -- TAMP1MSK TAMP1MSK : Boolean := False; -- TAMP2MSK TAMP2MSK : Boolean := False; -- TAMP3MSK TAMP3MSK : Boolean := False; -- unspecified Reserved_19_23 : HAL.UInt5 := 16#0#; -- TAMP1TRG TAMP1TRG : Boolean := False; -- TAMP2TRG TAMP2TRG : Boolean := False; -- TAMP3TRG TAMP3TRG : Boolean := False; -- unspecified Reserved_27_31 : HAL.UInt5 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CR2_Register use record TAMP1NOER at 0 range 0 .. 0; TAMP2NOER at 0 range 1 .. 1; TAMP3NOER at 0 range 2 .. 2; Reserved_3_15 at 0 range 3 .. 15; TAMP1MSK at 0 range 16 .. 16; TAMP2MSK at 0 range 17 .. 17; TAMP3MSK at 0 range 18 .. 18; Reserved_19_23 at 0 range 19 .. 23; TAMP1TRG at 0 range 24 .. 24; TAMP2TRG at 0 range 25 .. 25; TAMP3TRG at 0 range 26 .. 26; Reserved_27_31 at 0 range 27 .. 31; end record; subtype FLTCR_TAMPFREQ_Field is HAL.UInt3; subtype FLTCR_TAMPFLT_Field is HAL.UInt2; subtype FLTCR_TAMPPRCH_Field is HAL.UInt2; -- TAMP filter control register type FLTCR_Register is record -- TAMPFREQ TAMPFREQ : FLTCR_TAMPFREQ_Field := 16#0#; -- TAMPFLT TAMPFLT : FLTCR_TAMPFLT_Field := 16#0#; -- TAMPPRCH TAMPPRCH : FLTCR_TAMPPRCH_Field := 16#0#; -- TAMPPUDIS TAMPPUDIS : Boolean := False; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for FLTCR_Register use record TAMPFREQ at 0 range 0 .. 2; TAMPFLT at 0 range 3 .. 4; TAMPPRCH at 0 range 5 .. 6; TAMPPUDIS at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- TAMP interrupt enable register type IER_Register is record -- TAMP1IE TAMP1IE : Boolean := False; -- TAMP2IE TAMP2IE : Boolean := False; -- TAMP3IE TAMP3IE : Boolean := False; -- unspecified Reserved_3_17 : HAL.UInt15 := 16#0#; -- ITAMP3IE ITAMP3IE : Boolean := False; -- ITAMP4IE ITAMP4IE : Boolean := False; -- ITAMP5IE ITAMP5IE : Boolean := False; -- ITAMP6IE ITAMP6IE : Boolean := False; -- unspecified Reserved_22_31 : HAL.UInt10 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for IER_Register use record TAMP1IE at 0 range 0 .. 0; TAMP2IE at 0 range 1 .. 1; TAMP3IE at 0 range 2 .. 2; Reserved_3_17 at 0 range 3 .. 17; ITAMP3IE at 0 range 18 .. 18; ITAMP4IE at 0 range 19 .. 19; ITAMP5IE at 0 range 20 .. 20; ITAMP6IE at 0 range 21 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; -- TAMP status register type SR_Register is record -- Read-only. TAMP1F TAMP1F : Boolean; -- Read-only. TAMP2F TAMP2F : Boolean; -- Read-only. TAMP3F TAMP3F : Boolean; -- unspecified Reserved_3_17 : HAL.UInt15; -- Read-only. ITAMP3F ITAMP3F : Boolean; -- Read-only. ITAMP4F ITAMP4F : Boolean; -- Read-only. ITAMP5F ITAMP5F : Boolean; -- Read-only. ITAMP6F ITAMP6F : Boolean; -- unspecified Reserved_22_31 : HAL.UInt10; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record TAMP1F at 0 range 0 .. 0; TAMP2F at 0 range 1 .. 1; TAMP3F at 0 range 2 .. 2; Reserved_3_17 at 0 range 3 .. 17; ITAMP3F at 0 range 18 .. 18; ITAMP4F at 0 range 19 .. 19; ITAMP5F at 0 range 20 .. 20; ITAMP6F at 0 range 21 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; -- TAMP masked interrupt status register type MISR_Register is record -- Read-only. TAMP1MF: TAMP1MF : Boolean; -- Read-only. TAMP2MF TAMP2MF : Boolean; -- Read-only. TAMP3MF TAMP3MF : Boolean; -- unspecified Reserved_3_17 : HAL.UInt15; -- Read-only. ITAMP3MF ITAMP3MF : Boolean; -- Read-only. ITAMP4MF ITAMP4MF : Boolean; -- Read-only. ITAMP5MF ITAMP5MF : Boolean; -- Read-only. ITAMP6MF ITAMP6MF : Boolean; -- unspecified Reserved_22_31 : HAL.UInt10; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MISR_Register use record TAMP1MF at 0 range 0 .. 0; TAMP2MF at 0 range 1 .. 1; TAMP3MF at 0 range 2 .. 2; Reserved_3_17 at 0 range 3 .. 17; ITAMP3MF at 0 range 18 .. 18; ITAMP4MF at 0 range 19 .. 19; ITAMP5MF at 0 range 20 .. 20; ITAMP6MF at 0 range 21 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; -- TAMP status clear register type SCR_Register is record -- CTAMP1F CTAMP1F : Boolean := False; -- CTAMP2F CTAMP2F : Boolean := False; -- CTAMP3F CTAMP3F : Boolean := False; -- unspecified Reserved_3_17 : HAL.UInt15 := 16#0#; -- CITAMP3F CITAMP3F : Boolean := False; -- CITAMP4F CITAMP4F : Boolean := False; -- CITAMP5F CITAMP5F : Boolean := False; -- CITAMP6F CITAMP6F : Boolean := False; -- unspecified Reserved_22_31 : HAL.UInt10 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SCR_Register use record CTAMP1F at 0 range 0 .. 0; CTAMP2F at 0 range 1 .. 1; CTAMP3F at 0 range 2 .. 2; Reserved_3_17 at 0 range 3 .. 17; CITAMP3F at 0 range 18 .. 18; CITAMP4F at 0 range 19 .. 19; CITAMP5F at 0 range 20 .. 20; CITAMP6F at 0 range 21 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Tamper and backup registers type TAMP_Peripheral is record -- control register 1 CR1 : aliased CR1_Register; -- control register 2 CR2 : aliased CR2_Register; -- TAMP filter control register FLTCR : aliased FLTCR_Register; -- TAMP interrupt enable register IER : aliased IER_Register; -- TAMP status register SR : aliased SR_Register; -- TAMP masked interrupt status register MISR : aliased MISR_Register; -- TAMP status clear register SCR : aliased SCR_Register; -- TAMP backup register BKP0R : aliased HAL.UInt32; -- TAMP backup register BKP1R : aliased HAL.UInt32; -- TAMP backup register BKP2R : aliased HAL.UInt32; -- TAMP backup register BKP3R : aliased HAL.UInt32; -- TAMP backup register BKP4R : aliased HAL.UInt32; -- TAMP backup register BKP5R : aliased HAL.UInt32; -- TAMP backup register BKP6R : aliased HAL.UInt32; -- TAMP backup register BKP7R : aliased HAL.UInt32; -- TAMP backup register BKP8R : aliased HAL.UInt32; -- TAMP backup register BKP9R : aliased HAL.UInt32; -- TAMP backup register BKP10R : aliased HAL.UInt32; -- TAMP backup register BKP11R : aliased HAL.UInt32; -- TAMP backup register BKP12R : aliased HAL.UInt32; -- TAMP backup register BKP13R : aliased HAL.UInt32; -- TAMP backup register BKP14R : aliased HAL.UInt32; -- TAMP backup register BKP15R : aliased HAL.UInt32; -- TAMP backup register BKP16R : aliased HAL.UInt32; -- TAMP backup register BKP17R : aliased HAL.UInt32; -- TAMP backup register BKP18R : aliased HAL.UInt32; -- TAMP backup register BKP19R : aliased HAL.UInt32; -- TAMP backup register BKP20R : aliased HAL.UInt32; -- TAMP backup register BKP21R : aliased HAL.UInt32; -- TAMP backup register BKP22R : aliased HAL.UInt32; -- TAMP backup register BKP23R : aliased HAL.UInt32; -- TAMP backup register BKP24R : aliased HAL.UInt32; -- TAMP backup register BKP25R : aliased HAL.UInt32; -- TAMP backup register BKP26R : aliased HAL.UInt32; -- TAMP backup register BKP27R : aliased HAL.UInt32; -- TAMP backup register BKP28R : aliased HAL.UInt32; -- TAMP backup register BKP29R : aliased HAL.UInt32; -- TAMP backup register BKP30R : aliased HAL.UInt32; -- TAMP backup register BKP31R : aliased HAL.UInt32; end record with Volatile; for TAMP_Peripheral use record CR1 at 16#0# range 0 .. 31; CR2 at 16#4# range 0 .. 31; FLTCR at 16#C# range 0 .. 31; IER at 16#2C# range 0 .. 31; SR at 16#30# range 0 .. 31; MISR at 16#34# range 0 .. 31; SCR at 16#3C# range 0 .. 31; BKP0R at 16#100# range 0 .. 31; BKP1R at 16#104# range 0 .. 31; BKP2R at 16#108# range 0 .. 31; BKP3R at 16#10C# range 0 .. 31; BKP4R at 16#110# range 0 .. 31; BKP5R at 16#114# range 0 .. 31; BKP6R at 16#118# range 0 .. 31; BKP7R at 16#11C# range 0 .. 31; BKP8R at 16#120# range 0 .. 31; BKP9R at 16#124# range 0 .. 31; BKP10R at 16#128# range 0 .. 31; BKP11R at 16#12C# range 0 .. 31; BKP12R at 16#130# range 0 .. 31; BKP13R at 16#134# range 0 .. 31; BKP14R at 16#138# range 0 .. 31; BKP15R at 16#13C# range 0 .. 31; BKP16R at 16#140# range 0 .. 31; BKP17R at 16#144# range 0 .. 31; BKP18R at 16#148# range 0 .. 31; BKP19R at 16#14C# range 0 .. 31; BKP20R at 16#150# range 0 .. 31; BKP21R at 16#154# range 0 .. 31; BKP22R at 16#158# range 0 .. 31; BKP23R at 16#15C# range 0 .. 31; BKP24R at 16#160# range 0 .. 31; BKP25R at 16#164# range 0 .. 31; BKP26R at 16#168# range 0 .. 31; BKP27R at 16#16C# range 0 .. 31; BKP28R at 16#170# range 0 .. 31; BKP29R at 16#174# range 0 .. 31; BKP30R at 16#178# range 0 .. 31; BKP31R at 16#17C# range 0 .. 31; end record; -- Tamper and backup registers TAMP_Periph : aliased TAMP_Peripheral with Import, Address => TAMP_Base; end STM32_SVD.TAMP;
with Interfaces; with Atomic.Signed; package Atomic.Signed_32 is new Atomic.Signed (Interfaces.Integer_32);
package body Lto13_Pkg is procedure Proc is begin raise Constraint_Error; end; type T is null record; end Lto13_Pkg;
with Interfaces.C.Strings; with Tkmrpc.Types; with Tkmrpc.Results; package Tkmrpc.Clients.Ees is procedure Init (Result : out Results.Result_Type; Address : Interfaces.C.Strings.chars_ptr); pragma Export (C, Init, "ees_init"); pragma Export_Valued_Procedure (Init); -- Initialize EES client with given address. procedure Esa_Acquire (Result : out Results.Result_Type; Sp_Id : Types.Sp_Id_Type); pragma Export (C, Esa_Acquire, "ees_esa_acquire"); pragma Export_Valued_Procedure (Esa_Acquire, Mechanism => (Sp_Id => Value)); -- Trigger 'Acquire' event for an ESP SA. procedure Esa_Expire (Result : out Results.Result_Type; Sp_Id : Types.Sp_Id_Type; Spi_Rem : Types.Esp_Spi_Type; Protocol : Types.Protocol_Type; Hard : Types.Expiry_Flag_Type); pragma Export (C, Esa_Expire, "ees_esa_expire"); pragma Export_Valued_Procedure (Esa_Expire, Mechanism => (Sp_Id => Value, Spi_Rem => Value, Protocol => Value, Hard => Value)); -- Trigger 'Expire' event for an ESP SA. end Tkmrpc.Clients.Ees;
-- -- The author disclaims copyright to this source code. In place of -- a legal notice, here is a blessing: -- -- May you do good and not evil. -- May you find forgiveness for yourself and forgive others. -- May you share freely, not taking more than you give. -- with Ada.Text_IO; with Types; package Templates is subtype File_Type is Ada.Text_IO.File_Type; subtype Line_Number is Types.Line_Number; procedure Transfer (File : File_Type; Name : String; Line : in out Line_Number); -- procedure Open (User_Template : String; Error_Count : in out Integer; Success : out Integer); -- Thisk function finds the template file and opens it. File handle -- is located in the context structure. procedure Line_Directive (File : File_Type; Line : Line_Number; File_Name : String); -- Put line directive to File. Like '#line <Line> "<File_Name>"'. procedure Print (File : File_Type; Out_Name : String; No_Line_Numbers : Boolean; Include : String; Line : in out Line_Number); end Templates;
with Ada.Exceptions; with Ada.Text_IO; -- For int."+": with Interfaces.C; package body A_Nodes is Module_Name : constant String := "A_Nodes"; package AEX renames Ada.Exceptions; package ATI renames Ada.Text_IO; -- Checks to be sure no Unit with this ID has already been pushed. Raises -- Usage_Error if so. procedure Check_Unit_Node (This : access Class; Unit : in a_nodes_h.Unit_Struct) is Parent_Name : constant String := Module_Name; Module_Name : constant String := Parent_Name & ".Check_Unit_Node"; ID : constant a_nodes_h.Unit_ID := Unit.ID; use type Interfaces.C.int; begin if This.Unit_IDs.Contains (ID) then raise Usage_Error with Module_Name & ": Tried to push second Unit with ID => " & ID'Image; else This.Unit_IDs.Insert (ID); if ID > This.Highest_Unit_ID then This.Highest_Unit_ID := ID; end if; end if; end Check_Unit_Node; -- Checks to be sure no Element with this ID has already been pushed. Raises -- Usage_Error if so. procedure Check_Element_Node (This : access Class; Element : in a_nodes_h.Element_Struct) is Parent_Name : constant String := Module_Name; Module_Name : constant String := Parent_Name & ".Check_Element_Node"; ID : constant a_nodes_h.Element_ID := Element.ID; use type Interfaces.C.int; begin if This.Element_IDs.Contains (ID) then raise Usage_Error with Module_Name & ": Tried to push second Element with ID => " & ID'Image; else -- TODO: Remove when no longer needed for debug: -- Ada.Text_IO.Put_Line ("a_nodes.Check_Element_Node: ID => " & ID'Image); This.Element_IDs.Insert (ID); if ID > This.Highest_Element_ID then This.Highest_Element_ID := ID; end if; end if; end Check_Element_Node; procedure Print_Exception_Info (Module_Name : in String; X : in AEX.Exception_Occurrence) is begin ATI.Put_Line ((1 .. 40 => '#')); ATI.Put_Line (Module_Name & ": ***EXCEPTION*** " & Aex.Exception_Information (X)); ATI.Put_Line ((1 .. 40 => '#')); end Print_Exception_Info; ------------ -- EXPORTED: ------------ procedure Set (This : access Class; Context : in a_nodes_h.Context_Struct) is begin This.Nodes.Context := Context; end Set; ------------ -- EXPORTED: ------------ procedure Push (This : access Class; Unit : in a_nodes_h.Unit_Struct) is Parent_Name : constant String := Module_Name; Module_Name : constant String := Parent_Name & ".Push"; List_Node : a_nodes_h.Unit_Struct_List_Struct := a_nodes_h.Support.Default_Unit_Struct_List_Struct; use type Interfaces.C.int; use type a_nodes_h.Unit_Structs_Ptr; begin begin Check_Unit_Node (This, Unit); exception when X : Usage_Error => Print_Exception_Info (Module_Name, X); raise; end; List_Node.Unit := Unit; if This.Nodes.Units = null then List_Node.Next := null; List_Node.Next_Count := 0; else List_Node.Next := This.Nodes.Units; List_Node.Next_Count := This.Nodes.Units.Next_Count + 1; end if; This.Nodes.Units := new a_nodes_h.Unit_Struct_List_Struct'(List_Node); end Push; ------------ -- EXPORTED: ------------ procedure Push (This : access Class; Element : in a_nodes_h.Element_Struct) is Parent_Name : constant String := Module_Name; Module_Name : constant String := Parent_Name & ".Push"; List_Node : a_nodes_h.Element_Struct_List_Struct := a_nodes_h.Support.Default_Element_Struct_List_Struct; use type Interfaces.C.int; use type a_nodes_h.Element_Structs_Ptr; begin begin Check_Element_Node (This, Element); exception when X : Usage_Error => Print_Exception_Info (Module_Name, X); raise; end; List_Node.Element := Element; if This.Nodes.Elements = null then List_Node.Next := null; List_Node.Next_Count := 0; else List_Node.Next := This.Nodes.Elements; List_Node.Next_Count := This.Nodes.Elements.Next_Count + 1; end if; This.Nodes.Elements := new a_nodes_h.Element_Struct_List_Struct'(List_Node); end Push; ------------ -- EXPORTED: ------------ procedure Add_Not_Implemented (This : access Class) is begin This.Not_Implemented := This.Not_Implemented + 1; end Add_Not_Implemented; ------------ -- EXPORTED: ------------ function Get_Not_Implemented (This : access Class) return Natural is begin return This.Not_Implemented; end Get_Not_Implemented; ------------ -- EXPORTED: ------------ function Get_Nodes (This : access Class) return a_nodes_h.Nodes_Struct is begin return This.Nodes; end Get_Nodes; ------------ -- EXPORTED: ------------ procedure Print_Stats (This : access Class) is Parent_Name : constant String := Module_Name; Module_Name : constant String := Parent_Name & ".Print_Stats"; procedure Put_Line (Message : in String)is begin ATI.Put_Line (Module_Name & ": " & Message); end Put_Line; begin Put_Line ("Total Units :" & This.Unit_Ids.Length'Image); Put_Line ("Highest Unit ID :" & This.Highest_Unit_ID'Image); Put_Line ("Total Elements :" & This.Element_Ids.Length'Image); Put_Line ("Highest Element ID :" & This.Highest_Element_ID'Image); Put_Line ("Not_Implemented :" & This.Not_Implemented'Image); end Print_Stats; end A_Nodes;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Slim.Menu_Models is ----------- -- Child -- ----------- function Child (Self : Menu_Model'Class; Path : in out Menu_Path) return Boolean is begin if Self.Item_Count (Path) > 0 then Path := (Path.Length + 1, Path.List & 1); return True; else return False; end if; end Child; ---------- -- Next -- ---------- function Next (Self : Menu_Model'Class; Path : in out Menu_Path) return Boolean is begin if Path.Length > 0 and then Path.List (Path.Length) < Self.Item_Count (Self.Parent (Path)) then Path.List (Path.Length) := Path.List (Path.Length) + 1; return True; else return False; end if; end Next; ------------ -- Parent -- ------------ function Parent (Self : Menu_Model'Class; Path : Menu_Path) return Menu_Path is pragma Unreferenced (Self); begin if Path.Length = 0 then return Path; else return (Path.Length - 1, Path.List (1 .. Path.Length - 1)); end if; end Parent; -------------- -- Previous -- -------------- function Previous (Self : Menu_Model'Class; Path : in out Menu_Path) return Boolean is pragma Unreferenced (Self); begin if Path.Length > 0 and then Path.List (Path.Length) > 1 then Path.List (Path.Length) := Path.List (Path.Length) - 1; return True; else return False; end if; end Previous; ---------- -- Root -- ---------- function Root (Self : Menu_Model'Class) return Menu_Path is pragma Unreferenced (Self); begin return (Length => 0, List => <>); end Root; ----------------- -- Starts_With -- ----------------- function Starts_With (Self : Menu_Path; Prefix : Menu_Path) return Boolean is begin return Prefix.Length <= Self.Length and then Prefix.List = Self.List (1 .. Prefix.Length); end Starts_With; ------------ -- Suffix -- ------------ function Suffix (Self : Menu_Path; Prefix : Menu_Path) return Menu_Path is begin return (Self.Length - Prefix.Length, Self.List (Prefix.Length + 1 .. Self.Length)); end Suffix; end Slim.Menu_Models;
with Ada.Text_IO; use Ada.Text_IO; procedure Test is procedure P(A: integer; A: character) is begin New_Line; end; begin P(0,'a'); end;
-- -- Jan & Uwe R. Zimmer, Australia, July 2011 -- with Swarm_Configuration; use Swarm_Configuration; with Swarm_Configurations; use Swarm_Configurations; pragma Elaborate_All (Swarm_Configurations); with Swarm_Structures; use Swarm_Structures; with Swarm_Structures_Base; use Swarm_Structures_Base; package Swarm_Data is -- The Swarm_State is an unprotected, dynamic vector for maximal concurrency. -- Different tasks can update different parts of this vector concurrently. -- Critical operations (like deletions or insertions) -- are handled via the Swarm_Monitor in Swarm_Control. -- Swarm_State : Swarm_Vectors.Vector := Swarm_Vectors.Empty_Vector; Globes : constant Energy_Globes_Protected := Default_Protected_Globes (Configuration); end Swarm_Data;
procedure Function_Renaming is function Increment (I : Integer) return Integer is begin return I + 1; end Increment; function RenamedIncrement (NewI : Integer) return Integer renames Increment; begin null; end Function_Renaming;
with Rejuvenation.Placeholders; use Rejuvenation.Placeholders; with String_Maps; use String_Maps; package Rejuvenation.Replacer is function Replace (Node : Ada_Node'Class; Replacements : Map) return String with Pre => (for all Placeholder_Name of Get_Placeholder_Names (Node) => Replacements.Contains (Placeholder_Name)); end Rejuvenation.Replacer;
package Volatile13 is type Index_Map (Length : Natural) is record Map : String (1 .. Length); end record; type Index_Map_Access is access all Index_Map; pragma Volatile (Index_Map_Access); type Shared_String (Size : Natural) is limited record Length : Natural := 0; Index_Map : Index_Map_Access := null; end record; Shared_Empty : Shared_String := (Size => 64, others => <>); procedure Compute_Index_Map (Self : Shared_String); end Volatile13;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Internals.UML_Multiplicity_Elements; with AMF.Internals.UML_Named_Elements; with AMF.UML.Connectable_Element_Template_Parameters; with AMF.UML.Connector_Ends.Collections; with AMF.UML.Dependencies.Collections; with AMF.UML.Multiplicity_Elements; with AMF.UML.Named_Elements; with AMF.UML.Namespaces; with AMF.UML.Operations; with AMF.UML.Packages.Collections; with AMF.UML.Parameter_Sets.Collections; with AMF.UML.Parameterable_Elements; with AMF.UML.Parameters; with AMF.UML.String_Expressions; with AMF.UML.Template_Parameters; with AMF.UML.Types; with AMF.UML.Value_Specifications; with AMF.Visitors; package AMF.Internals.UML_Parameters is package UML_Multiplicity_Elements is new AMF.Internals.UML_Multiplicity_Elements (AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy); type UML_Parameter_Proxy is limited new UML_Multiplicity_Elements.UML_Multiplicity_Element_Proxy and AMF.UML.Parameters.UML_Parameter with null record; overriding function Get_Default (Self : not null access constant UML_Parameter_Proxy) return AMF.Optional_String; -- Getter of Parameter::default. -- -- Specifies a String that represents a value to be used when no argument -- is supplied for the Parameter. overriding procedure Set_Default (Self : not null access UML_Parameter_Proxy; To : AMF.Optional_String); -- Setter of Parameter::default. -- -- Specifies a String that represents a value to be used when no argument -- is supplied for the Parameter. overriding function Get_Default_Value (Self : not null access constant UML_Parameter_Proxy) return AMF.UML.Value_Specifications.UML_Value_Specification_Access; -- Getter of Parameter::defaultValue. -- -- Specifies a ValueSpecification that represents a value to be used when -- no argument is supplied for the Parameter. overriding procedure Set_Default_Value (Self : not null access UML_Parameter_Proxy; To : AMF.UML.Value_Specifications.UML_Value_Specification_Access); -- Setter of Parameter::defaultValue. -- -- Specifies a ValueSpecification that represents a value to be used when -- no argument is supplied for the Parameter. overriding function Get_Direction (Self : not null access constant UML_Parameter_Proxy) return AMF.UML.UML_Parameter_Direction_Kind; -- Getter of Parameter::direction. -- -- Indicates whether a parameter is being sent into or out of a behavioral -- element. overriding procedure Set_Direction (Self : not null access UML_Parameter_Proxy; To : AMF.UML.UML_Parameter_Direction_Kind); -- Setter of Parameter::direction. -- -- Indicates whether a parameter is being sent into or out of a behavioral -- element. overriding function Get_Effect (Self : not null access constant UML_Parameter_Proxy) return AMF.UML.Optional_UML_Parameter_Effect_Kind; -- Getter of Parameter::effect. -- -- Specifies the effect that the owner of the parameter has on values -- passed in or out of the parameter. overriding procedure Set_Effect (Self : not null access UML_Parameter_Proxy; To : AMF.UML.Optional_UML_Parameter_Effect_Kind); -- Setter of Parameter::effect. -- -- Specifies the effect that the owner of the parameter has on values -- passed in or out of the parameter. overriding function Get_Is_Exception (Self : not null access constant UML_Parameter_Proxy) return Boolean; -- Getter of Parameter::isException. -- -- Tells whether an output parameter may emit a value to the exclusion of -- the other outputs. overriding procedure Set_Is_Exception (Self : not null access UML_Parameter_Proxy; To : Boolean); -- Setter of Parameter::isException. -- -- Tells whether an output parameter may emit a value to the exclusion of -- the other outputs. overriding function Get_Is_Stream (Self : not null access constant UML_Parameter_Proxy) return Boolean; -- Getter of Parameter::isStream. -- -- Tells whether an input parameter may accept values while its behavior -- is executing, or whether an output parameter post values while the -- behavior is executing. overriding procedure Set_Is_Stream (Self : not null access UML_Parameter_Proxy; To : Boolean); -- Setter of Parameter::isStream. -- -- Tells whether an input parameter may accept values while its behavior -- is executing, or whether an output parameter post values while the -- behavior is executing. overriding function Get_Operation (Self : not null access constant UML_Parameter_Proxy) return AMF.UML.Operations.UML_Operation_Access; -- Getter of Parameter::operation. -- -- References the Operation owning this parameter. overriding procedure Set_Operation (Self : not null access UML_Parameter_Proxy; To : AMF.UML.Operations.UML_Operation_Access); -- Setter of Parameter::operation. -- -- References the Operation owning this parameter. overriding function Get_Parameter_Set (Self : not null access constant UML_Parameter_Proxy) return AMF.UML.Parameter_Sets.Collections.Set_Of_UML_Parameter_Set; -- Getter of Parameter::parameterSet. -- -- The parameter sets containing the parameter. See ParameterSet. overriding function Get_End (Self : not null access constant UML_Parameter_Proxy) return AMF.UML.Connector_Ends.Collections.Ordered_Set_Of_UML_Connector_End; -- Getter of ConnectableElement::end. -- -- Denotes a set of connector ends that attaches to this connectable -- element. overriding function Get_Template_Parameter (Self : not null access constant UML_Parameter_Proxy) return AMF.UML.Connectable_Element_Template_Parameters.UML_Connectable_Element_Template_Parameter_Access; -- Getter of ConnectableElement::templateParameter. -- -- The ConnectableElementTemplateParameter for this ConnectableElement -- parameter. overriding procedure Set_Template_Parameter (Self : not null access UML_Parameter_Proxy; To : AMF.UML.Connectable_Element_Template_Parameters.UML_Connectable_Element_Template_Parameter_Access); -- Setter of ConnectableElement::templateParameter. -- -- The ConnectableElementTemplateParameter for this ConnectableElement -- parameter. overriding function Get_Type (Self : not null access constant UML_Parameter_Proxy) return AMF.UML.Types.UML_Type_Access; -- Getter of TypedElement::type. -- -- The type of the TypedElement. -- This information is derived from the return result for this Operation. overriding procedure Set_Type (Self : not null access UML_Parameter_Proxy; To : AMF.UML.Types.UML_Type_Access); -- Setter of TypedElement::type. -- -- The type of the TypedElement. -- This information is derived from the return result for this Operation. overriding function Get_Client_Dependency (Self : not null access constant UML_Parameter_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency; -- Getter of NamedElement::clientDependency. -- -- Indicates the dependencies that reference the client. overriding function Get_Name_Expression (Self : not null access constant UML_Parameter_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access; -- Getter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding procedure Set_Name_Expression (Self : not null access UML_Parameter_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access); -- Setter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding function Get_Namespace (Self : not null access constant UML_Parameter_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Getter of NamedElement::namespace. -- -- Specifies the namespace that owns the NamedElement. overriding function Get_Qualified_Name (Self : not null access constant UML_Parameter_Proxy) return AMF.Optional_String; -- Getter of NamedElement::qualifiedName. -- -- A name which allows the NamedElement to be identified within a -- hierarchy of nested Namespaces. It is constructed from the names of the -- containing namespaces starting at the root of the hierarchy and ending -- with the name of the NamedElement itself. overriding function Get_Owning_Template_Parameter (Self : not null access constant UML_Parameter_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding procedure Set_Owning_Template_Parameter (Self : not null access UML_Parameter_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding function Get_Template_Parameter (Self : not null access constant UML_Parameter_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding procedure Set_Template_Parameter (Self : not null access UML_Parameter_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding function Default (Self : not null access constant UML_Parameter_Proxy) return AMF.Optional_String; -- Operation Parameter::default. -- -- Missing derivation for Parameter::/default : String overriding function Compatible_With (Self : not null access constant UML_Parameter_Proxy; Other : AMF.UML.Multiplicity_Elements.UML_Multiplicity_Element_Access) return Boolean; -- Operation MultiplicityElement::compatibleWith. -- -- The operation compatibleWith takes another multiplicity as input. It -- checks if one multiplicity is compatible with another. overriding function Includes_Cardinality (Self : not null access constant UML_Parameter_Proxy; C : Integer) return Boolean; -- Operation MultiplicityElement::includesCardinality. -- -- The query includesCardinality() checks whether the specified -- cardinality is valid for this multiplicity. overriding function Includes_Multiplicity (Self : not null access constant UML_Parameter_Proxy; M : AMF.UML.Multiplicity_Elements.UML_Multiplicity_Element_Access) return Boolean; -- Operation MultiplicityElement::includesMultiplicity. -- -- The query includesMultiplicity() checks whether this multiplicity -- includes all the cardinalities allowed by the specified multiplicity. overriding function Iss (Self : not null access constant UML_Parameter_Proxy; Lowerbound : Integer; Upperbound : Integer) return Boolean; -- Operation MultiplicityElement::is. -- -- The operation is determines if the upper and lower bound of the ranges -- are the ones given. overriding function Ends (Self : not null access constant UML_Parameter_Proxy) return AMF.UML.Connector_Ends.Collections.Set_Of_UML_Connector_End; -- Operation ConnectableElement::end. -- -- Missing derivation for ConnectableElement::/end : ConnectorEnd overriding function All_Owning_Packages (Self : not null access constant UML_Parameter_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package; -- Operation NamedElement::allOwningPackages. -- -- The query allOwningPackages() returns all the directly or indirectly -- owning packages. overriding function Is_Distinguishable_From (Self : not null access constant UML_Parameter_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean; -- Operation NamedElement::isDistinguishableFrom. -- -- The query isDistinguishableFrom() determines whether two NamedElements -- may logically co-exist within a Namespace. By default, two named -- elements are distinguishable if (a) they have unrelated types or (b) -- they have related types but different names. overriding function Namespace (Self : not null access constant UML_Parameter_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Operation NamedElement::namespace. -- -- Missing derivation for NamedElement::/namespace : Namespace overriding function Is_Compatible_With (Self : not null access constant UML_Parameter_Proxy; P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access) return Boolean; -- Operation ParameterableElement::isCompatibleWith. -- -- The query isCompatibleWith() determines if this parameterable element -- is compatible with the specified parameterable element. By default -- parameterable element P is compatible with parameterable element Q if -- the kind of P is the same or a subtype as the kind of Q. Subclasses -- should override this operation to specify different compatibility -- constraints. overriding function Is_Template_Parameter (Self : not null access constant UML_Parameter_Proxy) return Boolean; -- Operation ParameterableElement::isTemplateParameter. -- -- The query isTemplateParameter() determines if this parameterable -- element is exposed as a formal template parameter. overriding procedure Enter_Element (Self : not null access constant UML_Parameter_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Element (Self : not null access constant UML_Parameter_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Element (Self : not null access constant UML_Parameter_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end AMF.Internals.UML_Parameters;
-- Abstract : -- -- See spec. -- -- Copyright (C) 2017 - 2019 Free Software Foundation, Inc. -- -- This library is free software; you can redistribute it and/or modify it -- under terms of the GNU General Public License as published by the Free -- Software Foundation; either version 3, or (at your option) any later -- version. This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- As a special exception under Section 7 of GPL version 3, you are granted -- additional permissions described in the GCC Runtime Library Exception, -- version 3.1, as published by the Free Software Foundation. pragma License (Modified_GPL); with GNAT.Strings; package body WisiToken.Lexer is procedure Finalize (Object : in out Source) is begin case Object.Label is when String_Label => if not Object.User_Buffer then Ada.Strings.Unbounded.Free (Object.Buffer); end if; when File_Label => GNATCOLL.Mmap.Free (Object.Region); GNATCOLL.Mmap.Close (Object.File); end case; end Finalize; function Buffer (Source : in Lexer.Source) return GNATCOLL.Mmap.Str_Access is use GNATCOLL.Mmap; begin case Source.Label is when String_Label => return Short.To_Str_Access (GNAT.Strings.String_Access (Source.Buffer)); when File_Label => return Data (Source.Region); end case; end Buffer; function File_Name (Source : in Lexer.Source) return String is begin return -Source.File_Name; end File_Name; function To_Char_Pos (Source : in Lexer.Source; Lexer_Char_Pos : in Integer) return Base_Buffer_Pos is begin return Base_Buffer_Pos (Lexer_Char_Pos) + Source.Buffer_Nominal_First_Char - Buffer_Pos'First; end To_Char_Pos; end WisiToken.Lexer;
----------------------------------------------------------------------- -- volume - Bean to compute the cylinder volume -- Copyright (C) 2010, 2011, 2012 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Fixed; with Ada.Text_IO.Editing; with Ada.Numerics; with ASF.Events.Faces.Actions; package body Volume is use Ada.Strings.Unbounded; Pic : constant Ada.Text_IO.Editing.Picture := Ada.Text_IO.Editing.To_Picture ("ZZZZZZZZ9.99"); package Float_Output is new Ada.Text_IO.Editing.Decimal_Output (My_Float); package Run_Binding is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Compute_Bean, Method => Run, Name => "run"); Binding_Array : aliased constant Util.Beans.Methods.Method_Binding_Array := (Run_Binding.Proxy'Unchecked_Access, Run_Binding.Proxy'Unchecked_Access); -- ------------------------------ -- This bean provides some methods that can be used in a Method_Expression -- ------------------------------ overriding function Get_Method_Bindings (From : in Compute_Bean) return Util.Beans.Methods.Method_Binding_Array_Access is pragma Unreferenced (From); begin return Binding_Array'Unchecked_Access; end Get_Method_Bindings; -- ------------------------------ -- Compute the volume of the cylinder. -- ------------------------------ procedure Run (From : in out Compute_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is V : My_Float; begin V := (From.Radius * From.Radius); V := V * From.Height; From.Volume := V * 3.141; Outcome := To_Unbounded_String ("compute"); end Run; -- ------------------------------ -- Get the value identified by the name. -- ------------------------------ function Get_Value (From : Compute_Bean; Name : String) return Util.Beans.Objects.Object is begin if Name = "radius" and From.Radius >= 0.0 then return Util.Beans.Objects.To_Object (Float (From.Radius)); elsif Name = "height" and From.Height >= 0.0 then return Util.Beans.Objects.To_Object (Float (From.Height)); elsif Name = "volume" and From.Volume >= 0.0 then return Util.Beans.Objects.To_Object (Float (From.Volume)); elsif Name = "pi" then return Util.Beans.Objects.To_Object (Float (Ada.Numerics.Pi)); else return Util.Beans.Objects.Null_Object; end if; end Get_Value; -- ------------------------------ -- Set the value identified by the name. -- ------------------------------ procedure Set_Value (From : in out Compute_Bean; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "radius" then From.Radius := My_Float (Util.Beans.Objects.To_Float (Value)); elsif Name = "height" then From.Height := My_Float (Util.Beans.Objects.To_Float (Value)); end if; end Set_Value; -- ------------------------------ -- Convert the object value into a string. The object value is associated -- with the specified component. -- If the string cannot be converted, the Invalid_Conversion exception should be raised. -- ------------------------------ function To_String (Convert : in Float_Converter; Context : in ASF.Contexts.Faces.Faces_Context'Class; Component : in ASF.Components.Base.UIComponent'Class; Value : in Util.Beans.Objects.Object) return String is pragma Unreferenced (Convert, Context, Component); F : constant My_Float := My_Float (Util.Beans.Objects.To_Float (Value)); R : constant String := Float_Output.Image (F, Pic); begin return Ada.Strings.Fixed.Trim (R, Ada.Strings.Both); end To_String; -- ------------------------------ -- Convert the string into an object for the specified component. -- If the string cannot be converted, the Invalid_Conversion exception should be raised. -- ------------------------------ function To_Object (Convert : in Float_Converter; Context : in ASF.Contexts.Faces.Faces_Context'Class; Component : in ASF.Components.Base.UIComponent'Class; Value : in String) return Util.Beans.Objects.Object is pragma Unreferenced (Convert, Context, Component); begin return Util.Beans.Objects.To_Object (Float (My_Float'Value (Value))); end To_Object; end Volume;
package Discr46 is type Enum is (One, Two, Three); for Enum use (One => 1, Two => 2, Three => 3); type Rec1 (D : Boolean := False) is record case D is when False => null; when True => T : Integer; end case; end record; type Rec2 is record R : Rec1; C : Character; end record; type Arr is array (Enum) of Rec2; A : Arr; function F (Id : Enum) return Integer; end Discr46;
with Constant2_Pkg2; use Constant2_Pkg2; package Constant2_Pkg1 is Val : constant Boolean := F1 and then F2; end Constant2_Pkg1;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S W I T C H -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package together with a child package appropriate to the client tool -- scans switches. Note that the body of the appropriate Usage package must be -- coordinated with the switches that are recognized by this package. These -- Usage packages also act as the official documentation for the switches -- that are recognized. In addition, package Debug documents the otherwise -- undocumented debug switches that are also recognized. with Gnatvsn; with Types; use Types; ------------ -- Switch -- ------------ package Switch is -- Common switches for GNU tools Version_Switch : constant String := "--version"; Help_Switch : constant String := "--help"; ----------------- -- Subprograms -- ----------------- generic with procedure Usage; -- Print tool-specific part of --help message procedure Check_Version_And_Help_G (Tool_Name : String; Initial_Year : String; Version_String : String := Gnatvsn.Gnat_Version_String); -- Check if switches --version or --help is used. If one of this switch is -- used, issue the proper messages and end the process. procedure Display_Version (Tool_Name : String; Initial_Year : String; Version_String : String := Gnatvsn.Gnat_Version_String); -- Display version of a tool when switch --version is used procedure Display_Usage_Version_And_Help; -- Output the two lines of usage for switches --version and --help function Is_Switch (Switch_Chars : String) return Boolean; -- Returns True iff Switch_Chars is at least two characters long, and the -- first character is an hyphen ('-'). function Is_Front_End_Switch (Switch_Chars : String) return Boolean; -- Returns True iff Switch_Chars represents a front-end switch, i.e. it -- starts with -I, -gnat or -?RTS. function Is_Internal_GCC_Switch (Switch_Chars : String) return Boolean; -- Returns True iff Switch_Chars represents an internal GCC switch to be -- followed by a single argument, such as -dumpbase, --param or -auxbase. -- Even though passed by the "gcc" driver, these need not be stored in ALI -- files and may safely be ignored by non GCC back-ends. function Switch_Last (Switch_Chars : String) return Natural; -- Index in Switch_Chars of the last relevant character for later string -- comparison purposes. This is typically 'Last, minus one if there is a -- terminating ASCII.NUL. private -- This section contains some common routines used by the tool dependent -- child packages (there is one such child package for each tool that uses -- Switches to scan switches - Compiler/gnatbind/gnatmake/. Switch_Max_Value : constant := 999_999; -- Maximum value permitted in switches that take a value function Nat_Present (Switch_Chars : String; Max : Integer; Ptr : Integer) return Boolean; -- Returns True if an integer is at the current scan location or an equal -- sign. This is used as a guard for calling Scan_Nat. Switch_Chars is the -- string containing the switch, and Ptr points just past the switch -- character. Max is the maximum allowed value of Ptr. procedure Scan_Nat (Switch_Chars : String; Max : Integer; Ptr : in out Integer; Result : out Nat; Switch : Character); -- Scan natural integer parameter for switch. On entry, Ptr points just -- past the switch character, on exit it points past the last digit of the -- integer value. Max is the maximum allowed value of Ptr, so the scan is -- restricted to Switch_Chars (Ptr .. Max). It is possible for Ptr to be -- one greater than Max on return if the entire string is digits. Scan_Nat -- will skip an optional equal sign if it is present. Nat_Present must be -- True, or an error will be signalled. procedure Scan_Pos (Switch_Chars : String; Max : Integer; Ptr : in out Integer; Result : out Pos; Switch : Character); -- Scan positive integer parameter for switch. Identical to Scan_Nat with -- same parameters except that zero is considered out of range. procedure Bad_Switch (Switch : Character); procedure Bad_Switch (Switch : String); pragma No_Return (Bad_Switch); -- Fail with an appropriate message when a switch is not recognized end Switch;
-- Copyright 2014-2020 Free Software Foundation, Inc. -- -- 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 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. with Pck; use Pck; procedure Failure is type Funny_Char is (NUL, ' ', '"', '#', '$', TMI, '&', ''', '(', ')', SOT, ND, ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', UNS, INF, XMT, '?', '!', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', BEL, SND, CR, LF, DLT); type Funny_String is array (Positive range <>) of Funny_Char; pragma Pack (Funny_String); type Bounded_Funny_String (Size : Natural := 1) is record Str : Funny_String (1 .. Size) := (others => '0'); Length : Natural := 4; end record; Test : Bounded_Funny_String (100); begin Test.Str := (1 => 'A', others => NUL); Test.Length := 1; Do_Nothing (Test'Address); -- START end;
with Test_Solution; use Test_Solution; package Problem_2 is type Int64 is range -2**63 .. 2**63 - 1; type Int128 is range -2**127 .. 2**127 - 1; function Solution_1( Max : Int128 ) return Int128; function Solution_2( Max : Int128 ) return Int128; procedure Test_Solution_1; procedure Test_Solution_2; function Get_Solutions return Solution_Case; end Problem_2;
with Glib; use Glib; with Cairo; use Cairo; with Cairo.Png; use Cairo.Png; with Cairo.Pattern; use Cairo.Pattern; with Cairo.Image_Surface; use Cairo.Image_Surface; with Ada.Numerics; procedure Sphere is subtype Dub is Glib.Gdouble; Surface : Cairo_Surface; Cr : Cairo_Context; Pat : Cairo_Pattern; Status_Out : Cairo_Status; M_Pi : constant Dub := Dub (Ada.Numerics.Pi); begin Surface := Create (Cairo_Format_ARGB32, 512, 512); Cr := Create (Surface); Pat := Cairo.Pattern.Create_Radial (230.4, 204.8, 51.1, 204.8, 204.8, 256.0); Cairo.Pattern.Add_Color_Stop_Rgba (Pat, 0.0, 1.0, 1.0, 1.0, 1.0); Cairo.Pattern.Add_Color_Stop_Rgba (Pat, 1.0, 0.0, 0.0, 0.0, 1.0); Cairo.Set_Source (Cr, Pat); Cairo.Arc (Cr, 256.0, 256.0, 153.6, 0.0, 2.0 * M_Pi); Cairo.Fill (Cr); Cairo.Pattern.Destroy (Pat); Status_Out := Write_To_Png (Surface, "SphereAda.png"); pragma Assert (Status_Out = Cairo_Status_Success); end Sphere;
package body labels is function last_label return label_t is begin return last; end last_label; function get_by_name (str : string) return label_t is cur : labels_t.cursor := labels_t.find(labels, str); begin if cur = labels_t.no_element then return null_label; end if; return (cursor => cur); end get_by_name; function create (str : string; addr : pos_addr_t := null_pos_addr) return label_t is cur : labels_t.cursor; tb : boolean; begin labels_t.insert(labels, str, addr, cur, tb); if not tb then raise error_label_exist; end if; last := (cursor => cur); return last_label; end create; procedure create (str : string; addr : pos_addr_t := null_pos_addr) is begin void(create(str, addr)); end create; procedure set (label : label_t; addr : pos_addr_t) is begin if label.cursor = labels_t.no_element then raise error_label_is_null; end if; labels_t.replace_element(labels, label.cursor, addr); end set; function set (label : label_t; addr : pos_addr_t) return label_t is begin set(label, addr); return label; end set; function get (label : label_t) return pos_addr_t is begin if label.cursor = labels_t.no_element then raise error_label_is_null; end if; return labels_t.element(label.cursor); end get; function name (label : label_t) return string is begin if label.cursor = labels_t.no_element then raise error_label_is_null; end if; return labels_t.key(label.cursor); end name; procedure void (label : label_t) is begin null; end void; end labels;
----------------------------------------------------------------------- -- html.messages -- Faces messages -- Copyright (C) 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 ASF.Utils; with ASF.Applications.Messages; with ASF.Components.Base; -- The <b>ASF.Components.Html.Messages</b> package implements the <b>h:message</b> -- and <b>h:messages</b> components. package body ASF.Components.Html.Messages is use ASF.Components.Base; use ASF.Applications.Messages; MSG_ATTRIBUTE_NAMES : Util.Strings.String_Set.Set; FATAL_ATTRIBUTE_NAMES : Util.Strings.String_Set.Set; ERROR_ATTRIBUTE_NAMES : Util.Strings.String_Set.Set; WARN_ATTRIBUTE_NAMES : Util.Strings.String_Set.Set; INFO_ATTRIBUTE_NAMES : Util.Strings.String_Set.Set; -- ------------------------------ -- Check whether the UI component whose name is given in <b>Name</b> has some messages -- associated with it. -- ------------------------------ function Has_Message (Name : in Util.Beans.Objects.Object) return Util.Beans.Objects.Object is Context : constant ASF.Contexts.Faces.Faces_Context_Access := ASF.Contexts.Faces.Current; begin if Context = null then return Util.Beans.Objects.To_Object (False); end if; declare Id : constant String := Util.Beans.Objects.To_String (Name); Msgs : constant ASF.Applications.Messages.Vectors.Cursor := Context.Get_Messages (Id); begin return Util.Beans.Objects.To_Object (Applications.Messages.Vectors.Has_Element (Msgs)); end; end Has_Message; -- ------------------------------ -- Write a single message enclosed by the tag represented by <b>Tag</b>. -- ------------------------------ procedure Write_Message (UI : in UIHtmlComponent'Class; Message : in ASF.Applications.Messages.Message; Mode : in Message_Mode; Show_Detail : in Boolean; Show_Summary : in Boolean; Context : in out Faces_Context'Class) is Writer : constant Response_Writer_Access := Context.Get_Response_Writer; begin case Mode is when SPAN_NO_STYLE => Writer.Start_Element ("span"); when SPAN => Writer.Start_Element ("span"); UI.Render_Attributes (Context, MSG_ATTRIBUTE_NAMES, Writer); when LIST => Writer.Start_Element ("li"); when TABLE => Writer.Start_Element ("tr"); end case; case Get_Severity (Message) is when FATAL => UI.Render_Attributes (Context, FATAL_ATTRIBUTE_NAMES, Writer, Write_Id => Mode /= SPAN_NO_STYLE); when ERROR => UI.Render_Attributes (Context, ERROR_ATTRIBUTE_NAMES, Writer, Write_Id => Mode /= SPAN_NO_STYLE); when WARN => UI.Render_Attributes (Context, WARN_ATTRIBUTE_NAMES, Writer, Write_Id => Mode /= SPAN_NO_STYLE); when INFO | NONE => UI.Render_Attributes (Context, INFO_ATTRIBUTE_NAMES, Writer, Write_Id => Mode /= SPAN_NO_STYLE); end case; if Mode = TABLE then Writer.Start_Element ("td"); end if; if Show_Summary then Writer.Write_Text (Get_Summary (Message)); end if; if Show_Detail then Writer.Write_Text (Get_Detail (Message)); end if; case Mode is when SPAN | SPAN_NO_STYLE => Writer.End_Element ("span"); when LIST => Writer.End_Element ("li"); when TABLE => Writer.End_Element ("td"); Writer.End_Element ("tr"); end case; end Write_Message; -- ------------------------------ -- Render a list of messages each of them being enclosed by the <b>Tag</b> element. -- ------------------------------ procedure Write_Messages (UI : in UIHtmlComponent'Class; Mode : in Message_Mode; Context : in out Faces_Context'Class; Messages : in out ASF.Applications.Messages.Vectors.Cursor) is procedure Process_Message (Message : in ASF.Applications.Messages.Message); Show_Detail : constant Boolean := UI.Get_Attribute ("showDetail", Context, True); Show_Summary : constant Boolean := UI.Get_Attribute ("showSummary", Context, False); procedure Process_Message (Message : in ASF.Applications.Messages.Message) is begin Write_Message (UI, Message, Mode, Show_Detail, Show_Summary, Context); end Process_Message; begin while ASF.Applications.Messages.Vectors.Has_Element (Messages) loop Vectors.Query_Element (Messages, Process_Message'Access); Vectors.Next (Messages); end loop; end Write_Messages; -- ------------------------------ -- Encode the begining of the <b>h:message</b> component. -- ------------------------------ procedure Encode_Begin (UI : in UIMessage; Context : in out Faces_Context'Class) is begin if not UI.Is_Rendered (Context) then return; end if; declare Name : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, "for"); Messages : ASF.Applications.Messages.Vectors.Cursor; begin -- No specification of 'for' attribute, render the global messages. if Util.Beans.Objects.Is_Null (Name) then Messages := Context.Get_Messages (""); else declare Id : constant String := Util.Beans.Objects.To_String (Name); Target : constant UIComponent_Access := UI.Find (Id => Id); begin -- If the component does not exist, report an error in the logs. if Target = null then UI.Log_Error ("Cannot find component {0}", Id); else Messages := Context.Get_Messages (Id); end if; end; end if; -- If we have some message, render the first one (as specified by <h:message>). if ASF.Applications.Messages.Vectors.Has_Element (Messages) then declare Show_Detail : constant Boolean := UI.Get_Attribute ("showDetail", Context, True); Show_Summary : constant Boolean := UI.Get_Attribute ("showSummary", Context, False); begin Write_Message (UI, ASF.Applications.Messages.Vectors.Element (Messages), SPAN, Show_Detail, Show_Summary, Context); end; end if; end; end Encode_Begin; -- Encode the end of the <b>h:message</b> component. procedure Encode_End (UI : in UIMessage; Context : in out Faces_Context'Class) is begin null; end Encode_End; -- ------------------------------ -- Encode the begining of the <b>h:message</b> component. -- ------------------------------ procedure Encode_Begin (UI : in UIMessages; Context : in out Faces_Context'Class) is begin if UI.Is_Rendered (Context) then declare Name : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, "for"); Messages : ASF.Applications.Messages.Vectors.Cursor; begin -- No specification of 'for' attribute, render the global messages. if Util.Beans.Objects.Is_Null (Name) then if UI.Get_Attribute ("globalOnly", Context) then Messages := Context.Get_Messages (""); end if; else declare Id : constant String := Util.Beans.Objects.To_String (Name); Target : constant UIComponent_Access := UI.Find (Id => Id); begin -- If the component does not exist, report an error in the logs. if Target = null then UI.Log_Error ("Cannot find component {0}", Id); else Messages := Context.Get_Messages (Id); end if; end; end if; -- If we have some message, render them. if ASF.Applications.Messages.Vectors.Has_Element (Messages) then declare Writer : constant Response_Writer_Access := Context.Get_Response_Writer; Layout : constant String := Util.Beans.Objects.To_String (UI.Get_Attribute (Context, "layout")); begin if Layout = "table" then Writer.Start_Element ("table"); UI.Render_Attributes (Context, MSG_ATTRIBUTE_NAMES, Writer); Write_Messages (UI, TABLE, Context, Messages); Writer.End_Element ("table"); else Writer.Start_Element ("ul"); UI.Render_Attributes (Context, MSG_ATTRIBUTE_NAMES, Writer); Write_Messages (UI, LIST, Context, Messages); Writer.End_Element ("ul"); end if; end; end if; end; end if; end Encode_Begin; -- Encode the end of the <b>h:message</b> component. procedure Encode_End (UI : in UIMessages; Context : in out Faces_Context'Class) is begin null; end Encode_End; FATAL_CLASS_ATTR : aliased constant String := "fatalClass"; FATAL_STYLE_CLASS_ATTR : aliased constant String := "fatalStyle"; ERROR_CLASS_ATTR : aliased constant String := "errorClass"; ERROR_STYLE_CLASS_ATTR : aliased constant String := "errorStyle"; WARN_CLASS_ATTR : aliased constant String := "warnClass"; WARN_STYLE_CLASS_ATTR : aliased constant String := "warnStyle"; INFO_CLASS_ATTR : aliased constant String := "infoClass"; INFO_STYLE_CLASS_ATTR : aliased constant String := "infoStyle"; begin ASF.Utils.Set_Text_Attributes (MSG_ATTRIBUTE_NAMES); -- ASF.Utils.Set_Text_Attributes (WARN_ATTRIBUTE_NAMES); -- ASF.Utils.Set_Text_Attributes (INFO_ATTRIBUTE_NAMES); -- -- ASF.Utils.Set_Text_Attributes (FATAL_ATTRIBUTE_NAMES); FATAL_ATTRIBUTE_NAMES.Insert (FATAL_CLASS_ATTR'Access); FATAL_ATTRIBUTE_NAMES.Insert (FATAL_STYLE_CLASS_ATTR'Access); ERROR_ATTRIBUTE_NAMES.Insert (ERROR_CLASS_ATTR'Access); ERROR_ATTRIBUTE_NAMES.Insert (ERROR_STYLE_CLASS_ATTR'Access); WARN_ATTRIBUTE_NAMES.Insert (WARN_CLASS_ATTR'Access); WARN_ATTRIBUTE_NAMES.Insert (WARN_STYLE_CLASS_ATTR'Access); INFO_ATTRIBUTE_NAMES.Insert (INFO_CLASS_ATTR'Access); INFO_ATTRIBUTE_NAMES.Insert (INFO_STYLE_CLASS_ATTR'Access); end ASF.Components.Html.Messages;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . S O C K E T S . C O N S T A N T S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2000-2005, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package provides target dependent definitions of constant for use -- by the GNAT.Sockets package (g-socket.ads). This package should not be -- directly with'ed by an applications program. -- This is the version for powerpc-wrs-vxworks -- This file is generated automatically, do not modify it by hand! Instead, -- make changes to gen-soccon.c and re-run it on each target. package GNAT.Sockets.Constants is -------------- -- Families -- -------------- AF_INET : constant := 2; -- IPv4 address family AF_INET6 : constant := -1; -- IPv6 address family ----------- -- Modes -- ----------- SOCK_STREAM : constant := 1; -- Stream socket SOCK_DGRAM : constant := 2; -- Datagram socket ------------------- -- Socket errors -- ------------------- EACCES : constant := 13; -- Permission denied EADDRINUSE : constant := 48; -- Address already in use EADDRNOTAVAIL : constant := 49; -- Cannot assign address EAFNOSUPPORT : constant := 47; -- Addr family not supported EALREADY : constant := 69; -- Operation in progress EBADF : constant := 9; -- Bad file descriptor ECONNABORTED : constant := 53; -- Connection aborted ECONNREFUSED : constant := 61; -- Connection refused ECONNRESET : constant := 54; -- Connection reset by peer EDESTADDRREQ : constant := 40; -- Destination addr required EFAULT : constant := 14; -- Bad address EHOSTDOWN : constant := 67; -- Host is down EHOSTUNREACH : constant := 65; -- No route to host EINPROGRESS : constant := 68; -- Operation now in progress EINTR : constant := 4; -- Interrupted system call EINVAL : constant := 22; -- Invalid argument EIO : constant := 5; -- Input output error EISCONN : constant := 56; -- Socket already connected ELOOP : constant := 64; -- Too many symbolic lynks EMFILE : constant := 24; -- Too many open files EMSGSIZE : constant := 36; -- Message too long ENAMETOOLONG : constant := 26; -- Name too long ENETDOWN : constant := 62; -- Network is down ENETRESET : constant := 52; -- Disconn. on network reset ENETUNREACH : constant := 51; -- Network is unreachable ENOBUFS : constant := 55; -- No buffer space available ENOPROTOOPT : constant := 42; -- Protocol not available ENOTCONN : constant := 57; -- Socket not connected ENOTSOCK : constant := 50; -- Operation on non socket EOPNOTSUPP : constant := 45; -- Operation not supported EPFNOSUPPORT : constant := 46; -- Unknown protocol family EPROTONOSUPPORT : constant := 43; -- Unknown protocol EPROTOTYPE : constant := 41; -- Unknown protocol type ESHUTDOWN : constant := 58; -- Cannot send once shutdown ESOCKTNOSUPPORT : constant := 44; -- Socket type not supported ETIMEDOUT : constant := 60; -- Connection timed out ETOOMANYREFS : constant := 59; -- Too many references EWOULDBLOCK : constant := 70; -- Operation would block ----------------- -- Host errors -- ----------------- HOST_NOT_FOUND : constant := 1; -- Unknown host TRY_AGAIN : constant := 2; -- Host name lookup failure NO_DATA : constant := 4; -- No data record for name NO_RECOVERY : constant := 3; -- Non recoverable errors ------------------- -- Control flags -- ------------------- FIONBIO : constant := 16; -- Set/clear non-blocking io FIONREAD : constant := 1; -- How many bytes to read -------------------- -- Shutdown modes -- -------------------- SHUT_RD : constant := 0; -- No more recv SHUT_WR : constant := 1; -- No more send SHUT_RDWR : constant := 2; -- No more recv/send --------------------- -- Protocol levels -- --------------------- SOL_SOCKET : constant := 65535; -- Options for socket level IPPROTO_IP : constant := 0; -- Dummy protocol for IP IPPROTO_UDP : constant := 17; -- UDP IPPROTO_TCP : constant := 6; -- TCP ------------------- -- Request flags -- ------------------- MSG_OOB : constant := 1; -- Process out-of-band data MSG_PEEK : constant := 2; -- Peek at incoming data MSG_EOR : constant := 8; -- Send end of record MSG_WAITALL : constant := 64; -- Wait for full reception MSG_NOSIGNAL : constant := -1; -- No SIGPIPE on send MSG_Forced_Flags : constant := 0; -- Flags set on all send(2) calls -------------------- -- Socket options -- -------------------- TCP_NODELAY : constant := 1; -- Do not coalesce packets SO_REUSEADDR : constant := 4; -- Bind reuse local address SO_KEEPALIVE : constant := 8; -- Enable keep-alive msgs SO_LINGER : constant := 128; -- Defer close to flush data SO_BROADCAST : constant := 32; -- Can send broadcast msgs SO_SNDBUF : constant := 4097; -- Set/get send buffer size SO_RCVBUF : constant := 4098; -- Set/get recv buffer size SO_SNDTIMEO : constant := 4101; -- Emission timeout SO_RCVTIMEO : constant := 4102; -- Reception timeout SO_ERROR : constant := 4103; -- Get/clear error status IP_MULTICAST_IF : constant := 9; -- Set/get mcast interface IP_MULTICAST_TTL : constant := 10; -- Set/get multicast TTL IP_MULTICAST_LOOP : constant := 11; -- Set/get mcast loopback IP_ADD_MEMBERSHIP : constant := 12; -- Join a multicast group IP_DROP_MEMBERSHIP : constant := 13; -- Leave a multicast group ------------------- -- System limits -- ------------------- IOV_MAX : constant := 2147483647; -- Maximum writev iovcnt ---------------------- -- Type definitions -- ---------------------- -- Sizes (in bytes) of the components of struct timeval SIZEOF_tv_sec : constant := 4; -- tv_sec SIZEOF_tv_usec : constant := 4; -- tv_usec -------------------------------- -- VxWorks-specific constants -- -------------------------------- -- These constants may be used only within the VxWorks version of -- GNAT.Sockets.Thin. OK : constant := 0; -- VxWorks generic success ERROR : constant := -1; -- VxWorks generic error end GNAT.Sockets.Constants;
-- Demonstrates: -- Declaring arrays -- Indexted Component -- Slice procedure simple_array_expressions is type Arr_Type is array (Integer range <>) of Integer; Arr1 : Arr_Type ( 1 .. 26); begin Arr1(1) := 1; if Arr1(1) = 1 then null; end if; Arr1(7 .. 9) := (7, 8, 9); if Arr1(7) = 7 then null; end if; if 5 in 4 .. 6 then null; end if; if Arr1(2) not in 4 .. 6 | 0 then null; end if; end simple_array_expressions;
pragma Ada_2012; with Vulkan.Low_Level.Vulkan_Core_H; with Interfaces.C; package body Vulkan is use Vulkan.Low_Level.Vulkan_Core_H; use Interfaces.C; -------------------------------- -- VkEnumerateInstanceVersion -- -------------------------------- function VkEnumerateInstanceVersion return Integer is ApiVersion : aliased Unsigned_Short; Result : VkResult; begin Result := VkEnumerateInstanceVersion (ApiVersion'Access); if Result /= 0 then raise Vulkan_Error with Result'Img; end if; return Integer (ApiVersion); end VkEnumerateInstanceVersion; end Vulkan;
with Ada.Unchecked_Conversion; with ACO.Utils.Byte_Order; package body ACO.Generic_Entry_Types is use ACO.Utils.Byte_Order; function Swap (X : Byte_Array) return Byte_Array is (Byte_Array (Swap_Bus (Octets (X)))) with Inline; function Read (This : Entry_Type) return Item_Type is (This.Data); function Read (This : Entry_Type) return Byte_Array is (Swap (Convert (This.Data))); function Data_Length (This : Entry_Type) return Natural is (Item_Type'Size / 8); procedure Write (This : in out Entry_Type; Data : in Item_Type) is begin This.Data := Data; end Write; procedure Write (This : in out Entry_Type; Bytes : in Byte_Array) is begin This.Data := Convert (Swap (Bytes)); end Write; function Create (Accessability : Access_Mode; Data : Item_Type) return Entry_Type is ((Accessability, Data)); function Convert (Data : Item_Type) return Byte_Array is Bytes : constant Byte_Array (0 .. Data'Size / 8 - 1); for Bytes'Address use Data'Address; pragma Import (Convention => Ada, Entity => Bytes); begin return Bytes; end Convert; function Convert (Bytes : Byte_Array) return Item_Type is -- Might get alignment issues? function To_Item is new Ada.Unchecked_Conversion (Source => Byte_Array, Target => Item_Type); begin return To_Item (Bytes); end Convert; function "=" (L : Entry_Type; R : Item_Type) return Boolean is (L.Data = R); function "=" (L : Item_Type; R : Entry_Type) return Boolean is (L = R.Data); end ACO.Generic_Entry_Types;
pragma Style_Checks (Off); -- This spec has been automatically generated from ATSAMD51G19A.svd pragma Restrictions (No_Elaboration_Code); with HAL; with System; package SAM_SVD.RSTC is pragma Preelaborate; --------------- -- Registers -- --------------- -- Reset Cause type RSTC_RCAUSE_Register is record -- Read-only. Power On Reset POR : Boolean; -- Read-only. Brown Out CORE Detector Reset BODCORE : Boolean; -- Read-only. Brown Out VDD Detector Reset BODVDD : Boolean; -- Read-only. NVM Reset NVM : Boolean; -- Read-only. External Reset EXT : Boolean; -- Read-only. Watchdog Reset WDT : Boolean; -- Read-only. System Reset Request SYST : Boolean; -- Read-only. Backup Reset BACKUP : Boolean; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for RSTC_RCAUSE_Register use record POR at 0 range 0 .. 0; BODCORE at 0 range 1 .. 1; BODVDD at 0 range 2 .. 2; NVM at 0 range 3 .. 3; EXT at 0 range 4 .. 4; WDT at 0 range 5 .. 5; SYST at 0 range 6 .. 6; BACKUP at 0 range 7 .. 7; end record; -- Backup Exit Source type RSTC_BKUPEXIT_Register is record -- unspecified Reserved_0_0 : HAL.Bit; -- Read-only. Real Timer Counter Interrupt RTC : Boolean; -- Read-only. Battery Backup Power Switch BBPS : Boolean; -- unspecified Reserved_3_6 : HAL.UInt4; -- Read-only. Hibernate HIB : Boolean; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for RSTC_BKUPEXIT_Register use record Reserved_0_0 at 0 range 0 .. 0; RTC at 0 range 1 .. 1; BBPS at 0 range 2 .. 2; Reserved_3_6 at 0 range 3 .. 6; HIB at 0 range 7 .. 7; end record; ----------------- -- Peripherals -- ----------------- -- Reset Controller type RSTC_Peripheral is record -- Reset Cause RCAUSE : aliased RSTC_RCAUSE_Register; -- Backup Exit Source BKUPEXIT : aliased RSTC_BKUPEXIT_Register; end record with Volatile; for RSTC_Peripheral use record RCAUSE at 16#0# range 0 .. 7; BKUPEXIT at 16#2# range 0 .. 7; end record; -- Reset Controller RSTC_Periph : aliased RSTC_Peripheral with Import, Address => RSTC_Base; end SAM_SVD.RSTC;
with DDS.DataReader; with DDS.DataWriter; with DDS.Publisher; with DDS.Subscriber; with DDS.TopicDescription; with Interfaces.C.Extensions; with DDS.DomainParticipant; with DDS.Treats_Generic; with DDS.Request_Reply.Connext_C_Entity_Params; with DDS; with DDS.DataReaderListener; with Interfaces.C.Extensions; with Ada.Finalization; with DDS.Request_Reply.Untypedcommon; package DDS.Request_Reply.Connext_C_Replier is use Connext_C_Entity_Params; type RTI_Connext_ReplierUntypedImpl is abstract new Untypedcommon.RTI_Connext_EntityUntypedImpl with null Record; type RTI_Connext_ReplierUntypedImpl_Access is access all RTI_Connext_ReplierUntypedImpl'Class; type RTI_Connext_Replier is tagged; type RTI_Connext_Replier_Access is access RTI_Connext_Replier'Class; type RTI_Connext_ReplierListener is tagged; type RTI_Connext_ReplierListener_Access is access RTI_Connext_ReplierListener'Class; type RTI_Connext_SimpleReplierListener is interface; type RTI_Connext_SimpleReplierListener_Access is access all RTI_Connext_SimpleReplierListener'Class; procedure On_Request_Available (Self : RTI_Connext_SimpleReplierListener; Request : Interfaces.C.Extensions.Void_Ptr; Replier : not null access RTI_Connext_Replier) is abstract; procedure (Self : RTI_Connext_SimpleReplierListener; Requreplyest : Interfaces.C.Extensions.Void_Ptr) is abstract; function RTI_Connext_ReplierUntypedImpl_Initialize (Self : RTI_Connext_ReplierUntypedImpl; Params : RTI_Connext_EntityParams; Request_Type_Name : DDS.String; Reply_Type_Name : DDS.String; Request_Size : DDS.Integer; Reader_Listener : DDS.DataReaderListener.Ref_Access) return DDS.ReturnCode_T; function RTI_Connext_ReplierUntypedImpl_Send_Sample (Self : RTI_Connext_ReplierUntypedImpl; Data : Interfaces.C.Extensions.Void_Ptr; Related_Request_Info : DDS.SampleIdentity_T; WriteParams : DDS.WriteParams_T) return DDS.ReturnCode_T; type RTI_Connext_Replier is abstract new RTI_Connext_ReplierUntypedImpl with record Listener : RTI_Connext_ReplierListener_Access; SimpleListener : RTI_Connext_SimpleReplierListener; end record; type RTI_Connext_Replier_Access is access RTI_Connext_Replier'Class; function Create_Writer_Topic (Self : access RTI_Connext_Replier; Params : access RTI_Connext_EntityParams; Name : DDS.String) return DDS.TopicDescription.Ref_Access; type RTI_Connext_ReplierListener_OnRequestAvailableCallback is access procedure (Self : RTI_Connext_ReplierListener; Replier : not null RTI_Connext_Replier_Access); type RTI_Connext_ReplierListener is interface; procedure On_Request_Available (Self : not null access RTI_Connext_ReplierListener; Replier : not null access RTI_Connext_Replier'Class) is abstract; type RTI_Connext_ReplierParams is new Ada.Finalization.Limited_Controlled with record Participant : DDS.DomainParticipant.Ref_Access; Service_Name : DDS.String; Request_Topic_Name : DDS.String; Reply_Topic_Name : DDS.String; Qos_Library_Name : DDS.String; Qos_Profile_Name : DDS.String; Datawriter_Qos : DDS.DataWriterQos; Datareader_Qos : DDS.DataReaderQos; Publisher : DDS.Publisher.Ref_Access; Subscriber : DDS.Subscriber.Ref_Access; Listener : RTI_Connext_ReplierListener_Access; end record; procedure Initialize (Object : in out RTI_Connext_ReplierParams) is null; procedure Finalize (Object : in out RTI_Connext_ReplierParams) is null; function RTI_Connext_Replier_Delete (Self : RTI_Connext_Replier_Access) return DDS.ReturnCode_T; function RTI_Connext_Replier_Wait_For_Requests (Self : access RTI_Connext_Replier; Min_Count : DDS.Integer; Max_Wait : DDS.Duration_T) return DDS.ReturnCode_T; function RTI_Connext_ReplierUntypedImpl_Create return RTI_Connext_ReplierUntypedImpl_Access; function RTI_Connext_ReplierParams_toEntityParams (Self : not null access RTI_Connext_ReplierParams; ToParams : out RTI_Connext_EntityParams) return DDS.ReturnCode_T; end DDS.Request_Reply.Connext_C_Replier;
----------------------------------------------------------------------- -- awa_test_app - -- Copyright (C) 2020 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with ASF.Servlets.Faces; with Servlet.Core.Files; with ASF.Servlets.Ajax; with ASF.Filters.Dump; with ASF.Filters.Cache_Control; with Servlet.Core.Measures; with ASF.Security.Servlets; with ASF.Converters.Sizes; with AWA.Users.Servlets; with AWA.Users.Modules; with AWA.Mail.Modules; with AWA.Comments.Modules; with AWA.Blogs.Modules; with AWA.Tags.Modules; with AWA.Storages.Modules; with AWA.Applications; with AWA.Workspaces.Modules; with AWA.Wikis.Modules; with AWA.Wikis.Previews; with AWA.Jobs.Modules; with AWA.Images.Modules; with AWA.Counters.Modules; with AWA.Services.Filters; with AWA.Converters.Dates; package AWA_Test_App is CONFIG_PATH : constant String := "/test"; CONTEXT_PATH : constant String := "/test"; type Application is new AWA.Applications.Application with private; type Application_Access is access all Application'Class; -- Initialize the servlets provided by the application. -- This procedure is called by <b>Initialize</b>. -- It should register the application servlets. overriding procedure Initialize_Servlets (App : in out Application); -- Initialize the filters provided by the application. -- This procedure is called by <b>Initialize</b>. -- It should register the application filters. overriding procedure Initialize_Filters (App : in out Application); -- Initialize the AWA modules provided by the application. -- This procedure is called by <b>Initialize</b>. -- It should register the modules used by the application. overriding procedure Initialize_Modules (App : in out Application); private type Application is new AWA.Applications.Application with record Self : Application_Access; -- Application servlets and filters (add new servlet and filter instances here). Faces : aliased ASF.Servlets.Faces.Faces_Servlet; Ajax : aliased ASF.Servlets.Ajax.Ajax_Servlet; Files : aliased Servlet.Core.Files.File_Servlet; Dump : aliased ASF.Filters.Dump.Dump_Filter; Service_Filter : aliased AWA.Services.Filters.Service_Filter; Measures : aliased Servlet.Core.Measures.Measure_Servlet; No_Cache : aliased ASF.Filters.Cache_Control.Cache_Control_Filter; -- Authentication servlet and filter. Auth : aliased ASF.Security.Servlets.Request_Auth_Servlet; Verify_Auth : aliased AWA.Users.Servlets.Verify_Auth_Servlet; -- Converters shared by web requests. Rel_Date_Converter : aliased AWA.Converters.Dates.Relative_Date_Converter; Size_Converter : aliased ASF.Converters.Sizes.Size_Converter; -- The application modules. User_Module : aliased AWA.Users.Modules.User_Module; Workspace_Module : aliased AWA.Workspaces.Modules.Workspace_Module; Blog_Module : aliased AWA.Blogs.Modules.Blog_Module; Mail_Module : aliased AWA.Mail.Modules.Mail_Module; Comment_Module : aliased AWA.Comments.Modules.Comment_Module; Storage_Module : aliased AWA.Storages.Modules.Storage_Module; Tag_Module : aliased AWA.Tags.Modules.Tag_Module; Job_Module : aliased AWA.Jobs.Modules.Job_Module; Image_Module : aliased AWA.Images.Modules.Image_Module; Wiki_Module : aliased AWA.Wikis.Modules.Wiki_Module; Preview_Module : aliased AWA.Wikis.Previews.Preview_Module; Counter_Module : aliased AWA.Counters.Modules.Counter_Module; end record; end AWA_Test_App;
-- AOC 2020, Day 20 with Ada.Text_IO; use Ada.Text_IO; with Day; use Day; procedure main is part1 : constant Long_Integer := image_checksum("input.txt"); part2 : constant Long_Integer := water_roughness; begin put_line("Part 1: " & part1'IMAGE); put_line("Part 2: " & part2'IMAGE); end main;
------------------------------------------------------------------------------- -- This file is part of libsparkcrypto. -- -- Copyright (C) 2018 Componolit GmbH -- Copyright (C) 2010, Alexander Senier -- Copyright (C) 2010, secunet Security Networks AG -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- -- * Neither the name of the 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 LSC.Internal.Types; with LSC.Internal.RIPEMD160; with AUnit.Assertions; use AUnit.Assertions; with Util; use Util; use type LSC.Internal.Types.Word32_Array_Type; pragma Style_Checks ("-s"); pragma Warnings (Off, "formal parameter ""T"" is not referenced"); package body LSC_Internal_Test_RIPEMD160 is -- RIPEMD-160: A Strengthened Version of RIPEMD , Appendix B: Test values -- procedure Test_RIPEMD160_Empty (T : in out Test_Cases.Test_Case'Class) is Ctx : LSC.Internal.RIPEMD160.Context_Type; Hash : LSC.Internal.RIPEMD160.Hash_Type; Message : LSC.Internal.RIPEMD160.Block_Type; begin -- "" (empty string) Ctx := LSC.Internal.RIPEMD160.Context_Init; Message := LSC.Internal.RIPEMD160.Block_Type'(others => 0); LSC.Internal.RIPEMD160.Context_Finalize (Ctx, Message, 0); Hash := LSC.Internal.RIPEMD160.Get_Hash (Ctx); Assert (Hash = LSC.Internal.RIPEMD160.Hash_Type'(M (16#9c1185a5#), M (16#c5e9fc54#), M (16#61280897#), M (16#7ee8f548#), M (16#b2258d31#)), "Hash differs"); end Test_RIPEMD160_Empty; --------------------------------------------------------------------------- procedure Test_RIPEMD160_A (T : in out Test_Cases.Test_Case'Class) is Ctx : LSC.Internal.RIPEMD160.Context_Type; Hash : LSC.Internal.RIPEMD160.Hash_Type; Message : LSC.Internal.RIPEMD160.Block_Type; begin -- "a" Ctx := LSC.Internal.RIPEMD160.Context_Init; Message := LSC.Internal.RIPEMD160.Block_Type'(M (16#61000000#), others => 0); LSC.Internal.RIPEMD160.Context_Finalize (Ctx, Message, 8); Hash := LSC.Internal.RIPEMD160.Get_Hash (Ctx); Assert (Hash = LSC.Internal.RIPEMD160.Hash_Type'(M (16#0bdc9d2d#), M (16#256b3ee9#), M (16#daae347b#), M (16#e6f4dc83#), M (16#5a467ffe#)), "Hash differs"); end Test_RIPEMD160_A; --------------------------------------------------------------------------- procedure Test_RIPEMD160_ABC (T : in out Test_Cases.Test_Case'Class) is Ctx : LSC.Internal.RIPEMD160.Context_Type; Hash : LSC.Internal.RIPEMD160.Hash_Type; Message : LSC.Internal.RIPEMD160.Block_Type; begin -- "abc" Ctx := LSC.Internal.RIPEMD160.Context_Init; Message := LSC.Internal.RIPEMD160.Block_Type'(M (16#61626300#), others => 0); LSC.Internal.RIPEMD160.Context_Finalize (Ctx, Message, 24); Hash := LSC.Internal.RIPEMD160.Get_Hash (Ctx); Assert (Hash = LSC.Internal.RIPEMD160.Hash_Type'(M (16#8eb208f7#), M (16#e05d987a#), M (16#9b044a8e#), M (16#98c6b087#), M (16#f15a0bfc#)), "Hash differs"); end Test_RIPEMD160_ABC; --------------------------------------------------------------------------- procedure Test_RIPEMD160_Message_Digest (T : in out Test_Cases.Test_Case'Class) is Ctx : LSC.Internal.RIPEMD160.Context_Type; Hash : LSC.Internal.RIPEMD160.Hash_Type; Message : LSC.Internal.RIPEMD160.Block_Type; begin -- "message digest" Ctx := LSC.Internal.RIPEMD160.Context_Init; Message := LSC.Internal.RIPEMD160.Block_Type'(M (16#6d657373#), M (16#61676520#), M (16#64696765#), M (16#73740000#), others => 0); LSC.Internal.RIPEMD160.Context_Finalize (Ctx, Message, 112); Hash := LSC.Internal.RIPEMD160.Get_Hash (Ctx); Assert (Hash = LSC.Internal.RIPEMD160.Hash_Type'(M (16#5d0689ef#), M (16#49d2fae5#), M (16#72b881b1#), M (16#23a85ffa#), M (16#21595f36#)), "Hash differs"); end Test_RIPEMD160_Message_Digest; --------------------------------------------------------------------------- procedure Test_RIPEMD160_AtoZ (T : in out Test_Cases.Test_Case'Class) is Ctx : LSC.Internal.RIPEMD160.Context_Type; Hash : LSC.Internal.RIPEMD160.Hash_Type; Message : LSC.Internal.RIPEMD160.Block_Type; begin -- "abcdefghijklmnopqrstuvwxyz" Ctx := LSC.Internal.RIPEMD160.Context_Init; Message := LSC.Internal.RIPEMD160.Block_Type'(M (16#61626364#), M (16#65666768#), M (16#696a6b6c#), M (16#6d6e6f70#), M (16#71727374#), M (16#75767778#), M (16#797a0000#), others => 0); LSC.Internal.RIPEMD160.Context_Finalize (Ctx, Message, 208); Hash := LSC.Internal.RIPEMD160.Get_Hash (Ctx); Assert (Hash = LSC.Internal.RIPEMD160.Hash_Type'(M (16#f71c2710#), M (16#9c692c1b#), M (16#56bbdceb#), M (16#5b9d2865#), M (16#b3708dbc#)), "Hash differs"); end Test_RIPEMD160_AtoZ; --------------------------------------------------------------------------- procedure Test_RIPEMD160_ABCDEFG (T : in out Test_Cases.Test_Case'Class) is Ctx : LSC.Internal.RIPEMD160.Context_Type; Hash : LSC.Internal.RIPEMD160.Hash_Type; Message : LSC.Internal.RIPEMD160.Block_Type; begin -- "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" Ctx := LSC.Internal.RIPEMD160.Context_Init; Message := LSC.Internal.RIPEMD160.Block_Type'(M (16#61626364#), M (16#62636465#), M (16#63646566#), M (16#64656667#), M (16#65666768#), M (16#66676869#), M (16#6768696a#), M (16#68696a6b#), M (16#696a6b6c#), M (16#6a6b6c6d#), M (16#6b6c6d6e#), M (16#6c6d6e6f#), M (16#6d6e6f70#), M (16#6e6f7071#), others => 0); LSC.Internal.RIPEMD160.Context_Finalize (Ctx, Message, 448); Hash := LSC.Internal.RIPEMD160.Get_Hash (Ctx); Assert (Hash = LSC.Internal.RIPEMD160.Hash_Type'(M (16#12a05338#), M (16#4a9c0c88#), M (16#e405a06c#), M (16#27dcf49a#), M (16#da62eb2b#)), "Hash differs"); end Test_RIPEMD160_ABCDEFG; --------------------------------------------------------------------------- procedure Test_RIPEMD160_AZaz09 (T : in out Test_Cases.Test_Case'Class) is Ctx : LSC.Internal.RIPEMD160.Context_Type; Hash : LSC.Internal.RIPEMD160.Hash_Type; Message : LSC.Internal.RIPEMD160.Block_Type; begin -- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" Ctx := LSC.Internal.RIPEMD160.Context_Init; Message := LSC.Internal.RIPEMD160.Block_Type'(M (16#41424344#), M (16#45464748#), M (16#494a4b4c#), M (16#4d4e4f50#), M (16#51525354#), M (16#55565758#), M (16#595a6162#), M (16#63646566#), M (16#6768696a#), M (16#6b6c6d6e#), M (16#6f707172#), M (16#73747576#), M (16#7778797a#), M (16#30313233#), M (16#34353637#), M (16#38390000#)); LSC.Internal.RIPEMD160.Context_Finalize (Ctx, Message, 496); Hash := LSC.Internal.RIPEMD160.Get_Hash (Ctx); Assert (Hash = LSC.Internal.RIPEMD160.Hash_Type'(M (16#b0e20b6e#), M (16#31166402#), M (16#86ed3a87#), M (16#a5713079#), M (16#b21f5189#)), "Hash differs"); end Test_RIPEMD160_AZaz09; --------------------------------------------------------------------------- procedure Test_RIPEMD160_8x1to0 (T : in out Test_Cases.Test_Case'Class) is Ctx : LSC.Internal.RIPEMD160.Context_Type; Hash : LSC.Internal.RIPEMD160.Hash_Type; Message : LSC.Internal.RIPEMD160.Block_Type; begin -- 8 times "1234567890" Ctx := LSC.Internal.RIPEMD160.Context_Init; Message := LSC.Internal.RIPEMD160.Block_Type'(M (16#31323334#), M (16#35363738#), M (16#39303132#), M (16#33343536#), M (16#37383930#), M (16#31323334#), M (16#35363738#), M (16#39303132#), M (16#33343536#), M (16#37383930#), M (16#31323334#), M (16#35363738#), M (16#39303132#), M (16#33343536#), M (16#37383930#), M (16#31323334#)); LSC.Internal.RIPEMD160.Context_Update (Ctx, Message); Message := LSC.Internal.RIPEMD160.Block_Type'(M (16#35363738#), M (16#39303132#), M (16#33343536#), M (16#37383930#), others => 0); LSC.Internal.RIPEMD160.Context_Finalize (Ctx, Message, 128); Hash := LSC.Internal.RIPEMD160.Get_Hash (Ctx); Assert (Hash = LSC.Internal.RIPEMD160.Hash_Type'(M (16#9b752e45#), M (16#573d4b39#), M (16#f4dbd332#), M (16#3cab82bf#), M (16#63326bfb#)), "Hash differs"); end Test_RIPEMD160_8x1to0; --------------------------------------------------------------------------- procedure Test_RIPEMD160_1millionAs (T : in out Test_Cases.Test_Case'Class) is Ctx : LSC.Internal.RIPEMD160.Context_Type; Hash : LSC.Internal.RIPEMD160.Hash_Type; Message : LSC.Internal.RIPEMD160.Block_Type; begin -- 1 million times "a" Ctx := LSC.Internal.RIPEMD160.Context_Init; Message := LSC.Internal.RIPEMD160.Block_Type'(others => M (16#61616161#)); for I in Natural range 1 .. 15625 loop LSC.Internal.RIPEMD160.Context_Update (Ctx, Message); end loop; LSC.Internal.RIPEMD160.Context_Finalize (Ctx, Message, 0); Hash := LSC.Internal.RIPEMD160.Get_Hash (Ctx); Assert (Hash = LSC.Internal.RIPEMD160.Hash_Type'(M (16#52783243#), M (16#c1697bdb#), M (16#e16d37f9#), M (16#7f68f083#), M (16#25dc1528#)), "Hash differs"); end Test_RIPEMD160_1millionAs; --------------------------------------------------------------------------- procedure Register_Tests (T : in out Test_Case) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, Test_RIPEMD160_Empty'Access, "RIPEMD160 (empty string)"); Register_Routine (T, Test_RIPEMD160_A'Access, "RIPEMD160 ('a')"); Register_Routine (T, Test_RIPEMD160_ABC'Access, "RIPEMD160 ('abc')"); Register_Routine (T, Test_RIPEMD160_Message_Digest'Access, "RIPEMD160 ('message digest')"); Register_Routine (T, Test_RIPEMD160_AtoZ'Access, "RIPEMD160 ('a..z')"); Register_Routine (T, Test_RIPEMD160_ABCDEFG'Access, "RIPEMD160 ('abcdefg...')"); Register_Routine (T, Test_RIPEMD160_AZaz09'Access, "RIPEMD160 ('A..Za..z0..9')"); Register_Routine (T, Test_RIPEMD160_8x1to0'Access, "RIPEMD160 (8x'1..0'"); Register_Routine (T, Test_RIPEMD160_1millionAs'Access, "RIPEMD160 (1 million 'a's)"); end Register_Tests; --------------------------------------------------------------------------- function Name (T : Test_Case) return Test_String is begin return Format ("RIPEMD160"); end Name; end LSC_Internal_Test_RIPEMD160;
private with Interfaces; package Atomic.Critical_Section with Preelaborate is type Interrupt_State is private; procedure Enter (State : out Interrupt_State) with Inline_Always; procedure Leave (State : Interrupt_State) with Inline_Always; private type Interrupt_State is new Interfaces.Unsigned_32; end Atomic.Critical_Section;
with Text_IO; package body Control is procedure Put_Line (S: String) is begin Text_IO.Put_Line(S); end Put_Line; function Get_Line return String is S: String(1..5) := (others => ASCII.NUL); Char : Character; begin for I in 1 .. 3 loop Text_IO.Get(Char); Text_IO.Put(Char); S(I) := Char; end loop; --S := Text_IO.Get_Line; return S; end Get_Line; procedure Toggle_LedR is begin null; end; procedure Toggle_LedL is begin null; end; procedure Off_LedR is begin null; end; procedure Off_LedL is begin null; end; end Control;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2016 onox <denkpadje@gmail.com> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with AUnit.Assertions; with AUnit.Test_Caller; with Orka.Scenes.Singles.Trees; with Orka.Transforms.Singles.Matrices; package body Test_Scene_Trees is use Orka.Scenes.Singles.Trees; use AUnit.Assertions; package Caller is new AUnit.Test_Caller (Test); Test_Suite : aliased AUnit.Test_Suites.Test_Suite; function Suite return AUnit.Test_Suites.Access_Test_Suite is Name : constant String := "(Scene trees) "; begin Test_Suite.Add_Test (Caller.Create (Name & "Test Create_Tree function", Test_Create_Tree'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test Add_Node procedure (leaf node)", Test_Add_Leaf_Node'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test Add_Node procedure (non-leaf node)", Test_Add_Non_Leaf_Node'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test To_Cursor function (root node)", Test_To_Cursor_Root_Node'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test To_Cursor function (leaf node)", Test_To_Cursor_Leaf_Node'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test To_Cursor function (non-leaf node)", Test_To_Cursor_Non_Leaf_Node'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Raise Unknown_Node_Error in To_Cursor", Test_To_Cursor_Exception'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test Remove_Node procedure (leaf node)", Test_Remove_Leaf_Node'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test Remove_Node procedure (subtree)", Test_Remove_Subtree'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Raise Root_Removal_Error in Remove_Node", Test_Remove_Root_Exception'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test Set_Local_Transform procedure", Test_Set_Local_Transform'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test Update_Tree procedure", Test_Update_Tree'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test World_Transform function", Test_World_Transform'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test Depth function", Test_Depth'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test Width function", Test_Width'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test Visibility function", Test_Visibility'Access)); return Test_Suite'Access; end Suite; procedure Test_Create_Tree (Object : in out Test) is T : constant Tree := Create_Tree ("root"); pragma Unreferenced (T); begin null; end Test_Create_Tree; procedure Test_Add_Leaf_Node (Object : in out Test) is T : Tree := Create_Tree ("root"); begin T.Add_Node ("N1", "root"); T.Add_Node ("N2", "N1"); end Test_Add_Leaf_Node; procedure Test_Add_Non_Leaf_Node (Object : in out Test) is T : Tree := Create_Tree ("root"); begin T.Add_Node ("N1", "root"); T.Add_Node ("N2", "N1"); -- Add nodes to non-leaf nodes T.Add_Node ("N3", "N1"); T.Add_Node ("N4", "root"); end Test_Add_Non_Leaf_Node; procedure Test_To_Cursor_Root_Node (Object : in out Test) is T : constant Tree := Create_Tree ("root"); C : constant Cursor := T.To_Cursor ("root"); pragma Unreferenced (C); begin null; end Test_To_Cursor_Root_Node; procedure Test_To_Cursor_Leaf_Node (Object : in out Test) is T : Tree := Create_Tree ("root"); begin T.Add_Node ("N1", "root"); declare C : constant Cursor := T.To_Cursor ("N1"); pragma Unreferenced (C); begin null; end; end Test_To_Cursor_Leaf_Node; procedure Test_To_Cursor_Non_Leaf_Node (Object : in out Test) is T : Tree := Create_Tree ("root"); begin T.Add_Node ("N1", "root"); T.Add_Node ("N2", "N1"); declare C : constant Cursor := T.To_Cursor ("N1"); pragma Unreferenced (C); begin null; end; end Test_To_Cursor_Non_Leaf_Node; procedure Test_To_Cursor_Exception (Object : in out Test) is T : constant Tree := Create_Tree ("root"); begin declare C : constant Cursor := T.To_Cursor ("N1"); pragma Unreferenced (C); begin Assert (False, "Expected Unknown_Node_Error exception"); end; exception when Unknown_Node_Error => null; end Test_To_Cursor_Exception; procedure Test_Remove_Leaf_Node (Object : in out Test) is T : Tree := Create_Tree ("root"); begin T.Add_Node ("N1", "root"); T.Remove_Node ("N1"); begin declare C : constant Cursor := T.To_Cursor ("N1"); pragma Unreferenced (C); begin Assert (False, "Expected Unknown_Node_Error exception"); end; exception when Unknown_Node_Error => null; end; end Test_Remove_Leaf_Node; procedure Test_Remove_Subtree (Object : in out Test) is T : Tree := Create_Tree ("root"); begin T.Add_Node ("N1", "root"); T.Add_Node ("N2", "N1"); T.Remove_Node ("N1"); -- Test N1 has been removed begin declare C : constant Cursor := T.To_Cursor ("N1"); pragma Unreferenced (C); begin Assert (False, "Expected Unknown_Node_Error exception"); end; exception when Unknown_Node_Error => null; end; -- Test N2 has been removed begin declare C : constant Cursor := T.To_Cursor ("N2"); pragma Unreferenced (C); begin Assert (False, "Expected Unknown_Node_Error exception"); end; exception when Unknown_Node_Error => null; end; end Test_Remove_Subtree; procedure Test_Remove_Root_Exception (Object : in out Test) is T : Tree := Create_Tree ("root"); begin T.Remove_Node ("root"); Assert (False, "Excepted Root_Removal_Error exception"); exception when Root_Removal_Error => null; end Test_Remove_Root_Exception; procedure Test_Set_Local_Transform (Object : in out Test) is T : Tree := Create_Tree ("root"); C : constant Cursor := T.To_Cursor ("root"); package Transforms renames Orka.Transforms.Singles.Matrices; Offset : constant Transforms.Vector4 := (1.0, 2.0, 3.0, 1.0); begin T.Set_Local_Transform (C, Transforms.T (Offset)); end Test_Set_Local_Transform; procedure Test_Update_Tree (Object : in out Test) is T : Tree := Create_Tree ("root"); begin -- Depth 1 T.Update_Tree; -- Depth 2 T.Add_Node ("N1", "root"); T.Update_Tree; -- Depth 3 T.Add_Node ("N2", "N1"); T.Update_Tree; end Test_Update_Tree; procedure Test_World_Transform (Object : in out Test) is T : Tree := Create_Tree ("root"); begin T.Add_Node ("N1", "root"); declare C1 : constant Cursor := T.To_Cursor ("root"); C2 : constant Cursor := T.To_Cursor ("N1"); use type Orka.Transforms.Singles.Matrices.Matrix4; use type Orka.Transforms.Singles.Matrices.Vector4; package Transforms renames Orka.Transforms.Singles.Matrices; Offset : constant Transforms.Vector4 := (1.0, 2.0, 3.0, 1.0); begin Assert (T.World_Transform (C2) = Transforms.Identity_Matrix, "Unexpected World_Transform"); -- Update local transform of root node T.Set_Local_Transform (C1, Transforms.T (Offset)); T.Update_Tree; -- Check world transform of node N1 Assert (T.World_Transform (C2) (Orka.W) = Offset, "Unexpected World_Transform"); end; end Test_World_Transform; procedure Test_Depth (Object : in out Test) is T : Tree := Create_Tree ("root"); begin Assert (T.Depth = 1, "Unexpected Depth"); T.Add_Node ("N1", "root"); Assert (T.Depth = 2, "Unexpected Depth"); T.Add_Node ("N2", "N1"); Assert (T.Depth = 3, "Unexpected Depth"); T.Remove_Node ("N1"); Assert (T.Depth = 1, "Unexpected Depth"); end Test_Depth; procedure Test_Width (Object : in out Test) is T : Tree := Create_Tree ("root"); begin T.Add_Node ("N1", "root"); T.Add_Node ("N2", "root"); T.Add_Node ("N3", "N1"); Assert (T.Width (1) = 1, "Unexpected Width"); Assert (T.Width (2) = 2, "Unexpected Width"); Assert (T.Width (3) = 1, "Unexpected Width"); end Test_Width; procedure Test_Visibility (Object : in out Test) is T : Tree := Create_Tree ("root"); begin T.Add_Node ("N1", "root"); declare C1 : constant Cursor := T.To_Cursor ("root"); C2 : constant Cursor := T.To_Cursor ("N1"); begin Assert (T.Visibility (C2), "Unexpected Visibility"); -- Update local visibility of root node T.Set_Visibility (C1, False); T.Update_Tree; -- Check visibility of node N1 Assert (not T.Visibility (C2), "Unexpected Visibility"); end; end Test_Visibility; end Test_Scene_Trees;
with BBqueue; use BBqueue; package body COBS.Queue.Encoder is procedure Ensure_Buffer (This : in out Instance; Success : out Boolean); procedure Set (This : in out Instance; Index : Storage_Offset; Data : Storage_Element) with Pre => State (This.WG) = Valid, Inline; ------------------- -- Ensure_Buffer -- ------------------- procedure Ensure_Buffer (This : in out Instance; Success : out Boolean) is begin if State (This.WG) /= Valid then Grant (This.Queue, This.WG, Min_Buf_Size); if State (This.WG) /= Valid then Success := False; return; end if; This.Code_Pointer := This.Buffer'First + Slice (This.WG).From; This.Encode_Pointer := This.Code_Pointer + 1; end if; Success := True; return; end Ensure_Buffer; --------- -- Set -- --------- procedure Set (This : in out Instance; Index : Storage_Offset; Data : Storage_Element) is begin if Index not in This.Buffer'First + Slice (This.WG).From .. This.Buffer'First + Slice (This.WG).To then raise Program_Error; end if; This.Buffer (Index) := Data; end Set; ---------- -- Push -- ---------- procedure Push (This : in out Instance; Data : Storage_Element; Success : out Boolean) is begin Ensure_Buffer (This, Success); if not Success then return; end if; if Data /= 0 then Set (This, This.Encode_Pointer, Data); This.Encode_Pointer := This.Encode_Pointer + 1; This.Code := This.Code + 1; end if; if Data = 0 or else This.Code = 16#FF# then Set (This, This.Code_Pointer, This.Code); This.Prev_Code := This.Code; Commit (This.Queue, This.WG, Count (This.Code)); This.Code := 1; end if; end Push; --------------- -- End_Frame -- --------------- procedure End_Frame (This : in out Instance; Success : out Boolean) is begin Ensure_Buffer (This, Success); if not Success then return; end if; if This.Code /= 1 or else This.Prev_Code /= 16#FF# then Set (This, This.Code_Pointer, This.Code); Set (This, This.Encode_Pointer, 0); Commit (This.Queue, This.WG, Count (This.Code) + 1); else Set (This, This.Code_Pointer, 0); Commit (This.Queue, This.WG, Count (This.Code)); end if; This.Code := 1; This.Prev_Code := 1; end End_Frame; ---------------- -- Read_Slice -- ---------------- function Read_Slice (This : in out Instance) return Slice_Rec is function Make_Slice return Slice_Rec with Pre => State (This.RG) = Valid; function Make_Slice return Slice_Rec is Slice : constant BBqueue.Slice_Rec := BBqueue.Slice (This.RG); begin return (Slice.Length, This.Buffer (This.Buffer'First + Slice.From)'Address); end Make_Slice; begin if State (This.RG) = Valid then -- We already have a read grant return Make_Slice; else -- Try to get a new read grant BBqueue.Read (This.Queue, This.RG); if State (This.RG) = Valid then return Make_Slice; else -- No data available return (0, System.Null_Address); end if; end if; end Read_Slice; ------------- -- Release -- ------------- procedure Release (This : in out Instance) is begin if State (This.RG) = Valid then BBqueue.Release (This.Queue, This.RG); end if; end Release; ------------- -- Read_CB -- ------------- procedure Read_CB (This : in out Instance; Result : out Result_Kind) is G : Read_Grant := Empty; begin Read (This.Queue, G); Result := State (G); if Result = Valid then declare S : constant BBqueue.Slice_Rec := BBqueue.Slice (G); B : Storage_Array renames This.Buffer; To_Release : Count; begin Process_Read (B (B'First + S.From .. B'First + S.To), To_Release); Release (This.Queue, G, To_Release); pragma Assert (State (G) = Empty); end; end if; end Read_CB; end COBS.Queue.Encoder;
-- Copyright (c) 2015-2017 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- -- @summary -- Lexical Analysis Stuff -- -- @description -- This package provides namespace for lexical analysis algorithms -- and related data types. package Incr.Lexers is pragma Pure; end Incr.Lexers;
package body Opt21_Pkg is function Get_Object (Object : not null access R) return System.Address is begin return Object.Ptr; end; function Convert (W : Obj) return System.Address is begin if W = null then return System.Null_Address; else return Get_Object (W); end if; end; end Opt21_Pkg;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Contexts; package Program.Compilations is pragma Pure; -- A specific Compilation value is valid (usable) for as long as the -- Context variable, used to create it, remains open. Once an Context is -- closed, all associated Compilation values become invalid. It is -- erroneous to use an invalid Compilation value. type Compilation is limited interface; -- The Ada Compilation abstraction: -- -- The text of a program is submitted to the compiler in one or more -- compilations. Each compilation is a succession of compilation units. type Compilation_Access is access all Compilation'Class with Storage_Size => 0; function Is_Assigned (Self : access Compilation'Class) return Boolean is (Self /= null); not overriding function Context (Self : Compilation) return not null Program.Contexts.Context_Access is abstract; -- Return corresponding context not overriding function Text_Name (Self : Compilation) return Text is abstract; -- Returns the name of the text, or other structure, that was the source of -- the compilation that resulted in this Compilation. Returns a null string -- if the text name is not available for any reason. not overriding function Object_Name (Self : Compilation) return Text is abstract; -- Returns the name of the object, or other structure, that contains the -- binary result of the compilation for this Compilation. Returns a null -- string if the object name is not available for any reason. not overriding function Line_Count (Self : Compilation) return Natural is abstract; not overriding function Line (Self : Compilation; Index : Positive) return Text is abstract; not overriding function Lexical_Element_Count (Self : Compilation) return Natural is abstract; not overriding function Lexical_Element (Self : Compilation; Index : Positive) return Program.Lexical_Elements.Lexical_Element_Access is abstract; -- TODO: Compilation_Pragmas? end Program.Compilations;
----------------------------------------------------------------------- -- awa-users-filters -- Specific filters for authentication and key verification -- Copyright (C) 2011, 2012, 2015, 2019 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Util.Log.Loggers; with Util.Beans.Objects; with Servlet.Sessions; with Servlet.Cookies; with AWA.Applications; with AWA.Users.Filters; package body AWA.Sysadmin.Filters is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Sysadmin.Filters"); -- ------------------------------ -- Initialize the filter and configure the redirection URIs. -- ------------------------------ overriding procedure Initialize (Filter : in out Auth_Filter; Config : in Servlet.Core.Filter_Config) is Context : constant Servlet.Core.Servlet_Registry_Access := Servlet.Core.Get_Servlet_Context (Config); URI : constant String := Servlet.Core.Get_Init_Parameter (Config, AWA.Users.Filters.AUTH_FILTER_REDIRECT_PARAM); begin Filter.Login_URI := To_Unbounded_String (URI); end Initialize; -- ------------------------------ -- Display or redirects the user to the login page. This procedure is called when -- the user is not authenticated. -- ------------------------------ procedure Do_Login (Filter : in Auth_Filter; Request : in out Servlet.Requests.Request'Class; Response : in out Servlet.Responses.Response'Class) is use Servlet; Login_URI : constant String := To_String (Filter.Login_URI); Context : constant String := Request.Get_Context_Path; Servlet : constant String := Request.Get_Servlet_Path; URL : constant String := Context & Servlet & Request.Get_Path_Info; C : Cookies.Cookie := Cookies.Create (AWA.Users.Filters.REDIRECT_COOKIE, URL); begin Log.Info ("Sysadmin user is not logged, redirecting to {0}", Login_URI); Cookies.Set_Path (C, Request.Get_Context_Path); Cookies.Set_Max_Age (C, 86400); Response.Add_Cookie (Cookie => C); if Request.Get_Header ("X-Requested-With") = "" then Response.Send_Redirect (Location => Context & Login_URI); else Response.Send_Error (Responses.SC_UNAUTHORIZED); end if; end Do_Login; -- ------------------------------ -- Filter a request which contains an access key and verify that the -- key is valid and identifies a user. Once the user is known, create -- a session and setup the user principal. -- -- If the access key is missing or invalid, redirect to the -- <b>Invalid_Key_URI</b> associated with the filter. -- ------------------------------ overriding procedure Do_Filter (Filter : in Auth_Filter; Request : in out Servlet.Requests.Request'Class; Response : in out Servlet.Responses.Response'Class; Chain : in out Servlet.Core.Filter_Chain) is Session : Servlet.Sessions.Session := Request.Get_Session; Is_Admin : Util.Beans.Objects.Object; begin if not Session.Is_Valid then Response.Set_Status (Servlet.Responses.SC_UNAUTHORIZED); return; end if; Is_Admin := Session.Get_Attribute (ADMIN_AUTH_BEAN); if Util.Beans.Objects.Is_Null (Is_Admin) then if Filter.Login_URI /= Request.Get_Path then Filter.Do_Login (Request, Response); return; end if; end if; -- Request is authorized, proceed to the next filter. Servlet.Core.Do_Filter (Chain => Chain, Request => Request, Response => Response); end Do_Filter; end AWA.Sysadmin.Filters;
----------------------------------------------------------------------- -- gen-model-operations -- Operation declarations -- Copyright (C) 2012, 2016, 2017, 2018, 2021 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Gen.Model.Operations is -- ------------------------------ -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. -- ------------------------------ overriding function Get_Value (From : in Operation_Definition; Name : in String) return UBO.Object is begin if Name = "parameters" or Name = "columns" then return From.Parameters_Bean; elsif Name = "return" then return UBO.To_Object (From.Return_Type); elsif Name = "type" then return UBO.To_Object (Operation_Type'Image (From.Kind)); else return Definition (From).Get_Value (Name); end if; end Get_Value; -- Prepare the generation of the model. overriding procedure Prepare (O : in out Operation_Definition) is begin null; end Prepare; -- ------------------------------ -- Initialize the operation definition instance. -- ------------------------------ overriding procedure Initialize (O : in out Operation_Definition) is begin O.Parameters_Bean := UBO.To_Object (O.Parameters'Unchecked_Access, UBO.STATIC); end Initialize; -- ------------------------------ -- Add an operation parameter with the given name and type. -- ------------------------------ procedure Add_Parameter (Into : in out Operation_Definition; Name : in UString; Of_Type : in UString; Parameter : out Parameter_Definition_Access) is begin Parameter := new Parameter_Definition; Parameter.Set_Name (Name); Parameter.Type_Name := Of_Type; Into.Parameters.Append (Parameter); if Into.Kind = UNKNOWN and then Of_Type = "ASF.Parts.Part" then Into.Kind := ASF_UPLOAD; elsif Into.Kind = UNKNOWN and then Of_Type = "AWA.Events.Module_Event" then Into.Kind := AWA_EVENT; elsif Into.Kind = UNKNOWN then Into.Kind := ASF_ACTION; end if; end Add_Parameter; -- ------------------------------ -- Get the operation type. -- ------------------------------ function Get_Type (From : in Operation_Definition) return Operation_Type is begin return From.Kind; end Get_Type; -- ------------------------------ -- Create an operation with the given name. -- ------------------------------ function Create_Operation (Name : in UString) return Operation_Definition_Access is pragma Unreferenced (Name); Result : constant Operation_Definition_Access := new Operation_Definition; begin return Result; end Create_Operation; end Gen.Model.Operations;
------------------------------------------------------------------------------ -- -- -- GNAT RUNTIME COMPONENTS -- -- -- -- I N T E R F A C E S . C P P -- -- -- -- S p e c -- -- -- -- $Revision: 2 $ -- -- -- -- Copyright (c) 1992,1993,1994 NYU, All Rights Reserved -- -- -- -- 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, 675 Mass Ave, Cambridge, MA 02139, USA. -- -- -- ------------------------------------------------------------------------------ -- Definitions for interfacing to C++ classes with System; with System.Storage_Elements; package Interfaces.CPP is -- This package corresponds to Ada.Tags but applied to tagged types -- which are 'imported' from C++ and correspond to exactly to a C++ -- Class. GNAT doesn't know about the structure od the C++ dispatch -- table (Vtable) but always access it through the procedural interface -- defined below, thus the iplementation of this package (the body) can -- be customized to another C++ compiler without any change in the -- compiler code itself as long as this procedural interface is -- respected. Note that Ada.Tags defines a very similar procedural -- interface to the regular Ada Dispatch Table. type Vtable_Ptr is private; private -- Note: these procedures are accessible to Rtsfind, but not visible -- to a user who with's the package to get the Vtable_Ptr declaration. procedure Set_Vfunction_Address (Vptr : Vtable_Ptr; Position : Positive; Value : System.Address); -- Given a pointer to a Vtable (Vptr) and a position in the -- Vtable, put the address of the virtual function in it. -- (used for overriding) function Get_Vfunction_Address (Vptr : Vtable_Ptr; Position : Positive) return System.Address; -- Given a pointer to a Vtable (Vptr) and a position in the Vtable, this -- function returns the address of the virtual function stored in it. -- (used for dispatching calls) procedure Set_Idepth (Vptr : Vtable_Ptr; Value : Natural); -- Given a pointer to a Vtable, stores the value representing -- the depth in the inheritance tree. -- (used during elaboration of the tagged type) function Get_Idepth (Vptr : Vtable_Ptr) return Natural; -- Given a pointer to a Vtable, retreives the value representing -- the depth in the inheritance tree. -- (used for membership) procedure Set_Ancestor_Vptrs (Vptr : Vtable_Ptr; Value : System.Address); -- Given a pointer to a Vtable, stores the address of a table that can -- be used to store the Vptrs of the ancestors, this table is statically -- allocated by the compiler along with the Dispatch Table (Vtable) with -- a sufficient size to store all Vptrs ancestors in order to match the -- canonical implementation of membership test (see Ada.Tags for details). -- (used during elaboration of the tagged type) function Get_Ancestor_Vptrs (Vptr : Vtable_Ptr) return System.Address; -- Given a pointer to a Vtable, retreives the address of a -- table containing the Vptrs of the ancestors. -- (used for membership) function Displaced_This (Current_This : System.Address; Vptr : Vtable_Ptr; Position : Positive) return System.Address; -- Compute the displacement on the "this" pointer in order to be -- compatible with MI. -- (used for virtual function calls) function Vtable_Size (Entry_Count : Natural) return System.Storage_Elements.Storage_Count; -- Compute the size in 'storage_count' of a vtable of the given size -- (used to statically create the vtable) procedure Inherit_Vtable (Old_Vptr : Vtable_Ptr; New_Vptr : Vtable_Ptr; Entry_Count : Natural); -- The Vtable referenced by New_Vptr "inherits" the Entry_Count first -- entries of the Vtable referenced by Old_Vptr. This function is also -- responsible for inheriting the type specific information used for -- the membership implementation -- (used to initialize a new Vtable) function CPP_Membership (Obj_Vptr : Vtable_Ptr; Typ_Vptr : Vtable_Ptr) return Boolean; -- Given the tag of an object and the tag associated to a type, return -- true if Obj is in Typ'Class. -- (used for classwide membership test) type Vtable; type Vtable_Ptr is access all Vtable; pragma Inline (Set_Vfunction_Address); pragma Inline (Get_Vfunction_Address); pragma Inline (Set_Idepth); pragma Inline (Get_Idepth); pragma Inline (Set_Ancestor_Vptrs); pragma Inline (Get_Ancestor_Vptrs); pragma Inline (Displaced_This); pragma Inline (Vtable_Size); pragma Inline (Inherit_Vtable); pragma Inline (CPP_Membership); end Interfaces.CPP;
with Data; with Ada.Integer_Text_IO,Ada.Text_IO; use Ada.Integer_Text_IO,Ada.Text_IO; with System.Multiprocessors; use System.Multiprocessors; --F1 ME = MAX(B) *(MA*MD) --F2 MF = g*TRANS(MG)*(MK*ML) --F3 O = (MP *MR)*S + T procedure Main is N:Integer:=2; package Data1 is new Data (N); use Data1; Res1:Matrix; Res2:Matrix; Res3:Vector; CPU_0: CPU_Range := 1; CPU_1: CPU_Range := 2; CPU_2: CPU_Range := 3; procedure Tasks is task T1 is pragma Task_Name("T1"); pragma Priority (9); pragma Storage_Size(10000000); pragma CPU(CPU_0); end T1; task T2 is pragma Task_Name("T2"); pragma Priority (8); pragma Storage_Size(10000000); pragma CPU(CPU_1); end T2; task T3 is pragma Task_Name("T3"); pragma Priority (3); pragma Storage_Size(10000000); pragma CPU(CPU_2); end T3; task body T1 is B:Vector; MA:Matrix; MD:Matrix; --ME:Matrix; begin Put_Line("Task T1 started"); Vector_Filling_Ones(B); Matrix_Filling_Ones(MA); Matrix_Filling_Ones(MD); delay 1.0; Res1 := Func1(B=>B,MA=>MA,MD=>MD); delay 1.0; -- Put_Line("Task T1 finished"); end T1; task body T2 is g:Integer := N; MG:Matrix; MK:Matrix; ML:Matrix; --MF:Matrix; begin Put_Line("Task T2 started"); Matrix_Filling_Ones(MG); Matrix_Filling_Ones(MK); Matrix_Filling_Ones(ML); delay 1.0; Res2 := Func2(g => g, MG => MG, MK => MK, ML => ML ); delay 1.0; Put_Line("Task T2 finished"); end T2; task body T3 is MP,MR:Matrix; S,T:Vector; begin Put_Line("Task T3 started"); Matrix_Filling_Ones(MP); Matrix_Filling_Ones(MR); Vector_Filling_Ones(S); Vector_Filling_Ones(T); delay 1.0; Res3 := Func3(MP,MR,S,T); delay 1.0; Put_Line("Task T3 finished"); end T3; begin null; end Tasks; begin Tasks; Put("T1: ME = "); New_Line; Matrix_Output(Res1); Put("T2: ME = "); New_Line; Matrix_Output(Res2); New_Line; Put("T3: O = "); New_Line; Vector_Output(Res3); end Main;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- F N A M E -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2004 Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package, together with its child package Fname.UF define the -- association between source file names and unit names as defined -- (see package Uname for definition of format of unit names). with Types; use Types; package Fname is -- Note: this package spec does not depend on the Uname spec in the Ada -- sense, but the comments and description of the semantics do depend on -- the conventions established by Uname. --------------------------- -- File Name Conventions -- --------------------------- -- GNAT requires that there be a one to one correspondence between source -- file names (as used in the Osint package interface) and unit names as -- defined by the Uname package. This correspondence is defined by the -- two subprograms defined here in the Fname package. -- For full rules of file naming, see GNAT User's Guide. Note that the -- naming rules are affected by the presence of Source_File_Name pragmas -- that have been previously processed. -- Note that the file name does *not* include the directory name. The -- management of directories is provided by Osint, and full file names -- are used only for error message purposes within GNAT itself. ----------------- -- Subprograms -- ----------------- function Is_Predefined_File_Name (Fname : File_Name_Type; Renamings_Included : Boolean := True) return Boolean; -- This function determines if the given file name (which must be a simple -- file name with no directory information) is the file name for one of -- the predefined library units. On return, Name_Buffer contains the -- file name. The Renamings_Included parameter indicates whether annex -- J renamings such as Text_IO are to be considered as predefined. If -- Renamings_Included is True, then Text_IO will return True, otherwise -- only children of Ada, Interfaces and System return True. function Is_Predefined_File_Name (Renamings_Included : Boolean := True) return Boolean; -- This version is called with the file name already in Name_Buffer function Is_Internal_File_Name (Fname : File_Name_Type; Renamings_Included : Boolean := True) return Boolean; -- Similar to Is_Predefined_File_Name. The internal file set is a -- superset of the predefined file set including children of GNAT, -- and also children of DEC for the VMS case. procedure Tree_Read; -- Dummy procedure (reads dummy table values from tree file) procedure Tree_Write; -- Writes out internal tables to current tree file using Tree_Write -- This is actually a dummy routine, since the relevant table is -- no longer used, but we retain it for now, to avoid a tree file -- incompatibility with the 3.13 compiler. Should be removed for -- the 3.14a release ??? end Fname;
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with Ada.Characters.Latin_1; with Ada.Directories; with Ada.Exceptions; with File_Operations; with Utilities; with PortScan.Log; package body Port_Specification.Web is package LAT renames Ada.Characters.Latin_1; package DIR renames Ada.Directories; package FOP renames File_Operations; package LOG renames PortScan.Log; package UTL renames Utilities; -------------------------------------------------------------------------------------------- -- produce_page -------------------------------------------------------------------------------------------- procedure produce_page (specs : Portspecs; variant : String; dossier : TIO.File_Type; portdir : String; blocked : String; created : CAL.Time; changed : CAL.Time; devscan : Boolean) is begin TIO.Put_Line (dossier, page_header ("Ravenport: " & specs.get_namebase)); TIO.Put_Line (dossier, generate_body (specs => specs, variant => variant, portdir => portdir, blocked => blocked, created => created, changed => changed, devscan => devscan)); TIO.Put_Line (dossier, page_footer); end produce_page; -------------------------------------------------------------------------------------------- -- escape_value -------------------------------------------------------------------------------------------- function escape_value (raw : String) return String is function htmlval (rawchar : Character) return String; focus : constant String := LAT.Ampersand & LAT.Quotation & LAT.Less_Than_Sign & LAT.Greater_Than_Sign; curlen : Natural := raw'Length; result : String (1 .. raw'Length * 6) := (others => ' '); function htmlval (rawchar : Character) return String is begin case rawchar is when LAT.Ampersand => return "&amp;"; when LAT.Quotation => return "&quot;"; when LAT.Less_Than_Sign => return "&lt;"; when LAT.Greater_Than_Sign => return "&gt;"; when others => return ""; end case; end htmlval; begin result (1 .. curlen) := raw; for x in focus'Range loop if HT.count_char (result (1 .. curlen), focus (x)) > 0 then declare newstr : constant String := HT.replace_char (result (1 .. curlen), focus (x), htmlval (focus (x))); begin curlen := newstr'Length; result (1 .. curlen) := newstr; end; end if; end loop; return result (1 .. curlen); end escape_value; -------------------------------------------------------------------------------------------- -- nvpair -------------------------------------------------------------------------------------------- function nvpair (name, value : String) return String is begin return " " & name & LAT.Equals_Sign & LAT.Quotation & escape_value (value) & LAT.Quotation; end nvpair; -------------------------------------------------------------------------------------------- -- page_header -------------------------------------------------------------------------------------------- function page_header (title : String) return String is bing : constant String := LAT.Greater_Than_Sign & LAT.LF; content : constant String := "Ravenports individual port description"; csslink : constant String := "../../../style/ravenports.css"; cctrl : constant String := "public, max-age=21600"; -- valid 6 hours begin return "<!doctype html" & bing & "<html" & nvpair ("lang", "en") & bing & "<head" & bing & " <title>" & escape_value (title) & "</title" & bing & " <meta" & nvpair ("charset", "utf-8") & bing & " <meta" & nvpair ("name", "description") & nvpair ("content", content) & bing & " <meta" & nvpair ("http-equiv", "Cache-Control") & nvpair ("content", cctrl) & bing & " <link" & nvpair ("rel", "stylesheet") & nvpair ("href", csslink) & bing & "</head" & bing & "<body>"; end page_header; -------------------------------------------------------------------------------------------- -- page_footer -------------------------------------------------------------------------------------------- function page_footer return String is bing : constant String := LAT.Greater_Than_Sign & LAT.LF; link1val : constant String := "Ravenports catalog"; link2val : constant String := "Ravenports official site"; begin return " <div" & nvpair ("id", "footer") & bing & " <div" & nvpair ("id", "catlink") & ">" & link ("../../../index.html", "footlink", link1val) & " | " & link ("http://www.ravenports.com/", "footlink", link2val) & "</div" & bing & " </div" & bing & "</body>" & LAT.LF & "</html>"; end page_footer; -------------------------------------------------------------------------------------------- -- div -------------------------------------------------------------------------------------------- function div (id, value : String) return String is begin return "<div" & nvpair ("id", id) & ">" & escape_value (value) & "</div>" & LAT.LF; end div; -------------------------------------------------------------------------------------------- -- body_template -------------------------------------------------------------------------------------------- function body_template return String is ediv : constant String := "</div>" & LAT.LF; etd : constant String := "</td>" & LAT.LF; etr : constant String := "</tr>" & LAT.LF; btr : constant String := "<tr>" & LAT.LF; raw : constant String := " <div id='namebase'>@NAMEBASE@" & ediv & " <div id='shortblock'>" & LAT.LF & " <table id='sbt1'>" & LAT.LF & " <tbody>" & LAT.LF & " " & btr & " <td>Port variant" & etd & " <td id='variant'>@VARIANT@" & etd & " " & etr & " " & btr & " <td>Summary" & etd & " <td id='summary'>@TAGLINE@" & etd & " " & etr & "@BROKEN@" & "@DEPRECATED@" & "@ONLY_PLATFORM@" & "@EXC_PLATFORM@" & "@EXC_ARCH@" & " " & btr & " <td>Package version" & etd & " <td id='pkgversion'>@PKGVERSION@" & etd & " " & etr & " " & btr & " <td>Homepage" & etd & " <td id='homepage'>@HOMEPAGE@" & etd & " " & etr & " " & btr & " <td>Keywords" & etd & " <td id='keywords'>@KEYWORDS@" & etd & " " & etr & " " & btr & " <td>Maintainer" & etd & " <td id='maintainer'>@MAINTAINER@" & etd & " " & etr & " " & btr & " <td>License" & etd & " <td id='license'>@LICENSE@" & etd & " " & etr & " " & btr & " <td>Other variants" & etd & " <td id='othervar'>@OTHERVAR@" & etd & " " & etr & " " & btr & " <td>Ravenports" & etd & " <td id='ravenports'>@LNK_BUILDSHEET@ | @LNK_HISTORY_BS@" & etd & " " & etr & " " & btr & " <td>Ravensource" & etd & " <td id='ravensource'>@LNK_PORT@ | @LNK_HISTORY_PORT@" & etd & " " & etr & " " & btr & " <td>Last modified" & etd & " <td id='mdate'>@MDATETIME@" & etd & " " & etr & " " & btr & " <td>Port created" & etd & " <td id='cdate'>@CDATETIME@" & etd & " " & etr & " </tbody>" & LAT.LF & " </table>" & LAT.LF & " " & ediv & " <div id='pkgdesc'>" & LAT.LF & " <div id='pdtitle'>Subpackage Descriptions" & ediv & " <table id='pdt2'>" & LAT.LF & " <tbody>" & LAT.LF & "@DESCBODY@" & " </tbody>" & LAT.LF & " </table>" & LAT.LF & " " & ediv & " <div id='options'>" & LAT.LF & " <div id='optiontitle'>" & "Configuration Switches (platform-specific settings discarded)" & ediv & " <div id='optionblock'>@OPTIONBLOCK@" & ediv & " " & ediv & " <div id='dependencies'>" & LAT.LF & " <div id='deptitle'>Package Dependencies by Type" & ediv & " <table id='dpt3'>" & LAT.LF & " <tbody>" & LAT.LF & "@DEPBODY@" & " </tbody>" & LAT.LF & " </table>" & LAT.LF & " " & ediv & " <div id='master_sites'>" & LAT.LF & " <div id='mstitle'>Download groups" & ediv & " <table id='dlt4'>" & LAT.LF & " <tbody>" & LAT.LF & "@SITES@" & " </tbody>" & LAT.LF & " </table>" & LAT.LF & " " & ediv & " <div id='distinfo'>" & LAT.LF & " <div id='disttitle'>Distribution File Information" & ediv & " <div id='distblock'>@DISTINFO@" & ediv & " " & ediv & " <div id='upstream'>" & LAT.LF & " <div id='ustitle'>Ports that require @NAMEBASE@:@VARIANT@" & ediv & " <div id='upstream_inner'>" & LAT.LF & " <table id='ust5'>" & LAT.LF & " <tbody>" & LAT.LF & "@UPSTREAM@" & " </tbody>" & LAT.LF & " </table>" & LAT.LF & " " & ediv & " </div>"; begin return HT.replace_all (S => raw, reject => LAT.Apostrophe, shiny => LAT.Quotation); end body_template; -------------------------------------------------------------------------------------------- -- two_cell_row_template -------------------------------------------------------------------------------------------- function two_cell_row_template return String is begin return " <tr>" & LAT.LF & " <td>@CELL1@</td>" & LAT.LF & " <td>@CELL2@</td>" & LAT.LF & " </tr>" & LAT.LF; end two_cell_row_template; -------------------------------------------------------------------------------------------- -- link -------------------------------------------------------------------------------------------- function link (href, link_class, value : String) return String is begin return "<a" & nvpair ("href", href) & nvpair ("class", link_class) & ">" & value & "</a>"; end link; -------------------------------------------------------------------------------------------- -- format_homepage -------------------------------------------------------------------------------------------- function format_homepage (homepage : String) return String is begin if homepage = homepage_none then return "No known homepage"; end if; return link (homepage, "hplink", homepage); end format_homepage; -------------------------------------------------------------------------------------------- -- list_scheme -------------------------------------------------------------------------------------------- function list_scheme (licenses, scheme : String) return String is stripped : constant String := HT.replace_all (licenses, LAT.Quotation, ' '); begin if HT.IsBlank (licenses) then return "Not yet specified"; end if; if scheme = "single" then return stripped; end if; return stripped & LAT.Space & LAT.Left_Parenthesis & scheme & LAT.Right_Parenthesis; end list_scheme; -------------------------------------------------------------------------------------------- -- other_variants -------------------------------------------------------------------------------------------- function other_variants (specs : Portspecs; variant : String) return String is nvar : Natural := specs.get_number_of_variants; counter : Natural := 0; result : HT.Text; begin if nvar = 1 then return "There are no other variants."; end if; for x in 1 .. nvar loop declare nextvar : constant String := specs.get_list_item (sp_variants, x); begin if nextvar /= variant then counter := counter + 1; if counter > 1 then HT.SU.Append (result, " | "); end if; HT.SU.Append (result, link ("../" & nextvar & "/", "ovlink", nextvar)); end if; end; end loop; return HT.USS (result); end other_variants; -------------------------------------------------------------------------------------------- -- subpackage_description_block -------------------------------------------------------------------------------------------- function subpackage_description_block (specs : Portspecs; namebase : String; variant : String; portdir : String) return String is function description (variant, subpackage : String) return String; num_pkgs : Natural := specs.get_subpackage_length (variant); result : HT.Text; id2 : constant String := namebase & LAT.Hyphen & variant; function description (variant, subpackage : String) return String is trunk : constant String := portdir & "/descriptions/desc."; desc1 : constant String := trunk & subpackage & "." & variant; desc2 : constant String := trunk & subpackage; begin if DIR.Exists (desc1) then return FOP.get_file_contents (desc1); elsif DIR.Exists (desc2) then return FOP.get_file_contents (desc2); end if; if subpackage = "docs" then return "This is the documents subpackage of the " & id2 & " port."; elsif subpackage = "examples" then return "This is the examples subpackage of the " & id2 & " port."; elsif subpackage = "nls" then return "This is the native language support subpackage of the " & id2 & " port."; elsif subpackage = "complete" then return "This is the " & id2 & " metapackage." & LAT.LF & "It pulls in all subpackages of " & id2 & "."; else return "Subpackage description undefined (port maintainer error)."; end if; end description; begin for x in 1 .. num_pkgs loop declare row : HT.Text := HT.SUS (two_cell_row_template); spkg : constant String := specs.get_subpackage_item (variant, x); begin -- Don't escape CELL2, it's preformatted row := HT.replace_substring (row, "@CELL1@", spkg); row := HT.replace_substring (row, "@CELL2@", description (variant, spkg)); HT.SU.Append (result, row); end; end loop; return HT.USS (result); end subpackage_description_block; -------------------------------------------------------------------------------------------- -- dependency_block -------------------------------------------------------------------------------------------- function dependency_block (specs : Portspecs) return String is function link_block (field : spec_field) return String; procedure add_row (field : spec_field; listlen : Natural); result : HT.Text; nb : constant Natural := specs.get_list_length (sp_build_deps); nbr : constant Natural := specs.get_list_length (sp_buildrun_deps); nr : constant Natural := specs.get_list_length (sp_run_deps); xr : constant Natural := Natural (specs.extra_rundeps.Length); sb : constant Natural := Natural (specs.opsys_b_deps.Length); sbr : constant Natural := Natural (specs.opsys_br_deps.Length); sr : constant Natural := Natural (specs.opsys_r_deps.Length); procedure add_row (field : spec_field; listlen : Natural) is begin if listlen > 0 then declare row : HT.Text := HT.SUS (two_cell_row_template); begin if field = sp_build_deps then row := HT.replace_substring (row, "@CELL1@", "Build (only)"); elsif field = sp_buildrun_deps then row := HT.replace_substring (row, "@CELL1@", "Build and Runtime"); else row := HT.replace_substring (row, "@CELL1@", "Runtime (only)"); end if; row := HT.replace_substring (row, "@CELL2@", link_block (field)); HT.SU.Append (result, row); end; end if; end add_row; function link_block (field : spec_field) return String is procedure spkg_scan (position : list_crate.Cursor); procedure opsys_scan (position : list_crate.Cursor); procedure dump_dep (position : string_crate.Cursor); procedure process_opsys_dep (position : string_crate.Cursor); procedure dump_opsys_dep (position : def_crate.Cursor); listlen : constant Natural := specs.get_list_length (field); cell : HT.Text; spkg : HT.Text; ostr : HT.Text; tempstore : def_crate.Map; procedure spkg_scan (position : list_crate.Cursor) is rec : group_list renames list_crate.Element (position); begin spkg := rec.group; rec.list.Iterate (dump_dep'Access); end spkg_scan; procedure opsys_scan (position : list_crate.Cursor) is rec : group_list renames list_crate.Element (position); begin ostr := rec.group; rec.list.Iterate (process_opsys_dep'Access); end opsys_scan; procedure dump_dep (position : string_crate.Cursor) is dep : String := HT.USS (string_crate.Element (position)); namebase : String := HT.specific_field (dep, 1, ":"); bucket : String := UTL.bucket (namebase); variant : String := HT.specific_field (dep, 3, ":"); href : String := "../../../bucket_" & bucket & "/" & namebase & "/" & variant; value : String := dep & " (" & HT.USS (spkg) & " subpackage)"; lnk : String := link (href, "deplink", value); begin if HT.IsBlank (cell) then HT.SU.Append (cell, LAT.LF & lnk); else HT.SU.Append (cell, "<br/>" & LAT.LF & lnk); end if; end dump_dep; procedure dump_opsys_dep (position : def_crate.Cursor) is dep : String := HT.USS (def_crate.Key (position)); namebase : String := HT.specific_field (dep, 1, ":"); bucket : String := UTL.bucket (namebase); variant : String := HT.specific_field (dep, 3, ":"); href : String := "../../../bucket_" & bucket & "/" & namebase & "/" & variant; value : String := dep & " (" & HT.USS (def_crate.Element (position)) & ")"; lnk : String := link (href, "deplink", value); begin if HT.IsBlank (cell) then HT.SU.Append (cell, LAT.LF & lnk); else HT.SU.Append (cell, "<br/>" & LAT.LF & lnk); end if; end dump_opsys_dep; procedure process_opsys_dep (position : string_crate.Cursor) is new_index : HT.Text renames string_crate.Element (position); new_value : HT.Text; begin if tempstore.Contains (new_index) then new_value := tempstore.Element (new_index); HT.SU.Append (new_value, ", " & HT.USS (ostr)); tempstore.Delete (new_index); tempstore.Insert (new_index, new_value); else tempstore.Insert (new_index, ostr); end if; end process_opsys_dep; begin for x in 1 .. listlen loop declare dep : String := specs.get_list_item (field, x); namebase : String := HT.specific_field (dep, 1, ":"); bucket : String := UTL.bucket (namebase); variant : String := HT.specific_field (dep, 3, ":"); href : String := "../../../bucket_" & bucket & "/" & namebase & "/" & variant; lnk : String := link (href, "deplink", dep); begin if x = 1 then HT.SU.Append (cell, LAT.LF & lnk); else HT.SU.Append (cell, "<br/>" & LAT.LF & lnk); end if; end; end loop; if field = sp_build_deps then specs.opsys_b_deps.Iterate (opsys_scan'Access); end if; if field = sp_buildrun_deps then specs.opsys_br_deps.Iterate (opsys_scan'Access); end if; if field = sp_run_deps then specs.opsys_r_deps.Iterate (opsys_scan'Access); specs.extra_rundeps.Iterate (spkg_scan'Access); end if; tempstore.Iterate (dump_opsys_dep'Access); return HT.USS (cell); end link_block; begin if nb + nr + nbr + xr = 0 then return " <tr><td>This package has no dependency requirements of any kind.</td></tr>"; end if; add_row (sp_build_deps, nb + sb); add_row (sp_buildrun_deps, nbr + sbr); add_row (sp_run_deps, nr + sr + xr); return HT.USS (result); end dependency_block; -------------------------------------------------------------------------------------------- -- retrieve_distinfo -------------------------------------------------------------------------------------------- function retrieve_distinfo (specs : Portspecs; portdir : String) return String is distinfo : String := portdir & "/distinfo"; begin if DIR.Exists (distinfo) then return FOP.get_file_contents (distinfo); else return "This port does not contain distinfo information."; end if; end retrieve_distinfo; -------------------------------------------------------------------------------------------- -- master_sites_block -------------------------------------------------------------------------------------------- function master_sites_block (specs : Portspecs) return String is package crate is new CON.Vectors (Index_Type => Positive, Element_Type => HT.Text, "=" => HT.SU."="); package local_sorter is new crate.Generic_Sorting ("<" => HT.SU."<"); procedure group_scan (position : crate.Cursor); procedure gather (position : list_crate.Cursor); procedure dump_sites (position : string_crate.Cursor); function make_link (site : String) return String; num_groups : constant Natural := Natural (specs.dl_sites.Length); first_group : constant String := HT.USS (list_crate.Element (specs.dl_sites.First).group); cell2 : HT.Text; result : HT.Text; groups : crate.Vector; function make_link (site : String) return String is lnk : constant String := link (site, "sitelink", site); begin if HT.contains (site, "://") then return lnk; else return "mirror://" & site; end if; end make_link; procedure dump_sites (position : string_crate.Cursor) is site_string : HT.Text renames string_crate.Element (position); lnk : constant String := make_link (HT.USS (site_string)); begin if HT.IsBlank (cell2) then HT.SU.Append (cell2, lnk); else HT.SU.Append (cell2, "<br/>" & LAT.LF & lnk); end if; end dump_sites; procedure gather (position : list_crate.Cursor) is name : HT.Text renames list_crate.Key (position); begin if not HT.equivalent (name, dlgroup_main) then groups.Append (name); end if; end gather; procedure group_scan (position : crate.Cursor) is index : HT.Text renames crate.Element (position); rec : group_list renames specs.dl_sites.Element (index); cell1 : constant String := HT.USS (rec.group); row : HT.Text := HT.SUS (two_cell_row_template); begin cell2 := HT.SU.Null_Unbounded_String; rec.list.Iterate (dump_sites'Access); row := HT.replace_substring (row, "@CELL1@", cell1); row := HT.replace_substring (row, "@CELL2@", HT.USS (cell2)); HT.SU.Append (result, row); end group_scan; begin if num_groups = 1 and then first_group = dlgroup_none then return " <tr><td>This port does not download anything.</td></tr>"; end if; specs.dl_sites.Iterate (gather'Access); local_sorter.Sort (Container => groups); if specs.dl_sites.Contains (HT.SUS (dlgroup_main)) then groups.Prepend (HT.SUS (dlgroup_main)); end if; groups.Iterate (group_scan'Access); return HT.USS (result); end master_sites_block; -------------------------------------------------------------------------------------------- -- deprecated_message -------------------------------------------------------------------------------------------- function deprecated_message (specs : Portspecs) return String is row1 : HT.Text := HT.SUS (two_cell_row_template); row2 : HT.Text := HT.SUS (two_cell_row_template); begin if HT.IsBlank (specs.deprecated) then return ""; end if; row1 := HT.replace_substring (row1, "@CELL1@", "DEPRECATED"); row1 := HT.replace_substring (row1, "@CELL2@", HT.USS (specs.deprecated)); row2 := HT.replace_substring (row2, "@CELL1@", "Expiration Date"); row2 := HT.replace_substring (row2, "@CELL2@", HT.USS (specs.expire_date)); return HT.USS (row1) & HT.USS (row2); end deprecated_message; -------------------------------------------------------------------------------------------- -- broken_attributes -------------------------------------------------------------------------------------------- function broken_attributes (specs : Portspecs) return String is procedure group_scan (position : list_crate.Cursor); procedure dump_messages (position : string_crate.Cursor); row1 : HT.Text := HT.SUS (two_cell_row_template); content : HT.Text; index : HT.Text; procedure group_scan (position : list_crate.Cursor) is rec : group_list renames list_crate.Element (position); begin index := rec.group; rec.list.Iterate (dump_messages'Access); end group_scan; procedure dump_messages (position : string_crate.Cursor) is message : HT.Text renames string_crate.Element (position); esc_msg : String := "[" & HT.USS (index) & "] " & escape_value (HT.USS (message)); begin if HT.IsBlank (content) then HT.SU.Append (content, LAT.LF & esc_msg); else HT.SU.Append (content, "<br/>" & LAT.LF & esc_msg); end if; end dump_messages; begin if specs.broken.Is_Empty then return ""; end if; specs.broken.Iterate (group_scan'Access); row1 := HT.replace_substring (row1, "@CELL1@", "BROKEN"); row1 := HT.replace_substring (row1, "@CELL2@", HT.USS (content)); return HT.USS (row1); end broken_attributes; -------------------------------------------------------------------------------------------- -- inclusive_platform -------------------------------------------------------------------------------------------- function inclusive_platform (specs : Portspecs) return String is procedure dump (position : string_crate.Cursor); row1 : HT.Text := HT.SUS (two_cell_row_template); content : HT.Text; procedure dump (position : string_crate.Cursor) is message : HT.Text renames string_crate.Element (position); begin if HT.IsBlank (content) then HT.SU.Append (content, message); else HT.SU.Append (content, " | " & HT.USS (message)); end if; end dump; begin if specs.inc_opsys.Is_Empty then return ""; end if; specs.inc_opsys.Iterate (dump'Access); row1 := HT.replace_substring (row1, "@CELL1@", "Only for platform"); row1 := HT.replace_substring (row1, "@CELL2@", HT.USS (content)); return HT.USS (row1); end inclusive_platform; -------------------------------------------------------------------------------------------- -- exclusive_platform -------------------------------------------------------------------------------------------- function exclusive_platform (specs : Portspecs) return String is procedure dump (position : string_crate.Cursor); row1 : HT.Text := HT.SUS (two_cell_row_template); content : HT.Text; procedure dump (position : string_crate.Cursor) is message : HT.Text renames string_crate.Element (position); begin if HT.IsBlank (content) then HT.SU.Append (content, message); else HT.SU.Append (content, " | " & HT.USS (message)); end if; end dump; begin if specs.exc_opsys.Is_Empty then return ""; end if; specs.exc_opsys.Iterate (dump'Access); row1 := HT.replace_substring (row1, "@CELL1@", "Exclude platform"); row1 := HT.replace_substring (row1, "@CELL2@", HT.USS (content)); return HT.USS (row1); end exclusive_platform; -------------------------------------------------------------------------------------------- -- exclusive_arch -------------------------------------------------------------------------------------------- function exclusive_arch (specs : Portspecs) return String is procedure dump (position : string_crate.Cursor); row1 : HT.Text := HT.SUS (two_cell_row_template); content : HT.Text; procedure dump (position : string_crate.Cursor) is message : HT.Text renames string_crate.Element (position); begin if HT.IsBlank (content) then HT.SU.Append (content, message); else HT.SU.Append (content, " | " & HT.USS (message)); end if; end dump; begin if specs.exc_arch.Is_Empty then return ""; end if; specs.exc_arch.Iterate (dump'Access); row1 := HT.replace_substring (row1, "@CELL1@", "Exclude architecture"); row1 := HT.replace_substring (row1, "@CELL2@", HT.USS (content)); return HT.USS (row1); end exclusive_arch; -------------------------------------------------------------------------------------------- -- upstream -------------------------------------------------------------------------------------------- function upstream (blocked : String) return String is markers : HT.Line_Markers; result : HT.Text; begin if HT.IsBlank (blocked) then return "<tr><td>No other ports depend on this one.</td></tr>" & LAT.LF; end if; HT.initialize_markers (blocked, markers); loop exit when not HT.next_line_present (blocked, markers); declare line : constant String := HT.extract_line (blocked, markers); cell : constant String := HT.specific_field (line, 1, ";"); href : constant String := HT.specific_field (line, 2, ";"); lnk : constant String := link (href, "upslink", cell); row1 : HT.Text := HT.SUS (two_cell_row_template); begin row1 := HT.replace_substring (row1, "@CELL1@", lnk); row1 := HT.replace_substring (row1, "@CELL2@", HT.specific_field (line, 3, ";")); HT.SU.Append (result, row1); end; end loop; return HT.USS (result); exception when issue : others => return "<tr><td>" & Ada.Exceptions.Exception_Message (issue) & "</td></tr>" & LAT.LF & "<tr><td>" & blocked & "</td></tr>" & LAT.LF; end upstream; -------------------------------------------------------------------------------------------- -- generate_body -------------------------------------------------------------------------------------------- function generate_body (specs : Portspecs; variant : String; portdir : String; blocked : String; created : CAL.Time; changed : CAL.Time; devscan : Boolean) return String is result : HT.Text := HT.SUS (body_template); namebase : constant String := specs.get_namebase; bucket : constant String := UTL.bucket (namebase); catport : constant String := "bucket_" & bucket & "/" & namebase; subject : constant String := "Ravenports:%20" & specs.get_namebase & "%20port"; homepage : constant String := format_homepage (specs.get_field_value (sp_homepage)); tagline : constant String := escape_value (specs.get_tagline (variant)); isocdate : constant String := LOG.timestamp (created, True); isomdate : constant String := LOG.timestamp (changed, True); licenses : constant String := list_scheme (specs.get_field_value (sp_licenses), specs.get_license_scheme); lnk_bs : constant String := link ("https://raw.githubusercontent.com/jrmarino/Ravenports/master/" & catport, "ghlink", "Buildsheet"); lnk_bshy : constant String := link ("https://github.com/jrmarino/Ravenports/commits/master/" & catport, "histlink", "History"); lnk_port : constant String := link ("https://github.com/jrmarino/ravensource/tree/master/" & catport, "ghlink", "Port Directory"); lnk_pthy : constant String := link ("https://github.com/jrmarino/ravensource/commits/master/" & catport, "histlink", "History"); begin result := HT.replace_substring (result, "@NAMEBASE@", namebase); result := HT.replace_substring (result, "@NAMEBASE@", namebase); result := HT.replace_substring (result, "@VARIANT@", variant); result := HT.replace_substring (result, "@VARIANT@", variant); result := HT.replace_substring (result, "@HOMEPAGE@", homepage); result := HT.replace_substring (result, "@TAGLINE@", tagline); result := HT.replace_substring (result, "@PKGVERSION@", specs.calculate_pkgversion); result := HT.replace_substring (result, "@MAINTAINER@", specs.get_web_contacts (subject)); result := HT.replace_substring (result, "@KEYWORDS@", specs.get_field_value (sp_keywords)); result := HT.replace_substring (result, "@LICENSE@", licenses); result := HT.replace_substring (result, "@CDATETIME@", isocdate); result := HT.replace_substring (result, "@MDATETIME@", isomdate); result := HT.replace_substring (result, "@LNK_BUILDSHEET@", lnk_bs); result := HT.replace_substring (result, "@LNK_HISTORY_BS@", lnk_bshy); result := HT.replace_substring (result, "@LNK_PORT@", lnk_port); result := HT.replace_substring (result, "@LNK_HISTORY_PORT@", lnk_pthy); result := HT.replace_substring (result, "@OTHERVAR@", other_variants (specs, variant)); result := HT.replace_substring (result, "@OPTIONBLOCK@", specs.options_summary (variant)); result := HT.replace_substring (result, "@DISTINFO@", retrieve_distinfo (specs, portdir)); result := HT.replace_substring (result, "@DEPBODY@", dependency_block (specs)); result := HT.replace_substring (result, "@SITES@", master_sites_block (specs)); result := HT.replace_substring (result, "@DEPRECATED@", deprecated_message (specs)); result := HT.replace_substring (result, "@BROKEN@", broken_attributes (specs)); result := HT.replace_substring (result, "@ONLY_PLATFORM@", inclusive_platform (specs)); result := HT.replace_substring (result, "@EXC_PLATFORM@", exclusive_platform (specs)); result := HT.replace_substring (result, "@EXC_ARCH@", exclusive_arch (specs)); result := HT.replace_substring (result, "@UPSTREAM@", upstream (blocked)); result := HT.replace_substring (result, "@DESCBODY@", subpackage_description_block (specs, namebase, variant, portdir)); return HT.USS (result); end generate_body; -------------------------------------------------------------------------------------------- -- generate_catalog_index -------------------------------------------------------------------------------------------- function generate_catalog_index (dossier : TIO.File_Type; row_assembly_block : String) return Boolean is begin declare template_file : String := host_localbase & "/share/ravenadm/catalog.template"; template : constant String := FOP.get_file_contents (template_file); fullpage : HT.Text := HT.SUS (template); begin fullpage := HT.replace_substring (fullpage, "@ROW_ASSY@", row_assembly_block); TIO.Put_Line (dossier, HT.USS (fullpage)); return True; end; exception when others => TIO.Put_Line ("Failed to create the web site index"); return False; end generate_catalog_index; end Port_Specification.Web;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010-2012, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Ada.Command_Line; with Ada.Directories; with Ada.Integer_Wide_Text_IO; with Ada.Strings.Wide_Unbounded.Wide_Text_IO; with Ada.Wide_Text_IO; with Wide_Put_File_Header; with Parser_Extractor; package body Parser_Generator is use Ada.Integer_Wide_Text_IO; use Ada.Strings.Wide_Unbounded; use Ada.Strings.Wide_Unbounded.Wide_Text_IO; use Ada.Wide_Text_IO; use Parser_Extractor; function Parser_Template_File_Name return String; -- Returns file name of the parser's template. function Parser_File_Name return String; -- Returns file name of the parser's implementation file. function Parser_Tables_File_Name return String; -- Returns file name of the parser's tables data. ---------------------- -- Parser_File_Name -- ---------------------- function Parser_File_Name return String is Template : constant String := Ada.Directories.Simple_Name (Parser_Template_File_Name); begin return Template (Template'First .. Template'Last - 3); end Parser_File_Name; ----------------------------- -- Parser_Tables_File_Name -- ----------------------------- function Parser_Tables_File_Name return String is begin return Ada.Directories.Base_Name (Parser_File_Name) & "-tables.ads"; end Parser_Tables_File_Name; ------------------------------- -- Parser_Template_File_Name -- ------------------------------- function Parser_Template_File_Name return String is begin return Ada.Command_Line.Argument (3); end Parser_Template_File_Name; -------------------------- -- Generate_Parser_Code -- -------------------------- procedure Generate_Parser_Code is Input : File_Type; Output : File_Type; Buffer : Wide_String (1 .. 1024); Last : Natural; begin Open (Input, In_File, Parser_Template_File_Name, "wcem=8"); Create (Output, Out_File, Parser_File_Name, "wcem=8"); while not End_Of_File (Input) loop Get_Line (Input, Buffer, Last); if Buffer (1 .. Last) = "%%" then for J in 1 .. Natural (Choices.Length) loop declare Element : constant Choice_Information := Choices.Element (J); begin if not Element.Is_Empty then New_Line (Output); Put (Output, " when "); Put (Output, Element.Choice, 0); Put_Line (Output, " =>"); for J in 1 .. Natural (Element.Text.Length) loop if Length (Element.Text.Element (J)) /= 0 then Put (Output, " "); Put_Line (Output, Element.Text.Element (J)); else New_Line (Output); end if; end loop; end if; end; end loop; else Put_Line (Output, Buffer (1 .. Last)); end if; end loop; Close (Output); Close (Input); end Generate_Parser_Code; ---------------------------- -- Generate_Parser_Tables -- ---------------------------- procedure Generate_Parser_Tables is Output : File_Type; procedure Generate_Array (Name : Wide_String; Values : Integer_Vectors.Vector); procedure Generate_Array_Of_Pair (Name : Wide_String; Values : Pair_Vectors.Vector); -------------------- -- Generate_Array -- -------------------- procedure Generate_Array (Name : Wide_String; Values : Integer_Vectors.Vector) is begin New_Line (Output); Put (Output, " "); Put (Output, Name); Put (Output, " : constant array (0 .. "); Put (Output, Integer (Values.Length) - 1, 0); Put_Line (Output, ") of Integer :="); for J in 0 .. Natural (Values.Length) - 1 loop if J = 0 then Put (Output, " ("); elsif J mod 8 = 0 then Put_Line (Output, ","); Put (Output, " "); else Put (Output, ","); end if; Put (Output, Values.Element (J), 5); end loop; Put_Line (Output, ");"); end Generate_Array; ---------------------------- -- Generate_Array_Of_Pair -- ---------------------------- procedure Generate_Array_Of_Pair (Name : Wide_String; Values : Pair_Vectors.Vector) is begin New_Line (Output); Put (Output, " YY_"); Put (Output, Name); Put (Output, "_Matrix : constant array ("); Put (Output, Values.First_Index, 0); Put (Output, " .. "); Put (Output, Values.Last_Index, 0); Put (Output, ") of "); Put (Output, Name); Put_Line (Output, "_Entry :="); for J in Values.First_Index .. Values.Last_Index loop if J = Values.First_Index then Put (Output, " ("); elsif (J - Values.First_Index) mod 4 = 0 then Put_Line (Output, ","); Put (Output, " "); else Put (Output, ", "); end if; Put (Output, "("); Put (Output, Values.Element (J).First, 5); Put (Output, ", "); Put (Output, Values.Element (J).Second, 5); Put (Output, ")"); end loop; Put_Line (Output, ");"); end Generate_Array_Of_Pair; begin Create (Output, Out_File, Parser_Tables_File_Name, "wcem=8"); if Ada.Command_Line.Argument (1) = "regexp" then Wide_Put_File_Header (Output, "Localization, Internationalization, Globalization for Ada", 2010, 2010); elsif Ada.Command_Line.Argument (1) = "xml" then Wide_Put_File_Header (Output, "XML Processor", 2010, 2012); end if; Put_Line (Output, "pragma Style_Checks (""-t"");"); Put_Line (Output, "-- GNAT: Disable check for token separation rules, because format o" & "f the"); Put_Line (Output, "-- tables is not compatible with them."); New_Line (Output); if Ada.Command_Line.Argument (1) = "regexp" then Put (Output, "private package Matreshka.Internals.Regexps.Compiler"); elsif Ada.Command_Line.Argument (1) = "xml" then Put (Output, "private package XML.SAX.Simple_Readers"); end if; Put_Line (Output, ".Parser.Tables is"); if Ada.Command_Line.Argument (1) = "regexp" then New_Line (Output); Put_Line (Output, " pragma Preelaborate;"); end if; New_Line (Output); Put_Line (Output, " type Goto_Entry is record"); Put_Line (Output, " Nonterm : Integer;"); Put_Line (Output, " Newstate : Integer;"); Put_Line (Output, " end record;"); New_Line (Output); Put_Line (Output, " type Shift_Reduce_Entry is record"); Put_Line (Output, " T : Integer;"); Put_Line (Output, " Act : Integer;"); Put_Line (Output, " end record;"); New_Line (Output); Put (Output, " YY_Default : constant := "); Put (Output, YY_Default, 5); Put_Line (Output, ";"); Put (Output, " YY_First_Shift_Entry : constant := "); Put (Output, YY_First_Shift_Entry, 5); Put_Line (Output, ";"); Put (Output, " YY_Accept_Code : constant := "); Put (Output, YY_Accept_Code, 5); Put_Line (Output, ";"); Put (Output, " YY_Error_Code : constant := "); Put (Output, YY_Error_Code, 5); Put_Line (Output, ";"); -- Generate goto matrix Generate_Array_Of_Pair ("Goto", YY_Goto_Matrix); Generate_Array ("YY_Goto_Offset", YY_Goto_Offset); Generate_Array ("YY_Rule_Length", YY_Rule_Length); Generate_Array ("YY_Get_LHS_Rule", YY_Get_LHS_Rule); -- Generate shitf-reduce matrix Generate_Array_Of_Pair ("Shift_Reduce", YY_Shift_Reduce_Matrix); Generate_Array ("YY_Shift_Reduce_Offset", YY_Shift_Reduce_Offset); New_Line (Output); if Ada.Command_Line.Argument (1) = "regexp" then Put (Output, "end Matreshka.Internals.Regexps.Compiler"); elsif Ada.Command_Line.Argument (1) = "xml" then Put (Output, "end XML.SAX.Simple_Readers"); end if; Put_Line (Output, ".Parser.Tables;"); Close (Output); end Generate_Parser_Tables; end Parser_Generator;
pragma License (Unrestricted); -- implementation unit required by compiler package System.Val_Real is pragma Pure; -- required for Float'Value by compiler (s-valrea.ads) function Value_Real (Str : String) return Long_Long_Float; end System.Val_Real;
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ---------------------------------------------------------------- with Ada.Streams.Stream_IO; with Ada.Wide_Wide_Text_IO; with League.Application; with League.Stream_Element_Vectors; with League.String_Vectors; with League.Strings; with League.JSON.Objects; with AWS.Client; with JWS.RS256; with ACME; procedure Hello_World_Run is function "+" (V : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; procedure Read_File (Name : String; Value : out League.Stream_Element_Vectors.Stream_Element_Vector); Domain : constant League.Strings.Universal_String := League.Application.Arguments.Element (1); procedure Read_File (Name : String; Value : out League.Stream_Element_Vectors.Stream_Element_Vector) is Input : Ada.Streams.Stream_IO.File_Type; Data : Ada.Streams.Stream_Element_Array (1 .. 4096); Last : Ada.Streams.Stream_Element_Count; begin Ada.Streams.Stream_IO.Open (Input, Ada.Streams.Stream_IO.In_File, Name); Ada.Streams.Stream_IO.Read (Input, Data, Last); Ada.Streams.Stream_IO.Close (Input); Value.Append (Data (1 .. Last)); end Read_File; Context : ACME.Context; Term_Of_Service : League.Strings.Universal_String; Private_Key : League.Stream_Element_Vectors.Stream_Element_Vector; Public_Key : League.Stream_Element_Vectors.Stream_Element_Vector; CSR : League.Stream_Element_Vectors.Stream_Element_Vector; Account : League.Strings.Universal_String; Order : League.Strings.Universal_String; Cert : League.Strings.Universal_String; DNS_List : League.String_Vectors.Universal_String_Vector; Auth_List : League.String_Vectors.Universal_String_Vector; Finalize : League.Strings.Universal_String; C1, C2 : ACME.Challenge; JWK : League.JSON.Objects.JSON_Object; Status : League.Strings.Universal_String; Text : League.Strings.Universal_String; begin AWS.Client.Set_Debug (True); -- Read keys and CSR Read_File ("/tmp/priv.dat", Private_Key); Read_File ("/tmp/pub.dat", Public_Key); Read_File ("/tmp/csr.dat", CSR); Context.Initialize (+"https://acme-staging-v02.api.letsencrypt.org/directory", Term_Of_Service); Ada.Wide_Wide_Text_IO.Put ("Please read Term Of Service: "); Ada.Wide_Wide_Text_IO.Put_Line (Term_Of_Service.To_Wide_Wide_String); -- Construct JWK from out public key to pass it to CA and create account JWK := JWS.RS256.Public_JWK (Public_Key.To_Stream_Element_Array); Context.Create_Account (Public_Key => JWK, Private_Key => Private_Key, Contact => League.String_Vectors.Empty_Universal_String_Vector, TOS_Agreed => True, Only_Existing => False, Account_URL => Account); -- Request domain certificate by creating an order DNS_List.Append (Domain); Context.Create_Order (Account_URL => Account, Private_Key => Private_Key, DNS_Id_List => DNS_List, Auth_List => Auth_List, Finalize => Finalize, Order_URL => Order); -- Get challenges required to fulfill authorization requirements Context.Get_Challenges (Account_URL => Account, Private_Key => Private_Key, Auth_URL => Auth_List (1), HTTP => C1, DNS => C2); -- Overcome the HTTP challenge Ada.Wide_Wide_Text_IO.Put ("Put this content: "); Ada.Wide_Wide_Text_IO.Put_Line (ACME.Key_Authorization (C1.Token, JWK).To_Wide_Wide_String); Ada.Wide_Wide_Text_IO.Put ("To be accessible at http://"); Ada.Wide_Wide_Text_IO.Put (Domain.To_Wide_Wide_String); Ada.Wide_Wide_Text_IO.Put ("/.well-known/acme-challenge/"); Ada.Wide_Wide_Text_IO.Put_Line (C1.Token.To_Wide_Wide_String); Ada.Wide_Wide_Text_IO.Put_Line ("Then press ENTER"); declare -- Wait ENTER pressing Ignore : Wide_Wide_String := Ada.Wide_Wide_Text_IO.Get_Line; begin null; end; -- Notify the server Context.Challenge_Complete (Account_URL => Account, Private_Key => Private_Key, Challenge => C1); -- Wait the server to verify the challenge loop Context.Challenge_Status (Account_URL => Account, Private_Key => Private_Key, Challenge => C1, Status => Status); Ada.Wide_Wide_Text_IO.Put ("Challenge Status:"); Ada.Wide_Wide_Text_IO.Put_Line (Status.To_Wide_Wide_String); exit when Status.Ends_With ("valid"); -- valid or invalid delay 1.0; end loop; -- Finalize the order: loop Context.Get_Order_Status (Account_URL => Account, Private_Key => Private_Key, Order_URL => Order, Certificate => Cert, Status => Status); Ada.Wide_Wide_Text_IO.Put ("Order Status:"); Ada.Wide_Wide_Text_IO.Put_Line (Status.To_Wide_Wide_String); exit when Status.Ends_With ("valid"); -- valid or invalid if Status.To_Wide_Wide_String = "ready" then Context.Finalize_Order (Account_URL => Account, Private_Key => Private_Key, Finalize => Finalize, CSR => CSR); else delay 1.0; end if; end loop; -- Download the certificate if Status.To_Wide_Wide_String = "valid" then Context.Get_Certificate (Account_URL => Account, Private_Key => Private_Key, Certificate => Cert, Text => Text); Ada.Wide_Wide_Text_IO.Put_Line (Text.To_Wide_Wide_String); end if; end Hello_World_Run;
with MSPGD; package MSPGD.GPIO is pragma Preelaborate; type Alt_Func_Type is (IO, Primary, Secondary, Device_Specific, Analog, Comparator); type Direction_Type is (Input, Output); type Resistor_Type is (None, Up, Down); subtype Pin_Type is Integer range 0 .. 7; subtype Port_Type is Unsigned_8 range 1 .. 8; end MSPGD.GPIO;
------------------------------------------------------------------------------- -- Copyright (c) 2016 Daniel King -- -- 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. ------------------------------------------------------------------------------- -- Provides an API for reading the state of the S1 switches on the -- EVB1000 board. -- -- On S1 there are 8 individual switches that can be toggled on or off. -- Out of these switches, only switches 3 .. 8 are available to the -- STM32F105 host processor, as switches 1 and 2 are used to set the BOOT0 -- and BOOT1 pins. package EVB1000.S1 with SPARK_Mode => On, Abstract_State => (Switch_State with External), Initializes => Switch_State is type Bit is mod 2 with Size => 1; type Switch_Number is range 3 .. 8; -- Only switches 3 .. 8 are available on S1 to the host processor. -- Switches 1 and 2 determine the BOOT pins' setting. type Switch_Bit_Array is array (Switch_Number) of Bit; procedure Read_Switch(Switch : in Switch_Number; State : out Bit) with Global => (Input => Switch_State), Depends => (State => (Switch_State, Switch)); -- Read the current state of a switch. -- -- The state of the switch is 1 if the switch is 'on', otherwise it is 0 if -- the switch is 'off'. procedure Read_All(Switches : out Switch_Bit_Array) with Global => (Input => Switch_State), Depends => (Switches => Switch_State); -- Read the current state of all 6 switches. -- -- The state of each switch is 1 if the switch is 'on', otherwise it is 0 if -- the switch is 'off'. end EVB1000.S1;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ D I S P -- -- -- -- S p e c -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- This package contains routines involved in tagged types and dynamic -- dispatching. with Types; use Types; package Sem_Disp is procedure Check_Controlling_Formals (Typ : Entity_Id; Subp : Entity_Id); -- Check that all controlling parameters of Subp are of type Typ, -- that defaults for controlling parameters are tag-indeterminate, -- and that the nominal subtype of the parameters and result -- statically match the first subtype of the controlling type. procedure Check_Dispatching_Call (N : Node_Id); -- Check if a call is a dispatching call. The subprogram is known to -- be a dispatching operation. The call is dispatching if all the -- controlling actuals are dynamically tagged. This procedure is called -- after overload resolution, so the call is known to be unambiguous. procedure Check_Dispatching_Operation (Subp, Old_Subp : Entity_Id); -- Add "Subp" to the list of primitive operations of the corresponding type -- if it has a parameter of this type and is defined at a proper place for -- primitive operations (new primitives are only defined in package spec, -- overridden operation can be defined in any scope). If Old_Subp is not -- Empty we are in the overriding case. procedure Check_Operation_From_Incomplete_Type (Subp : Entity_Id; Typ : Entity_Id); -- If a primitive operation was defined for the incomplete view of the -- type, and the full type declaration is a derived type definition, -- the operation may override an inherited one. procedure Check_Operation_From_Private_View (Subp, Old_Subp : Entity_Id); -- Add "Old_Subp" to the list of primitive operations of the corresponding -- tagged type if it is the full view of a private tagged type. The Alias -- of "OldSubp" is adjusted to point to the inherited procedure of the -- full view because it is always this one which has to be called. function Find_Controlling_Arg (N : Node_Id) return Node_Id; -- Returns the actual controlling argument if N is dynamically tagged, -- and Empty if it is not dynamically tagged. function Find_Dispatching_Type (Subp : Entity_Id) return Entity_Id; -- Check whether a subprogram is dispatching, and find the tagged -- type of the controlling argument or arguments. function Is_Dynamically_Tagged (N : Node_Id) return Boolean; -- Used to determine whether a call is dispatching, i.e. if is an -- an expression of a class_Wide type, or a call to a function with -- controlling result where at least one operand is dynamically tagged. function Is_Tag_Indeterminate (N : Node_Id) return Boolean; -- An expression is tag-indeterminate if it is a call that dispatches -- on result, and all controlling operands are also indeterminate. -- Such a function call may inherit a tag from an enclosing call. procedure Override_Dispatching_Operation (Tagged_Type : Entity_Id; Prev_Op : Entity_Id; New_Op : Entity_Id); -- Replace an implicit dispatching operation with an explicit one. -- Prev_Op is an inherited primitive operation which is overridden -- by the explicit declaration of New_Op. procedure Propagate_Tag (Control : Node_Id; Actual : Node_Id); -- If a function call is tag-indeterminate, its controlling argument is -- found in the context; either an enclosing call, or the left-hand side -- of the enclosing assignment statement. The tag must be propagated -- recursively to the tag-indeterminate actuals of the call. end Sem_Disp;
with Ada.Text_IO; use Ada.Text_IO; procedure Lcm_Test is function Gcd (A, B : Integer) return Integer is M : Integer := A; N : Integer := B; T : Integer; begin while N /= 0 loop T := M; M := N; N := T mod N; end loop; return M; end Gcd; function Lcm (A, B : Integer) return Integer is begin if A = 0 or B = 0 then return 0; end if; return abs (A) * (abs (B) / Gcd (A, B)); end Lcm; begin Put_Line ("LCM of 12, 18 is" & Integer'Image (Lcm (12, 18))); Put_Line ("LCM of -6, 14 is" & Integer'Image (Lcm (-6, 14))); Put_Line ("LCM of 35, 0 is" & Integer'Image (Lcm (35, 0))); end Lcm_Test;
with Interfaces.C; package Libtcod is type Width is new Interfaces.C.int range 0 .. Interfaces.C.int'Last; type Height is new Interfaces.C.int range 0 .. Interfaces.C.int'Last; end Libtcod;
-- { dg-do run } with Ifaces; use Ifaces; procedure test_ifaces is view2 : access Iface_2'Class; obj : aliased DT := (m_name => "Abdu"); begin view2 := Iface_2'Class(obj)'Access; view2.all.op2; end;
-- -- Jan & Uwe R. Zimmer, Australia, July 2011 -- -- -- Usage if the purpose is to "catch all": -- -- begin -- .. -- exception -- when Exception_Id : others => Show_Exception (Exception_Id); -- end; -- with Ada.Exceptions; use Ada.Exceptions; package Exceptions is procedure Show_Exception (Exception_Identifier : Exception_Occurrence; Optional_Message : String := ""); end Exceptions;
-- This spec has been automatically generated from STM32L0x3.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.STK is pragma Preelaborate; --------------- -- Registers -- --------------- -- SysTick control and status register type CSR_Register is record -- Counter enable ENABLE : Boolean := False; -- SysTick exception request enable TICKINT : Boolean := False; -- Clock source selection CLKSOURCE : Boolean := False; -- unspecified Reserved_3_15 : HAL.UInt13 := 16#0#; -- COUNTFLAG COUNTFLAG : Boolean := False; -- unspecified Reserved_17_31 : HAL.UInt15 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CSR_Register use record ENABLE at 0 range 0 .. 0; TICKINT at 0 range 1 .. 1; CLKSOURCE at 0 range 2 .. 2; Reserved_3_15 at 0 range 3 .. 15; COUNTFLAG at 0 range 16 .. 16; Reserved_17_31 at 0 range 17 .. 31; end record; subtype RVR_RELOAD_Field is HAL.UInt24; -- SysTick reload value register type RVR_Register is record -- RELOAD value RELOAD : RVR_RELOAD_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RVR_Register use record RELOAD at 0 range 0 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype CVR_CURRENT_Field is HAL.UInt24; -- SysTick current value register type CVR_Register is record -- Current counter value CURRENT : CVR_CURRENT_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CVR_Register use record CURRENT at 0 range 0 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype CALIB_TENMS_Field is HAL.UInt24; -- SysTick calibration value register type CALIB_Register is record -- Calibration value TENMS : CALIB_TENMS_Field := 16#0#; -- unspecified Reserved_24_29 : HAL.UInt6 := 16#0#; -- SKEW flag: Indicates whether the TENMS value is exact SKEW : Boolean := False; -- NOREF flag. Reads as zero NOREF : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CALIB_Register use record TENMS at 0 range 0 .. 23; Reserved_24_29 at 0 range 24 .. 29; SKEW at 0 range 30 .. 30; NOREF at 0 range 31 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- SysTick timer type STK_Peripheral is record -- SysTick control and status register CSR : aliased CSR_Register; -- SysTick reload value register RVR : aliased RVR_Register; -- SysTick current value register CVR : aliased CVR_Register; -- SysTick calibration value register CALIB : aliased CALIB_Register; end record with Volatile; for STK_Peripheral use record CSR at 16#0# range 0 .. 31; RVR at 16#4# range 0 .. 31; CVR at 16#8# range 0 .. 31; CALIB at 16#C# range 0 .. 31; end record; -- SysTick timer STK_Periph : aliased STK_Peripheral with Import, Address => System'To_Address (16#E000E010#); end STM32_SVD.STK;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ C H 8 -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2016, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Atree; use Atree; with Debug; use Debug; with Einfo; use Einfo; with Elists; use Elists; with Errout; use Errout; with Exp_Disp; use Exp_Disp; with Exp_Tss; use Exp_Tss; with Exp_Util; use Exp_Util; with Fname; use Fname; with Freeze; use Freeze; with Ghost; use Ghost; with Impunit; use Impunit; with Lib; use Lib; with Lib.Load; use Lib.Load; with Lib.Xref; use Lib.Xref; with Namet; use Namet; with Namet.Sp; use Namet.Sp; with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; with Output; use Output; with Restrict; use Restrict; with Rident; use Rident; with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Aux; use Sem_Aux; with Sem_Cat; use Sem_Cat; with Sem_Ch3; use Sem_Ch3; with Sem_Ch4; use Sem_Ch4; with Sem_Ch6; use Sem_Ch6; with Sem_Ch12; use Sem_Ch12; with Sem_Ch13; use Sem_Ch13; with Sem_Dim; use Sem_Dim; with Sem_Disp; use Sem_Disp; with Sem_Dist; use Sem_Dist; with Sem_Eval; use Sem_Eval; with Sem_Res; use Sem_Res; with Sem_Util; use Sem_Util; with Sem_Type; use Sem_Type; with Stand; use Stand; with Sinfo; use Sinfo; with Sinfo.CN; use Sinfo.CN; with Snames; use Snames; with Style; use Style; with Table; with Tbuild; use Tbuild; with Uintp; use Uintp; package body Sem_Ch8 is ------------------------------------ -- Visibility and Name Resolution -- ------------------------------------ -- This package handles name resolution and the collection of possible -- interpretations for overloaded names, prior to overload resolution. -- Name resolution is the process that establishes a mapping between source -- identifiers and the entities they denote at each point in the program. -- Each entity is represented by a defining occurrence. Each identifier -- that denotes an entity points to the corresponding defining occurrence. -- This is the entity of the applied occurrence. Each occurrence holds -- an index into the names table, where source identifiers are stored. -- Each entry in the names table for an identifier or designator uses the -- Info pointer to hold a link to the currently visible entity that has -- this name (see subprograms Get_Name_Entity_Id and Set_Name_Entity_Id -- in package Sem_Util). The visibility is initialized at the beginning of -- semantic processing to make entities in package Standard immediately -- visible. The visibility table is used in a more subtle way when -- compiling subunits (see below). -- Entities that have the same name (i.e. homonyms) are chained. In the -- case of overloaded entities, this chain holds all the possible meanings -- of a given identifier. The process of overload resolution uses type -- information to select from this chain the unique meaning of a given -- identifier. -- Entities are also chained in their scope, through the Next_Entity link. -- As a consequence, the name space is organized as a sparse matrix, where -- each row corresponds to a scope, and each column to a source identifier. -- Open scopes, that is to say scopes currently being compiled, have their -- corresponding rows of entities in order, innermost scope first. -- The scopes of packages that are mentioned in context clauses appear in -- no particular order, interspersed among open scopes. This is because -- in the course of analyzing the context of a compilation, a package -- declaration is first an open scope, and subsequently an element of the -- context. If subunits or child units are present, a parent unit may -- appear under various guises at various times in the compilation. -- When the compilation of the innermost scope is complete, the entities -- defined therein are no longer visible. If the scope is not a package -- declaration, these entities are never visible subsequently, and can be -- removed from visibility chains. If the scope is a package declaration, -- its visible declarations may still be accessible. Therefore the entities -- defined in such a scope are left on the visibility chains, and only -- their visibility (immediately visibility or potential use-visibility) -- is affected. -- The ordering of homonyms on their chain does not necessarily follow -- the order of their corresponding scopes on the scope stack. For -- example, if package P and the enclosing scope both contain entities -- named E, then when compiling the package body the chain for E will -- hold the global entity first, and the local one (corresponding to -- the current inner scope) next. As a result, name resolution routines -- do not assume any relative ordering of the homonym chains, either -- for scope nesting or to order of appearance of context clauses. -- When compiling a child unit, entities in the parent scope are always -- immediately visible. When compiling the body of a child unit, private -- entities in the parent must also be made immediately visible. There -- are separate routines to make the visible and private declarations -- visible at various times (see package Sem_Ch7). -- +--------+ +-----+ -- | In use |-------->| EU1 |--------------------------> -- +--------+ +-----+ -- | | -- +--------+ +-----+ +-----+ -- | Stand. |---------------->| ES1 |--------------->| ES2 |---> -- +--------+ +-----+ +-----+ -- | | -- +---------+ | +-----+ -- | with'ed |------------------------------>| EW2 |---> -- +---------+ | +-----+ -- | | -- +--------+ +-----+ +-----+ -- | Scope2 |---------------->| E12 |--------------->| E22 |---> -- +--------+ +-----+ +-----+ -- | | -- +--------+ +-----+ +-----+ -- | Scope1 |---------------->| E11 |--------------->| E12 |---> -- +--------+ +-----+ +-----+ -- ^ | | -- | | | -- | +---------+ | | -- | | with'ed |-----------------------------------------> -- | +---------+ | | -- | | | -- Scope stack | | -- (innermost first) | | -- +----------------------------+ -- Names table => | Id1 | | | | Id2 | -- +----------------------------+ -- Name resolution must deal with several syntactic forms: simple names, -- qualified names, indexed names, and various forms of calls. -- Each identifier points to an entry in the names table. The resolution -- of a simple name consists in traversing the homonym chain, starting -- from the names table. If an entry is immediately visible, it is the one -- designated by the identifier. If only potentially use-visible entities -- are on the chain, we must verify that they do not hide each other. If -- the entity we find is overloadable, we collect all other overloadable -- entities on the chain as long as they are not hidden. -- -- To resolve expanded names, we must find the entity at the intersection -- of the entity chain for the scope (the prefix) and the homonym chain -- for the selector. In general, homonym chains will be much shorter than -- entity chains, so it is preferable to start from the names table as -- well. If the entity found is overloadable, we must collect all other -- interpretations that are defined in the scope denoted by the prefix. -- For records, protected types, and tasks, their local entities are -- removed from visibility chains on exit from the corresponding scope. -- From the outside, these entities are always accessed by selected -- notation, and the entity chain for the record type, protected type, -- etc. is traversed sequentially in order to find the designated entity. -- The discriminants of a type and the operations of a protected type or -- task are unchained on exit from the first view of the type, (such as -- a private or incomplete type declaration, or a protected type speci- -- fication) and re-chained when compiling the second view. -- In the case of operators, we do not make operators on derived types -- explicit. As a result, the notation P."+" may denote either a user- -- defined function with name "+", or else an implicit declaration of the -- operator "+" in package P. The resolution of expanded names always -- tries to resolve an operator name as such an implicitly defined entity, -- in addition to looking for explicit declarations. -- All forms of names that denote entities (simple names, expanded names, -- character literals in some cases) have a Entity attribute, which -- identifies the entity denoted by the name. --------------------- -- The Scope Stack -- --------------------- -- The Scope stack keeps track of the scopes currently been compiled. -- Every entity that contains declarations (including records) is placed -- on the scope stack while it is being processed, and removed at the end. -- Whenever a non-package scope is exited, the entities defined therein -- are removed from the visibility table, so that entities in outer scopes -- become visible (see previous description). On entry to Sem, the scope -- stack only contains the package Standard. As usual, subunits complicate -- this picture ever so slightly. -- The Rtsfind mechanism can force a call to Semantics while another -- compilation is in progress. The unit retrieved by Rtsfind must be -- compiled in its own context, and has no access to the visibility of -- the unit currently being compiled. The procedures Save_Scope_Stack and -- Restore_Scope_Stack make entities in current open scopes invisible -- before compiling the retrieved unit, and restore the compilation -- environment afterwards. ------------------------ -- Compiling subunits -- ------------------------ -- Subunits must be compiled in the environment of the corresponding stub, -- that is to say with the same visibility into the parent (and its -- context) that is available at the point of the stub declaration, but -- with the additional visibility provided by the context clause of the -- subunit itself. As a result, compilation of a subunit forces compilation -- of the parent (see description in lib-). At the point of the stub -- declaration, Analyze is called recursively to compile the proper body of -- the subunit, but without reinitializing the names table, nor the scope -- stack (i.e. standard is not pushed on the stack). In this fashion the -- context of the subunit is added to the context of the parent, and the -- subunit is compiled in the correct environment. Note that in the course -- of processing the context of a subunit, Standard will appear twice on -- the scope stack: once for the parent of the subunit, and once for the -- unit in the context clause being compiled. However, the two sets of -- entities are not linked by homonym chains, so that the compilation of -- any context unit happens in a fresh visibility environment. ------------------------------- -- Processing of USE Clauses -- ------------------------------- -- Every defining occurrence has a flag indicating if it is potentially use -- visible. Resolution of simple names examines this flag. The processing -- of use clauses consists in setting this flag on all visible entities -- defined in the corresponding package. On exit from the scope of the use -- clause, the corresponding flag must be reset. However, a package may -- appear in several nested use clauses (pathological but legal, alas) -- which forces us to use a slightly more involved scheme: -- a) The defining occurrence for a package holds a flag -In_Use- to -- indicate that it is currently in the scope of a use clause. If a -- redundant use clause is encountered, then the corresponding occurrence -- of the package name is flagged -Redundant_Use-. -- b) On exit from a scope, the use clauses in its declarative part are -- scanned. The visibility flag is reset in all entities declared in -- package named in a use clause, as long as the package is not flagged -- as being in a redundant use clause (in which case the outer use -- clause is still in effect, and the direct visibility of its entities -- must be retained). -- Note that entities are not removed from their homonym chains on exit -- from the package specification. A subsequent use clause does not need -- to rechain the visible entities, but only to establish their direct -- visibility. ----------------------------------- -- Handling private declarations -- ----------------------------------- -- The principle that each entity has a single defining occurrence clashes -- with the presence of two separate definitions for private types: the -- first is the private type declaration, and second is the full type -- declaration. It is important that all references to the type point to -- the same defining occurrence, namely the first one. To enforce the two -- separate views of the entity, the corresponding information is swapped -- between the two declarations. Outside of the package, the defining -- occurrence only contains the private declaration information, while in -- the private part and the body of the package the defining occurrence -- contains the full declaration. To simplify the swap, the defining -- occurrence that currently holds the private declaration points to the -- full declaration. During semantic processing the defining occurrence -- also points to a list of private dependents, that is to say access types -- or composite types whose designated types or component types are -- subtypes or derived types of the private type in question. After the -- full declaration has been seen, the private dependents are updated to -- indicate that they have full definitions. ------------------------------------ -- Handling of Undefined Messages -- ------------------------------------ -- In normal mode, only the first use of an undefined identifier generates -- a message. The table Urefs is used to record error messages that have -- been issued so that second and subsequent ones do not generate further -- messages. However, the second reference causes text to be added to the -- original undefined message noting "(more references follow)". The -- full error list option (-gnatf) forces messages to be generated for -- every reference and disconnects the use of this table. type Uref_Entry is record Node : Node_Id; -- Node for identifier for which original message was posted. The -- Chars field of this identifier is used to detect later references -- to the same identifier. Err : Error_Msg_Id; -- Records error message Id of original undefined message. Reset to -- No_Error_Msg after the second occurrence, where it is used to add -- text to the original message as described above. Nvis : Boolean; -- Set if the message is not visible rather than undefined Loc : Source_Ptr; -- Records location of error message. Used to make sure that we do -- not consider a, b : undefined as two separate instances, which -- would otherwise happen, since the parser converts this sequence -- to a : undefined; b : undefined. end record; package Urefs is new Table.Table ( Table_Component_Type => Uref_Entry, Table_Index_Type => Nat, Table_Low_Bound => 1, Table_Initial => 10, Table_Increment => 100, Table_Name => "Urefs"); Candidate_Renaming : Entity_Id; -- Holds a candidate interpretation that appears in a subprogram renaming -- declaration and does not match the given specification, but matches at -- least on the first formal. Allows better error message when given -- specification omits defaulted parameters, a common error. ----------------------- -- Local Subprograms -- ----------------------- procedure Analyze_Generic_Renaming (N : Node_Id; K : Entity_Kind); -- Common processing for all three kinds of generic renaming declarations. -- Enter new name and indicate that it renames the generic unit. procedure Analyze_Renamed_Character (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean); -- Renamed entity is given by a character literal, which must belong -- to the return type of the new entity. Is_Body indicates whether the -- declaration is a renaming_as_body. If the original declaration has -- already been frozen (because of an intervening body, e.g.) the body of -- the function must be built now. The same applies to the following -- various renaming procedures. procedure Analyze_Renamed_Dereference (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean); -- Renamed entity is given by an explicit dereference. Prefix must be a -- conformant access_to_subprogram type. procedure Analyze_Renamed_Entry (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean); -- If the renamed entity in a subprogram renaming is an entry or protected -- subprogram, build a body for the new entity whose only statement is a -- call to the renamed entity. procedure Analyze_Renamed_Family_Member (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean); -- Used when the renamed entity is an indexed component. The prefix must -- denote an entry family. procedure Analyze_Renamed_Primitive_Operation (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean); -- If the renamed entity in a subprogram renaming is a primitive operation -- or a class-wide operation in prefix form, save the target object, -- which must be added to the list of actuals in any subsequent call. -- The renaming operation is intrinsic because the compiler must in -- fact generate a wrapper for it (6.3.1 (10 1/2)). function Applicable_Use (Pack_Name : Node_Id) return Boolean; -- Common code to Use_One_Package and Set_Use, to determine whether use -- clause must be processed. Pack_Name is an entity name that references -- the package in question. procedure Attribute_Renaming (N : Node_Id); -- Analyze renaming of attribute as subprogram. The renaming declaration N -- is rewritten as a subprogram body that returns the attribute reference -- applied to the formals of the function. procedure Set_Entity_Or_Discriminal (N : Node_Id; E : Entity_Id); -- Set Entity, with style check if need be. For a discriminant reference, -- replace by the corresponding discriminal, i.e. the parameter of the -- initialization procedure that corresponds to the discriminant. procedure Check_Frozen_Renaming (N : Node_Id; Subp : Entity_Id); -- A renaming_as_body may occur after the entity of the original decla- -- ration has been frozen. In that case, the body of the new entity must -- be built now, because the usual mechanism of building the renamed -- body at the point of freezing will not work. Subp is the subprogram -- for which N provides the Renaming_As_Body. procedure Check_In_Previous_With_Clause (N : Node_Id; Nam : Node_Id); -- N is a use_package clause and Nam the package name, or N is a use_type -- clause and Nam is the prefix of the type name. In either case, verify -- that the package is visible at that point in the context: either it -- appears in a previous with_clause, or because it is a fully qualified -- name and the root ancestor appears in a previous with_clause. procedure Check_Library_Unit_Renaming (N : Node_Id; Old_E : Entity_Id); -- Verify that the entity in a renaming declaration that is a library unit -- is itself a library unit and not a nested unit or subunit. Also check -- that if the renaming is a child unit of a generic parent, then the -- renamed unit must also be a child unit of that parent. Finally, verify -- that a renamed generic unit is not an implicit child declared within -- an instance of the parent. procedure Chain_Use_Clause (N : Node_Id); -- Chain use clause onto list of uses clauses headed by First_Use_Clause in -- the proper scope table entry. This is usually the current scope, but it -- will be an inner scope when installing the use clauses of the private -- declarations of a parent unit prior to compiling the private part of a -- child unit. This chain is traversed when installing/removing use clauses -- when compiling a subunit or instantiating a generic body on the fly, -- when it is necessary to save and restore full environments. function Enclosing_Instance return Entity_Id; -- In an instance nested within another one, several semantic checks are -- unnecessary because the legality of the nested instance has been checked -- in the enclosing generic unit. This applies in particular to legality -- checks on actuals for formal subprograms of the inner instance, which -- are checked as subprogram renamings, and may be complicated by confusion -- in private/full views. This function returns the instance enclosing the -- current one if there is such, else it returns Empty. -- -- If the renaming determines the entity for the default of a formal -- subprogram nested within another instance, choose the innermost -- candidate. This is because if the formal has a box, and we are within -- an enclosing instance where some candidate interpretations are local -- to this enclosing instance, we know that the default was properly -- resolved when analyzing the generic, so we prefer the local -- candidates to those that are external. This is not always the case -- but is a reasonable heuristic on the use of nested generics. The -- proper solution requires a full renaming model. function Has_Implicit_Character_Literal (N : Node_Id) return Boolean; -- Find a type derived from Character or Wide_Character in the prefix of N. -- Used to resolved qualified names whose selector is a character literal. function Has_Private_With (E : Entity_Id) return Boolean; -- Ada 2005 (AI-262): Determines if the current compilation unit has a -- private with on E. procedure Find_Expanded_Name (N : Node_Id); -- The input is a selected component known to be an expanded name. Verify -- legality of selector given the scope denoted by prefix, and change node -- N into a expanded name with a properly set Entity field. function Find_Renamed_Entity (N : Node_Id; Nam : Node_Id; New_S : Entity_Id; Is_Actual : Boolean := False) return Entity_Id; -- Find the renamed entity that corresponds to the given parameter profile -- in a subprogram renaming declaration. The renamed entity may be an -- operator, a subprogram, an entry, or a protected operation. Is_Actual -- indicates that the renaming is the one generated for an actual subpro- -- gram in an instance, for which special visibility checks apply. function Has_Implicit_Operator (N : Node_Id) return Boolean; -- N is an expanded name whose selector is an operator name (e.g. P."+"). -- declarative part contains an implicit declaration of an operator if it -- has a declaration of a type to which one of the predefined operators -- apply. The existence of this routine is an implementation artifact. A -- more straightforward but more space-consuming choice would be to make -- all inherited operators explicit in the symbol table. procedure Inherit_Renamed_Profile (New_S : Entity_Id; Old_S : Entity_Id); -- A subprogram defined by a renaming declaration inherits the parameter -- profile of the renamed entity. The subtypes given in the subprogram -- specification are discarded and replaced with those of the renamed -- subprogram, which are then used to recheck the default values. function Is_Appropriate_For_Record (T : Entity_Id) return Boolean; -- Prefix is appropriate for record if it is of a record type, or an access -- to such. function Is_Appropriate_For_Entry_Prefix (T : Entity_Id) return Boolean; -- True if it is of a task type, a protected type, or else an access to one -- of these types. procedure Note_Redundant_Use (Clause : Node_Id); -- Mark the name in a use clause as redundant if the corresponding entity -- is already use-visible. Emit a warning if the use clause comes from -- source and the proper warnings are enabled. procedure Premature_Usage (N : Node_Id); -- Diagnose usage of an entity before it is visible procedure Use_One_Package (P : Entity_Id; N : Node_Id); -- Make visible entities declared in package P potentially use-visible -- in the current context. Also used in the analysis of subunits, when -- re-installing use clauses of parent units. N is the use_clause that -- names P (and possibly other packages). procedure Use_One_Type (Id : Node_Id; Installed : Boolean := False); -- Id is the subtype mark from a use type clause. This procedure makes -- the primitive operators of the type potentially use-visible. The -- boolean flag Installed indicates that the clause is being reinstalled -- after previous analysis, and primitive operations are already chained -- on the Used_Operations list of the clause. procedure Write_Info; -- Write debugging information on entities declared in current scope -------------------------------- -- Analyze_Exception_Renaming -- -------------------------------- -- The language only allows a single identifier, but the tree holds an -- identifier list. The parser has already issued an error message if -- there is more than one element in the list. procedure Analyze_Exception_Renaming (N : Node_Id) is Id : constant Entity_Id := Defining_Entity (N); Nam : constant Node_Id := Name (N); begin Check_SPARK_05_Restriction ("exception renaming is not allowed", N); Enter_Name (Id); Analyze (Nam); Set_Ekind (Id, E_Exception); Set_Etype (Id, Standard_Exception_Type); Set_Is_Pure (Id, Is_Pure (Current_Scope)); if Is_Entity_Name (Nam) and then Present (Entity (Nam)) and then Ekind (Entity (Nam)) = E_Exception then if Present (Renamed_Object (Entity (Nam))) then Set_Renamed_Object (Id, Renamed_Object (Entity (Nam))); else Set_Renamed_Object (Id, Entity (Nam)); end if; -- The exception renaming declaration may become Ghost if it renames -- a Ghost entity. Mark_Ghost_Renaming (N, Entity (Nam)); else Error_Msg_N ("invalid exception name in renaming", Nam); end if; -- Implementation-defined aspect specifications can appear in a renaming -- declaration, but not language-defined ones. The call to procedure -- Analyze_Aspect_Specifications will take care of this error check. if Has_Aspects (N) then Analyze_Aspect_Specifications (N, Id); end if; end Analyze_Exception_Renaming; --------------------------- -- Analyze_Expanded_Name -- --------------------------- procedure Analyze_Expanded_Name (N : Node_Id) is begin -- If the entity pointer is already set, this is an internal node, or a -- node that is analyzed more than once, after a tree modification. In -- such a case there is no resolution to perform, just set the type. In -- either case, start by analyzing the prefix. Analyze (Prefix (N)); if Present (Entity (N)) then if Is_Type (Entity (N)) then Set_Etype (N, Entity (N)); else Set_Etype (N, Etype (Entity (N))); end if; else Find_Expanded_Name (N); end if; -- In either case, propagate dimension of entity to expanded name Analyze_Dimension (N); end Analyze_Expanded_Name; --------------------------------------- -- Analyze_Generic_Function_Renaming -- --------------------------------------- procedure Analyze_Generic_Function_Renaming (N : Node_Id) is begin Analyze_Generic_Renaming (N, E_Generic_Function); end Analyze_Generic_Function_Renaming; -------------------------------------- -- Analyze_Generic_Package_Renaming -- -------------------------------------- procedure Analyze_Generic_Package_Renaming (N : Node_Id) is begin -- Test for the Text_IO special unit case here, since we may be renaming -- one of the subpackages of Text_IO, then join common routine. Check_Text_IO_Special_Unit (Name (N)); Analyze_Generic_Renaming (N, E_Generic_Package); end Analyze_Generic_Package_Renaming; ---------------------------------------- -- Analyze_Generic_Procedure_Renaming -- ---------------------------------------- procedure Analyze_Generic_Procedure_Renaming (N : Node_Id) is begin Analyze_Generic_Renaming (N, E_Generic_Procedure); end Analyze_Generic_Procedure_Renaming; ------------------------------ -- Analyze_Generic_Renaming -- ------------------------------ procedure Analyze_Generic_Renaming (N : Node_Id; K : Entity_Kind) is New_P : constant Entity_Id := Defining_Entity (N); Inst : Boolean := False; Old_P : Entity_Id; begin if Name (N) = Error then return; end if; Check_SPARK_05_Restriction ("generic renaming is not allowed", N); Generate_Definition (New_P); if Current_Scope /= Standard_Standard then Set_Is_Pure (New_P, Is_Pure (Current_Scope)); end if; if Nkind (Name (N)) = N_Selected_Component then Check_Generic_Child_Unit (Name (N), Inst); else Analyze (Name (N)); end if; if not Is_Entity_Name (Name (N)) then Error_Msg_N ("expect entity name in renaming declaration", Name (N)); Old_P := Any_Id; else Old_P := Entity (Name (N)); end if; Enter_Name (New_P); Set_Ekind (New_P, K); if Etype (Old_P) = Any_Type then null; elsif Ekind (Old_P) /= K then Error_Msg_N ("invalid generic unit name", Name (N)); else if Present (Renamed_Object (Old_P)) then Set_Renamed_Object (New_P, Renamed_Object (Old_P)); else Set_Renamed_Object (New_P, Old_P); end if; -- The generic renaming declaration may become Ghost if it renames a -- Ghost entity. Mark_Ghost_Renaming (N, Old_P); Set_Is_Pure (New_P, Is_Pure (Old_P)); Set_Is_Preelaborated (New_P, Is_Preelaborated (Old_P)); Set_Etype (New_P, Etype (Old_P)); Set_Has_Completion (New_P); if In_Open_Scopes (Old_P) then Error_Msg_N ("within its scope, generic denotes its instance", N); end if; -- For subprograms, propagate the Intrinsic flag, to allow, e.g. -- renamings and subsequent instantiations of Unchecked_Conversion. if Ekind_In (Old_P, E_Generic_Function, E_Generic_Procedure) then Set_Is_Intrinsic_Subprogram (New_P, Is_Intrinsic_Subprogram (Old_P)); end if; Check_Library_Unit_Renaming (N, Old_P); end if; -- Implementation-defined aspect specifications can appear in a renaming -- declaration, but not language-defined ones. The call to procedure -- Analyze_Aspect_Specifications will take care of this error check. if Has_Aspects (N) then Analyze_Aspect_Specifications (N, New_P); end if; end Analyze_Generic_Renaming; ----------------------------- -- Analyze_Object_Renaming -- ----------------------------- procedure Analyze_Object_Renaming (N : Node_Id) is Id : constant Entity_Id := Defining_Identifier (N); Loc : constant Source_Ptr := Sloc (N); Nam : constant Node_Id := Name (N); Dec : Node_Id; T : Entity_Id; T2 : Entity_Id; procedure Check_Constrained_Object; -- If the nominal type is unconstrained but the renamed object is -- constrained, as can happen with renaming an explicit dereference or -- a function return, build a constrained subtype from the object. If -- the renaming is for a formal in an accept statement, the analysis -- has already established its actual subtype. This is only relevant -- if the renamed object is an explicit dereference. ------------------------------ -- Check_Constrained_Object -- ------------------------------ procedure Check_Constrained_Object is Typ : constant Entity_Id := Etype (Nam); Subt : Entity_Id; begin if Nkind_In (Nam, N_Function_Call, N_Explicit_Dereference) and then Is_Composite_Type (Etype (Nam)) and then not Is_Constrained (Etype (Nam)) and then not Has_Unknown_Discriminants (Etype (Nam)) and then Expander_Active then -- If Actual_Subtype is already set, nothing to do if Ekind_In (Id, E_Variable, E_Constant) and then Present (Actual_Subtype (Id)) then null; -- A renaming of an unchecked union has no actual subtype elsif Is_Unchecked_Union (Typ) then null; -- If a record is limited its size is invariant. This is the case -- in particular with record types with an access discirminant -- that are used in iterators. This is an optimization, but it -- also prevents typing anomalies when the prefix is further -- expanded. Limited types with discriminants are included. elsif Is_Limited_Record (Typ) or else (Ekind (Typ) = E_Limited_Private_Type and then Has_Discriminants (Typ) and then Is_Access_Type (Etype (First_Discriminant (Typ)))) then null; else Subt := Make_Temporary (Loc, 'T'); Remove_Side_Effects (Nam); Insert_Action (N, Make_Subtype_Declaration (Loc, Defining_Identifier => Subt, Subtype_Indication => Make_Subtype_From_Expr (Nam, Typ))); Rewrite (Subtype_Mark (N), New_Occurrence_Of (Subt, Loc)); Set_Etype (Nam, Subt); -- Freeze subtype at once, to prevent order of elaboration -- issues in the backend. The renamed object exists, so its -- type is already frozen in any case. Freeze_Before (N, Subt); end if; end if; end Check_Constrained_Object; -- Start of processing for Analyze_Object_Renaming begin if Nam = Error then return; end if; Check_SPARK_05_Restriction ("object renaming is not allowed", N); Set_Is_Pure (Id, Is_Pure (Current_Scope)); Enter_Name (Id); -- The renaming of a component that depends on a discriminant requires -- an actual subtype, because in subsequent use of the object Gigi will -- be unable to locate the actual bounds. This explicit step is required -- when the renaming is generated in removing side effects of an -- already-analyzed expression. if Nkind (Nam) = N_Selected_Component and then Analyzed (Nam) then -- The object renaming declaration may become Ghost if it renames a -- Ghost entity. if Is_Entity_Name (Nam) then Mark_Ghost_Renaming (N, Entity (Nam)); end if; T := Etype (Nam); Dec := Build_Actual_Subtype_Of_Component (Etype (Nam), Nam); if Present (Dec) then Insert_Action (N, Dec); T := Defining_Identifier (Dec); Set_Etype (Nam, T); end if; -- Complete analysis of the subtype mark in any case, for ASIS use if Present (Subtype_Mark (N)) then Find_Type (Subtype_Mark (N)); end if; elsif Present (Subtype_Mark (N)) then Find_Type (Subtype_Mark (N)); T := Entity (Subtype_Mark (N)); Analyze (Nam); -- The object renaming declaration may become Ghost if it renames a -- Ghost entity. if Is_Entity_Name (Nam) then Mark_Ghost_Renaming (N, Entity (Nam)); end if; -- Reject renamings of conversions unless the type is tagged, or -- the conversion is implicit (which can occur for cases of anonymous -- access types in Ada 2012). if Nkind (Nam) = N_Type_Conversion and then Comes_From_Source (Nam) and then not Is_Tagged_Type (T) then Error_Msg_N ("renaming of conversion only allowed for tagged types", Nam); end if; Resolve (Nam, T); -- If the renamed object is a function call of a limited type, -- the expansion of the renaming is complicated by the presence -- of various temporaries and subtypes that capture constraints -- of the renamed object. Rewrite node as an object declaration, -- whose expansion is simpler. Given that the object is limited -- there is no copy involved and no performance hit. if Nkind (Nam) = N_Function_Call and then Is_Limited_View (Etype (Nam)) and then not Is_Constrained (Etype (Nam)) and then Comes_From_Source (N) then Set_Etype (Id, T); Set_Ekind (Id, E_Constant); Rewrite (N, Make_Object_Declaration (Loc, Defining_Identifier => Id, Constant_Present => True, Object_Definition => New_Occurrence_Of (Etype (Nam), Loc), Expression => Relocate_Node (Nam))); return; end if; -- Ada 2012 (AI05-149): Reject renaming of an anonymous access object -- when renaming declaration has a named access type. The Ada 2012 -- coverage rules allow an anonymous access type in the context of -- an expected named general access type, but the renaming rules -- require the types to be the same. (An exception is when the type -- of the renaming is also an anonymous access type, which can only -- happen due to a renaming created by the expander.) if Nkind (Nam) = N_Type_Conversion and then not Comes_From_Source (Nam) and then Ekind (Etype (Expression (Nam))) = E_Anonymous_Access_Type and then Ekind (T) /= E_Anonymous_Access_Type then Wrong_Type (Expression (Nam), T); -- Should we give better error??? end if; -- Check that a class-wide object is not being renamed as an object -- of a specific type. The test for access types is needed to exclude -- cases where the renamed object is a dynamically tagged access -- result, such as occurs in certain expansions. if Is_Tagged_Type (T) then Check_Dynamically_Tagged_Expression (Expr => Nam, Typ => T, Related_Nod => N); end if; -- Ada 2005 (AI-230/AI-254): Access renaming else pragma Assert (Present (Access_Definition (N))); T := Access_Definition (Related_Nod => N, N => Access_Definition (N)); Analyze (Nam); -- The object renaming declaration may become Ghost if it renames a -- Ghost entity. if Is_Entity_Name (Nam) then Mark_Ghost_Renaming (N, Entity (Nam)); end if; -- Ada 2005 AI05-105: if the declaration has an anonymous access -- type, the renamed object must also have an anonymous type, and -- this is a name resolution rule. This was implicit in the last part -- of the first sentence in 8.5.1(3/2), and is made explicit by this -- recent AI. if not Is_Overloaded (Nam) then if Ekind (Etype (Nam)) /= Ekind (T) then Error_Msg_N ("expect anonymous access type in object renaming", N); end if; else declare I : Interp_Index; It : Interp; Typ : Entity_Id := Empty; Seen : Boolean := False; begin Get_First_Interp (Nam, I, It); while Present (It.Typ) loop -- Renaming is ambiguous if more than one candidate -- interpretation is type-conformant with the context. if Ekind (It.Typ) = Ekind (T) then if Ekind (T) = E_Anonymous_Access_Subprogram_Type and then Type_Conformant (Designated_Type (T), Designated_Type (It.Typ)) then if not Seen then Seen := True; else Error_Msg_N ("ambiguous expression in renaming", Nam); end if; elsif Ekind (T) = E_Anonymous_Access_Type and then Covers (Designated_Type (T), Designated_Type (It.Typ)) then if not Seen then Seen := True; else Error_Msg_N ("ambiguous expression in renaming", Nam); end if; end if; if Covers (T, It.Typ) then Typ := It.Typ; Set_Etype (Nam, Typ); Set_Is_Overloaded (Nam, False); end if; end if; Get_Next_Interp (I, It); end loop; end; end if; Resolve (Nam, T); -- Do not perform the legality checks below when the resolution of -- the renaming name failed because the associated type is Any_Type. if Etype (Nam) = Any_Type then null; -- Ada 2005 (AI-231): In the case where the type is defined by an -- access_definition, the renamed entity shall be of an access-to- -- constant type if and only if the access_definition defines an -- access-to-constant type. ARM 8.5.1(4) elsif Constant_Present (Access_Definition (N)) and then not Is_Access_Constant (Etype (Nam)) then Error_Msg_N ("(Ada 2005): the renamed object is not access-to-constant " & "(RM 8.5.1(6))", N); elsif not Constant_Present (Access_Definition (N)) and then Is_Access_Constant (Etype (Nam)) then Error_Msg_N ("(Ada 2005): the renamed object is not access-to-variable " & "(RM 8.5.1(6))", N); end if; if Is_Access_Subprogram_Type (Etype (Nam)) then Check_Subtype_Conformant (Designated_Type (T), Designated_Type (Etype (Nam))); elsif not Subtypes_Statically_Match (Designated_Type (T), Available_View (Designated_Type (Etype (Nam)))) then Error_Msg_N ("subtype of renamed object does not statically match", N); end if; end if; -- Special processing for renaming function return object. Some errors -- and warnings are produced only for calls that come from source. if Nkind (Nam) = N_Function_Call then case Ada_Version is -- Usage is illegal in Ada 83, but renamings are also introduced -- during expansion, and error does not apply to those. when Ada_83 => if Comes_From_Source (N) then Error_Msg_N ("(Ada 83) cannot rename function return object", Nam); end if; -- In Ada 95, warn for odd case of renaming parameterless function -- call if this is not a limited type (where this is useful). when others => if Warn_On_Object_Renames_Function and then No (Parameter_Associations (Nam)) and then not Is_Limited_Type (Etype (Nam)) and then Comes_From_Source (Nam) then Error_Msg_N ("renaming function result object is suspicious?R?", Nam); Error_Msg_NE ("\function & will be called only once?R?", Nam, Entity (Name (Nam))); Error_Msg_N -- CODEFIX ("\suggest using an initialized constant " & "object instead?R?", Nam); end if; end case; end if; Check_Constrained_Object; -- An object renaming requires an exact match of the type. Class-wide -- matching is not allowed. if Is_Class_Wide_Type (T) and then Base_Type (Etype (Nam)) /= Base_Type (T) then Wrong_Type (Nam, T); end if; T2 := Etype (Nam); -- Ada 2005 (AI-326): Handle wrong use of incomplete type if Nkind (Nam) = N_Explicit_Dereference and then Ekind (Etype (T2)) = E_Incomplete_Type then Error_Msg_NE ("invalid use of incomplete type&", Id, T2); return; elsif Ekind (Etype (T)) = E_Incomplete_Type then Error_Msg_NE ("invalid use of incomplete type&", Id, T); return; end if; -- Ada 2005 (AI-327) if Ada_Version >= Ada_2005 and then Nkind (Nam) = N_Attribute_Reference and then Attribute_Name (Nam) = Name_Priority then null; elsif Ada_Version >= Ada_2005 and then Nkind (Nam) in N_Has_Entity then declare Nam_Decl : Node_Id; Nam_Ent : Entity_Id; begin if Nkind (Nam) = N_Attribute_Reference then Nam_Ent := Entity (Prefix (Nam)); else Nam_Ent := Entity (Nam); end if; Nam_Decl := Parent (Nam_Ent); if Has_Null_Exclusion (N) and then not Has_Null_Exclusion (Nam_Decl) then -- Ada 2005 (AI-423): If the object name denotes a generic -- formal object of a generic unit G, and the object renaming -- declaration occurs within the body of G or within the body -- of a generic unit declared within the declarative region -- of G, then the declaration of the formal object of G must -- have a null exclusion or a null-excluding subtype. if Is_Formal_Object (Nam_Ent) and then In_Generic_Scope (Id) then if not Can_Never_Be_Null (Etype (Nam_Ent)) then Error_Msg_N ("renamed formal does not exclude `NULL` " & "(RM 8.5.1(4.6/2))", N); elsif In_Package_Body (Scope (Id)) then Error_Msg_N ("formal object does not have a null exclusion" & "(RM 8.5.1(4.6/2))", N); end if; -- Ada 2005 (AI-423): Otherwise, the subtype of the object name -- shall exclude null. elsif not Can_Never_Be_Null (Etype (Nam_Ent)) then Error_Msg_N ("renamed object does not exclude `NULL` " & "(RM 8.5.1(4.6/2))", N); -- An instance is illegal if it contains a renaming that -- excludes null, and the actual does not. The renaming -- declaration has already indicated that the declaration -- of the renamed actual in the instance will raise -- constraint_error. elsif Nkind (Nam_Decl) = N_Object_Declaration and then In_Instance and then Present (Corresponding_Generic_Association (Nam_Decl)) and then Nkind (Expression (Nam_Decl)) = N_Raise_Constraint_Error then Error_Msg_N ("renamed actual does not exclude `NULL` " & "(RM 8.5.1(4.6/2))", N); -- Finally, if there is a null exclusion, the subtype mark -- must not be null-excluding. elsif No (Access_Definition (N)) and then Can_Never_Be_Null (T) then Error_Msg_NE ("`NOT NULL` not allowed (& already excludes null)", N, T); end if; elsif Can_Never_Be_Null (T) and then not Can_Never_Be_Null (Etype (Nam_Ent)) then Error_Msg_N ("renamed object does not exclude `NULL` " & "(RM 8.5.1(4.6/2))", N); elsif Has_Null_Exclusion (N) and then No (Access_Definition (N)) and then Can_Never_Be_Null (T) then Error_Msg_NE ("`NOT NULL` not allowed (& already excludes null)", N, T); end if; end; end if; -- Set the Ekind of the entity, unless it has been set already, as is -- the case for the iteration object over a container with no variable -- indexing. In that case it's been marked as a constant, and we do not -- want to change it to a variable. if Ekind (Id) /= E_Constant then Set_Ekind (Id, E_Variable); end if; -- Initialize the object size and alignment. Note that we used to call -- Init_Size_Align here, but that's wrong for objects which have only -- an Esize, not an RM_Size field. Init_Object_Size_Align (Id); if T = Any_Type or else Etype (Nam) = Any_Type then return; -- Verify that the renamed entity is an object or a function call. It -- may have been rewritten in several ways. elsif Is_Object_Reference (Nam) then if Comes_From_Source (N) then if Is_Dependent_Component_Of_Mutable_Object (Nam) then Error_Msg_N ("illegal renaming of discriminant-dependent component", Nam); end if; -- If the renaming comes from source and the renamed object is a -- dereference, then mark the prefix as needing debug information, -- since it might have been rewritten hence internally generated -- and Debug_Renaming_Declaration will link the renaming to it. if Nkind (Nam) = N_Explicit_Dereference and then Is_Entity_Name (Prefix (Nam)) then Set_Debug_Info_Needed (Entity (Prefix (Nam))); end if; end if; -- A static function call may have been folded into a literal elsif Nkind (Original_Node (Nam)) = N_Function_Call -- When expansion is disabled, attribute reference is not rewritten -- as function call. Otherwise it may be rewritten as a conversion, -- so check original node. or else (Nkind (Original_Node (Nam)) = N_Attribute_Reference and then Is_Function_Attribute_Name (Attribute_Name (Original_Node (Nam)))) -- Weird but legal, equivalent to renaming a function call. Illegal -- if the literal is the result of constant-folding an attribute -- reference that is not a function. or else (Is_Entity_Name (Nam) and then Ekind (Entity (Nam)) = E_Enumeration_Literal and then Nkind (Original_Node (Nam)) /= N_Attribute_Reference) or else (Nkind (Nam) = N_Type_Conversion and then Is_Tagged_Type (Entity (Subtype_Mark (Nam)))) then null; elsif Nkind (Nam) = N_Type_Conversion then Error_Msg_N ("renaming of conversion only allowed for tagged types", Nam); -- Ada 2005 (AI-327) elsif Ada_Version >= Ada_2005 and then Nkind (Nam) = N_Attribute_Reference and then Attribute_Name (Nam) = Name_Priority then null; -- Allow internally generated x'Ref resulting in N_Reference node elsif Nkind (Nam) = N_Reference then null; else Error_Msg_N ("expect object name in renaming", Nam); end if; Set_Etype (Id, T2); if not Is_Variable (Nam) then Set_Ekind (Id, E_Constant); Set_Never_Set_In_Source (Id, True); Set_Is_True_Constant (Id, True); end if; -- The entity of the renaming declaration needs to reflect whether the -- renamed object is volatile. Is_Volatile is set if the renamed object -- is volatile in the RM legality sense. Set_Is_Volatile (Id, Is_Volatile_Object (Nam)); -- Also copy settings of Atomic/Independent/Volatile_Full_Access if Is_Entity_Name (Nam) then Set_Is_Atomic (Id, Is_Atomic (Entity (Nam))); Set_Is_Independent (Id, Is_Independent (Entity (Nam))); Set_Is_Volatile_Full_Access (Id, Is_Volatile_Full_Access (Entity (Nam))); end if; -- Treat as volatile if we just set the Volatile flag if Is_Volatile (Id) -- Or if we are renaming an entity which was marked this way -- Are there more cases, e.g. X(J) where X is Treat_As_Volatile ??? or else (Is_Entity_Name (Nam) and then Treat_As_Volatile (Entity (Nam))) then Set_Treat_As_Volatile (Id, True); end if; -- Now make the link to the renamed object Set_Renamed_Object (Id, Nam); -- Implementation-defined aspect specifications can appear in a renaming -- declaration, but not language-defined ones. The call to procedure -- Analyze_Aspect_Specifications will take care of this error check. if Has_Aspects (N) then Analyze_Aspect_Specifications (N, Id); end if; -- Deal with dimensions Analyze_Dimension (N); end Analyze_Object_Renaming; ------------------------------ -- Analyze_Package_Renaming -- ------------------------------ procedure Analyze_Package_Renaming (N : Node_Id) is New_P : constant Entity_Id := Defining_Entity (N); Old_P : Entity_Id; Spec : Node_Id; begin if Name (N) = Error then return; end if; -- Check for Text_IO special unit (we may be renaming a Text_IO child) Check_Text_IO_Special_Unit (Name (N)); if Current_Scope /= Standard_Standard then Set_Is_Pure (New_P, Is_Pure (Current_Scope)); end if; Enter_Name (New_P); Analyze (Name (N)); if Is_Entity_Name (Name (N)) then Old_P := Entity (Name (N)); else Old_P := Any_Id; end if; if Etype (Old_P) = Any_Type then Error_Msg_N ("expect package name in renaming", Name (N)); elsif Ekind (Old_P) /= E_Package and then not (Ekind (Old_P) = E_Generic_Package and then In_Open_Scopes (Old_P)) then if Ekind (Old_P) = E_Generic_Package then Error_Msg_N ("generic package cannot be renamed as a package", Name (N)); else Error_Msg_Sloc := Sloc (Old_P); Error_Msg_NE ("expect package name in renaming, found& declared#", Name (N), Old_P); end if; -- Set basic attributes to minimize cascaded errors Set_Ekind (New_P, E_Package); Set_Etype (New_P, Standard_Void_Type); -- Here for OK package renaming else -- Entities in the old package are accessible through the renaming -- entity. The simplest implementation is to have both packages share -- the entity list. Set_Ekind (New_P, E_Package); Set_Etype (New_P, Standard_Void_Type); if Present (Renamed_Object (Old_P)) then Set_Renamed_Object (New_P, Renamed_Object (Old_P)); else Set_Renamed_Object (New_P, Old_P); end if; -- The package renaming declaration may become Ghost if it renames a -- Ghost entity. Mark_Ghost_Renaming (N, Old_P); Set_Has_Completion (New_P); Set_First_Entity (New_P, First_Entity (Old_P)); Set_Last_Entity (New_P, Last_Entity (Old_P)); Set_First_Private_Entity (New_P, First_Private_Entity (Old_P)); Check_Library_Unit_Renaming (N, Old_P); Generate_Reference (Old_P, Name (N)); -- If the renaming is in the visible part of a package, then we set -- Renamed_In_Spec for the renamed package, to prevent giving -- warnings about no entities referenced. Such a warning would be -- overenthusiastic, since clients can see entities in the renamed -- package via the visible package renaming. declare Ent : constant Entity_Id := Cunit_Entity (Current_Sem_Unit); begin if Ekind (Ent) = E_Package and then not In_Private_Part (Ent) and then In_Extended_Main_Source_Unit (N) and then Ekind (Old_P) = E_Package then Set_Renamed_In_Spec (Old_P); end if; end; -- If this is the renaming declaration of a package instantiation -- within itself, it is the declaration that ends the list of actuals -- for the instantiation. At this point, the subtypes that rename -- the actuals are flagged as generic, to avoid spurious ambiguities -- if the actuals for two distinct formals happen to coincide. If -- the actual is a private type, the subtype has a private completion -- that is flagged in the same fashion. -- Resolution is identical to what is was in the original generic. -- On exit from the generic instance, these are turned into regular -- subtypes again, so they are compatible with types in their class. if not Is_Generic_Instance (Old_P) then return; else Spec := Specification (Unit_Declaration_Node (Old_P)); end if; if Nkind (Spec) = N_Package_Specification and then Present (Generic_Parent (Spec)) and then Old_P = Current_Scope and then Chars (New_P) = Chars (Generic_Parent (Spec)) then declare E : Entity_Id; begin E := First_Entity (Old_P); while Present (E) and then E /= New_P loop if Is_Type (E) and then Nkind (Parent (E)) = N_Subtype_Declaration then Set_Is_Generic_Actual_Type (E); if Is_Private_Type (E) and then Present (Full_View (E)) then Set_Is_Generic_Actual_Type (Full_View (E)); end if; end if; Next_Entity (E); end loop; end; end if; end if; -- Implementation-defined aspect specifications can appear in a renaming -- declaration, but not language-defined ones. The call to procedure -- Analyze_Aspect_Specifications will take care of this error check. if Has_Aspects (N) then Analyze_Aspect_Specifications (N, New_P); end if; end Analyze_Package_Renaming; ------------------------------- -- Analyze_Renamed_Character -- ------------------------------- procedure Analyze_Renamed_Character (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean) is C : constant Node_Id := Name (N); begin if Ekind (New_S) = E_Function then Resolve (C, Etype (New_S)); if Is_Body then Check_Frozen_Renaming (N, New_S); end if; else Error_Msg_N ("character literal can only be renamed as function", N); end if; end Analyze_Renamed_Character; --------------------------------- -- Analyze_Renamed_Dereference -- --------------------------------- procedure Analyze_Renamed_Dereference (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean) is Nam : constant Node_Id := Name (N); P : constant Node_Id := Prefix (Nam); Typ : Entity_Id; Ind : Interp_Index; It : Interp; begin if not Is_Overloaded (P) then if Ekind (Etype (Nam)) /= E_Subprogram_Type or else not Type_Conformant (Etype (Nam), New_S) then Error_Msg_N ("designated type does not match specification", P); else Resolve (P); end if; return; else Typ := Any_Type; Get_First_Interp (Nam, Ind, It); while Present (It.Nam) loop if Ekind (It.Nam) = E_Subprogram_Type and then Type_Conformant (It.Nam, New_S) then if Typ /= Any_Id then Error_Msg_N ("ambiguous renaming", P); return; else Typ := It.Nam; end if; end if; Get_Next_Interp (Ind, It); end loop; if Typ = Any_Type then Error_Msg_N ("designated type does not match specification", P); else Resolve (N, Typ); if Is_Body then Check_Frozen_Renaming (N, New_S); end if; end if; end if; end Analyze_Renamed_Dereference; --------------------------- -- Analyze_Renamed_Entry -- --------------------------- procedure Analyze_Renamed_Entry (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean) is Nam : constant Node_Id := Name (N); Sel : constant Node_Id := Selector_Name (Nam); Is_Actual : constant Boolean := Present (Corresponding_Formal_Spec (N)); Old_S : Entity_Id; begin if Entity (Sel) = Any_Id then -- Selector is undefined on prefix. Error emitted already Set_Has_Completion (New_S); return; end if; -- Otherwise find renamed entity and build body of New_S as a call to it Old_S := Find_Renamed_Entity (N, Selector_Name (Nam), New_S); if Old_S = Any_Id then Error_Msg_N (" no subprogram or entry matches specification", N); else if Is_Body then Check_Subtype_Conformant (New_S, Old_S, N); Generate_Reference (New_S, Defining_Entity (N), 'b'); Style.Check_Identifier (Defining_Entity (N), New_S); else -- Only mode conformance required for a renaming_as_declaration Check_Mode_Conformant (New_S, Old_S, N); end if; Inherit_Renamed_Profile (New_S, Old_S); -- The prefix can be an arbitrary expression that yields a task or -- protected object, so it must be resolved. Resolve (Prefix (Nam), Scope (Old_S)); end if; Set_Convention (New_S, Convention (Old_S)); Set_Has_Completion (New_S, Inside_A_Generic); -- AI05-0225: If the renamed entity is a procedure or entry of a -- protected object, the target object must be a variable. if Ekind (Scope (Old_S)) in Protected_Kind and then Ekind (New_S) = E_Procedure and then not Is_Variable (Prefix (Nam)) then if Is_Actual then Error_Msg_N ("target object of protected operation used as actual for " & "formal procedure must be a variable", Nam); else Error_Msg_N ("target object of protected operation renamed as procedure, " & "must be a variable", Nam); end if; end if; if Is_Body then Check_Frozen_Renaming (N, New_S); end if; end Analyze_Renamed_Entry; ----------------------------------- -- Analyze_Renamed_Family_Member -- ----------------------------------- procedure Analyze_Renamed_Family_Member (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean) is Nam : constant Node_Id := Name (N); P : constant Node_Id := Prefix (Nam); Old_S : Entity_Id; begin if (Is_Entity_Name (P) and then Ekind (Entity (P)) = E_Entry_Family) or else (Nkind (P) = N_Selected_Component and then Ekind (Entity (Selector_Name (P))) = E_Entry_Family) then if Is_Entity_Name (P) then Old_S := Entity (P); else Old_S := Entity (Selector_Name (P)); end if; if not Entity_Matches_Spec (Old_S, New_S) then Error_Msg_N ("entry family does not match specification", N); elsif Is_Body then Check_Subtype_Conformant (New_S, Old_S, N); Generate_Reference (New_S, Defining_Entity (N), 'b'); Style.Check_Identifier (Defining_Entity (N), New_S); end if; else Error_Msg_N ("no entry family matches specification", N); end if; Set_Has_Completion (New_S, Inside_A_Generic); if Is_Body then Check_Frozen_Renaming (N, New_S); end if; end Analyze_Renamed_Family_Member; ----------------------------------------- -- Analyze_Renamed_Primitive_Operation -- ----------------------------------------- procedure Analyze_Renamed_Primitive_Operation (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean) is Old_S : Entity_Id; function Conforms (Subp : Entity_Id; Ctyp : Conformance_Type) return Boolean; -- Verify that the signatures of the renamed entity and the new entity -- match. The first formal of the renamed entity is skipped because it -- is the target object in any subsequent call. -------------- -- Conforms -- -------------- function Conforms (Subp : Entity_Id; Ctyp : Conformance_Type) return Boolean is Old_F : Entity_Id; New_F : Entity_Id; begin if Ekind (Subp) /= Ekind (New_S) then return False; end if; Old_F := Next_Formal (First_Formal (Subp)); New_F := First_Formal (New_S); while Present (Old_F) and then Present (New_F) loop if not Conforming_Types (Etype (Old_F), Etype (New_F), Ctyp) then return False; end if; if Ctyp >= Mode_Conformant and then Ekind (Old_F) /= Ekind (New_F) then return False; end if; Next_Formal (New_F); Next_Formal (Old_F); end loop; return True; end Conforms; -- Start of processing for Analyze_Renamed_Primitive_Operation begin if not Is_Overloaded (Selector_Name (Name (N))) then Old_S := Entity (Selector_Name (Name (N))); if not Conforms (Old_S, Type_Conformant) then Old_S := Any_Id; end if; else -- Find the operation that matches the given signature declare It : Interp; Ind : Interp_Index; begin Old_S := Any_Id; Get_First_Interp (Selector_Name (Name (N)), Ind, It); while Present (It.Nam) loop if Conforms (It.Nam, Type_Conformant) then Old_S := It.Nam; end if; Get_Next_Interp (Ind, It); end loop; end; end if; if Old_S = Any_Id then Error_Msg_N (" no subprogram or entry matches specification", N); else if Is_Body then if not Conforms (Old_S, Subtype_Conformant) then Error_Msg_N ("subtype conformance error in renaming", N); end if; Generate_Reference (New_S, Defining_Entity (N), 'b'); Style.Check_Identifier (Defining_Entity (N), New_S); else -- Only mode conformance required for a renaming_as_declaration if not Conforms (Old_S, Mode_Conformant) then Error_Msg_N ("mode conformance error in renaming", N); end if; -- Enforce the rule given in (RM 6.3.1 (10.1/2)): a prefixed -- view of a subprogram is intrinsic, because the compiler has -- to generate a wrapper for any call to it. If the name in a -- subprogram renaming is a prefixed view, the entity is thus -- intrinsic, and 'Access cannot be applied to it. Set_Convention (New_S, Convention_Intrinsic); end if; -- Inherit_Renamed_Profile (New_S, Old_S); -- The prefix can be an arbitrary expression that yields an -- object, so it must be resolved. Resolve (Prefix (Name (N))); end if; end Analyze_Renamed_Primitive_Operation; --------------------------------- -- Analyze_Subprogram_Renaming -- --------------------------------- procedure Analyze_Subprogram_Renaming (N : Node_Id) is Formal_Spec : constant Entity_Id := Corresponding_Formal_Spec (N); Is_Actual : constant Boolean := Present (Formal_Spec); Nam : constant Node_Id := Name (N); Save_AV : constant Ada_Version_Type := Ada_Version; Save_AVP : constant Node_Id := Ada_Version_Pragma; Save_AV_Exp : constant Ada_Version_Type := Ada_Version_Explicit; Spec : constant Node_Id := Specification (N); Old_S : Entity_Id := Empty; Rename_Spec : Entity_Id; procedure Build_Class_Wide_Wrapper (Ren_Id : out Entity_Id; Wrap_Id : out Entity_Id); -- Ada 2012 (AI05-0071): A generic/instance scenario involving a formal -- type with unknown discriminants and a generic primitive operation of -- the said type with a box require special processing when the actual -- is a class-wide type: -- -- generic -- type Formal_Typ (<>) is private; -- with procedure Prim_Op (Param : Formal_Typ) is <>; -- package Gen is ... -- -- package Inst is new Gen (Actual_Typ'Class); -- -- In this case the general renaming mechanism used in the prologue of -- an instance no longer applies: -- -- procedure Prim_Op (Param : Formal_Typ) renames Prim_Op; -- -- The above is replaced the following wrapper/renaming combination: -- -- procedure Wrapper (Param : Formal_Typ) is -- wrapper -- begin -- Prim_Op (Param); -- primitive -- end Wrapper; -- -- procedure Prim_Op (Param : Formal_Typ) renames Wrapper; -- -- This transformation applies only if there is no explicit visible -- class-wide operation at the point of the instantiation. Ren_Id is -- the entity of the renaming declaration. When the transformation -- applies, Wrap_Id is the entity of the generated class-wide wrapper -- (or Any_Id). Otherwise, Wrap_Id is the entity of the class-wide -- operation. procedure Check_Null_Exclusion (Ren : Entity_Id; Sub : Entity_Id); -- Ada 2005 (AI-423): Given renaming Ren of subprogram Sub, check the -- following AI rules: -- -- If Ren is a renaming of a formal subprogram and one of its -- parameters has a null exclusion, then the corresponding formal -- in Sub must also have one. Otherwise the subtype of the Sub's -- formal parameter must exclude null. -- -- If Ren is a renaming of a formal function and its return -- profile has a null exclusion, then Sub's return profile must -- have one. Otherwise the subtype of Sub's return profile must -- exclude null. procedure Freeze_Actual_Profile; -- In Ada 2012, enforce the freezing rule concerning formal incomplete -- types: a callable entity freezes its profile, unless it has an -- incomplete untagged formal (RM 13.14(10.2/3)). function Has_Class_Wide_Actual return Boolean; -- Ada 2012 (AI05-071, AI05-0131): True if N is the renaming for a -- defaulted formal subprogram where the actual for the controlling -- formal type is class-wide. function Original_Subprogram (Subp : Entity_Id) return Entity_Id; -- Find renamed entity when the declaration is a renaming_as_body and -- the renamed entity may itself be a renaming_as_body. Used to enforce -- rule that a renaming_as_body is illegal if the declaration occurs -- before the subprogram it completes is frozen, and renaming indirectly -- renames the subprogram itself.(Defect Report 8652/0027). ------------------------------ -- Build_Class_Wide_Wrapper -- ------------------------------ procedure Build_Class_Wide_Wrapper (Ren_Id : out Entity_Id; Wrap_Id : out Entity_Id) is Loc : constant Source_Ptr := Sloc (N); function Build_Call (Subp_Id : Entity_Id; Params : List_Id) return Node_Id; -- Create a dispatching call to invoke routine Subp_Id with actuals -- built from the parameter specifications of list Params. function Build_Expr_Fun_Call (Subp_Id : Entity_Id; Params : List_Id) return Node_Id; -- Create a dispatching call to invoke function Subp_Id with actuals -- built from the parameter specifications of list Params. Return -- directly the call, so that it can be used inside an expression -- function. This is a specificity of the GNATprove mode. function Build_Spec (Subp_Id : Entity_Id) return Node_Id; -- Create a subprogram specification based on the subprogram profile -- of Subp_Id. function Find_Primitive (Typ : Entity_Id) return Entity_Id; -- Find a primitive subprogram of type Typ which matches the profile -- of the renaming declaration. procedure Interpretation_Error (Subp_Id : Entity_Id); -- Emit a continuation error message suggesting subprogram Subp_Id as -- a possible interpretation. function Is_Intrinsic_Equality (Subp_Id : Entity_Id) return Boolean; -- Determine whether subprogram Subp_Id denotes the intrinsic "=" -- operator. function Is_Suitable_Candidate (Subp_Id : Entity_Id) return Boolean; -- Determine whether subprogram Subp_Id is a suitable candidate for -- the role of a wrapped subprogram. ---------------- -- Build_Call -- ---------------- function Build_Call (Subp_Id : Entity_Id; Params : List_Id) return Node_Id is Actuals : constant List_Id := New_List; Call_Ref : constant Node_Id := New_Occurrence_Of (Subp_Id, Loc); Formal : Node_Id; begin -- Build the actual parameters of the call Formal := First (Params); while Present (Formal) loop Append_To (Actuals, Make_Identifier (Loc, Chars (Defining_Identifier (Formal)))); Next (Formal); end loop; -- Generate: -- return Subp_Id (Actuals); if Ekind_In (Subp_Id, E_Function, E_Operator) then return Make_Simple_Return_Statement (Loc, Expression => Make_Function_Call (Loc, Name => Call_Ref, Parameter_Associations => Actuals)); -- Generate: -- Subp_Id (Actuals); else return Make_Procedure_Call_Statement (Loc, Name => Call_Ref, Parameter_Associations => Actuals); end if; end Build_Call; ------------------------- -- Build_Expr_Fun_Call -- ------------------------- function Build_Expr_Fun_Call (Subp_Id : Entity_Id; Params : List_Id) return Node_Id is Actuals : constant List_Id := New_List; Call_Ref : constant Node_Id := New_Occurrence_Of (Subp_Id, Loc); Formal : Node_Id; begin pragma Assert (Ekind_In (Subp_Id, E_Function, E_Operator)); -- Build the actual parameters of the call Formal := First (Params); while Present (Formal) loop Append_To (Actuals, Make_Identifier (Loc, Chars (Defining_Identifier (Formal)))); Next (Formal); end loop; -- Generate: -- Subp_Id (Actuals); return Make_Function_Call (Loc, Name => Call_Ref, Parameter_Associations => Actuals); end Build_Expr_Fun_Call; ---------------- -- Build_Spec -- ---------------- function Build_Spec (Subp_Id : Entity_Id) return Node_Id is Params : constant List_Id := Copy_Parameter_List (Subp_Id); Spec_Id : constant Entity_Id := Make_Defining_Identifier (Loc, Chars => New_External_Name (Chars (Subp_Id), 'R')); begin if Ekind (Formal_Spec) = E_Procedure then return Make_Procedure_Specification (Loc, Defining_Unit_Name => Spec_Id, Parameter_Specifications => Params); else return Make_Function_Specification (Loc, Defining_Unit_Name => Spec_Id, Parameter_Specifications => Params, Result_Definition => New_Copy_Tree (Result_Definition (Spec))); end if; end Build_Spec; -------------------- -- Find_Primitive -- -------------------- function Find_Primitive (Typ : Entity_Id) return Entity_Id is procedure Replace_Parameter_Types (Spec : Node_Id); -- Given a specification Spec, replace all class-wide parameter -- types with reference to type Typ. ----------------------------- -- Replace_Parameter_Types -- ----------------------------- procedure Replace_Parameter_Types (Spec : Node_Id) is Formal : Node_Id; Formal_Id : Entity_Id; Formal_Typ : Node_Id; begin Formal := First (Parameter_Specifications (Spec)); while Present (Formal) loop Formal_Id := Defining_Identifier (Formal); Formal_Typ := Parameter_Type (Formal); -- Create a new entity for each class-wide formal to prevent -- aliasing with the original renaming. Replace the type of -- such a parameter with the candidate type. if Nkind (Formal_Typ) = N_Identifier and then Is_Class_Wide_Type (Etype (Formal_Typ)) then Set_Defining_Identifier (Formal, Make_Defining_Identifier (Loc, Chars (Formal_Id))); Set_Parameter_Type (Formal, New_Occurrence_Of (Typ, Loc)); end if; Next (Formal); end loop; end Replace_Parameter_Types; -- Local variables Alt_Ren : constant Node_Id := New_Copy_Tree (N); Alt_Nam : constant Node_Id := Name (Alt_Ren); Alt_Spec : constant Node_Id := Specification (Alt_Ren); Subp_Id : Entity_Id; -- Start of processing for Find_Primitive begin -- Each attempt to find a suitable primitive of a particular type -- operates on its own copy of the original renaming. As a result -- the original renaming is kept decoration and side-effect free. -- Inherit the overloaded status of the renamed subprogram name if Is_Overloaded (Nam) then Set_Is_Overloaded (Alt_Nam); Save_Interps (Nam, Alt_Nam); end if; -- The copied renaming is hidden from visibility to prevent the -- pollution of the enclosing context. Set_Defining_Unit_Name (Alt_Spec, Make_Temporary (Loc, 'R')); -- The types of all class-wide parameters must be changed to the -- candidate type. Replace_Parameter_Types (Alt_Spec); -- Try to find a suitable primitive which matches the altered -- profile of the renaming specification. Subp_Id := Find_Renamed_Entity (N => Alt_Ren, Nam => Name (Alt_Ren), New_S => Analyze_Subprogram_Specification (Alt_Spec), Is_Actual => Is_Actual); -- Do not return Any_Id if the resolion of the altered profile -- failed as this complicates further checks on the caller side, -- return Empty instead. if Subp_Id = Any_Id then return Empty; else return Subp_Id; end if; end Find_Primitive; -------------------------- -- Interpretation_Error -- -------------------------- procedure Interpretation_Error (Subp_Id : Entity_Id) is begin Error_Msg_Sloc := Sloc (Subp_Id); if Is_Internal (Subp_Id) then Error_Msg_NE ("\\possible interpretation: predefined & #", Spec, Formal_Spec); else Error_Msg_NE ("\\possible interpretation: & defined #", Spec, Formal_Spec); end if; end Interpretation_Error; --------------------------- -- Is_Intrinsic_Equality -- --------------------------- function Is_Intrinsic_Equality (Subp_Id : Entity_Id) return Boolean is begin return Ekind (Subp_Id) = E_Operator and then Chars (Subp_Id) = Name_Op_Eq and then Is_Intrinsic_Subprogram (Subp_Id); end Is_Intrinsic_Equality; --------------------------- -- Is_Suitable_Candidate -- --------------------------- function Is_Suitable_Candidate (Subp_Id : Entity_Id) return Boolean is begin if No (Subp_Id) then return False; -- An intrinsic subprogram is never a good candidate. This is an -- indication of a missing primitive, either defined directly or -- inherited from a parent tagged type. elsif Is_Intrinsic_Subprogram (Subp_Id) then return False; else return True; end if; end Is_Suitable_Candidate; -- Local variables Actual_Typ : Entity_Id := Empty; -- The actual class-wide type for Formal_Typ CW_Prim_OK : Boolean; CW_Prim_Op : Entity_Id; -- The class-wide subprogram (if available) which corresponds to the -- renamed generic formal subprogram. Formal_Typ : Entity_Id := Empty; -- The generic formal type with unknown discriminants Root_Prim_OK : Boolean; Root_Prim_Op : Entity_Id; -- The root type primitive (if available) which corresponds to the -- renamed generic formal subprogram. Root_Typ : Entity_Id := Empty; -- The root type of Actual_Typ Body_Decl : Node_Id; Formal : Node_Id; Prim_Op : Entity_Id; Spec_Decl : Node_Id; New_Spec : Node_Id; -- Start of processing for Build_Class_Wide_Wrapper begin -- Analyze the specification of the renaming in case the generation -- of the class-wide wrapper fails. Ren_Id := Analyze_Subprogram_Specification (Spec); Wrap_Id := Any_Id; -- Do not attempt to build a wrapper if the renaming is in error if Error_Posted (Nam) then return; end if; -- Analyze the renamed name, but do not resolve it. The resolution is -- completed once a suitable subprogram is found. Analyze (Nam); -- When the renamed name denotes the intrinsic operator equals, the -- name must be treated as overloaded. This allows for a potential -- match against the root type's predefined equality function. if Is_Intrinsic_Equality (Entity (Nam)) then Set_Is_Overloaded (Nam); Collect_Interps (Nam); end if; -- Step 1: Find the generic formal type with unknown discriminants -- and its corresponding class-wide actual type from the renamed -- generic formal subprogram. Formal := First_Formal (Formal_Spec); while Present (Formal) loop if Has_Unknown_Discriminants (Etype (Formal)) and then not Is_Class_Wide_Type (Etype (Formal)) and then Is_Class_Wide_Type (Get_Instance_Of (Etype (Formal))) then Formal_Typ := Etype (Formal); Actual_Typ := Get_Instance_Of (Formal_Typ); Root_Typ := Etype (Actual_Typ); exit; end if; Next_Formal (Formal); end loop; -- The specification of the generic formal subprogram should always -- contain a formal type with unknown discriminants whose actual is -- a class-wide type, otherwise this indicates a failure in routine -- Has_Class_Wide_Actual. pragma Assert (Present (Formal_Typ)); -- Step 2: Find the proper class-wide subprogram or primitive which -- corresponds to the renamed generic formal subprogram. CW_Prim_Op := Find_Primitive (Actual_Typ); CW_Prim_OK := Is_Suitable_Candidate (CW_Prim_Op); Root_Prim_Op := Find_Primitive (Root_Typ); Root_Prim_OK := Is_Suitable_Candidate (Root_Prim_Op); -- The class-wide actual type has two subprograms which correspond to -- the renamed generic formal subprogram: -- with procedure Prim_Op (Param : Formal_Typ); -- procedure Prim_Op (Param : Actual_Typ); -- may be inherited -- procedure Prim_Op (Param : Actual_Typ'Class); -- Even though the declaration of the two subprograms is legal, a -- call to either one is ambiguous and therefore illegal. if CW_Prim_OK and Root_Prim_OK then -- A user-defined primitive has precedence over a predefined one if Is_Internal (CW_Prim_Op) and then not Is_Internal (Root_Prim_Op) then Prim_Op := Root_Prim_Op; elsif Is_Internal (Root_Prim_Op) and then not Is_Internal (CW_Prim_Op) then Prim_Op := CW_Prim_Op; elsif CW_Prim_Op = Root_Prim_Op then Prim_Op := Root_Prim_Op; -- Otherwise both candidate subprograms are user-defined and -- ambiguous. else Error_Msg_NE ("ambiguous actual for generic subprogram &", Spec, Formal_Spec); Interpretation_Error (Root_Prim_Op); Interpretation_Error (CW_Prim_Op); return; end if; elsif CW_Prim_OK and not Root_Prim_OK then Prim_Op := CW_Prim_Op; elsif not CW_Prim_OK and Root_Prim_OK then Prim_Op := Root_Prim_Op; -- An intrinsic equality may act as a suitable candidate in the case -- of a null type extension where the parent's equality is hidden. A -- call to an intrinsic equality is expanded as dispatching. elsif Present (Root_Prim_Op) and then Is_Intrinsic_Equality (Root_Prim_Op) then Prim_Op := Root_Prim_Op; -- Otherwise there are no candidate subprograms. Let the caller -- diagnose the error. else return; end if; -- At this point resolution has taken place and the name is no longer -- overloaded. Mark the primitive as referenced. Set_Is_Overloaded (Name (N), False); Set_Referenced (Prim_Op); -- Do not generate a wrapper when the only candidate is a class-wide -- subprogram. Instead modify the renaming to directly map the actual -- to the generic formal. if CW_Prim_OK and then Prim_Op = CW_Prim_Op then Wrap_Id := Prim_Op; Rewrite (Nam, New_Occurrence_Of (Prim_Op, Loc)); return; end if; -- Step 3: Create the declaration and the body of the wrapper, insert -- all the pieces into the tree. -- In GNATprove mode, create a function wrapper in the form of an -- expression function, so that an implicit postcondition relating -- the result of calling the wrapper function and the result of the -- dispatching call to the wrapped function is known during proof. if GNATprove_Mode and then Ekind_In (Ren_Id, E_Function, E_Operator) then New_Spec := Build_Spec (Ren_Id); Body_Decl := Make_Expression_Function (Loc, Specification => New_Spec, Expression => Build_Expr_Fun_Call (Subp_Id => Prim_Op, Params => Parameter_Specifications (New_Spec))); Wrap_Id := Defining_Entity (Body_Decl); -- Otherwise, create separate spec and body for the subprogram else Spec_Decl := Make_Subprogram_Declaration (Loc, Specification => Build_Spec (Ren_Id)); Insert_Before_And_Analyze (N, Spec_Decl); Wrap_Id := Defining_Entity (Spec_Decl); Body_Decl := Make_Subprogram_Body (Loc, Specification => Build_Spec (Ren_Id), Declarations => New_List, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List ( Build_Call (Subp_Id => Prim_Op, Params => Parameter_Specifications (Specification (Spec_Decl)))))); Set_Corresponding_Body (Spec_Decl, Defining_Entity (Body_Decl)); end if; -- If the operator carries an Eliminated pragma, indicate that the -- wrapper is also to be eliminated, to prevent spurious error when -- using gnatelim on programs that include box-initialization of -- equality operators. Set_Is_Eliminated (Wrap_Id, Is_Eliminated (Prim_Op)); -- In GNATprove mode, insert the body in the tree for analysis if GNATprove_Mode then Insert_Before_And_Analyze (N, Body_Decl); end if; -- The generated body does not freeze and must be analyzed when the -- class-wide wrapper is frozen. The body is only needed if expansion -- is enabled. if Expander_Active then Append_Freeze_Action (Wrap_Id, Body_Decl); end if; -- Step 4: The subprogram renaming aliases the wrapper Rewrite (Nam, New_Occurrence_Of (Wrap_Id, Loc)); end Build_Class_Wide_Wrapper; -------------------------- -- Check_Null_Exclusion -- -------------------------- procedure Check_Null_Exclusion (Ren : Entity_Id; Sub : Entity_Id) is Ren_Formal : Entity_Id; Sub_Formal : Entity_Id; begin -- Parameter check Ren_Formal := First_Formal (Ren); Sub_Formal := First_Formal (Sub); while Present (Ren_Formal) and then Present (Sub_Formal) loop if Has_Null_Exclusion (Parent (Ren_Formal)) and then not (Has_Null_Exclusion (Parent (Sub_Formal)) or else Can_Never_Be_Null (Etype (Sub_Formal))) then Error_Msg_NE ("`NOT NULL` required for parameter &", Parent (Sub_Formal), Sub_Formal); end if; Next_Formal (Ren_Formal); Next_Formal (Sub_Formal); end loop; -- Return profile check if Nkind (Parent (Ren)) = N_Function_Specification and then Nkind (Parent (Sub)) = N_Function_Specification and then Has_Null_Exclusion (Parent (Ren)) and then not (Has_Null_Exclusion (Parent (Sub)) or else Can_Never_Be_Null (Etype (Sub))) then Error_Msg_N ("return must specify `NOT NULL`", Result_Definition (Parent (Sub))); end if; end Check_Null_Exclusion; --------------------------- -- Freeze_Actual_Profile -- --------------------------- procedure Freeze_Actual_Profile is F : Entity_Id; Has_Untagged_Inc : Boolean; Instantiation_Node : constant Node_Id := Parent (N); begin if Ada_Version >= Ada_2012 then F := First_Formal (Formal_Spec); Has_Untagged_Inc := False; while Present (F) loop if Ekind (Etype (F)) = E_Incomplete_Type and then not Is_Tagged_Type (Etype (F)) then Has_Untagged_Inc := True; exit; end if; F := Next_Formal (F); end loop; if Ekind (Formal_Spec) = E_Function and then not Is_Tagged_Type (Etype (Formal_Spec)) then Has_Untagged_Inc := True; end if; if not Has_Untagged_Inc then F := First_Formal (Old_S); while Present (F) loop Freeze_Before (Instantiation_Node, Etype (F)); if Is_Incomplete_Or_Private_Type (Etype (F)) and then No (Underlying_Type (Etype (F))) then -- Exclude generic types, or types derived from them. -- They will be frozen in the enclosing instance. if Is_Generic_Type (Etype (F)) or else Is_Generic_Type (Root_Type (Etype (F))) then null; -- A limited view of a type declared elsewhere needs no -- freezing actions. elsif From_Limited_With (Etype (F)) then null; else Error_Msg_NE ("type& must be frozen before this point", Instantiation_Node, Etype (F)); end if; end if; F := Next_Formal (F); end loop; end if; end if; end Freeze_Actual_Profile; --------------------------- -- Has_Class_Wide_Actual -- --------------------------- function Has_Class_Wide_Actual return Boolean is Formal : Entity_Id; Formal_Typ : Entity_Id; begin if Is_Actual then Formal := First_Formal (Formal_Spec); while Present (Formal) loop Formal_Typ := Etype (Formal); if Has_Unknown_Discriminants (Formal_Typ) and then not Is_Class_Wide_Type (Formal_Typ) and then Is_Class_Wide_Type (Get_Instance_Of (Formal_Typ)) then return True; end if; Next_Formal (Formal); end loop; end if; return False; end Has_Class_Wide_Actual; ------------------------- -- Original_Subprogram -- ------------------------- function Original_Subprogram (Subp : Entity_Id) return Entity_Id is Orig_Decl : Node_Id; Orig_Subp : Entity_Id; begin -- First case: renamed entity is itself a renaming if Present (Alias (Subp)) then return Alias (Subp); elsif Nkind (Unit_Declaration_Node (Subp)) = N_Subprogram_Declaration and then Present (Corresponding_Body (Unit_Declaration_Node (Subp))) then -- Check if renamed entity is a renaming_as_body Orig_Decl := Unit_Declaration_Node (Corresponding_Body (Unit_Declaration_Node (Subp))); if Nkind (Orig_Decl) = N_Subprogram_Renaming_Declaration then Orig_Subp := Entity (Name (Orig_Decl)); if Orig_Subp = Rename_Spec then -- Circularity detected return Orig_Subp; else return (Original_Subprogram (Orig_Subp)); end if; else return Subp; end if; else return Subp; end if; end Original_Subprogram; -- Local variables CW_Actual : constant Boolean := Has_Class_Wide_Actual; -- Ada 2012 (AI05-071, AI05-0131): True if the renaming is for a -- defaulted formal subprogram when the actual for a related formal -- type is class-wide. Inst_Node : Node_Id := Empty; New_S : Entity_Id; -- Start of processing for Analyze_Subprogram_Renaming begin -- We must test for the attribute renaming case before the Analyze -- call because otherwise Sem_Attr will complain that the attribute -- is missing an argument when it is analyzed. if Nkind (Nam) = N_Attribute_Reference then -- In the case of an abstract formal subprogram association, rewrite -- an actual given by a stream attribute as the name of the -- corresponding stream primitive of the type. -- In a generic context the stream operations are not generated, and -- this must be treated as a normal attribute reference, to be -- expanded in subsequent instantiations. if Is_Actual and then Is_Abstract_Subprogram (Formal_Spec) and then Expander_Active then declare Prefix_Type : constant Entity_Id := Entity (Prefix (Nam)); Stream_Prim : Entity_Id; begin -- The class-wide forms of the stream attributes are not -- primitive dispatching operations (even though they -- internally dispatch to a stream attribute). if Is_Class_Wide_Type (Prefix_Type) then Error_Msg_N ("attribute must be a primitive dispatching operation", Nam); return; end if; -- Retrieve the primitive subprogram associated with the -- attribute. This can only be a stream attribute, since those -- are the only ones that are dispatching (and the actual for -- an abstract formal subprogram must be dispatching -- operation). case Attribute_Name (Nam) is when Name_Input => Stream_Prim := Find_Optional_Prim_Op (Prefix_Type, TSS_Stream_Input); when Name_Output => Stream_Prim := Find_Optional_Prim_Op (Prefix_Type, TSS_Stream_Output); when Name_Read => Stream_Prim := Find_Optional_Prim_Op (Prefix_Type, TSS_Stream_Read); when Name_Write => Stream_Prim := Find_Optional_Prim_Op (Prefix_Type, TSS_Stream_Write); when others => Error_Msg_N ("attribute must be a primitive dispatching operation", Nam); return; end case; -- If no operation was found, and the type is limited, the user -- should have defined one. if No (Stream_Prim) then if Is_Limited_Type (Prefix_Type) then Error_Msg_NE ("stream operation not defined for type&", N, Prefix_Type); return; -- Otherwise, compiler should have generated default else raise Program_Error; end if; end if; -- Rewrite the attribute into the name of its corresponding -- primitive dispatching subprogram. We can then proceed with -- the usual processing for subprogram renamings. declare Prim_Name : constant Node_Id := Make_Identifier (Sloc (Nam), Chars => Chars (Stream_Prim)); begin Set_Entity (Prim_Name, Stream_Prim); Rewrite (Nam, Prim_Name); Analyze (Nam); end; end; -- Normal processing for a renaming of an attribute else Attribute_Renaming (N); return; end if; end if; -- Check whether this declaration corresponds to the instantiation of a -- formal subprogram. -- If this is an instantiation, the corresponding actual is frozen and -- error messages can be made more precise. If this is a default -- subprogram, the entity is already established in the generic, and is -- not retrieved by visibility. If it is a default with a box, the -- candidate interpretations, if any, have been collected when building -- the renaming declaration. If overloaded, the proper interpretation is -- determined in Find_Renamed_Entity. If the entity is an operator, -- Find_Renamed_Entity applies additional visibility checks. if Is_Actual then Inst_Node := Unit_Declaration_Node (Formal_Spec); -- Check whether the renaming is for a defaulted actual subprogram -- with a class-wide actual. -- The class-wide wrapper is not needed in GNATprove_Mode and there -- is an external axiomatization on the package. if CW_Actual and then Box_Present (Inst_Node) and then not (GNATprove_Mode and then Present (Containing_Package_With_Ext_Axioms (Formal_Spec))) then Build_Class_Wide_Wrapper (New_S, Old_S); elsif Is_Entity_Name (Nam) and then Present (Entity (Nam)) and then not Comes_From_Source (Nam) and then not Is_Overloaded (Nam) then Old_S := Entity (Nam); -- The subprogram renaming declaration may become Ghost if it -- renames a Ghost entity. Mark_Ghost_Renaming (N, Old_S); New_S := Analyze_Subprogram_Specification (Spec); -- Operator case if Ekind (Old_S) = E_Operator then -- Box present if Box_Present (Inst_Node) then Old_S := Find_Renamed_Entity (N, Name (N), New_S, Is_Actual); -- If there is an immediately visible homonym of the operator -- and the declaration has a default, this is worth a warning -- because the user probably did not intend to get the pre- -- defined operator, visible in the generic declaration. To -- find if there is an intended candidate, analyze the renaming -- again in the current context. elsif Scope (Old_S) = Standard_Standard and then Present (Default_Name (Inst_Node)) then declare Decl : constant Node_Id := New_Copy_Tree (N); Hidden : Entity_Id; begin Set_Entity (Name (Decl), Empty); Analyze (Name (Decl)); Hidden := Find_Renamed_Entity (Decl, Name (Decl), New_S, True); if Present (Hidden) and then In_Open_Scopes (Scope (Hidden)) and then Is_Immediately_Visible (Hidden) and then Comes_From_Source (Hidden) and then Hidden /= Old_S then Error_Msg_Sloc := Sloc (Hidden); Error_Msg_N ("default subprogram is resolved in the generic " & "declaration (RM 12.6(17))??", N); Error_Msg_NE ("\and will not use & #??", N, Hidden); end if; end; end if; end if; else Analyze (Nam); -- The subprogram renaming declaration may become Ghost if it -- renames a Ghost entity. if Is_Entity_Name (Nam) then Mark_Ghost_Renaming (N, Entity (Nam)); end if; New_S := Analyze_Subprogram_Specification (Spec); end if; else -- Renamed entity must be analyzed first, to avoid being hidden by -- new name (which might be the same in a generic instance). Analyze (Nam); -- The subprogram renaming declaration may become Ghost if it renames -- a Ghost entity. if Is_Entity_Name (Nam) then Mark_Ghost_Renaming (N, Entity (Nam)); end if; -- The renaming defines a new overloaded entity, which is analyzed -- like a subprogram declaration. New_S := Analyze_Subprogram_Specification (Spec); end if; if Current_Scope /= Standard_Standard then Set_Is_Pure (New_S, Is_Pure (Current_Scope)); end if; -- Set SPARK mode from current context Set_SPARK_Pragma (New_S, SPARK_Mode_Pragma); Set_SPARK_Pragma_Inherited (New_S); Rename_Spec := Find_Corresponding_Spec (N); -- Case of Renaming_As_Body if Present (Rename_Spec) then -- Renaming declaration is the completion of the declaration of -- Rename_Spec. We build an actual body for it at the freezing point. Set_Corresponding_Spec (N, Rename_Spec); -- Deal with special case of stream functions of abstract types -- and interfaces. if Nkind (Unit_Declaration_Node (Rename_Spec)) = N_Abstract_Subprogram_Declaration then -- Input stream functions are abstract if the object type is -- abstract. Similarly, all default stream functions for an -- interface type are abstract. However, these subprograms may -- receive explicit declarations in representation clauses, making -- the attribute subprograms usable as defaults in subsequent -- type extensions. -- In this case we rewrite the declaration to make the subprogram -- non-abstract. We remove the previous declaration, and insert -- the new one at the point of the renaming, to prevent premature -- access to unfrozen types. The new declaration reuses the -- specification of the previous one, and must not be analyzed. pragma Assert (Is_Primitive (Entity (Nam)) and then Is_Abstract_Type (Find_Dispatching_Type (Entity (Nam)))); declare Old_Decl : constant Node_Id := Unit_Declaration_Node (Rename_Spec); New_Decl : constant Node_Id := Make_Subprogram_Declaration (Sloc (N), Specification => Relocate_Node (Specification (Old_Decl))); begin Remove (Old_Decl); Insert_After (N, New_Decl); Set_Is_Abstract_Subprogram (Rename_Spec, False); Set_Analyzed (New_Decl); end; end if; Set_Corresponding_Body (Unit_Declaration_Node (Rename_Spec), New_S); if Ada_Version = Ada_83 and then Comes_From_Source (N) then Error_Msg_N ("(Ada 83) renaming cannot serve as a body", N); end if; Set_Convention (New_S, Convention (Rename_Spec)); Check_Fully_Conformant (New_S, Rename_Spec); Set_Public_Status (New_S); -- The specification does not introduce new formals, but only -- repeats the formals of the original subprogram declaration. -- For cross-reference purposes, and for refactoring tools, we -- treat the formals of the renaming declaration as body formals. Reference_Body_Formals (Rename_Spec, New_S); -- Indicate that the entity in the declaration functions like the -- corresponding body, and is not a new entity. The body will be -- constructed later at the freeze point, so indicate that the -- completion has not been seen yet. Set_Ekind (New_S, E_Subprogram_Body); New_S := Rename_Spec; Set_Has_Completion (Rename_Spec, False); -- Ada 2005: check overriding indicator if Present (Overridden_Operation (Rename_Spec)) then if Must_Not_Override (Specification (N)) then Error_Msg_NE ("subprogram& overrides inherited operation", N, Rename_Spec); elsif Style_Check and then not Must_Override (Specification (N)) then Style.Missing_Overriding (N, Rename_Spec); end if; elsif Must_Override (Specification (N)) then Error_Msg_NE ("subprogram& is not overriding", N, Rename_Spec); end if; -- Normal subprogram renaming (not renaming as body) else Generate_Definition (New_S); New_Overloaded_Entity (New_S); if Is_Entity_Name (Nam) and then Is_Intrinsic_Subprogram (Entity (Nam)) then null; else Check_Delayed_Subprogram (New_S); end if; end if; -- There is no need for elaboration checks on the new entity, which may -- be called before the next freezing point where the body will appear. -- Elaboration checks refer to the real entity, not the one created by -- the renaming declaration. Set_Kill_Elaboration_Checks (New_S, True); -- If we had a previous error, indicate a completely is present to stop -- junk cascaded messages, but don't take any further action. if Etype (Nam) = Any_Type then Set_Has_Completion (New_S); return; -- Case where name has the form of a selected component elsif Nkind (Nam) = N_Selected_Component then -- A name which has the form A.B can designate an entry of task A, a -- protected operation of protected object A, or finally a primitive -- operation of object A. In the later case, A is an object of some -- tagged type, or an access type that denotes one such. To further -- distinguish these cases, note that the scope of a task entry or -- protected operation is type of the prefix. -- The prefix could be an overloaded function call that returns both -- kinds of operations. This overloading pathology is left to the -- dedicated reader ??? declare T : constant Entity_Id := Etype (Prefix (Nam)); begin if Present (T) and then (Is_Tagged_Type (T) or else (Is_Access_Type (T) and then Is_Tagged_Type (Designated_Type (T)))) and then Scope (Entity (Selector_Name (Nam))) /= T then Analyze_Renamed_Primitive_Operation (N, New_S, Present (Rename_Spec)); return; else -- Renamed entity is an entry or protected operation. For those -- cases an explicit body is built (at the point of freezing of -- this entity) that contains a call to the renamed entity. -- This is not allowed for renaming as body if the renamed -- spec is already frozen (see RM 8.5.4(5) for details). if Present (Rename_Spec) and then Is_Frozen (Rename_Spec) then Error_Msg_N ("renaming-as-body cannot rename entry as subprogram", N); Error_Msg_NE ("\since & is already frozen (RM 8.5.4(5))", N, Rename_Spec); else Analyze_Renamed_Entry (N, New_S, Present (Rename_Spec)); end if; return; end if; end; -- Case where name is an explicit dereference X.all elsif Nkind (Nam) = N_Explicit_Dereference then -- Renamed entity is designated by access_to_subprogram expression. -- Must build body to encapsulate call, as in the entry case. Analyze_Renamed_Dereference (N, New_S, Present (Rename_Spec)); return; -- Indexed component elsif Nkind (Nam) = N_Indexed_Component then Analyze_Renamed_Family_Member (N, New_S, Present (Rename_Spec)); return; -- Character literal elsif Nkind (Nam) = N_Character_Literal then Analyze_Renamed_Character (N, New_S, Present (Rename_Spec)); return; -- Only remaining case is where we have a non-entity name, or a renaming -- of some other non-overloadable entity. elsif not Is_Entity_Name (Nam) or else not Is_Overloadable (Entity (Nam)) then -- Do not mention the renaming if it comes from an instance if not Is_Actual then Error_Msg_N ("expect valid subprogram name in renaming", N); else Error_Msg_NE ("no visible subprogram for formal&", N, Nam); end if; return; end if; -- Find the renamed entity that matches the given specification. Disable -- Ada_83 because there is no requirement of full conformance between -- renamed entity and new entity, even though the same circuit is used. -- This is a bit of an odd case, which introduces a really irregular use -- of Ada_Version[_Explicit]. Would be nice to find cleaner way to do -- this. ??? Ada_Version := Ada_Version_Type'Max (Ada_Version, Ada_95); Ada_Version_Pragma := Empty; Ada_Version_Explicit := Ada_Version; if No (Old_S) then Old_S := Find_Renamed_Entity (N, Name (N), New_S, Is_Actual); -- The visible operation may be an inherited abstract operation that -- was overridden in the private part, in which case a call will -- dispatch to the overriding operation. Use the overriding one in -- the renaming declaration, to prevent spurious errors below. if Is_Overloadable (Old_S) and then Is_Abstract_Subprogram (Old_S) and then No (DTC_Entity (Old_S)) and then Present (Alias (Old_S)) and then not Is_Abstract_Subprogram (Alias (Old_S)) and then Present (Overridden_Operation (Alias (Old_S))) then Old_S := Alias (Old_S); end if; -- When the renamed subprogram is overloaded and used as an actual -- of a generic, its entity is set to the first available homonym. -- We must first disambiguate the name, then set the proper entity. if Is_Actual and then Is_Overloaded (Nam) then Set_Entity (Nam, Old_S); end if; end if; -- Most common case: subprogram renames subprogram. No body is generated -- in this case, so we must indicate the declaration is complete as is. -- and inherit various attributes of the renamed subprogram. if No (Rename_Spec) then Set_Has_Completion (New_S); Set_Is_Imported (New_S, Is_Imported (Entity (Nam))); Set_Is_Pure (New_S, Is_Pure (Entity (Nam))); Set_Is_Preelaborated (New_S, Is_Preelaborated (Entity (Nam))); -- Ada 2005 (AI-423): Check the consistency of null exclusions -- between a subprogram and its correct renaming. -- Note: the Any_Id check is a guard that prevents compiler crashes -- when performing a null exclusion check between a renaming and a -- renamed subprogram that has been found to be illegal. if Ada_Version >= Ada_2005 and then Entity (Nam) /= Any_Id then Check_Null_Exclusion (Ren => New_S, Sub => Entity (Nam)); end if; -- Enforce the Ada 2005 rule that the renamed entity cannot require -- overriding. The flag Requires_Overriding is set very selectively -- and misses some other illegal cases. The additional conditions -- checked below are sufficient but not necessary ??? -- The rule does not apply to the renaming generated for an actual -- subprogram in an instance. if Is_Actual then null; -- Guard against previous errors, and omit renamings of predefined -- operators. elsif not Ekind_In (Old_S, E_Function, E_Procedure) then null; elsif Requires_Overriding (Old_S) or else (Is_Abstract_Subprogram (Old_S) and then Present (Find_Dispatching_Type (Old_S)) and then not Is_Abstract_Type (Find_Dispatching_Type (Old_S))) then Error_Msg_N ("renamed entity cannot be subprogram that requires overriding " & "(RM 8.5.4 (5.1))", N); end if; end if; if Old_S /= Any_Id then if Is_Actual and then From_Default (N) then -- This is an implicit reference to the default actual Generate_Reference (Old_S, Nam, Typ => 'i', Force => True); else Generate_Reference (Old_S, Nam); end if; Check_Internal_Protected_Use (N, Old_S); -- For a renaming-as-body, require subtype conformance, but if the -- declaration being completed has not been frozen, then inherit the -- convention of the renamed subprogram prior to checking conformance -- (unless the renaming has an explicit convention established; the -- rule stated in the RM doesn't seem to address this ???). if Present (Rename_Spec) then Generate_Reference (Rename_Spec, Defining_Entity (Spec), 'b'); Style.Check_Identifier (Defining_Entity (Spec), Rename_Spec); if not Is_Frozen (Rename_Spec) then if not Has_Convention_Pragma (Rename_Spec) then Set_Convention (New_S, Convention (Old_S)); end if; if Ekind (Old_S) /= E_Operator then Check_Mode_Conformant (New_S, Old_S, Spec); end if; if Original_Subprogram (Old_S) = Rename_Spec then Error_Msg_N ("unfrozen subprogram cannot rename itself ", N); end if; else Check_Subtype_Conformant (New_S, Old_S, Spec); end if; Check_Frozen_Renaming (N, Rename_Spec); -- Check explicitly that renamed entity is not intrinsic, because -- in a generic the renamed body is not built. In this case, -- the renaming_as_body is a completion. if Inside_A_Generic then if Is_Frozen (Rename_Spec) and then Is_Intrinsic_Subprogram (Old_S) then Error_Msg_N ("subprogram in renaming_as_body cannot be intrinsic", Name (N)); end if; Set_Has_Completion (Rename_Spec); end if; elsif Ekind (Old_S) /= E_Operator then -- If this a defaulted subprogram for a class-wide actual there is -- no check for mode conformance, given that the signatures don't -- match (the source mentions T but the actual mentions T'Class). if CW_Actual then null; elsif not Is_Actual or else No (Enclosing_Instance) then Check_Mode_Conformant (New_S, Old_S); end if; if Is_Actual and then Error_Posted (New_S) then Error_Msg_NE ("invalid actual subprogram: & #!", N, Old_S); end if; end if; if No (Rename_Spec) then -- The parameter profile of the new entity is that of the renamed -- entity: the subtypes given in the specification are irrelevant. Inherit_Renamed_Profile (New_S, Old_S); -- A call to the subprogram is transformed into a call to the -- renamed entity. This is transitive if the renamed entity is -- itself a renaming. if Present (Alias (Old_S)) then Set_Alias (New_S, Alias (Old_S)); else Set_Alias (New_S, Old_S); end if; -- Note that we do not set Is_Intrinsic_Subprogram if we have a -- renaming as body, since the entity in this case is not an -- intrinsic (it calls an intrinsic, but we have a real body for -- this call, and it is in this body that the required intrinsic -- processing will take place). -- Also, if this is a renaming of inequality, the renamed operator -- is intrinsic, but what matters is the corresponding equality -- operator, which may be user-defined. Set_Is_Intrinsic_Subprogram (New_S, Is_Intrinsic_Subprogram (Old_S) and then (Chars (Old_S) /= Name_Op_Ne or else Ekind (Old_S) = E_Operator or else Is_Intrinsic_Subprogram (Corresponding_Equality (Old_S)))); if Ekind (Alias (New_S)) = E_Operator then Set_Has_Delayed_Freeze (New_S, False); end if; -- If the renaming corresponds to an association for an abstract -- formal subprogram, then various attributes must be set to -- indicate that the renaming is an abstract dispatching operation -- with a controlling type. if Is_Actual and then Is_Abstract_Subprogram (Formal_Spec) then -- Mark the renaming as abstract here, so Find_Dispatching_Type -- see it as corresponding to a generic association for a -- formal abstract subprogram Set_Is_Abstract_Subprogram (New_S); declare New_S_Ctrl_Type : constant Entity_Id := Find_Dispatching_Type (New_S); Old_S_Ctrl_Type : constant Entity_Id := Find_Dispatching_Type (Old_S); begin -- The actual must match the (instance of the) formal, -- and must be a controlling type. if Old_S_Ctrl_Type /= New_S_Ctrl_Type or else No (New_S_Ctrl_Type) then Error_Msg_NE ("actual must be dispatching subprogram for type&", Nam, New_S_Ctrl_Type); else Set_Is_Dispatching_Operation (New_S); Check_Controlling_Formals (New_S_Ctrl_Type, New_S); -- If the actual in the formal subprogram is itself a -- formal abstract subprogram association, there's no -- dispatch table component or position to inherit. if Present (DTC_Entity (Old_S)) then Set_DTC_Entity (New_S, DTC_Entity (Old_S)); Set_DT_Position_Value (New_S, DT_Position (Old_S)); end if; end if; end; end if; end if; if Is_Actual then null; -- The following is illegal, because F hides whatever other F may -- be around: -- function F (...) renames F; elsif Old_S = New_S or else (Nkind (Nam) /= N_Expanded_Name and then Chars (Old_S) = Chars (New_S)) then Error_Msg_N ("subprogram cannot rename itself", N); -- This is illegal even if we use a selector: -- function F (...) renames Pkg.F; -- because F is still hidden. elsif Nkind (Nam) = N_Expanded_Name and then Entity (Prefix (Nam)) = Current_Scope and then Chars (Selector_Name (Nam)) = Chars (New_S) then -- This is an error, but we overlook the error and accept the -- renaming if the special Overriding_Renamings mode is in effect. if not Overriding_Renamings then Error_Msg_NE ("implicit operation& is not visible (RM 8.3 (15))", Nam, Old_S); end if; end if; Set_Convention (New_S, Convention (Old_S)); if Is_Abstract_Subprogram (Old_S) then if Present (Rename_Spec) then Error_Msg_N ("a renaming-as-body cannot rename an abstract subprogram", N); Set_Has_Completion (Rename_Spec); else Set_Is_Abstract_Subprogram (New_S); end if; end if; Check_Library_Unit_Renaming (N, Old_S); -- Pathological case: procedure renames entry in the scope of its -- task. Entry is given by simple name, but body must be built for -- procedure. Of course if called it will deadlock. if Ekind (Old_S) = E_Entry then Set_Has_Completion (New_S, False); Set_Alias (New_S, Empty); end if; -- Do not freeze the renaming nor the renamed entity when the context -- is an enclosing generic. Freezing is an expansion activity, and in -- addition the renamed entity may depend on the generic formals of -- the enclosing generic. if Is_Actual and not Inside_A_Generic then Freeze_Before (N, Old_S); Freeze_Actual_Profile; Set_Has_Delayed_Freeze (New_S, False); Freeze_Before (N, New_S); -- An abstract subprogram is only allowed as an actual in the case -- where the formal subprogram is also abstract. if (Ekind (Old_S) = E_Procedure or else Ekind (Old_S) = E_Function) and then Is_Abstract_Subprogram (Old_S) and then not Is_Abstract_Subprogram (Formal_Spec) then Error_Msg_N ("abstract subprogram not allowed as generic actual", Nam); end if; end if; else -- A common error is to assume that implicit operators for types are -- defined in Standard, or in the scope of a subtype. In those cases -- where the renamed entity is given with an expanded name, it is -- worth mentioning that operators for the type are not declared in -- the scope given by the prefix. if Nkind (Nam) = N_Expanded_Name and then Nkind (Selector_Name (Nam)) = N_Operator_Symbol and then Scope (Entity (Nam)) = Standard_Standard then declare T : constant Entity_Id := Base_Type (Etype (First_Formal (New_S))); begin Error_Msg_Node_2 := Prefix (Nam); Error_Msg_NE ("operator for type& is not declared in&", Prefix (Nam), T); end; else Error_Msg_NE ("no visible subprogram matches the specification for&", Spec, New_S); end if; if Present (Candidate_Renaming) then declare F1 : Entity_Id; F2 : Entity_Id; T1 : Entity_Id; begin F1 := First_Formal (Candidate_Renaming); F2 := First_Formal (New_S); T1 := First_Subtype (Etype (F1)); while Present (F1) and then Present (F2) loop Next_Formal (F1); Next_Formal (F2); end loop; if Present (F1) and then Present (Default_Value (F1)) then if Present (Next_Formal (F1)) then Error_Msg_NE ("\missing specification for & and other formals with " & "defaults", Spec, F1); else Error_Msg_NE ("\missing specification for &", Spec, F1); end if; end if; if Nkind (Nam) = N_Operator_Symbol and then From_Default (N) then Error_Msg_Node_2 := T1; Error_Msg_NE ("default & on & is not directly visible", Nam, Nam); end if; end; end if; end if; -- Ada 2005 AI 404: if the new subprogram is dispatching, verify that -- controlling access parameters are known non-null for the renamed -- subprogram. Test also applies to a subprogram instantiation that -- is dispatching. Test is skipped if some previous error was detected -- that set Old_S to Any_Id. if Ada_Version >= Ada_2005 and then Old_S /= Any_Id and then not Is_Dispatching_Operation (Old_S) and then Is_Dispatching_Operation (New_S) then declare Old_F : Entity_Id; New_F : Entity_Id; begin Old_F := First_Formal (Old_S); New_F := First_Formal (New_S); while Present (Old_F) loop if Ekind (Etype (Old_F)) = E_Anonymous_Access_Type and then Is_Controlling_Formal (New_F) and then not Can_Never_Be_Null (Old_F) then Error_Msg_N ("access parameter is controlling,", New_F); Error_Msg_NE ("\corresponding parameter of& must be explicitly null " & "excluding", New_F, Old_S); end if; Next_Formal (Old_F); Next_Formal (New_F); end loop; end; end if; -- A useful warning, suggested by Ada Bug Finder (Ada-Europe 2005) -- is to warn if an operator is being renamed as a different operator. -- If the operator is predefined, examine the kind of the entity, not -- the abbreviated declaration in Standard. if Comes_From_Source (N) and then Present (Old_S) and then (Nkind (Old_S) = N_Defining_Operator_Symbol or else Ekind (Old_S) = E_Operator) and then Nkind (New_S) = N_Defining_Operator_Symbol and then Chars (Old_S) /= Chars (New_S) then Error_Msg_NE ("& is being renamed as a different operator??", N, Old_S); end if; -- Check for renaming of obsolescent subprogram Check_Obsolescent_2005_Entity (Entity (Nam), Nam); -- Another warning or some utility: if the new subprogram as the same -- name as the old one, the old one is not hidden by an outer homograph, -- the new one is not a public symbol, and the old one is otherwise -- directly visible, the renaming is superfluous. if Chars (Old_S) = Chars (New_S) and then Comes_From_Source (N) and then Scope (Old_S) /= Standard_Standard and then Warn_On_Redundant_Constructs and then (Is_Immediately_Visible (Old_S) or else Is_Potentially_Use_Visible (Old_S)) and then Is_Overloadable (Current_Scope) and then Chars (Current_Scope) /= Chars (Old_S) then Error_Msg_N ("redundant renaming, entity is directly visible?r?", Name (N)); end if; -- Implementation-defined aspect specifications can appear in a renaming -- declaration, but not language-defined ones. The call to procedure -- Analyze_Aspect_Specifications will take care of this error check. if Has_Aspects (N) then Analyze_Aspect_Specifications (N, New_S); end if; Ada_Version := Save_AV; Ada_Version_Pragma := Save_AVP; Ada_Version_Explicit := Save_AV_Exp; -- In GNATprove mode, the renamings of actual subprograms are replaced -- with wrapper functions that make it easier to propagate axioms to the -- points of call within an instance. Wrappers are generated if formal -- subprogram is subject to axiomatization. -- The types in the wrapper profiles are obtained from (instances of) -- the types of the formal subprogram. if Is_Actual and then GNATprove_Mode and then Present (Containing_Package_With_Ext_Axioms (Formal_Spec)) and then not Inside_A_Generic then if Ekind (Old_S) = E_Function then Rewrite (N, Build_Function_Wrapper (Formal_Spec, Old_S)); Analyze (N); elsif Ekind (Old_S) = E_Operator then Rewrite (N, Build_Operator_Wrapper (Formal_Spec, Old_S)); Analyze (N); end if; end if; end Analyze_Subprogram_Renaming; ------------------------- -- Analyze_Use_Package -- ------------------------- -- Resolve the package names in the use clause, and make all the visible -- entities defined in the package potentially use-visible. If the package -- is already in use from a previous use clause, its visible entities are -- already use-visible. In that case, mark the occurrence as a redundant -- use. If the package is an open scope, i.e. if the use clause occurs -- within the package itself, ignore it. procedure Analyze_Use_Package (N : Node_Id) is Ghost_Id : Entity_Id := Empty; Living_Id : Entity_Id := Empty; Pack : Entity_Id; Pack_Name : Node_Id; begin Check_SPARK_05_Restriction ("use clause is not allowed", N); Set_Hidden_By_Use_Clause (N, No_Elist); -- Use clause not allowed in a spec of a predefined package declaration -- except that packages whose file name starts a-n are OK (these are -- children of Ada.Numerics, which are never loaded by Rtsfind). if Is_Predefined_File_Name (Unit_File_Name (Current_Sem_Unit)) and then Name_Buffer (1 .. 3) /= "a-n" and then Nkind (Unit (Cunit (Current_Sem_Unit))) = N_Package_Declaration then Error_Msg_N ("use clause not allowed in predefined spec", N); end if; -- Chain clause to list of use clauses in current scope if Nkind (Parent (N)) /= N_Compilation_Unit then Chain_Use_Clause (N); end if; -- Loop through package names to identify referenced packages Pack_Name := First (Names (N)); while Present (Pack_Name) loop Analyze (Pack_Name); if Nkind (Parent (N)) = N_Compilation_Unit and then Nkind (Pack_Name) = N_Expanded_Name then declare Pref : Node_Id; begin Pref := Prefix (Pack_Name); while Nkind (Pref) = N_Expanded_Name loop Pref := Prefix (Pref); end loop; if Entity (Pref) = Standard_Standard then Error_Msg_N ("predefined package Standard cannot appear in a context " & "clause", Pref); end if; end; end if; Next (Pack_Name); end loop; -- Loop through package names to mark all entities as potentially use -- visible. Pack_Name := First (Names (N)); while Present (Pack_Name) loop if Is_Entity_Name (Pack_Name) then Pack := Entity (Pack_Name); if Ekind (Pack) /= E_Package and then Etype (Pack) /= Any_Type then if Ekind (Pack) = E_Generic_Package then Error_Msg_N -- CODEFIX ("a generic package is not allowed in a use clause", Pack_Name); elsif Ekind_In (Pack, E_Generic_Function, E_Generic_Package) then Error_Msg_N -- CODEFIX ("a generic subprogram is not allowed in a use clause", Pack_Name); elsif Ekind_In (Pack, E_Function, E_Procedure, E_Operator) then Error_Msg_N -- CODEFIX ("a subprogram is not allowed in a use clause", Pack_Name); else Error_Msg_N ("& is not allowed in a use clause", Pack_Name); end if; else if Nkind (Parent (N)) = N_Compilation_Unit then Check_In_Previous_With_Clause (N, Pack_Name); end if; if Applicable_Use (Pack_Name) then Use_One_Package (Pack, N); end if; -- Capture the first Ghost package and the first living package if Is_Entity_Name (Pack_Name) then Pack := Entity (Pack_Name); if Is_Ghost_Entity (Pack) then if No (Ghost_Id) then Ghost_Id := Pack; end if; elsif No (Living_Id) then Living_Id := Pack; end if; end if; end if; -- Report error because name denotes something other than a package else Error_Msg_N ("& is not a package", Pack_Name); end if; Next (Pack_Name); end loop; -- Detect a mixture of Ghost packages and living packages within the -- same use package clause. Ideally one would split a use package clause -- with multiple names into multiple use package clauses with a single -- name, however clients of the front end would have to adapt to this -- change. if Present (Ghost_Id) and then Present (Living_Id) then Error_Msg_N ("use clause cannot mention ghost and non-ghost ghost units", N); Error_Msg_Sloc := Sloc (Ghost_Id); Error_Msg_NE ("\& # declared as ghost", N, Ghost_Id); Error_Msg_Sloc := Sloc (Living_Id); Error_Msg_NE ("\& # declared as non-ghost", N, Living_Id); end if; Mark_Ghost_Clause (N); end Analyze_Use_Package; ---------------------- -- Analyze_Use_Type -- ---------------------- procedure Analyze_Use_Type (N : Node_Id) is E : Entity_Id; Ghost_Id : Entity_Id := Empty; Id : Node_Id; Living_Id : Entity_Id := Empty; begin Set_Hidden_By_Use_Clause (N, No_Elist); -- Chain clause to list of use clauses in current scope if Nkind (Parent (N)) /= N_Compilation_Unit then Chain_Use_Clause (N); end if; -- If the Used_Operations list is already initialized, the clause has -- been analyzed previously, and it is begin reinstalled, for example -- when the clause appears in a package spec and we are compiling the -- corresponding package body. In that case, make the entities on the -- existing list use_visible, and mark the corresponding types In_Use. if Present (Used_Operations (N)) then declare Mark : Node_Id; Elmt : Elmt_Id; begin Mark := First (Subtype_Marks (N)); while Present (Mark) loop Use_One_Type (Mark, Installed => True); Next (Mark); end loop; Elmt := First_Elmt (Used_Operations (N)); while Present (Elmt) loop Set_Is_Potentially_Use_Visible (Node (Elmt)); Next_Elmt (Elmt); end loop; end; return; end if; -- Otherwise, create new list and attach to it the operations that -- are made use-visible by the clause. Set_Used_Operations (N, New_Elmt_List); Id := First (Subtype_Marks (N)); while Present (Id) loop Find_Type (Id); E := Entity (Id); if E /= Any_Type then Use_One_Type (Id); if Nkind (Parent (N)) = N_Compilation_Unit then if Nkind (Id) = N_Identifier then Error_Msg_N ("type is not directly visible", Id); elsif Is_Child_Unit (Scope (E)) and then Scope (E) /= System_Aux_Id then Check_In_Previous_With_Clause (N, Prefix (Id)); end if; end if; else -- If the use_type_clause appears in a compilation unit context, -- check whether it comes from a unit that may appear in a -- limited_with_clause, for a better error message. if Nkind (Parent (N)) = N_Compilation_Unit and then Nkind (Id) /= N_Identifier then declare Item : Node_Id; Pref : Node_Id; function Mentioned (Nam : Node_Id) return Boolean; -- Check whether the prefix of expanded name for the type -- appears in the prefix of some limited_with_clause. --------------- -- Mentioned -- --------------- function Mentioned (Nam : Node_Id) return Boolean is begin return Nkind (Name (Item)) = N_Selected_Component and then Chars (Prefix (Name (Item))) = Chars (Nam); end Mentioned; begin Pref := Prefix (Id); Item := First (Context_Items (Parent (N))); while Present (Item) and then Item /= N loop if Nkind (Item) = N_With_Clause and then Limited_Present (Item) and then Mentioned (Pref) then Change_Error_Text (Get_Msg_Id, "premature usage of incomplete type"); end if; Next (Item); end loop; end; end if; end if; -- Capture the first Ghost type and the first living type if Is_Ghost_Entity (E) then if No (Ghost_Id) then Ghost_Id := E; end if; elsif No (Living_Id) then Living_Id := E; end if; Next (Id); end loop; -- Detect a mixture of Ghost types and living types within the same use -- type clause. Ideally one would split a use type clause with multiple -- marks into multiple use type clauses with a single mark, however -- clients of the front end will have to adapt to this change. if Present (Ghost_Id) and then Present (Living_Id) then Error_Msg_N ("use clause cannot mention ghost and non-ghost ghost types", N); Error_Msg_Sloc := Sloc (Ghost_Id); Error_Msg_NE ("\& # declared as ghost", N, Ghost_Id); Error_Msg_Sloc := Sloc (Living_Id); Error_Msg_NE ("\& # declared as non-ghost", N, Living_Id); end if; Mark_Ghost_Clause (N); end Analyze_Use_Type; -------------------- -- Applicable_Use -- -------------------- function Applicable_Use (Pack_Name : Node_Id) return Boolean is Pack : constant Entity_Id := Entity (Pack_Name); begin if In_Open_Scopes (Pack) then if Warn_On_Redundant_Constructs and then Pack = Current_Scope then Error_Msg_NE -- CODEFIX ("& is already use-visible within itself?r?", Pack_Name, Pack); end if; return False; elsif In_Use (Pack) then Note_Redundant_Use (Pack_Name); return False; elsif Present (Renamed_Object (Pack)) and then In_Use (Renamed_Object (Pack)) then Note_Redundant_Use (Pack_Name); return False; else return True; end if; end Applicable_Use; ------------------------ -- Attribute_Renaming -- ------------------------ procedure Attribute_Renaming (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Nam : constant Node_Id := Name (N); Spec : constant Node_Id := Specification (N); New_S : constant Entity_Id := Defining_Unit_Name (Spec); Aname : constant Name_Id := Attribute_Name (Nam); Form_Num : Nat := 0; Expr_List : List_Id := No_List; Attr_Node : Node_Id; Body_Node : Node_Id; Param_Spec : Node_Id; begin Generate_Definition (New_S); -- This procedure is called in the context of subprogram renaming, and -- thus the attribute must be one that is a subprogram. All of those -- have at least one formal parameter, with the exceptions of the GNAT -- attribute 'Img, which GNAT treats as renameable. if not Is_Non_Empty_List (Parameter_Specifications (Spec)) then if Aname /= Name_Img then Error_Msg_N ("subprogram renaming an attribute must have formals", N); return; end if; else Param_Spec := First (Parameter_Specifications (Spec)); while Present (Param_Spec) loop Form_Num := Form_Num + 1; if Nkind (Parameter_Type (Param_Spec)) /= N_Access_Definition then Find_Type (Parameter_Type (Param_Spec)); -- The profile of the new entity denotes the base type (s) of -- the types given in the specification. For access parameters -- there are no subtypes involved. Rewrite (Parameter_Type (Param_Spec), New_Occurrence_Of (Base_Type (Entity (Parameter_Type (Param_Spec))), Loc)); end if; if No (Expr_List) then Expr_List := New_List; end if; Append_To (Expr_List, Make_Identifier (Loc, Chars => Chars (Defining_Identifier (Param_Spec)))); -- The expressions in the attribute reference are not freeze -- points. Neither is the attribute as a whole, see below. Set_Must_Not_Freeze (Last (Expr_List)); Next (Param_Spec); end loop; end if; -- Immediate error if too many formals. Other mismatches in number or -- types of parameters are detected when we analyze the body of the -- subprogram that we construct. if Form_Num > 2 then Error_Msg_N ("too many formals for attribute", N); -- Error if the attribute reference has expressions that look like -- formal parameters. elsif Present (Expressions (Nam)) then Error_Msg_N ("illegal expressions in attribute reference", Nam); elsif Nam_In (Aname, Name_Compose, Name_Exponent, Name_Leading_Part, Name_Pos, Name_Round, Name_Scaling, Name_Val) then if Nkind (N) = N_Subprogram_Renaming_Declaration and then Present (Corresponding_Formal_Spec (N)) then Error_Msg_N ("generic actual cannot be attribute involving universal type", Nam); else Error_Msg_N ("attribute involving a universal type cannot be renamed", Nam); end if; end if; -- Rewrite attribute node to have a list of expressions corresponding to -- the subprogram formals. A renaming declaration is not a freeze point, -- and the analysis of the attribute reference should not freeze the -- type of the prefix. We use the original node in the renaming so that -- its source location is preserved, and checks on stream attributes are -- properly applied. Attr_Node := Relocate_Node (Nam); Set_Expressions (Attr_Node, Expr_List); Set_Must_Not_Freeze (Attr_Node); Set_Must_Not_Freeze (Prefix (Nam)); -- Case of renaming a function if Nkind (Spec) = N_Function_Specification then if Is_Procedure_Attribute_Name (Aname) then Error_Msg_N ("attribute can only be renamed as procedure", Nam); return; end if; Find_Type (Result_Definition (Spec)); Rewrite (Result_Definition (Spec), New_Occurrence_Of (Base_Type (Entity (Result_Definition (Spec))), Loc)); Body_Node := Make_Subprogram_Body (Loc, Specification => Spec, Declarations => New_List, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List ( Make_Simple_Return_Statement (Loc, Expression => Attr_Node)))); -- Case of renaming a procedure else if not Is_Procedure_Attribute_Name (Aname) then Error_Msg_N ("attribute can only be renamed as function", Nam); return; end if; Body_Node := Make_Subprogram_Body (Loc, Specification => Spec, Declarations => New_List, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List (Attr_Node))); end if; -- In case of tagged types we add the body of the generated function to -- the freezing actions of the type (because in the general case such -- type is still not frozen). We exclude from this processing generic -- formal subprograms found in instantiations. -- We must exclude restricted run-time libraries because -- entity AST_Handler is defined in package System.Aux_Dec which is not -- available in those platforms. Note that we cannot use the function -- Restricted_Profile (instead of Configurable_Run_Time_Mode) because -- the ZFP run-time library is not defined as a profile, and we do not -- want to deal with AST_Handler in ZFP mode. if not Configurable_Run_Time_Mode and then not Present (Corresponding_Formal_Spec (N)) and then Etype (Nam) /= RTE (RE_AST_Handler) then declare P : constant Node_Id := Prefix (Nam); begin -- The prefix of 'Img is an object that is evaluated for each call -- of the function that renames it. if Aname = Name_Img then Preanalyze_And_Resolve (P); -- For all other attribute renamings, the prefix is a subtype else Find_Type (P); end if; -- If the target type is not yet frozen, add the body to the -- actions to be elaborated at freeze time. if Is_Tagged_Type (Etype (P)) and then In_Open_Scopes (Scope (Etype (P))) then Ensure_Freeze_Node (Etype (P)); Append_Freeze_Action (Etype (P), Body_Node); else Rewrite (N, Body_Node); Analyze (N); Set_Etype (New_S, Base_Type (Etype (New_S))); end if; end; -- Generic formal subprograms or AST_Handler renaming else Rewrite (N, Body_Node); Analyze (N); Set_Etype (New_S, Base_Type (Etype (New_S))); end if; if Is_Compilation_Unit (New_S) then Error_Msg_N ("a library unit can only rename another library unit", N); end if; -- We suppress elaboration warnings for the resulting entity, since -- clearly they are not needed, and more particularly, in the case -- of a generic formal subprogram, the resulting entity can appear -- after the instantiation itself, and thus look like a bogus case -- of access before elaboration. Set_Suppress_Elaboration_Warnings (New_S); end Attribute_Renaming; ---------------------- -- Chain_Use_Clause -- ---------------------- procedure Chain_Use_Clause (N : Node_Id) is Pack : Entity_Id; Level : Int := Scope_Stack.Last; begin if not Is_Compilation_Unit (Current_Scope) or else not Is_Child_Unit (Current_Scope) then null; -- Common case elsif Defining_Entity (Parent (N)) = Current_Scope then null; -- Common case for compilation unit else -- If declaration appears in some other scope, it must be in some -- parent unit when compiling a child. Pack := Defining_Entity (Parent (N)); if not In_Open_Scopes (Pack) then null; -- default as well -- If the use clause appears in an ancestor and we are in the -- private part of the immediate parent, the use clauses are -- already installed. elsif Pack /= Scope (Current_Scope) and then In_Private_Part (Scope (Current_Scope)) then null; else -- Find entry for parent unit in scope stack while Scope_Stack.Table (Level).Entity /= Pack loop Level := Level - 1; end loop; end if; end if; Set_Next_Use_Clause (N, Scope_Stack.Table (Level).First_Use_Clause); Scope_Stack.Table (Level).First_Use_Clause := N; end Chain_Use_Clause; --------------------------- -- Check_Frozen_Renaming -- --------------------------- procedure Check_Frozen_Renaming (N : Node_Id; Subp : Entity_Id) is B_Node : Node_Id; Old_S : Entity_Id; begin if Is_Frozen (Subp) and then not Has_Completion (Subp) then B_Node := Build_Renamed_Body (Parent (Declaration_Node (Subp)), Defining_Entity (N)); if Is_Entity_Name (Name (N)) then Old_S := Entity (Name (N)); if not Is_Frozen (Old_S) and then Operating_Mode /= Check_Semantics then Append_Freeze_Action (Old_S, B_Node); else Insert_After (N, B_Node); Analyze (B_Node); end if; if Is_Intrinsic_Subprogram (Old_S) and then not In_Instance then Error_Msg_N ("subprogram used in renaming_as_body cannot be intrinsic", Name (N)); end if; else Insert_After (N, B_Node); Analyze (B_Node); end if; end if; end Check_Frozen_Renaming; ------------------------------- -- Set_Entity_Or_Discriminal -- ------------------------------- procedure Set_Entity_Or_Discriminal (N : Node_Id; E : Entity_Id) is P : Node_Id; begin -- If the entity is not a discriminant, or else expansion is disabled, -- simply set the entity. if not In_Spec_Expression or else Ekind (E) /= E_Discriminant or else Inside_A_Generic then Set_Entity_With_Checks (N, E); -- The replacement of a discriminant by the corresponding discriminal -- is not done for a task discriminant that appears in a default -- expression of an entry parameter. See Exp_Ch2.Expand_Discriminant -- for details on their handling. elsif Is_Concurrent_Type (Scope (E)) then P := Parent (N); while Present (P) and then not Nkind_In (P, N_Parameter_Specification, N_Component_Declaration) loop P := Parent (P); end loop; if Present (P) and then Nkind (P) = N_Parameter_Specification then null; else Set_Entity (N, Discriminal (E)); end if; -- Otherwise, this is a discriminant in a context in which -- it is a reference to the corresponding parameter of the -- init proc for the enclosing type. else Set_Entity (N, Discriminal (E)); end if; end Set_Entity_Or_Discriminal; ----------------------------------- -- Check_In_Previous_With_Clause -- ----------------------------------- procedure Check_In_Previous_With_Clause (N : Node_Id; Nam : Entity_Id) is Pack : constant Entity_Id := Entity (Original_Node (Nam)); Item : Node_Id; Par : Node_Id; begin Item := First (Context_Items (Parent (N))); while Present (Item) and then Item /= N loop if Nkind (Item) = N_With_Clause -- Protect the frontend against previous critical errors and then Nkind (Name (Item)) /= N_Selected_Component and then Entity (Name (Item)) = Pack then Par := Nam; -- Find root library unit in with_clause while Nkind (Par) = N_Expanded_Name loop Par := Prefix (Par); end loop; if Is_Child_Unit (Entity (Original_Node (Par))) then Error_Msg_NE ("& is not directly visible", Par, Entity (Par)); else return; end if; end if; Next (Item); end loop; -- On exit, package is not mentioned in a previous with_clause. -- Check if its prefix is. if Nkind (Nam) = N_Expanded_Name then Check_In_Previous_With_Clause (N, Prefix (Nam)); elsif Pack /= Any_Id then Error_Msg_NE ("& is not visible", Nam, Pack); end if; end Check_In_Previous_With_Clause; --------------------------------- -- Check_Library_Unit_Renaming -- --------------------------------- procedure Check_Library_Unit_Renaming (N : Node_Id; Old_E : Entity_Id) is New_E : Entity_Id; begin if Nkind (Parent (N)) /= N_Compilation_Unit then return; -- Check for library unit. Note that we used to check for the scope -- being Standard here, but that was wrong for Standard itself. elsif not Is_Compilation_Unit (Old_E) and then not Is_Child_Unit (Old_E) then Error_Msg_N ("renamed unit must be a library unit", Name (N)); -- Entities defined in Standard (operators and boolean literals) cannot -- be renamed as library units. elsif Scope (Old_E) = Standard_Standard and then Sloc (Old_E) = Standard_Location then Error_Msg_N ("renamed unit must be a library unit", Name (N)); elsif Present (Parent_Spec (N)) and then Nkind (Unit (Parent_Spec (N))) = N_Generic_Package_Declaration and then not Is_Child_Unit (Old_E) then Error_Msg_N ("renamed unit must be a child unit of generic parent", Name (N)); elsif Nkind (N) in N_Generic_Renaming_Declaration and then Nkind (Name (N)) = N_Expanded_Name and then Is_Generic_Instance (Entity (Prefix (Name (N)))) and then Is_Generic_Unit (Old_E) then Error_Msg_N ("renamed generic unit must be a library unit", Name (N)); elsif Is_Package_Or_Generic_Package (Old_E) then -- Inherit categorization flags New_E := Defining_Entity (N); Set_Is_Pure (New_E, Is_Pure (Old_E)); Set_Is_Preelaborated (New_E, Is_Preelaborated (Old_E)); Set_Is_Remote_Call_Interface (New_E, Is_Remote_Call_Interface (Old_E)); Set_Is_Remote_Types (New_E, Is_Remote_Types (Old_E)); Set_Is_Shared_Passive (New_E, Is_Shared_Passive (Old_E)); end if; end Check_Library_Unit_Renaming; ------------------------ -- Enclosing_Instance -- ------------------------ function Enclosing_Instance return Entity_Id is S : Entity_Id; begin if not Is_Generic_Instance (Current_Scope) then return Empty; end if; S := Scope (Current_Scope); while S /= Standard_Standard loop if Is_Generic_Instance (S) then return S; end if; S := Scope (S); end loop; return Empty; end Enclosing_Instance; --------------- -- End_Scope -- --------------- procedure End_Scope is Id : Entity_Id; Prev : Entity_Id; Outer : Entity_Id; begin Id := First_Entity (Current_Scope); while Present (Id) loop -- An entity in the current scope is not necessarily the first one -- on its homonym chain. Find its predecessor if any, -- If it is an internal entity, it will not be in the visibility -- chain altogether, and there is nothing to unchain. if Id /= Current_Entity (Id) then Prev := Current_Entity (Id); while Present (Prev) and then Present (Homonym (Prev)) and then Homonym (Prev) /= Id loop Prev := Homonym (Prev); end loop; -- Skip to end of loop if Id is not in the visibility chain if No (Prev) or else Homonym (Prev) /= Id then goto Next_Ent; end if; else Prev := Empty; end if; Set_Is_Immediately_Visible (Id, False); Outer := Homonym (Id); while Present (Outer) and then Scope (Outer) = Current_Scope loop Outer := Homonym (Outer); end loop; -- Reset homonym link of other entities, but do not modify link -- between entities in current scope, so that the back-end can have -- a proper count of local overloadings. if No (Prev) then Set_Name_Entity_Id (Chars (Id), Outer); elsif Scope (Prev) /= Scope (Id) then Set_Homonym (Prev, Outer); end if; <<Next_Ent>> Next_Entity (Id); end loop; -- If the scope generated freeze actions, place them before the -- current declaration and analyze them. Type declarations and -- the bodies of initialization procedures can generate such nodes. -- We follow the parent chain until we reach a list node, which is -- the enclosing list of declarations. If the list appears within -- a protected definition, move freeze nodes outside the protected -- type altogether. if Present (Scope_Stack.Table (Scope_Stack.Last).Pending_Freeze_Actions) then declare Decl : Node_Id; L : constant List_Id := Scope_Stack.Table (Scope_Stack.Last).Pending_Freeze_Actions; begin if Is_Itype (Current_Scope) then Decl := Associated_Node_For_Itype (Current_Scope); else Decl := Parent (Current_Scope); end if; Pop_Scope; while not (Is_List_Member (Decl)) or else Nkind_In (Parent (Decl), N_Protected_Definition, N_Task_Definition) loop Decl := Parent (Decl); end loop; Insert_List_Before_And_Analyze (Decl, L); end; else Pop_Scope; end if; end End_Scope; --------------------- -- End_Use_Clauses -- --------------------- procedure End_Use_Clauses (Clause : Node_Id) is U : Node_Id; begin -- Remove Use_Type clauses first, because they affect the -- visibility of operators in subsequent used packages. U := Clause; while Present (U) loop if Nkind (U) = N_Use_Type_Clause then End_Use_Type (U); end if; Next_Use_Clause (U); end loop; U := Clause; while Present (U) loop if Nkind (U) = N_Use_Package_Clause then End_Use_Package (U); end if; Next_Use_Clause (U); end loop; end End_Use_Clauses; --------------------- -- End_Use_Package -- --------------------- procedure End_Use_Package (N : Node_Id) is Pack_Name : Node_Id; Pack : Entity_Id; Id : Entity_Id; Elmt : Elmt_Id; function Is_Primitive_Operator_In_Use (Op : Entity_Id; F : Entity_Id) return Boolean; -- Check whether Op is a primitive operator of a use-visible type ---------------------------------- -- Is_Primitive_Operator_In_Use -- ---------------------------------- function Is_Primitive_Operator_In_Use (Op : Entity_Id; F : Entity_Id) return Boolean is T : constant Entity_Id := Base_Type (Etype (F)); begin return In_Use (T) and then Scope (T) = Scope (Op); end Is_Primitive_Operator_In_Use; -- Start of processing for End_Use_Package begin Pack_Name := First (Names (N)); while Present (Pack_Name) loop -- Test that Pack_Name actually denotes a package before processing if Is_Entity_Name (Pack_Name) and then Ekind (Entity (Pack_Name)) = E_Package then Pack := Entity (Pack_Name); if In_Open_Scopes (Pack) then null; elsif not Redundant_Use (Pack_Name) then Set_In_Use (Pack, False); Set_Current_Use_Clause (Pack, Empty); Id := First_Entity (Pack); while Present (Id) loop -- Preserve use-visibility of operators that are primitive -- operators of a type that is use-visible through an active -- use_type clause. if Nkind (Id) = N_Defining_Operator_Symbol and then (Is_Primitive_Operator_In_Use (Id, First_Formal (Id)) or else (Present (Next_Formal (First_Formal (Id))) and then Is_Primitive_Operator_In_Use (Id, Next_Formal (First_Formal (Id))))) then null; else Set_Is_Potentially_Use_Visible (Id, False); end if; if Is_Private_Type (Id) and then Present (Full_View (Id)) then Set_Is_Potentially_Use_Visible (Full_View (Id), False); end if; Next_Entity (Id); end loop; if Present (Renamed_Object (Pack)) then Set_In_Use (Renamed_Object (Pack), False); Set_Current_Use_Clause (Renamed_Object (Pack), Empty); end if; if Chars (Pack) = Name_System and then Scope (Pack) = Standard_Standard and then Present_System_Aux then Id := First_Entity (System_Aux_Id); while Present (Id) loop Set_Is_Potentially_Use_Visible (Id, False); if Is_Private_Type (Id) and then Present (Full_View (Id)) then Set_Is_Potentially_Use_Visible (Full_View (Id), False); end if; Next_Entity (Id); end loop; Set_In_Use (System_Aux_Id, False); end if; else Set_Redundant_Use (Pack_Name, False); end if; end if; Next (Pack_Name); end loop; if Present (Hidden_By_Use_Clause (N)) then Elmt := First_Elmt (Hidden_By_Use_Clause (N)); while Present (Elmt) loop declare E : constant Entity_Id := Node (Elmt); begin -- Reset either Use_Visibility or Direct_Visibility, depending -- on how the entity was hidden by the use clause. if In_Use (Scope (E)) and then Used_As_Generic_Actual (Scope (E)) then Set_Is_Potentially_Use_Visible (Node (Elmt)); else Set_Is_Immediately_Visible (Node (Elmt)); end if; Next_Elmt (Elmt); end; end loop; Set_Hidden_By_Use_Clause (N, No_Elist); end if; end End_Use_Package; ------------------ -- End_Use_Type -- ------------------ procedure End_Use_Type (N : Node_Id) is Elmt : Elmt_Id; Id : Entity_Id; T : Entity_Id; -- Start of processing for End_Use_Type begin Id := First (Subtype_Marks (N)); while Present (Id) loop -- A call to Rtsfind may occur while analyzing a use_type clause, -- in which case the type marks are not resolved yet, and there is -- nothing to remove. if not Is_Entity_Name (Id) or else No (Entity (Id)) then goto Continue; end if; T := Entity (Id); if T = Any_Type or else From_Limited_With (T) then null; -- Note that the use_type clause may mention a subtype of the type -- whose primitive operations have been made visible. Here as -- elsewhere, it is the base type that matters for visibility. elsif In_Open_Scopes (Scope (Base_Type (T))) then null; elsif not Redundant_Use (Id) then Set_In_Use (T, False); Set_In_Use (Base_Type (T), False); Set_Current_Use_Clause (T, Empty); Set_Current_Use_Clause (Base_Type (T), Empty); end if; <<Continue>> Next (Id); end loop; if Is_Empty_Elmt_List (Used_Operations (N)) then return; else Elmt := First_Elmt (Used_Operations (N)); while Present (Elmt) loop Set_Is_Potentially_Use_Visible (Node (Elmt), False); Next_Elmt (Elmt); end loop; end if; end End_Use_Type; ---------------------- -- Find_Direct_Name -- ---------------------- procedure Find_Direct_Name (N : Node_Id) is E : Entity_Id; E2 : Entity_Id; Msg : Boolean; Inst : Entity_Id := Empty; -- Enclosing instance, if any Homonyms : Entity_Id; -- Saves start of homonym chain Nvis_Entity : Boolean; -- Set True to indicate that there is at least one entity on the homonym -- chain which, while not visible, is visible enough from the user point -- of view to warrant an error message of "not visible" rather than -- undefined. Nvis_Is_Private_Subprg : Boolean := False; -- Ada 2005 (AI-262): Set True to indicate that a form of Beaujolais -- effect concerning library subprograms has been detected. Used to -- generate the precise error message. function From_Actual_Package (E : Entity_Id) return Boolean; -- Returns true if the entity is an actual for a package that is itself -- an actual for a formal package of the current instance. Such an -- entity requires special handling because it may be use-visible but -- hides directly visible entities defined outside the instance, because -- the corresponding formal did so in the generic. function Is_Actual_Parameter return Boolean; -- This function checks if the node N is an identifier that is an actual -- parameter of a procedure call. If so it returns True, otherwise it -- return False. The reason for this check is that at this stage we do -- not know what procedure is being called if the procedure might be -- overloaded, so it is premature to go setting referenced flags or -- making calls to Generate_Reference. We will wait till Resolve_Actuals -- for that processing function Known_But_Invisible (E : Entity_Id) return Boolean; -- This function determines whether a reference to the entity E, which -- is not visible, can reasonably be considered to be known to the -- writer of the reference. This is a heuristic test, used only for -- the purposes of figuring out whether we prefer to complain that an -- entity is undefined or invisible (and identify the declaration of -- the invisible entity in the latter case). The point here is that we -- don't want to complain that something is invisible and then point to -- something entirely mysterious to the writer. procedure Nvis_Messages; -- Called if there are no visible entries for N, but there is at least -- one non-directly visible, or hidden declaration. This procedure -- outputs an appropriate set of error messages. procedure Undefined (Nvis : Boolean); -- This function is called if the current node has no corresponding -- visible entity or entities. The value set in Msg indicates whether -- an error message was generated (multiple error messages for the -- same variable are generally suppressed, see body for details). -- Msg is True if an error message was generated, False if not. This -- value is used by the caller to determine whether or not to output -- additional messages where appropriate. The parameter is set False -- to get the message "X is undefined", and True to get the message -- "X is not visible". ------------------------- -- From_Actual_Package -- ------------------------- function From_Actual_Package (E : Entity_Id) return Boolean is Scop : constant Entity_Id := Scope (E); -- Declared scope of candidate entity Act : Entity_Id; function Declared_In_Actual (Pack : Entity_Id) return Boolean; -- Recursive function that does the work and examines actuals of -- actual packages of current instance. ------------------------ -- Declared_In_Actual -- ------------------------ function Declared_In_Actual (Pack : Entity_Id) return Boolean is Act : Entity_Id; begin if No (Associated_Formal_Package (Pack)) then return False; else Act := First_Entity (Pack); while Present (Act) loop if Renamed_Object (Pack) = Scop then return True; -- Check for end of list of actuals. elsif Ekind (Act) = E_Package and then Renamed_Object (Act) = Pack then return False; elsif Ekind (Act) = E_Package and then Declared_In_Actual (Act) then return True; end if; Next_Entity (Act); end loop; return False; end if; end Declared_In_Actual; -- Start of processing for From_Actual_Package begin if not In_Instance then return False; else Inst := Current_Scope; while Present (Inst) and then Ekind (Inst) /= E_Package and then not Is_Generic_Instance (Inst) loop Inst := Scope (Inst); end loop; if No (Inst) then return False; end if; Act := First_Entity (Inst); while Present (Act) loop if Ekind (Act) = E_Package and then Declared_In_Actual (Act) then return True; end if; Next_Entity (Act); end loop; return False; end if; end From_Actual_Package; ------------------------- -- Is_Actual_Parameter -- ------------------------- function Is_Actual_Parameter return Boolean is begin return Nkind (N) = N_Identifier and then (Nkind (Parent (N)) = N_Procedure_Call_Statement or else (Nkind (Parent (N)) = N_Parameter_Association and then N = Explicit_Actual_Parameter (Parent (N)) and then Nkind (Parent (Parent (N))) = N_Procedure_Call_Statement)); end Is_Actual_Parameter; ------------------------- -- Known_But_Invisible -- ------------------------- function Known_But_Invisible (E : Entity_Id) return Boolean is Fname : File_Name_Type; begin -- Entities in Standard are always considered to be known if Sloc (E) <= Standard_Location then return True; -- An entity that does not come from source is always considered -- to be unknown, since it is an artifact of code expansion. elsif not Comes_From_Source (E) then return False; -- In gnat internal mode, we consider all entities known. The -- historical reason behind this discrepancy is not known??? But the -- only effect is to modify the error message given, so it is not -- critical. Since it only affects the exact wording of error -- messages in illegal programs, we do not mention this as an -- effect of -gnatg, since it is not a language modification. elsif GNAT_Mode then return True; end if; -- Here we have an entity that is not from package Standard, and -- which comes from Source. See if it comes from an internal file. Fname := Unit_File_Name (Get_Source_Unit (E)); -- Case of from internal file if Is_Internal_File_Name (Fname) then -- Private part entities in internal files are never considered -- to be known to the writer of normal application code. if Is_Hidden (E) then return False; end if; -- Entities from System packages other than System and -- System.Storage_Elements are not considered to be known. -- System.Auxxxx files are also considered known to the user. -- Should refine this at some point to generally distinguish -- between known and unknown internal files ??? Get_Name_String (Fname); return Name_Len < 2 or else Name_Buffer (1 .. 2) /= "s-" or else Name_Buffer (3 .. 8) = "stoele" or else Name_Buffer (3 .. 5) = "aux"; -- If not an internal file, then entity is definitely known, even if -- it is in a private part (the message generated will note that it -- is in a private part). else return True; end if; end Known_But_Invisible; ------------------- -- Nvis_Messages -- ------------------- procedure Nvis_Messages is Comp_Unit : Node_Id; Ent : Entity_Id; Found : Boolean := False; Hidden : Boolean := False; Item : Node_Id; begin -- Ada 2005 (AI-262): Generate a precise error concerning the -- Beaujolais effect that was previously detected if Nvis_Is_Private_Subprg then pragma Assert (Nkind (E2) = N_Defining_Identifier and then Ekind (E2) = E_Function and then Scope (E2) = Standard_Standard and then Has_Private_With (E2)); -- Find the sloc corresponding to the private with'ed unit Comp_Unit := Cunit (Current_Sem_Unit); Error_Msg_Sloc := No_Location; Item := First (Context_Items (Comp_Unit)); while Present (Item) loop if Nkind (Item) = N_With_Clause and then Private_Present (Item) and then Entity (Name (Item)) = E2 then Error_Msg_Sloc := Sloc (Item); exit; end if; Next (Item); end loop; pragma Assert (Error_Msg_Sloc /= No_Location); Error_Msg_N ("(Ada 2005): hidden by private with clause #", N); return; end if; Undefined (Nvis => True); if Msg then -- First loop does hidden declarations Ent := Homonyms; while Present (Ent) loop if Is_Potentially_Use_Visible (Ent) then if not Hidden then Error_Msg_N -- CODEFIX ("multiple use clauses cause hiding!", N); Hidden := True; end if; Error_Msg_Sloc := Sloc (Ent); Error_Msg_N -- CODEFIX ("hidden declaration#!", N); end if; Ent := Homonym (Ent); end loop; -- If we found hidden declarations, then that's enough, don't -- bother looking for non-visible declarations as well. if Hidden then return; end if; -- Second loop does non-directly visible declarations Ent := Homonyms; while Present (Ent) loop if not Is_Potentially_Use_Visible (Ent) then -- Do not bother the user with unknown entities if not Known_But_Invisible (Ent) then goto Continue; end if; Error_Msg_Sloc := Sloc (Ent); -- Output message noting that there is a non-visible -- declaration, distinguishing the private part case. if Is_Hidden (Ent) then Error_Msg_N ("non-visible (private) declaration#!", N); -- If the entity is declared in a generic package, it -- cannot be visible, so there is no point in adding it -- to the list of candidates if another homograph from a -- non-generic package has been seen. elsif Ekind (Scope (Ent)) = E_Generic_Package and then Found then null; else Error_Msg_N -- CODEFIX ("non-visible declaration#!", N); if Ekind (Scope (Ent)) /= E_Generic_Package then Found := True; end if; if Is_Compilation_Unit (Ent) and then Nkind (Parent (Parent (N))) = N_Use_Package_Clause then Error_Msg_Qual_Level := 99; Error_Msg_NE -- CODEFIX ("\\missing `WITH &;`", N, Ent); Error_Msg_Qual_Level := 0; end if; if Ekind (Ent) = E_Discriminant and then Present (Corresponding_Discriminant (Ent)) and then Scope (Corresponding_Discriminant (Ent)) = Etype (Scope (Ent)) then Error_Msg_N ("inherited discriminant not allowed here" & " (RM 3.8 (12), 3.8.1 (6))!", N); end if; end if; -- Set entity and its containing package as referenced. We -- can't be sure of this, but this seems a better choice -- to avoid unused entity messages. if Comes_From_Source (Ent) then Set_Referenced (Ent); Set_Referenced (Cunit_Entity (Get_Source_Unit (Ent))); end if; end if; <<Continue>> Ent := Homonym (Ent); end loop; end if; end Nvis_Messages; --------------- -- Undefined -- --------------- procedure Undefined (Nvis : Boolean) is Emsg : Error_Msg_Id; begin -- We should never find an undefined internal name. If we do, then -- see if we have previous errors. If so, ignore on the grounds that -- it is probably a cascaded message (e.g. a block label from a badly -- formed block). If no previous errors, then we have a real internal -- error of some kind so raise an exception. if Is_Internal_Name (Chars (N)) then if Total_Errors_Detected /= 0 then return; else raise Program_Error; end if; end if; -- A very specialized error check, if the undefined variable is -- a case tag, and the case type is an enumeration type, check -- for a possible misspelling, and if so, modify the identifier -- Named aggregate should also be handled similarly ??? if Nkind (N) = N_Identifier and then Nkind (Parent (N)) = N_Case_Statement_Alternative then declare Case_Stm : constant Node_Id := Parent (Parent (N)); Case_Typ : constant Entity_Id := Etype (Expression (Case_Stm)); Lit : Node_Id; begin if Is_Enumeration_Type (Case_Typ) and then not Is_Standard_Character_Type (Case_Typ) then Lit := First_Literal (Case_Typ); Get_Name_String (Chars (Lit)); if Chars (Lit) /= Chars (N) and then Is_Bad_Spelling_Of (Chars (N), Chars (Lit)) then Error_Msg_Node_2 := Lit; Error_Msg_N -- CODEFIX ("& is undefined, assume misspelling of &", N); Rewrite (N, New_Occurrence_Of (Lit, Sloc (N))); return; end if; Lit := Next_Literal (Lit); end if; end; end if; -- Normal processing Set_Entity (N, Any_Id); Set_Etype (N, Any_Type); -- We use the table Urefs to keep track of entities for which we -- have issued errors for undefined references. Multiple errors -- for a single name are normally suppressed, however we modify -- the error message to alert the programmer to this effect. for J in Urefs.First .. Urefs.Last loop if Chars (N) = Chars (Urefs.Table (J).Node) then if Urefs.Table (J).Err /= No_Error_Msg and then Sloc (N) /= Urefs.Table (J).Loc then Error_Msg_Node_1 := Urefs.Table (J).Node; if Urefs.Table (J).Nvis then Change_Error_Text (Urefs.Table (J).Err, "& is not visible (more references follow)"); else Change_Error_Text (Urefs.Table (J).Err, "& is undefined (more references follow)"); end if; Urefs.Table (J).Err := No_Error_Msg; end if; -- Although we will set Msg False, and thus suppress the -- message, we also set Error_Posted True, to avoid any -- cascaded messages resulting from the undefined reference. Msg := False; Set_Error_Posted (N, True); return; end if; end loop; -- If entry not found, this is first undefined occurrence if Nvis then Error_Msg_N ("& is not visible!", N); Emsg := Get_Msg_Id; else Error_Msg_N ("& is undefined!", N); Emsg := Get_Msg_Id; -- A very bizarre special check, if the undefined identifier -- is put or put_line, then add a special error message (since -- this is a very common error for beginners to make). if Nam_In (Chars (N), Name_Put, Name_Put_Line) then Error_Msg_N -- CODEFIX ("\\possible missing `WITH Ada.Text_'I'O; " & "USE Ada.Text_'I'O`!", N); -- Another special check if N is the prefix of a selected -- component which is a known unit, add message complaining -- about missing with for this unit. elsif Nkind (Parent (N)) = N_Selected_Component and then N = Prefix (Parent (N)) and then Is_Known_Unit (Parent (N)) then Error_Msg_Node_2 := Selector_Name (Parent (N)); Error_Msg_N -- CODEFIX ("\\missing `WITH &.&;`", Prefix (Parent (N))); end if; -- Now check for possible misspellings declare E : Entity_Id; Ematch : Entity_Id := Empty; Last_Name_Id : constant Name_Id := Name_Id (Nat (First_Name_Id) + Name_Entries_Count - 1); begin for Nam in First_Name_Id .. Last_Name_Id loop E := Get_Name_Entity_Id (Nam); if Present (E) and then (Is_Immediately_Visible (E) or else Is_Potentially_Use_Visible (E)) then if Is_Bad_Spelling_Of (Chars (N), Nam) then Ematch := E; exit; end if; end if; end loop; if Present (Ematch) then Error_Msg_NE -- CODEFIX ("\possible misspelling of&", N, Ematch); end if; end; end if; -- Make entry in undefined references table unless the full errors -- switch is set, in which case by refraining from generating the -- table entry, we guarantee that we get an error message for every -- undefined reference. if not All_Errors_Mode then Urefs.Append ( (Node => N, Err => Emsg, Nvis => Nvis, Loc => Sloc (N))); end if; Msg := True; end Undefined; -- Start of processing for Find_Direct_Name begin -- If the entity pointer is already set, this is an internal node, or -- a node that is analyzed more than once, after a tree modification. -- In such a case there is no resolution to perform, just set the type. if Present (Entity (N)) then if Is_Type (Entity (N)) then Set_Etype (N, Entity (N)); else declare Entyp : constant Entity_Id := Etype (Entity (N)); begin -- One special case here. If the Etype field is already set, -- and references the packed array type corresponding to the -- etype of the referenced entity, then leave it alone. This -- happens for trees generated from Exp_Pakd, where expressions -- can be deliberately "mis-typed" to the packed array type. if Is_Array_Type (Entyp) and then Is_Packed (Entyp) and then Present (Etype (N)) and then Etype (N) = Packed_Array_Impl_Type (Entyp) then null; -- If not that special case, then just reset the Etype else Set_Etype (N, Etype (Entity (N))); end if; end; end if; return; end if; -- Here if Entity pointer was not set, we need full visibility analysis -- First we generate debugging output if the debug E flag is set. if Debug_Flag_E then Write_Str ("Looking for "); Write_Name (Chars (N)); Write_Eol; end if; Homonyms := Current_Entity (N); Nvis_Entity := False; E := Homonyms; while Present (E) loop -- If entity is immediately visible or potentially use visible, then -- process the entity and we are done. if Is_Immediately_Visible (E) then goto Immediately_Visible_Entity; elsif Is_Potentially_Use_Visible (E) then goto Potentially_Use_Visible_Entity; -- Note if a known but invisible entity encountered elsif Known_But_Invisible (E) then Nvis_Entity := True; end if; -- Move to next entity in chain and continue search E := Homonym (E); end loop; -- If no entries on homonym chain that were potentially visible, -- and no entities reasonably considered as non-visible, then -- we have a plain undefined reference, with no additional -- explanation required. if not Nvis_Entity then Undefined (Nvis => False); -- Otherwise there is at least one entry on the homonym chain that -- is reasonably considered as being known and non-visible. else Nvis_Messages; end if; goto Done; -- Processing for a potentially use visible entry found. We must search -- the rest of the homonym chain for two reasons. First, if there is a -- directly visible entry, then none of the potentially use-visible -- entities are directly visible (RM 8.4(10)). Second, we need to check -- for the case of multiple potentially use-visible entries hiding one -- another and as a result being non-directly visible (RM 8.4(11)). <<Potentially_Use_Visible_Entity>> declare Only_One_Visible : Boolean := True; All_Overloadable : Boolean := Is_Overloadable (E); begin E2 := Homonym (E); while Present (E2) loop if Is_Immediately_Visible (E2) then -- If the use-visible entity comes from the actual for a -- formal package, it hides a directly visible entity from -- outside the instance. if From_Actual_Package (E) and then Scope_Depth (E2) < Scope_Depth (Inst) then goto Found; else E := E2; goto Immediately_Visible_Entity; end if; elsif Is_Potentially_Use_Visible (E2) then Only_One_Visible := False; All_Overloadable := All_Overloadable and Is_Overloadable (E2); -- Ada 2005 (AI-262): Protect against a form of Beaujolais effect -- that can occur in private_with clauses. Example: -- with A; -- private with B; package A is -- package C is function B return Integer; -- use A; end A; -- V1 : Integer := B; -- private function B return Integer; -- V2 : Integer := B; -- end C; -- V1 resolves to A.B, but V2 resolves to library unit B elsif Ekind (E2) = E_Function and then Scope (E2) = Standard_Standard and then Has_Private_With (E2) then Only_One_Visible := False; All_Overloadable := False; Nvis_Is_Private_Subprg := True; exit; end if; E2 := Homonym (E2); end loop; -- On falling through this loop, we have checked that there are no -- immediately visible entities. Only_One_Visible is set if exactly -- one potentially use visible entity exists. All_Overloadable is -- set if all the potentially use visible entities are overloadable. -- The condition for legality is that either there is one potentially -- use visible entity, or if there is more than one, then all of them -- are overloadable. if Only_One_Visible or All_Overloadable then goto Found; -- If there is more than one potentially use-visible entity and at -- least one of them non-overloadable, we have an error (RM 8.4(11)). -- Note that E points to the first such entity on the homonym list. -- Special case: if one of the entities is declared in an actual -- package, it was visible in the generic, and takes precedence over -- other entities that are potentially use-visible. Same if it is -- declared in a local instantiation of the current instance. else if In_Instance then -- Find current instance Inst := Current_Scope; while Present (Inst) and then Inst /= Standard_Standard loop if Is_Generic_Instance (Inst) then exit; end if; Inst := Scope (Inst); end loop; E2 := E; while Present (E2) loop if From_Actual_Package (E2) or else (Is_Generic_Instance (Scope (E2)) and then Scope_Depth (Scope (E2)) > Scope_Depth (Inst)) then E := E2; goto Found; end if; E2 := Homonym (E2); end loop; Nvis_Messages; goto Done; elsif Is_Predefined_File_Name (Unit_File_Name (Current_Sem_Unit)) then -- A use-clause in the body of a system file creates conflict -- with some entity in a user scope, while rtsfind is active. -- Keep only the entity coming from another predefined unit. E2 := E; while Present (E2) loop if Is_Predefined_File_Name (Unit_File_Name (Get_Source_Unit (Sloc (E2)))) then E := E2; goto Found; end if; E2 := Homonym (E2); end loop; -- Entity must exist because predefined unit is correct raise Program_Error; else Nvis_Messages; goto Done; end if; end if; end; -- Come here with E set to the first immediately visible entity on -- the homonym chain. This is the one we want unless there is another -- immediately visible entity further on in the chain for an inner -- scope (RM 8.3(8)). <<Immediately_Visible_Entity>> declare Level : Int; Scop : Entity_Id; begin -- Find scope level of initial entity. When compiling through -- Rtsfind, the previous context is not completely invisible, and -- an outer entity may appear on the chain, whose scope is below -- the entry for Standard that delimits the current scope stack. -- Indicate that the level for this spurious entry is outside of -- the current scope stack. Level := Scope_Stack.Last; loop Scop := Scope_Stack.Table (Level).Entity; exit when Scop = Scope (E); Level := Level - 1; exit when Scop = Standard_Standard; end loop; -- Now search remainder of homonym chain for more inner entry -- If the entity is Standard itself, it has no scope, and we -- compare it with the stack entry directly. E2 := Homonym (E); while Present (E2) loop if Is_Immediately_Visible (E2) then -- If a generic package contains a local declaration that -- has the same name as the generic, there may be a visibility -- conflict in an instance, where the local declaration must -- also hide the name of the corresponding package renaming. -- We check explicitly for a package declared by a renaming, -- whose renamed entity is an instance that is on the scope -- stack, and that contains a homonym in the same scope. Once -- we have found it, we know that the package renaming is not -- immediately visible, and that the identifier denotes the -- other entity (and its homonyms if overloaded). if Scope (E) = Scope (E2) and then Ekind (E) = E_Package and then Present (Renamed_Object (E)) and then Is_Generic_Instance (Renamed_Object (E)) and then In_Open_Scopes (Renamed_Object (E)) and then Comes_From_Source (N) then Set_Is_Immediately_Visible (E, False); E := E2; else for J in Level + 1 .. Scope_Stack.Last loop if Scope_Stack.Table (J).Entity = Scope (E2) or else Scope_Stack.Table (J).Entity = E2 then Level := J; E := E2; exit; end if; end loop; end if; end if; E2 := Homonym (E2); end loop; -- At the end of that loop, E is the innermost immediately -- visible entity, so we are all set. end; -- Come here with entity found, and stored in E <<Found>> begin -- Check violation of No_Wide_Characters restriction Check_Wide_Character_Restriction (E, N); -- When distribution features are available (Get_PCS_Name /= -- Name_No_DSA), a remote access-to-subprogram type is converted -- into a record type holding whatever information is needed to -- perform a remote call on an RCI subprogram. In that case we -- rewrite any occurrence of the RAS type into the equivalent record -- type here. 'Access attribute references and RAS dereferences are -- then implemented using specific TSSs. However when distribution is -- not available (case of Get_PCS_Name = Name_No_DSA), we bypass the -- generation of these TSSs, and we must keep the RAS type in its -- original access-to-subprogram form (since all calls through a -- value of such type will be local anyway in the absence of a PCS). if Comes_From_Source (N) and then Is_Remote_Access_To_Subprogram_Type (E) and then Ekind (E) = E_Access_Subprogram_Type and then Expander_Active and then Get_PCS_Name /= Name_No_DSA then Rewrite (N, New_Occurrence_Of (Equivalent_Type (E), Sloc (N))); goto Done; end if; -- Set the entity. Note that the reason we call Set_Entity for the -- overloadable case, as opposed to Set_Entity_With_Checks is -- that in the overloaded case, the initial call can set the wrong -- homonym. The call that sets the right homonym is in Sem_Res and -- that call does use Set_Entity_With_Checks, so we don't miss -- a style check. if Is_Overloadable (E) then Set_Entity (N, E); else Set_Entity_With_Checks (N, E); end if; if Is_Type (E) then Set_Etype (N, E); else Set_Etype (N, Get_Full_View (Etype (E))); end if; if Debug_Flag_E then Write_Str (" found "); Write_Entity_Info (E, " "); end if; -- If the Ekind of the entity is Void, it means that all homonyms -- are hidden from all visibility (RM 8.3(5,14-20)). However, this -- test is skipped if the current scope is a record and the name is -- a pragma argument expression (case of Atomic and Volatile pragmas -- and possibly other similar pragmas added later, which are allowed -- to reference components in the current record). if Ekind (E) = E_Void and then (not Is_Record_Type (Current_Scope) or else Nkind (Parent (N)) /= N_Pragma_Argument_Association) then Premature_Usage (N); -- If the entity is overloadable, collect all interpretations of the -- name for subsequent overload resolution. We optimize a bit here to -- do this only if we have an overloadable entity that is not on its -- own on the homonym chain. elsif Is_Overloadable (E) and then (Present (Homonym (E)) or else Current_Entity (N) /= E) then Collect_Interps (N); -- If no homonyms were visible, the entity is unambiguous if not Is_Overloaded (N) then if not Is_Actual_Parameter then Generate_Reference (E, N); end if; end if; -- Case of non-overloadable entity, set the entity providing that -- we do not have the case of a discriminant reference within a -- default expression. Such references are replaced with the -- corresponding discriminal, which is the formal corresponding to -- to the discriminant in the initialization procedure. else -- Entity is unambiguous, indicate that it is referenced here -- For a renaming of an object, always generate simple reference, -- we don't try to keep track of assignments in this case, except -- in SPARK mode where renamings are traversed for generating -- local effects of subprograms. if Is_Object (E) and then Present (Renamed_Object (E)) and then not GNATprove_Mode then Generate_Reference (E, N); -- If the renamed entity is a private protected component, -- reference the original component as well. This needs to be -- done because the private renamings are installed before any -- analysis has occurred. Reference to a private component will -- resolve to the renaming and the original component will be -- left unreferenced, hence the following. if Is_Prival (E) then Generate_Reference (Prival_Link (E), N); end if; -- One odd case is that we do not want to set the Referenced flag -- if the entity is a label, and the identifier is the label in -- the source, since this is not a reference from the point of -- view of the user. elsif Nkind (Parent (N)) = N_Label then declare R : constant Boolean := Referenced (E); begin -- Generate reference unless this is an actual parameter -- (see comment below) if Is_Actual_Parameter then Generate_Reference (E, N); Set_Referenced (E, R); end if; end; -- Normal case, not a label: generate reference else if not Is_Actual_Parameter then -- Package or generic package is always a simple reference if Ekind_In (E, E_Package, E_Generic_Package) then Generate_Reference (E, N, 'r'); -- Else see if we have a left hand side else case Is_LHS (N) is when Yes => Generate_Reference (E, N, 'm'); when No => Generate_Reference (E, N, 'r'); -- If we don't know now, generate reference later when Unknown => Deferred_References.Append ((E, N)); end case; end if; end if; end if; Set_Entity_Or_Discriminal (N, E); -- The name may designate a generalized reference, in which case -- the dereference interpretation will be included. Context is -- one in which a name is legal. if Ada_Version >= Ada_2012 and then (Nkind (Parent (N)) in N_Subexpr or else Nkind_In (Parent (N), N_Assignment_Statement, N_Object_Declaration, N_Parameter_Association)) then Check_Implicit_Dereference (N, Etype (E)); end if; end if; end; -- Come here with entity set <<Done>> Check_Restriction_No_Use_Of_Entity (N); end Find_Direct_Name; ------------------------ -- Find_Expanded_Name -- ------------------------ -- This routine searches the homonym chain of the entity until it finds -- an entity declared in the scope denoted by the prefix. If the entity -- is private, it may nevertheless be immediately visible, if we are in -- the scope of its declaration. procedure Find_Expanded_Name (N : Node_Id) is function In_Abstract_View_Pragma (Nod : Node_Id) return Boolean; -- Determine whether expanded name Nod appears within a pragma which is -- a suitable context for an abstract view of a state or variable. The -- following pragmas fall in this category: -- Depends -- Global -- Initializes -- Refined_Depends -- Refined_Global -- -- In addition, pragma Abstract_State is also considered suitable even -- though it is an illegal context for an abstract view as this allows -- for proper resolution of abstract views of variables. This illegal -- context is later flagged in the analysis of indicator Part_Of. ----------------------------- -- In_Abstract_View_Pragma -- ----------------------------- function In_Abstract_View_Pragma (Nod : Node_Id) return Boolean is Par : Node_Id; begin -- Climb the parent chain looking for a pragma Par := Nod; while Present (Par) loop if Nkind (Par) = N_Pragma then if Nam_In (Pragma_Name_Unmapped (Par), Name_Abstract_State, Name_Depends, Name_Global, Name_Initializes, Name_Refined_Depends, Name_Refined_Global) then return True; -- Otherwise the pragma is not a legal context for an abstract -- view. else exit; end if; -- Prevent the search from going too far elsif Is_Body_Or_Package_Declaration (Par) then exit; end if; Par := Parent (Par); end loop; return False; end In_Abstract_View_Pragma; -- Local variables Selector : constant Node_Id := Selector_Name (N); Candidate : Entity_Id := Empty; P_Name : Entity_Id; Id : Entity_Id; -- Start of processing for Find_Expanded_Name begin P_Name := Entity (Prefix (N)); -- If the prefix is a renamed package, look for the entity in the -- original package. if Ekind (P_Name) = E_Package and then Present (Renamed_Object (P_Name)) then P_Name := Renamed_Object (P_Name); -- Rewrite node with entity field pointing to renamed object Rewrite (Prefix (N), New_Copy (Prefix (N))); Set_Entity (Prefix (N), P_Name); -- If the prefix is an object of a concurrent type, look for -- the entity in the associated task or protected type. elsif Is_Concurrent_Type (Etype (P_Name)) then P_Name := Etype (P_Name); end if; Id := Current_Entity (Selector); declare Is_New_Candidate : Boolean; begin while Present (Id) loop if Scope (Id) = P_Name then Candidate := Id; Is_New_Candidate := True; -- Handle abstract views of states and variables. These are -- acceptable candidates only when the reference to the view -- appears in certain pragmas. if Ekind (Id) = E_Abstract_State and then From_Limited_With (Id) and then Present (Non_Limited_View (Id)) then if In_Abstract_View_Pragma (N) then Candidate := Non_Limited_View (Id); Is_New_Candidate := True; -- Hide the candidate because it is not used in a proper -- context. else Candidate := Empty; Is_New_Candidate := False; end if; end if; -- Ada 2005 (AI-217): Handle shadow entities associated with -- types declared in limited-withed nested packages. We don't need -- to handle E_Incomplete_Subtype entities because the entities -- in the limited view are always E_Incomplete_Type and -- E_Class_Wide_Type entities (see Build_Limited_Views). -- Regarding the expression used to evaluate the scope, it -- is important to note that the limited view also has shadow -- entities associated nested packages. For this reason the -- correct scope of the entity is the scope of the real entity. -- The non-limited view may itself be incomplete, in which case -- get the full view if available. elsif Ekind_In (Id, E_Incomplete_Type, E_Class_Wide_Type) and then From_Limited_With (Id) and then Present (Non_Limited_View (Id)) and then Scope (Non_Limited_View (Id)) = P_Name then Candidate := Get_Full_View (Non_Limited_View (Id)); Is_New_Candidate := True; else Is_New_Candidate := False; end if; if Is_New_Candidate then -- If entity is a child unit, either it is a visible child of -- the prefix, or we are in the body of a generic prefix, as -- will happen when a child unit is instantiated in the body -- of a generic parent. This is because the instance body does -- not restore the full compilation context, given that all -- non-local references have been captured. if Is_Child_Unit (Id) or else P_Name = Standard_Standard then exit when Is_Visible_Lib_Unit (Id) or else (Is_Child_Unit (Id) and then In_Open_Scopes (Scope (Id)) and then In_Instance_Body); else exit when not Is_Hidden (Id); end if; exit when Is_Immediately_Visible (Id); end if; Id := Homonym (Id); end loop; end; if No (Id) and then Ekind_In (P_Name, E_Procedure, E_Function) and then Is_Generic_Instance (P_Name) then -- Expanded name denotes entity in (instance of) generic subprogram. -- The entity may be in the subprogram instance, or may denote one of -- the formals, which is declared in the enclosing wrapper package. P_Name := Scope (P_Name); Id := Current_Entity (Selector); while Present (Id) loop exit when Scope (Id) = P_Name; Id := Homonym (Id); end loop; end if; if No (Id) or else Chars (Id) /= Chars (Selector) then Set_Etype (N, Any_Type); -- If we are looking for an entity defined in System, try to find it -- in the child package that may have been provided as an extension -- to System. The Extend_System pragma will have supplied the name of -- the extension, which may have to be loaded. if Chars (P_Name) = Name_System and then Scope (P_Name) = Standard_Standard and then Present (System_Extend_Unit) and then Present_System_Aux (N) then Set_Entity (Prefix (N), System_Aux_Id); Find_Expanded_Name (N); return; -- There is an implicit instance of the predefined operator in -- the given scope. The operator entity is defined in Standard. -- Has_Implicit_Operator makes the node into an Expanded_Name. elsif Nkind (Selector) = N_Operator_Symbol and then Has_Implicit_Operator (N) then return; -- If there is no literal defined in the scope denoted by the -- prefix, the literal may belong to (a type derived from) -- Standard_Character, for which we have no explicit literals. elsif Nkind (Selector) = N_Character_Literal and then Has_Implicit_Character_Literal (N) then return; else -- If the prefix is a single concurrent object, use its name in -- the error message, rather than that of the anonymous type. if Is_Concurrent_Type (P_Name) and then Is_Internal_Name (Chars (P_Name)) then Error_Msg_Node_2 := Entity (Prefix (N)); else Error_Msg_Node_2 := P_Name; end if; if P_Name = System_Aux_Id then P_Name := Scope (P_Name); Set_Entity (Prefix (N), P_Name); end if; if Present (Candidate) then -- If we know that the unit is a child unit we can give a more -- accurate error message. if Is_Child_Unit (Candidate) then -- If the candidate is a private child unit and we are in -- the visible part of a public unit, specialize the error -- message. There might be a private with_clause for it, -- but it is not currently active. if Is_Private_Descendant (Candidate) and then Ekind (Current_Scope) = E_Package and then not In_Private_Part (Current_Scope) and then not Is_Private_Descendant (Current_Scope) then Error_Msg_N ("private child unit& is not visible here", Selector); -- Normal case where we have a missing with for a child unit else Error_Msg_Qual_Level := 99; Error_Msg_NE -- CODEFIX ("missing `WITH &;`", Selector, Candidate); Error_Msg_Qual_Level := 0; end if; -- Here we don't know that this is a child unit else Error_Msg_NE ("& is not a visible entity of&", N, Selector); end if; else -- Within the instantiation of a child unit, the prefix may -- denote the parent instance, but the selector has the name -- of the original child. That is to say, when A.B appears -- within an instantiation of generic child unit B, the scope -- stack includes an instance of A (P_Name) and an instance -- of B under some other name. We scan the scope to find this -- child instance, which is the desired entity. -- Note that the parent may itself be a child instance, if -- the reference is of the form A.B.C, in which case A.B has -- already been rewritten with the proper entity. if In_Open_Scopes (P_Name) and then Is_Generic_Instance (P_Name) then declare Gen_Par : constant Entity_Id := Generic_Parent (Specification (Unit_Declaration_Node (P_Name))); S : Entity_Id := Current_Scope; P : Entity_Id; begin for J in reverse 0 .. Scope_Stack.Last loop S := Scope_Stack.Table (J).Entity; exit when S = Standard_Standard; if Ekind_In (S, E_Function, E_Package, E_Procedure) then P := Generic_Parent (Specification (Unit_Declaration_Node (S))); -- Check that P is a generic child of the generic -- parent of the prefix. if Present (P) and then Chars (P) = Chars (Selector) and then Scope (P) = Gen_Par then Id := S; goto Found; end if; end if; end loop; end; end if; -- If this is a selection from Ada, System or Interfaces, then -- we assume a missing with for the corresponding package. if Is_Known_Unit (N) then if not Error_Posted (N) then Error_Msg_Node_2 := Selector; Error_Msg_N -- CODEFIX ("missing `WITH &.&;`", Prefix (N)); end if; -- If this is a selection from a dummy package, then suppress -- the error message, of course the entity is missing if the -- package is missing. elsif Sloc (Error_Msg_Node_2) = No_Location then null; -- Here we have the case of an undefined component else -- The prefix may hide a homonym in the context that -- declares the desired entity. This error can use a -- specialized message. if In_Open_Scopes (P_Name) then declare H : constant Entity_Id := Homonym (P_Name); begin if Present (H) and then Is_Compilation_Unit (H) and then (Is_Immediately_Visible (H) or else Is_Visible_Lib_Unit (H)) then Id := First_Entity (H); while Present (Id) loop if Chars (Id) = Chars (Selector) then Error_Msg_Qual_Level := 99; Error_Msg_Name_1 := Chars (Selector); Error_Msg_NE ("% not declared in&", N, P_Name); Error_Msg_NE ("\use fully qualified name starting with " & "Standard to make& visible", N, H); Error_Msg_Qual_Level := 0; goto Done; end if; Next_Entity (Id); end loop; end if; -- If not found, standard error message Error_Msg_NE ("& not declared in&", N, Selector); <<Done>> null; end; else Error_Msg_NE ("& not declared in&", N, Selector); end if; -- Check for misspelling of some entity in prefix Id := First_Entity (P_Name); while Present (Id) loop if Is_Bad_Spelling_Of (Chars (Id), Chars (Selector)) and then not Is_Internal_Name (Chars (Id)) then Error_Msg_NE -- CODEFIX ("possible misspelling of&", Selector, Id); exit; end if; Next_Entity (Id); end loop; -- Specialize the message if this may be an instantiation -- of a child unit that was not mentioned in the context. if Nkind (Parent (N)) = N_Package_Instantiation and then Is_Generic_Instance (Entity (Prefix (N))) and then Is_Compilation_Unit (Generic_Parent (Parent (Entity (Prefix (N))))) then Error_Msg_Node_2 := Selector; Error_Msg_N -- CODEFIX ("\missing `WITH &.&;`", Prefix (N)); end if; end if; end if; Id := Any_Id; end if; end if; <<Found>> if Comes_From_Source (N) and then Is_Remote_Access_To_Subprogram_Type (Id) and then Ekind (Id) = E_Access_Subprogram_Type and then Present (Equivalent_Type (Id)) then -- If we are not actually generating distribution code (i.e. the -- current PCS is the dummy non-distributed version), then the -- Equivalent_Type will be missing, and Id should be treated as -- a regular access-to-subprogram type. Id := Equivalent_Type (Id); Set_Chars (Selector, Chars (Id)); end if; -- Ada 2005 (AI-50217): Check usage of entities in limited withed units if Ekind (P_Name) = E_Package and then From_Limited_With (P_Name) then if From_Limited_With (Id) or else Is_Type (Id) or else Ekind (Id) = E_Package then null; else Error_Msg_N ("limited withed package can only be used to access incomplete " & "types", N); end if; end if; if Is_Task_Type (P_Name) and then ((Ekind (Id) = E_Entry and then Nkind (Parent (N)) /= N_Attribute_Reference) or else (Ekind (Id) = E_Entry_Family and then Nkind (Parent (Parent (N))) /= N_Attribute_Reference)) then -- If both the task type and the entry are in scope, this may still -- be the expanded name of an entry formal. if In_Open_Scopes (Id) and then Nkind (Parent (N)) = N_Selected_Component then null; else -- It is an entry call after all, either to the current task -- (which will deadlock) or to an enclosing task. Analyze_Selected_Component (N); return; end if; end if; Change_Selected_Component_To_Expanded_Name (N); -- Set appropriate type if Is_Type (Id) then Set_Etype (N, Id); else Set_Etype (N, Get_Full_View (Etype (Id))); end if; -- Do style check and generate reference, but skip both steps if this -- entity has homonyms, since we may not have the right homonym set yet. -- The proper homonym will be set during the resolve phase. if Has_Homonym (Id) then Set_Entity (N, Id); else Set_Entity_Or_Discriminal (N, Id); case Is_LHS (N) is when Yes => Generate_Reference (Id, N, 'm'); when No => Generate_Reference (Id, N, 'r'); when Unknown => Deferred_References.Append ((Id, N)); end case; end if; -- Check for violation of No_Wide_Characters Check_Wide_Character_Restriction (Id, N); -- If the Ekind of the entity is Void, it means that all homonyms are -- hidden from all visibility (RM 8.3(5,14-20)). if Ekind (Id) = E_Void then Premature_Usage (N); elsif Is_Overloadable (Id) and then Present (Homonym (Id)) then declare H : Entity_Id := Homonym (Id); begin while Present (H) loop if Scope (H) = Scope (Id) and then (not Is_Hidden (H) or else Is_Immediately_Visible (H)) then Collect_Interps (N); exit; end if; H := Homonym (H); end loop; -- If an extension of System is present, collect possible explicit -- overloadings declared in the extension. if Chars (P_Name) = Name_System and then Scope (P_Name) = Standard_Standard and then Present (System_Extend_Unit) and then Present_System_Aux (N) then H := Current_Entity (Id); while Present (H) loop if Scope (H) = System_Aux_Id then Add_One_Interp (N, H, Etype (H)); end if; H := Homonym (H); end loop; end if; end; end if; if Nkind (Selector_Name (N)) = N_Operator_Symbol and then Scope (Id) /= Standard_Standard then -- In addition to user-defined operators in the given scope, there -- may be an implicit instance of the predefined operator. The -- operator (defined in Standard) is found in Has_Implicit_Operator, -- and added to the interpretations. Procedure Add_One_Interp will -- determine which hides which. if Has_Implicit_Operator (N) then null; end if; end if; -- If there is a single interpretation for N we can generate a -- reference to the unique entity found. if Is_Overloadable (Id) and then not Is_Overloaded (N) then Generate_Reference (Id, N); end if; Check_Restriction_No_Use_Of_Entity (N); end Find_Expanded_Name; ------------------------- -- Find_Renamed_Entity -- ------------------------- function Find_Renamed_Entity (N : Node_Id; Nam : Node_Id; New_S : Entity_Id; Is_Actual : Boolean := False) return Entity_Id is Ind : Interp_Index; I1 : Interp_Index := 0; -- Suppress junk warnings It : Interp; It1 : Interp; Old_S : Entity_Id; Inst : Entity_Id; function Is_Visible_Operation (Op : Entity_Id) return Boolean; -- If the renamed entity is an implicit operator, check whether it is -- visible because its operand type is properly visible. This check -- applies to explicit renamed entities that appear in the source in a -- renaming declaration or a formal subprogram instance, but not to -- default generic actuals with a name. function Report_Overload return Entity_Id; -- List possible interpretations, and specialize message in the -- case of a generic actual. function Within (Inner, Outer : Entity_Id) return Boolean; -- Determine whether a candidate subprogram is defined within the -- enclosing instance. If yes, it has precedence over outer candidates. -------------------------- -- Is_Visible_Operation -- -------------------------- function Is_Visible_Operation (Op : Entity_Id) return Boolean is Scop : Entity_Id; Typ : Entity_Id; Btyp : Entity_Id; begin if Ekind (Op) /= E_Operator or else Scope (Op) /= Standard_Standard or else (In_Instance and then (not Is_Actual or else Present (Enclosing_Instance))) then return True; else -- For a fixed point type operator, check the resulting type, -- because it may be a mixed mode integer * fixed operation. if Present (Next_Formal (First_Formal (New_S))) and then Is_Fixed_Point_Type (Etype (New_S)) then Typ := Etype (New_S); else Typ := Etype (First_Formal (New_S)); end if; Btyp := Base_Type (Typ); if Nkind (Nam) /= N_Expanded_Name then return (In_Open_Scopes (Scope (Btyp)) or else Is_Potentially_Use_Visible (Btyp) or else In_Use (Btyp) or else In_Use (Scope (Btyp))); else Scop := Entity (Prefix (Nam)); if Ekind (Scop) = E_Package and then Present (Renamed_Object (Scop)) then Scop := Renamed_Object (Scop); end if; -- Operator is visible if prefix of expanded name denotes -- scope of type, or else type is defined in System_Aux -- and the prefix denotes System. return Scope (Btyp) = Scop or else (Scope (Btyp) = System_Aux_Id and then Scope (Scope (Btyp)) = Scop); end if; end if; end Is_Visible_Operation; ------------ -- Within -- ------------ function Within (Inner, Outer : Entity_Id) return Boolean is Sc : Entity_Id; begin Sc := Scope (Inner); while Sc /= Standard_Standard loop if Sc = Outer then return True; else Sc := Scope (Sc); end if; end loop; return False; end Within; --------------------- -- Report_Overload -- --------------------- function Report_Overload return Entity_Id is begin if Is_Actual then Error_Msg_NE -- CODEFIX ("ambiguous actual subprogram&, " & "possible interpretations:", N, Nam); else Error_Msg_N -- CODEFIX ("ambiguous subprogram, " & "possible interpretations:", N); end if; List_Interps (Nam, N); return Old_S; end Report_Overload; -- Start of processing for Find_Renamed_Entity begin Old_S := Any_Id; Candidate_Renaming := Empty; if Is_Overloaded (Nam) then Get_First_Interp (Nam, Ind, It); while Present (It.Nam) loop if Entity_Matches_Spec (It.Nam, New_S) and then Is_Visible_Operation (It.Nam) then if Old_S /= Any_Id then -- Note: The call to Disambiguate only happens if a -- previous interpretation was found, in which case I1 -- has received a value. It1 := Disambiguate (Nam, I1, Ind, Etype (Old_S)); if It1 = No_Interp then Inst := Enclosing_Instance; if Present (Inst) then if Within (It.Nam, Inst) then if Within (Old_S, Inst) then -- Choose the innermost subprogram, which would -- have hidden the outer one in the generic. if Scope_Depth (It.Nam) < Scope_Depth (Old_S) then return Old_S; else return It.Nam; end if; end if; elsif Within (Old_S, Inst) then return (Old_S); else return Report_Overload; end if; -- If not within an instance, ambiguity is real else return Report_Overload; end if; else Old_S := It1.Nam; exit; end if; else I1 := Ind; Old_S := It.Nam; end if; elsif Present (First_Formal (It.Nam)) and then Present (First_Formal (New_S)) and then (Base_Type (Etype (First_Formal (It.Nam))) = Base_Type (Etype (First_Formal (New_S)))) then Candidate_Renaming := It.Nam; end if; Get_Next_Interp (Ind, It); end loop; Set_Entity (Nam, Old_S); if Old_S /= Any_Id then Set_Is_Overloaded (Nam, False); end if; -- Non-overloaded case else if Is_Actual and then Present (Enclosing_Instance) and then Entity_Matches_Spec (Entity (Nam), New_S) then Old_S := Entity (Nam); elsif Entity_Matches_Spec (Entity (Nam), New_S) then Candidate_Renaming := New_S; if Is_Visible_Operation (Entity (Nam)) then Old_S := Entity (Nam); end if; elsif Present (First_Formal (Entity (Nam))) and then Present (First_Formal (New_S)) and then (Base_Type (Etype (First_Formal (Entity (Nam)))) = Base_Type (Etype (First_Formal (New_S)))) then Candidate_Renaming := Entity (Nam); end if; end if; return Old_S; end Find_Renamed_Entity; ----------------------------- -- Find_Selected_Component -- ----------------------------- procedure Find_Selected_Component (N : Node_Id) is P : constant Node_Id := Prefix (N); P_Name : Entity_Id; -- Entity denoted by prefix P_Type : Entity_Id; -- and its type Nam : Node_Id; function Available_Subtype return Boolean; -- A small optimization: if the prefix is constrained and the component -- is an array type we may already have a usable subtype for it, so we -- can use it rather than generating a new one, because the bounds -- will be the values of the discriminants and not discriminant refs. -- This simplifies value tracing in GNATProve. For consistency, both -- the entity name and the subtype come from the constrained component. -- This is only used in GNATProve mode: when generating code it may be -- necessary to create an itype in the scope of use of the selected -- component, e.g. in the context of a expanded record equality. function Is_Reference_In_Subunit return Boolean; -- In a subunit, the scope depth is not a proper measure of hiding, -- because the context of the proper body may itself hide entities in -- parent units. This rare case requires inspecting the tree directly -- because the proper body is inserted in the main unit and its context -- is simply added to that of the parent. ----------------------- -- Available_Subtype -- ----------------------- function Available_Subtype return Boolean is Comp : Entity_Id; begin if GNATprove_Mode then Comp := First_Entity (Etype (P)); while Present (Comp) loop if Chars (Comp) = Chars (Selector_Name (N)) then Set_Etype (N, Etype (Comp)); Set_Entity (Selector_Name (N), Comp); Set_Etype (Selector_Name (N), Etype (Comp)); return True; end if; Next_Component (Comp); end loop; end if; return False; end Available_Subtype; ----------------------------- -- Is_Reference_In_Subunit -- ----------------------------- function Is_Reference_In_Subunit return Boolean is Clause : Node_Id; Comp_Unit : Node_Id; begin Comp_Unit := N; while Present (Comp_Unit) and then Nkind (Comp_Unit) /= N_Compilation_Unit loop Comp_Unit := Parent (Comp_Unit); end loop; if No (Comp_Unit) or else Nkind (Unit (Comp_Unit)) /= N_Subunit then return False; end if; -- Now check whether the package is in the context of the subunit Clause := First (Context_Items (Comp_Unit)); while Present (Clause) loop if Nkind (Clause) = N_With_Clause and then Entity (Name (Clause)) = P_Name then return True; end if; Clause := Next (Clause); end loop; return False; end Is_Reference_In_Subunit; -- Start of processing for Find_Selected_Component begin Analyze (P); if Nkind (P) = N_Error then return; end if; -- Selector name cannot be a character literal or an operator symbol in -- SPARK, except for the operator symbol in a renaming. if Restriction_Check_Required (SPARK_05) then if Nkind (Selector_Name (N)) = N_Character_Literal then Check_SPARK_05_Restriction ("character literal cannot be prefixed", N); elsif Nkind (Selector_Name (N)) = N_Operator_Symbol and then Nkind (Parent (N)) /= N_Subprogram_Renaming_Declaration then Check_SPARK_05_Restriction ("operator symbol cannot be prefixed", N); end if; end if; -- If the selector already has an entity, the node has been constructed -- in the course of expansion, and is known to be valid. Do not verify -- that it is defined for the type (it may be a private component used -- in the expansion of record equality). if Present (Entity (Selector_Name (N))) then if No (Etype (N)) or else Etype (N) = Any_Type then declare Sel_Name : constant Node_Id := Selector_Name (N); Selector : constant Entity_Id := Entity (Sel_Name); C_Etype : Node_Id; begin Set_Etype (Sel_Name, Etype (Selector)); if not Is_Entity_Name (P) then Resolve (P); end if; -- Build an actual subtype except for the first parameter -- of an init proc, where this actual subtype is by -- definition incorrect, since the object is uninitialized -- (and does not even have defined discriminants etc.) if Is_Entity_Name (P) and then Ekind (Entity (P)) = E_Function then Nam := New_Copy (P); if Is_Overloaded (P) then Save_Interps (P, Nam); end if; Rewrite (P, Make_Function_Call (Sloc (P), Name => Nam)); Analyze_Call (P); Analyze_Selected_Component (N); return; elsif Ekind (Selector) = E_Component and then (not Is_Entity_Name (P) or else Chars (Entity (P)) /= Name_uInit) then -- Check if we already have an available subtype we can use if Ekind (Etype (P)) = E_Record_Subtype and then Nkind (Parent (Etype (P))) = N_Subtype_Declaration and then Is_Array_Type (Etype (Selector)) and then not Is_Packed (Etype (Selector)) and then Available_Subtype then return; -- Do not build the subtype when referencing components of -- dispatch table wrappers. Required to avoid generating -- elaboration code with HI runtimes. elsif RTU_Loaded (Ada_Tags) and then ((RTE_Available (RE_Dispatch_Table_Wrapper) and then Scope (Selector) = RTE (RE_Dispatch_Table_Wrapper)) or else (RTE_Available (RE_No_Dispatch_Table_Wrapper) and then Scope (Selector) = RTE (RE_No_Dispatch_Table_Wrapper))) then C_Etype := Empty; else C_Etype := Build_Actual_Subtype_Of_Component (Etype (Selector), N); end if; else C_Etype := Empty; end if; if No (C_Etype) then C_Etype := Etype (Selector); else Insert_Action (N, C_Etype); C_Etype := Defining_Identifier (C_Etype); end if; Set_Etype (N, C_Etype); end; -- If this is the name of an entry or protected operation, and -- the prefix is an access type, insert an explicit dereference, -- so that entry calls are treated uniformly. if Is_Access_Type (Etype (P)) and then Is_Concurrent_Type (Designated_Type (Etype (P))) then declare New_P : constant Node_Id := Make_Explicit_Dereference (Sloc (P), Prefix => Relocate_Node (P)); begin Rewrite (P, New_P); Set_Etype (P, Designated_Type (Etype (Prefix (P)))); end; end if; -- If the selected component appears within a default expression -- and it has an actual subtype, the pre-analysis has not yet -- completed its analysis, because Insert_Actions is disabled in -- that context. Within the init proc of the enclosing type we -- must complete this analysis, if an actual subtype was created. elsif Inside_Init_Proc then declare Typ : constant Entity_Id := Etype (N); Decl : constant Node_Id := Declaration_Node (Typ); begin if Nkind (Decl) = N_Subtype_Declaration and then not Analyzed (Decl) and then Is_List_Member (Decl) and then No (Parent (Decl)) then Remove (Decl); Insert_Action (N, Decl); end if; end; end if; return; elsif Is_Entity_Name (P) then P_Name := Entity (P); -- The prefix may denote an enclosing type which is the completion -- of an incomplete type declaration. if Is_Type (P_Name) then Set_Entity (P, Get_Full_View (P_Name)); Set_Etype (P, Entity (P)); P_Name := Entity (P); end if; P_Type := Base_Type (Etype (P)); if Debug_Flag_E then Write_Str ("Found prefix type to be "); Write_Entity_Info (P_Type, " "); Write_Eol; end if; -- The designated type may be a limited view with no components. -- Check whether the non-limited view is available, because in some -- cases this will not be set when installing the context. Rewrite -- the node by introducing an explicit dereference at once, and -- setting the type of the rewritten prefix to the non-limited view -- of the original designated type. if Is_Access_Type (P_Type) then declare Desig_Typ : constant Entity_Id := Directly_Designated_Type (P_Type); begin if Is_Incomplete_Type (Desig_Typ) and then From_Limited_With (Desig_Typ) and then Present (Non_Limited_View (Desig_Typ)) then Rewrite (P, Make_Explicit_Dereference (Sloc (P), Prefix => Relocate_Node (P))); Set_Etype (P, Get_Full_View (Non_Limited_View (Desig_Typ))); P_Type := Etype (P); end if; end; end if; -- First check for components of a record object (not the -- result of a call, which is handled below). if Is_Appropriate_For_Record (P_Type) and then not Is_Overloadable (P_Name) and then not Is_Type (P_Name) then -- Selected component of record. Type checking will validate -- name of selector. -- ??? Could we rewrite an implicit dereference into an explicit -- one here? Analyze_Selected_Component (N); -- Reference to type name in predicate/invariant expression elsif Is_Appropriate_For_Entry_Prefix (P_Type) and then not In_Open_Scopes (P_Name) and then (not Is_Concurrent_Type (Etype (P_Name)) or else not In_Open_Scopes (Etype (P_Name))) then -- Call to protected operation or entry. Type checking is -- needed on the prefix. Analyze_Selected_Component (N); elsif (In_Open_Scopes (P_Name) and then Ekind (P_Name) /= E_Void and then not Is_Overloadable (P_Name)) or else (Is_Concurrent_Type (Etype (P_Name)) and then In_Open_Scopes (Etype (P_Name))) then -- Prefix denotes an enclosing loop, block, or task, i.e. an -- enclosing construct that is not a subprogram or accept. -- A special case: a protected body may call an operation -- on an external object of the same type, in which case it -- is not an expanded name. If the prefix is the type itself, -- or the context is a single synchronized object it can only -- be interpreted as an expanded name. if Is_Concurrent_Type (Etype (P_Name)) then if Is_Type (P_Name) or else Present (Anonymous_Object (Etype (P_Name))) then Find_Expanded_Name (N); else Analyze_Selected_Component (N); return; end if; else Find_Expanded_Name (N); end if; elsif Ekind (P_Name) = E_Package then Find_Expanded_Name (N); elsif Is_Overloadable (P_Name) then -- The subprogram may be a renaming (of an enclosing scope) as -- in the case of the name of the generic within an instantiation. if Ekind_In (P_Name, E_Procedure, E_Function) and then Present (Alias (P_Name)) and then Is_Generic_Instance (Alias (P_Name)) then P_Name := Alias (P_Name); end if; if Is_Overloaded (P) then -- The prefix must resolve to a unique enclosing construct declare Found : Boolean := False; Ind : Interp_Index; It : Interp; begin Get_First_Interp (P, Ind, It); while Present (It.Nam) loop if In_Open_Scopes (It.Nam) then if Found then Error_Msg_N ( "prefix must be unique enclosing scope", N); Set_Entity (N, Any_Id); Set_Etype (N, Any_Type); return; else Found := True; P_Name := It.Nam; end if; end if; Get_Next_Interp (Ind, It); end loop; end; end if; if In_Open_Scopes (P_Name) then Set_Entity (P, P_Name); Set_Is_Overloaded (P, False); Find_Expanded_Name (N); else -- If no interpretation as an expanded name is possible, it -- must be a selected component of a record returned by a -- function call. Reformat prefix as a function call, the rest -- is done by type resolution. -- Error if the prefix is procedure or entry, as is P.X if Ekind (P_Name) /= E_Function and then (not Is_Overloaded (P) or else Nkind (Parent (N)) = N_Procedure_Call_Statement) then -- Prefix may mention a package that is hidden by a local -- declaration: let the user know. Scan the full homonym -- chain, the candidate package may be anywhere on it. if Present (Homonym (Current_Entity (P_Name))) then P_Name := Current_Entity (P_Name); while Present (P_Name) loop exit when Ekind (P_Name) = E_Package; P_Name := Homonym (P_Name); end loop; if Present (P_Name) then if not Is_Reference_In_Subunit then Error_Msg_Sloc := Sloc (Entity (Prefix (N))); Error_Msg_NE ("package& is hidden by declaration#", N, P_Name); end if; Set_Entity (Prefix (N), P_Name); Find_Expanded_Name (N); return; else P_Name := Entity (Prefix (N)); end if; end if; Error_Msg_NE ("invalid prefix in selected component&", N, P_Name); Change_Selected_Component_To_Expanded_Name (N); Set_Entity (N, Any_Id); Set_Etype (N, Any_Type); -- Here we have a function call, so do the reformatting else Nam := New_Copy (P); Save_Interps (P, Nam); -- We use Replace here because this is one of those cases -- where the parser has missclassified the node, and we fix -- things up and then do the semantic analysis on the fixed -- up node. Normally we do this using one of the Sinfo.CN -- routines, but this is too tricky for that. -- Note that using Rewrite would be wrong, because we would -- have a tree where the original node is unanalyzed, and -- this violates the required interface for ASIS. Replace (P, Make_Function_Call (Sloc (P), Name => Nam)); -- Now analyze the reformatted node Analyze_Call (P); -- If the prefix is illegal after this transformation, there -- may be visibility errors on the prefix. The safest is to -- treat the selected component as an error. if Error_Posted (P) then Set_Etype (N, Any_Type); return; else Analyze_Selected_Component (N); end if; end if; end if; -- Remaining cases generate various error messages else -- Format node as expanded name, to avoid cascaded errors -- If the limited_with transformation was applied earlier, restore -- source for proper error reporting. if not Comes_From_Source (P) and then Nkind (P) = N_Explicit_Dereference then Rewrite (P, Prefix (P)); P_Type := Etype (P); end if; Change_Selected_Component_To_Expanded_Name (N); Set_Entity (N, Any_Id); Set_Etype (N, Any_Type); -- Issue error message, but avoid this if error issued already. -- Use identifier of prefix if one is available. if P_Name = Any_Id then null; -- It is not an error if the prefix is the current instance of -- type name, e.g. the expression of a type aspect, when it is -- analyzed for ASIS use. elsif Is_Entity_Name (P) and then Is_Current_Instance (P) then null; elsif Ekind (P_Name) = E_Void then Premature_Usage (P); elsif Nkind (P) /= N_Attribute_Reference then -- This may have been meant as a prefixed call to a primitive -- of an untagged type. If it is a function call check type of -- its first formal and add explanation. declare F : constant Entity_Id := Current_Entity (Selector_Name (N)); begin if Present (F) and then Is_Overloadable (F) and then Present (First_Entity (F)) and then not Is_Tagged_Type (Etype (First_Entity (F))) then Error_Msg_N ("prefixed call is only allowed for objects of a " & "tagged type", N); end if; end; Error_Msg_N ("invalid prefix in selected component&", P); if Is_Access_Type (P_Type) and then Ekind (Designated_Type (P_Type)) = E_Incomplete_Type then Error_Msg_N ("\dereference must not be of an incomplete type " & "(RM 3.10.1)", P); end if; else Error_Msg_N ("invalid prefix in selected component", P); end if; end if; -- Selector name is restricted in SPARK if Nkind (N) = N_Expanded_Name and then Restriction_Check_Required (SPARK_05) then if Is_Subprogram (P_Name) then Check_SPARK_05_Restriction ("prefix of expanded name cannot be a subprogram", P); elsif Ekind (P_Name) = E_Loop then Check_SPARK_05_Restriction ("prefix of expanded name cannot be a loop statement", P); end if; end if; else -- If prefix is not the name of an entity, it must be an expression, -- whose type is appropriate for a record. This is determined by -- type resolution. Analyze_Selected_Component (N); end if; Analyze_Dimension (N); end Find_Selected_Component; --------------- -- Find_Type -- --------------- procedure Find_Type (N : Node_Id) is C : Entity_Id; Typ : Entity_Id; T : Entity_Id; T_Name : Entity_Id; begin if N = Error then return; elsif Nkind (N) = N_Attribute_Reference then -- Class attribute. This is not valid in Ada 83 mode, but we do not -- need to enforce that at this point, since the declaration of the -- tagged type in the prefix would have been flagged already. if Attribute_Name (N) = Name_Class then Check_Restriction (No_Dispatch, N); Find_Type (Prefix (N)); -- Propagate error from bad prefix if Etype (Prefix (N)) = Any_Type then Set_Entity (N, Any_Type); Set_Etype (N, Any_Type); return; end if; T := Base_Type (Entity (Prefix (N))); -- Case where type is not known to be tagged. Its appearance in -- the prefix of the 'Class attribute indicates that the full view -- will be tagged. if not Is_Tagged_Type (T) then if Ekind (T) = E_Incomplete_Type then -- It is legal to denote the class type of an incomplete -- type. The full type will have to be tagged, of course. -- In Ada 2005 this usage is declared obsolescent, so we -- warn accordingly. This usage is only legal if the type -- is completed in the current scope, and not for a limited -- view of a type. if Ada_Version >= Ada_2005 then -- Test whether the Available_View of a limited type view -- is tagged, since the limited view may not be marked as -- tagged if the type itself has an untagged incomplete -- type view in its package. if From_Limited_With (T) and then not Is_Tagged_Type (Available_View (T)) then Error_Msg_N ("prefix of Class attribute must be tagged", N); Set_Etype (N, Any_Type); Set_Entity (N, Any_Type); return; -- ??? This test is temporarily disabled (always -- False) because it causes an unwanted warning on -- GNAT sources (built with -gnatg, which includes -- Warn_On_Obsolescent_ Feature). Once this issue -- is cleared in the sources, it can be enabled. elsif Warn_On_Obsolescent_Feature and then False then Error_Msg_N ("applying 'Class to an untagged incomplete type" & " is an obsolescent feature (RM J.11)?r?", N); end if; end if; Set_Is_Tagged_Type (T); Set_Direct_Primitive_Operations (T, New_Elmt_List); Make_Class_Wide_Type (T); Set_Entity (N, Class_Wide_Type (T)); Set_Etype (N, Class_Wide_Type (T)); elsif Ekind (T) = E_Private_Type and then not Is_Generic_Type (T) and then In_Private_Part (Scope (T)) then -- The Class attribute can be applied to an untagged private -- type fulfilled by a tagged type prior to the full type -- declaration (but only within the parent package's private -- part). Create the class-wide type now and check that the -- full type is tagged later during its analysis. Note that -- we do not mark the private type as tagged, unlike the -- case of incomplete types, because the type must still -- appear untagged to outside units. if No (Class_Wide_Type (T)) then Make_Class_Wide_Type (T); end if; Set_Entity (N, Class_Wide_Type (T)); Set_Etype (N, Class_Wide_Type (T)); else -- Should we introduce a type Any_Tagged and use Wrong_Type -- here, it would be a bit more consistent??? Error_Msg_NE ("tagged type required, found}", Prefix (N), First_Subtype (T)); Set_Entity (N, Any_Type); return; end if; -- Case of tagged type else if Is_Concurrent_Type (T) then if No (Corresponding_Record_Type (Entity (Prefix (N)))) then -- Previous error. Use current type, which at least -- provides some operations. C := Entity (Prefix (N)); else C := Class_Wide_Type (Corresponding_Record_Type (Entity (Prefix (N)))); end if; else C := Class_Wide_Type (Entity (Prefix (N))); end if; Set_Entity_With_Checks (N, C); Generate_Reference (C, N); Set_Etype (N, C); end if; -- Base attribute, not allowed in Ada 83 elsif Attribute_Name (N) = Name_Base then Error_Msg_Name_1 := Name_Base; Check_SPARK_05_Restriction ("attribute% is only allowed as prefix of another attribute", N); if Ada_Version = Ada_83 and then Comes_From_Source (N) then Error_Msg_N ("(Ada 83) Base attribute not allowed in subtype mark", N); else Find_Type (Prefix (N)); Typ := Entity (Prefix (N)); if Ada_Version >= Ada_95 and then not Is_Scalar_Type (Typ) and then not Is_Generic_Type (Typ) then Error_Msg_N ("prefix of Base attribute must be scalar type", Prefix (N)); elsif Warn_On_Redundant_Constructs and then Base_Type (Typ) = Typ then Error_Msg_NE -- CODEFIX ("redundant attribute, & is its own base type?r?", N, Typ); end if; T := Base_Type (Typ); -- Rewrite attribute reference with type itself (see similar -- processing in Analyze_Attribute, case Base). Preserve prefix -- if present, for other legality checks. if Nkind (Prefix (N)) = N_Expanded_Name then Rewrite (N, Make_Expanded_Name (Sloc (N), Chars => Chars (T), Prefix => New_Copy (Prefix (Prefix (N))), Selector_Name => New_Occurrence_Of (T, Sloc (N)))); else Rewrite (N, New_Occurrence_Of (T, Sloc (N))); end if; Set_Entity (N, T); Set_Etype (N, T); end if; elsif Attribute_Name (N) = Name_Stub_Type then -- This is handled in Analyze_Attribute Analyze (N); -- All other attributes are invalid in a subtype mark else Error_Msg_N ("invalid attribute in subtype mark", N); end if; else Analyze (N); if Is_Entity_Name (N) then T_Name := Entity (N); else Error_Msg_N ("subtype mark required in this context", N); Set_Etype (N, Any_Type); return; end if; if T_Name = Any_Id or else Etype (N) = Any_Type then -- Undefined id. Make it into a valid type Set_Entity (N, Any_Type); elsif not Is_Type (T_Name) and then T_Name /= Standard_Void_Type then Error_Msg_Sloc := Sloc (T_Name); Error_Msg_N ("subtype mark required in this context", N); Error_Msg_NE ("\\found & declared#", N, T_Name); Set_Entity (N, Any_Type); else -- If the type is an incomplete type created to handle -- anonymous access components of a record type, then the -- incomplete type is the visible entity and subsequent -- references will point to it. Mark the original full -- type as referenced, to prevent spurious warnings. if Is_Incomplete_Type (T_Name) and then Present (Full_View (T_Name)) and then not Comes_From_Source (T_Name) then Set_Referenced (Full_View (T_Name)); end if; T_Name := Get_Full_View (T_Name); -- Ada 2005 (AI-251, AI-50217): Handle interfaces visible through -- limited-with clauses if From_Limited_With (T_Name) and then Ekind (T_Name) in Incomplete_Kind and then Present (Non_Limited_View (T_Name)) and then Is_Interface (Non_Limited_View (T_Name)) then T_Name := Non_Limited_View (T_Name); end if; if In_Open_Scopes (T_Name) then if Ekind (Base_Type (T_Name)) = E_Task_Type then -- In Ada 2005, a task name can be used in an access -- definition within its own body. It cannot be used -- in the discriminant part of the task declaration, -- nor anywhere else in the declaration because entries -- cannot have access parameters. if Ada_Version >= Ada_2005 and then Nkind (Parent (N)) = N_Access_Definition then Set_Entity (N, T_Name); Set_Etype (N, T_Name); if Has_Completion (T_Name) then return; else Error_Msg_N ("task type cannot be used as type mark " & "within its own declaration", N); end if; else Error_Msg_N ("task type cannot be used as type mark " & "within its own spec or body", N); end if; elsif Ekind (Base_Type (T_Name)) = E_Protected_Type then -- In Ada 2005, a protected name can be used in an access -- definition within its own body. if Ada_Version >= Ada_2005 and then Nkind (Parent (N)) = N_Access_Definition then Set_Entity (N, T_Name); Set_Etype (N, T_Name); return; else Error_Msg_N ("protected type cannot be used as type mark " & "within its own spec or body", N); end if; else Error_Msg_N ("type declaration cannot refer to itself", N); end if; Set_Etype (N, Any_Type); Set_Entity (N, Any_Type); Set_Error_Posted (T_Name); return; end if; Set_Entity (N, T_Name); Set_Etype (N, T_Name); end if; end if; if Present (Etype (N)) and then Comes_From_Source (N) then if Is_Fixed_Point_Type (Etype (N)) then Check_Restriction (No_Fixed_Point, N); elsif Is_Floating_Point_Type (Etype (N)) then Check_Restriction (No_Floating_Point, N); end if; -- A Ghost type must appear in a specific context if Is_Ghost_Entity (Etype (N)) then Check_Ghost_Context (Etype (N), N); end if; end if; end Find_Type; ------------------------------------ -- Has_Implicit_Character_Literal -- ------------------------------------ function Has_Implicit_Character_Literal (N : Node_Id) return Boolean is Id : Entity_Id; Found : Boolean := False; P : constant Entity_Id := Entity (Prefix (N)); Priv_Id : Entity_Id := Empty; begin if Ekind (P) = E_Package and then not In_Open_Scopes (P) then Priv_Id := First_Private_Entity (P); end if; if P = Standard_Standard then Change_Selected_Component_To_Expanded_Name (N); Rewrite (N, Selector_Name (N)); Analyze (N); Set_Etype (Original_Node (N), Standard_Character); return True; end if; Id := First_Entity (P); while Present (Id) and then Id /= Priv_Id loop if Is_Standard_Character_Type (Id) and then Is_Base_Type (Id) then -- We replace the node with the literal itself, resolve as a -- character, and set the type correctly. if not Found then Change_Selected_Component_To_Expanded_Name (N); Rewrite (N, Selector_Name (N)); Analyze (N); Set_Etype (N, Id); Set_Etype (Original_Node (N), Id); Found := True; else -- More than one type derived from Character in given scope. -- Collect all possible interpretations. Add_One_Interp (N, Id, Id); end if; end if; Next_Entity (Id); end loop; return Found; end Has_Implicit_Character_Literal; ---------------------- -- Has_Private_With -- ---------------------- function Has_Private_With (E : Entity_Id) return Boolean is Comp_Unit : constant Node_Id := Cunit (Current_Sem_Unit); Item : Node_Id; begin Item := First (Context_Items (Comp_Unit)); while Present (Item) loop if Nkind (Item) = N_With_Clause and then Private_Present (Item) and then Entity (Name (Item)) = E then return True; end if; Next (Item); end loop; return False; end Has_Private_With; --------------------------- -- Has_Implicit_Operator -- --------------------------- function Has_Implicit_Operator (N : Node_Id) return Boolean is Op_Id : constant Name_Id := Chars (Selector_Name (N)); P : constant Entity_Id := Entity (Prefix (N)); Id : Entity_Id; Priv_Id : Entity_Id := Empty; procedure Add_Implicit_Operator (T : Entity_Id; Op_Type : Entity_Id := Empty); -- Add implicit interpretation to node N, using the type for which a -- predefined operator exists. If the operator yields a boolean type, -- the Operand_Type is implicitly referenced by the operator, and a -- reference to it must be generated. --------------------------- -- Add_Implicit_Operator -- --------------------------- procedure Add_Implicit_Operator (T : Entity_Id; Op_Type : Entity_Id := Empty) is Predef_Op : Entity_Id; begin Predef_Op := Current_Entity (Selector_Name (N)); while Present (Predef_Op) and then Scope (Predef_Op) /= Standard_Standard loop Predef_Op := Homonym (Predef_Op); end loop; if Nkind (N) = N_Selected_Component then Change_Selected_Component_To_Expanded_Name (N); end if; -- If the context is an unanalyzed function call, determine whether -- a binary or unary interpretation is required. if Nkind (Parent (N)) = N_Indexed_Component then declare Is_Binary_Call : constant Boolean := Present (Next (First (Expressions (Parent (N))))); Is_Binary_Op : constant Boolean := First_Entity (Predef_Op) /= Last_Entity (Predef_Op); Predef_Op2 : constant Entity_Id := Homonym (Predef_Op); begin if Is_Binary_Call then if Is_Binary_Op then Add_One_Interp (N, Predef_Op, T); else Add_One_Interp (N, Predef_Op2, T); end if; else if not Is_Binary_Op then Add_One_Interp (N, Predef_Op, T); else Add_One_Interp (N, Predef_Op2, T); end if; end if; end; else Add_One_Interp (N, Predef_Op, T); -- For operators with unary and binary interpretations, if -- context is not a call, add both if Present (Homonym (Predef_Op)) then Add_One_Interp (N, Homonym (Predef_Op), T); end if; end if; -- The node is a reference to a predefined operator, and -- an implicit reference to the type of its operands. if Present (Op_Type) then Generate_Operator_Reference (N, Op_Type); else Generate_Operator_Reference (N, T); end if; end Add_Implicit_Operator; -- Start of processing for Has_Implicit_Operator begin if Ekind (P) = E_Package and then not In_Open_Scopes (P) then Priv_Id := First_Private_Entity (P); end if; Id := First_Entity (P); case Op_Id is -- Boolean operators: an implicit declaration exists if the scope -- contains a declaration for a derived Boolean type, or for an -- array of Boolean type. when Name_Op_And | Name_Op_Not | Name_Op_Or | Name_Op_Xor => while Id /= Priv_Id loop if Valid_Boolean_Arg (Id) and then Is_Base_Type (Id) then Add_Implicit_Operator (Id); return True; end if; Next_Entity (Id); end loop; -- Equality: look for any non-limited type (result is Boolean) when Name_Op_Eq | Name_Op_Ne => while Id /= Priv_Id loop if Is_Type (Id) and then not Is_Limited_Type (Id) and then Is_Base_Type (Id) then Add_Implicit_Operator (Standard_Boolean, Id); return True; end if; Next_Entity (Id); end loop; -- Comparison operators: scalar type, or array of scalar when Name_Op_Ge | Name_Op_Gt | Name_Op_Le | Name_Op_Lt => while Id /= Priv_Id loop if (Is_Scalar_Type (Id) or else (Is_Array_Type (Id) and then Is_Scalar_Type (Component_Type (Id)))) and then Is_Base_Type (Id) then Add_Implicit_Operator (Standard_Boolean, Id); return True; end if; Next_Entity (Id); end loop; -- Arithmetic operators: any numeric type when Name_Op_Abs | Name_Op_Add | Name_Op_Divide | Name_Op_Expon | Name_Op_Mod | Name_Op_Multiply | Name_Op_Rem | Name_Op_Subtract => while Id /= Priv_Id loop if Is_Numeric_Type (Id) and then Is_Base_Type (Id) then Add_Implicit_Operator (Id); return True; end if; Next_Entity (Id); end loop; -- Concatenation: any one-dimensional array type when Name_Op_Concat => while Id /= Priv_Id loop if Is_Array_Type (Id) and then Number_Dimensions (Id) = 1 and then Is_Base_Type (Id) then Add_Implicit_Operator (Id); return True; end if; Next_Entity (Id); end loop; -- What is the others condition here? Should we be using a -- subtype of Name_Id that would restrict to operators ??? when others => null; end case; -- If we fall through, then we do not have an implicit operator return False; end Has_Implicit_Operator; ----------------------------------- -- Has_Loop_In_Inner_Open_Scopes -- ----------------------------------- function Has_Loop_In_Inner_Open_Scopes (S : Entity_Id) return Boolean is begin -- Several scope stacks are maintained by Scope_Stack. The base of the -- currently active scope stack is denoted by the Is_Active_Stack_Base -- flag in the scope stack entry. Note that the scope stacks used to -- simply be delimited implicitly by the presence of Standard_Standard -- at their base, but there now are cases where this is not sufficient -- because Standard_Standard actually may appear in the middle of the -- active set of scopes. for J in reverse 0 .. Scope_Stack.Last loop -- S was reached without seing a loop scope first if Scope_Stack.Table (J).Entity = S then return False; -- S was not yet reached, so it contains at least one inner loop elsif Ekind (Scope_Stack.Table (J).Entity) = E_Loop then return True; end if; -- Check Is_Active_Stack_Base to tell us when to stop, as there are -- cases where Standard_Standard appears in the middle of the active -- set of scopes. This affects the declaration and overriding of -- private inherited operations in instantiations of generic child -- units. pragma Assert (not Scope_Stack.Table (J).Is_Active_Stack_Base); end loop; raise Program_Error; -- unreachable end Has_Loop_In_Inner_Open_Scopes; -------------------- -- In_Open_Scopes -- -------------------- function In_Open_Scopes (S : Entity_Id) return Boolean is begin -- Several scope stacks are maintained by Scope_Stack. The base of the -- currently active scope stack is denoted by the Is_Active_Stack_Base -- flag in the scope stack entry. Note that the scope stacks used to -- simply be delimited implicitly by the presence of Standard_Standard -- at their base, but there now are cases where this is not sufficient -- because Standard_Standard actually may appear in the middle of the -- active set of scopes. for J in reverse 0 .. Scope_Stack.Last loop if Scope_Stack.Table (J).Entity = S then return True; end if; -- Check Is_Active_Stack_Base to tell us when to stop, as there are -- cases where Standard_Standard appears in the middle of the active -- set of scopes. This affects the declaration and overriding of -- private inherited operations in instantiations of generic child -- units. exit when Scope_Stack.Table (J).Is_Active_Stack_Base; end loop; return False; end In_Open_Scopes; ----------------------------- -- Inherit_Renamed_Profile -- ----------------------------- procedure Inherit_Renamed_Profile (New_S : Entity_Id; Old_S : Entity_Id) is New_F : Entity_Id; Old_F : Entity_Id; Old_T : Entity_Id; New_T : Entity_Id; begin if Ekind (Old_S) = E_Operator then New_F := First_Formal (New_S); while Present (New_F) loop Set_Etype (New_F, Base_Type (Etype (New_F))); Next_Formal (New_F); end loop; Set_Etype (New_S, Base_Type (Etype (New_S))); else New_F := First_Formal (New_S); Old_F := First_Formal (Old_S); while Present (New_F) loop New_T := Etype (New_F); Old_T := Etype (Old_F); -- If the new type is a renaming of the old one, as is the case -- for actuals in instances, retain its name, to simplify later -- disambiguation. if Nkind (Parent (New_T)) = N_Subtype_Declaration and then Is_Entity_Name (Subtype_Indication (Parent (New_T))) and then Entity (Subtype_Indication (Parent (New_T))) = Old_T then null; else Set_Etype (New_F, Old_T); end if; Next_Formal (New_F); Next_Formal (Old_F); end loop; pragma Assert (No (Old_F)); if Ekind_In (Old_S, E_Function, E_Enumeration_Literal) then Set_Etype (New_S, Etype (Old_S)); end if; end if; end Inherit_Renamed_Profile; ---------------- -- Initialize -- ---------------- procedure Initialize is begin Urefs.Init; end Initialize; ------------------------- -- Install_Use_Clauses -- ------------------------- procedure Install_Use_Clauses (Clause : Node_Id; Force_Installation : Boolean := False) is U : Node_Id; P : Node_Id; Id : Entity_Id; begin U := Clause; while Present (U) loop -- Case of USE package if Nkind (U) = N_Use_Package_Clause then P := First (Names (U)); while Present (P) loop Id := Entity (P); if Ekind (Id) = E_Package then if In_Use (Id) then Note_Redundant_Use (P); elsif Present (Renamed_Object (Id)) and then In_Use (Renamed_Object (Id)) then Note_Redundant_Use (P); elsif Force_Installation or else Applicable_Use (P) then Use_One_Package (Id, U); end if; end if; Next (P); end loop; -- Case of USE TYPE else P := First (Subtype_Marks (U)); while Present (P) loop if not Is_Entity_Name (P) or else No (Entity (P)) then null; elsif Entity (P) /= Any_Type then Use_One_Type (P); end if; Next (P); end loop; end if; Next_Use_Clause (U); end loop; end Install_Use_Clauses; ------------------------------------- -- Is_Appropriate_For_Entry_Prefix -- ------------------------------------- function Is_Appropriate_For_Entry_Prefix (T : Entity_Id) return Boolean is P_Type : Entity_Id := T; begin if Is_Access_Type (P_Type) then P_Type := Designated_Type (P_Type); end if; return Is_Task_Type (P_Type) or else Is_Protected_Type (P_Type); end Is_Appropriate_For_Entry_Prefix; ------------------------------- -- Is_Appropriate_For_Record -- ------------------------------- function Is_Appropriate_For_Record (T : Entity_Id) return Boolean is function Has_Components (T1 : Entity_Id) return Boolean; -- Determine if given type has components (i.e. is either a record -- type or a type that has discriminants). -------------------- -- Has_Components -- -------------------- function Has_Components (T1 : Entity_Id) return Boolean is begin return Is_Record_Type (T1) or else (Is_Private_Type (T1) and then Has_Discriminants (T1)) or else (Is_Task_Type (T1) and then Has_Discriminants (T1)) or else (Is_Incomplete_Type (T1) and then From_Limited_With (T1) and then Present (Non_Limited_View (T1)) and then Is_Record_Type (Get_Full_View (Non_Limited_View (T1)))); end Has_Components; -- Start of processing for Is_Appropriate_For_Record begin return Present (T) and then (Has_Components (T) or else (Is_Access_Type (T) and then Has_Components (Designated_Type (T)))); end Is_Appropriate_For_Record; ------------------------ -- Note_Redundant_Use -- ------------------------ procedure Note_Redundant_Use (Clause : Node_Id) is Pack_Name : constant Entity_Id := Entity (Clause); Cur_Use : constant Node_Id := Current_Use_Clause (Pack_Name); Decl : constant Node_Id := Parent (Clause); Prev_Use : Node_Id := Empty; Redundant : Node_Id := Empty; -- The Use_Clause which is actually redundant. In the simplest case it -- is Pack itself, but when we compile a body we install its context -- before that of its spec, in which case it is the use_clause in the -- spec that will appear to be redundant, and we want the warning to be -- placed on the body. Similar complications appear when the redundancy -- is between a child unit and one of its ancestors. begin Set_Redundant_Use (Clause, True); if not Comes_From_Source (Clause) or else In_Instance or else not Warn_On_Redundant_Constructs then return; end if; if not Is_Compilation_Unit (Current_Scope) then -- If the use_clause is in an inner scope, it is made redundant by -- some clause in the current context, with one exception: If we're -- compiling a nested package body, and the use_clause comes from the -- corresponding spec, the clause is not necessarily fully redundant, -- so we should not warn. If a warning was warranted, it would have -- been given when the spec was processed. if Nkind (Parent (Decl)) = N_Package_Specification then declare Package_Spec_Entity : constant Entity_Id := Defining_Unit_Name (Parent (Decl)); begin if In_Package_Body (Package_Spec_Entity) then return; end if; end; end if; Redundant := Clause; Prev_Use := Cur_Use; elsif Nkind (Unit (Cunit (Current_Sem_Unit))) = N_Package_Body then declare Cur_Unit : constant Unit_Number_Type := Get_Source_Unit (Cur_Use); New_Unit : constant Unit_Number_Type := Get_Source_Unit (Clause); Scop : Entity_Id; begin if Cur_Unit = New_Unit then -- Redundant clause in same body Redundant := Clause; Prev_Use := Cur_Use; elsif Cur_Unit = Current_Sem_Unit then -- If the new clause is not in the current unit it has been -- analyzed first, and it makes the other one redundant. -- However, if the new clause appears in a subunit, Cur_Unit -- is still the parent, and in that case the redundant one -- is the one appearing in the subunit. if Nkind (Unit (Cunit (New_Unit))) = N_Subunit then Redundant := Clause; Prev_Use := Cur_Use; -- Most common case: redundant clause in body, -- original clause in spec. Current scope is spec entity. elsif Current_Scope = Defining_Entity ( Unit (Library_Unit (Cunit (Current_Sem_Unit)))) then Redundant := Cur_Use; Prev_Use := Clause; else -- The new clause may appear in an unrelated unit, when -- the parents of a generic are being installed prior to -- instantiation. In this case there must be no warning. -- We detect this case by checking whether the current top -- of the stack is related to the current compilation. Scop := Current_Scope; while Present (Scop) and then Scop /= Standard_Standard loop if Is_Compilation_Unit (Scop) and then not Is_Child_Unit (Scop) then return; elsif Scop = Cunit_Entity (Current_Sem_Unit) then exit; end if; Scop := Scope (Scop); end loop; Redundant := Cur_Use; Prev_Use := Clause; end if; elsif New_Unit = Current_Sem_Unit then Redundant := Clause; Prev_Use := Cur_Use; else -- Neither is the current unit, so they appear in parent or -- sibling units. Warning will be emitted elsewhere. return; end if; end; elsif Nkind (Unit (Cunit (Current_Sem_Unit))) = N_Package_Declaration and then Present (Parent_Spec (Unit (Cunit (Current_Sem_Unit)))) then -- Use_clause is in child unit of current unit, and the child unit -- appears in the context of the body of the parent, so it has been -- installed first, even though it is the redundant one. Depending on -- their placement in the context, the visible or the private parts -- of the two units, either might appear as redundant, but the -- message has to be on the current unit. if Get_Source_Unit (Cur_Use) = Current_Sem_Unit then Redundant := Cur_Use; Prev_Use := Clause; else Redundant := Clause; Prev_Use := Cur_Use; end if; -- If the new use clause appears in the private part of a parent unit -- it may appear to be redundant w.r.t. a use clause in a child unit, -- but the previous use clause was needed in the visible part of the -- child, and no warning should be emitted. if Nkind (Parent (Decl)) = N_Package_Specification and then List_Containing (Decl) = Private_Declarations (Parent (Decl)) then declare Par : constant Entity_Id := Defining_Entity (Parent (Decl)); Spec : constant Node_Id := Specification (Unit (Cunit (Current_Sem_Unit))); begin if Is_Compilation_Unit (Par) and then Par /= Cunit_Entity (Current_Sem_Unit) and then Parent (Cur_Use) = Spec and then List_Containing (Cur_Use) = Visible_Declarations (Spec) then return; end if; end; end if; -- Finally, if the current use clause is in the context then -- the clause is redundant when it is nested within the unit. elsif Nkind (Parent (Cur_Use)) = N_Compilation_Unit and then Nkind (Parent (Parent (Clause))) /= N_Compilation_Unit and then Get_Source_Unit (Cur_Use) = Get_Source_Unit (Clause) then Redundant := Clause; Prev_Use := Cur_Use; else null; end if; if Present (Redundant) then Error_Msg_Sloc := Sloc (Prev_Use); Error_Msg_NE -- CODEFIX ("& is already use-visible through previous use clause #??", Redundant, Pack_Name); end if; end Note_Redundant_Use; --------------- -- Pop_Scope -- --------------- procedure Pop_Scope is SST : Scope_Stack_Entry renames Scope_Stack.Table (Scope_Stack.Last); S : constant Entity_Id := SST.Entity; begin if Debug_Flag_E then Write_Info; end if; -- Set Default_Storage_Pool field of the library unit if necessary if Ekind_In (S, E_Package, E_Generic_Package) and then Nkind (Parent (Unit_Declaration_Node (S))) = N_Compilation_Unit then declare Aux : constant Node_Id := Aux_Decls_Node (Parent (Unit_Declaration_Node (S))); begin if No (Default_Storage_Pool (Aux)) then Set_Default_Storage_Pool (Aux, Default_Pool); end if; end; end if; Scope_Suppress := SST.Save_Scope_Suppress; Local_Suppress_Stack_Top := SST.Save_Local_Suppress_Stack_Top; Check_Policy_List := SST.Save_Check_Policy_List; Default_Pool := SST.Save_Default_Storage_Pool; No_Tagged_Streams := SST.Save_No_Tagged_Streams; SPARK_Mode := SST.Save_SPARK_Mode; SPARK_Mode_Pragma := SST.Save_SPARK_Mode_Pragma; Default_SSO := SST.Save_Default_SSO; Uneval_Old := SST.Save_Uneval_Old; if Debug_Flag_W then Write_Str ("<-- exiting scope: "); Write_Name (Chars (Current_Scope)); Write_Str (", Depth="); Write_Int (Int (Scope_Stack.Last)); Write_Eol; end if; End_Use_Clauses (SST.First_Use_Clause); -- If the actions to be wrapped are still there they will get lost -- causing incomplete code to be generated. It is better to abort in -- this case (and we do the abort even with assertions off since the -- penalty is incorrect code generation). if SST.Actions_To_Be_Wrapped /= Scope_Actions'(others => No_List) then raise Program_Error; end if; -- Free last subprogram name if allocated, and pop scope Free (SST.Last_Subprogram_Name); Scope_Stack.Decrement_Last; end Pop_Scope; --------------- -- Push_Scope -- --------------- procedure Push_Scope (S : Entity_Id) is E : constant Entity_Id := Scope (S); begin if Ekind (S) = E_Void then null; -- Set scope depth if not a non-concurrent type, and we have not yet set -- the scope depth. This means that we have the first occurrence of the -- scope, and this is where the depth is set. elsif (not Is_Type (S) or else Is_Concurrent_Type (S)) and then not Scope_Depth_Set (S) then if S = Standard_Standard then Set_Scope_Depth_Value (S, Uint_0); elsif Is_Child_Unit (S) then Set_Scope_Depth_Value (S, Uint_1); elsif not Is_Record_Type (Current_Scope) then if Ekind (S) = E_Loop then Set_Scope_Depth_Value (S, Scope_Depth (Current_Scope)); else Set_Scope_Depth_Value (S, Scope_Depth (Current_Scope) + 1); end if; end if; end if; Scope_Stack.Increment_Last; declare SST : Scope_Stack_Entry renames Scope_Stack.Table (Scope_Stack.Last); begin SST.Entity := S; SST.Save_Scope_Suppress := Scope_Suppress; SST.Save_Local_Suppress_Stack_Top := Local_Suppress_Stack_Top; SST.Save_Check_Policy_List := Check_Policy_List; SST.Save_Default_Storage_Pool := Default_Pool; SST.Save_No_Tagged_Streams := No_Tagged_Streams; SST.Save_SPARK_Mode := SPARK_Mode; SST.Save_SPARK_Mode_Pragma := SPARK_Mode_Pragma; SST.Save_Default_SSO := Default_SSO; SST.Save_Uneval_Old := Uneval_Old; -- Each new scope pushed onto the scope stack inherits the component -- alignment of the previous scope. This emulates the "visibility" -- semantics of pragma Component_Alignment. if Scope_Stack.Last > Scope_Stack.First then SST.Component_Alignment_Default := Scope_Stack.Table (Scope_Stack.Last - 1). Component_Alignment_Default; -- Otherwise, this is the first scope being pushed on the scope -- stack. Inherit the component alignment from the configuration -- form of pragma Component_Alignment (if any). else SST.Component_Alignment_Default := Configuration_Component_Alignment; end if; SST.Last_Subprogram_Name := null; SST.Is_Transient := False; SST.Node_To_Be_Wrapped := Empty; SST.Pending_Freeze_Actions := No_List; SST.Actions_To_Be_Wrapped := (others => No_List); SST.First_Use_Clause := Empty; SST.Is_Active_Stack_Base := False; SST.Previous_Visibility := False; SST.Locked_Shared_Objects := No_Elist; end; if Debug_Flag_W then Write_Str ("--> new scope: "); Write_Name (Chars (Current_Scope)); Write_Str (", Id="); Write_Int (Int (Current_Scope)); Write_Str (", Depth="); Write_Int (Int (Scope_Stack.Last)); Write_Eol; end if; -- Deal with copying flags from the previous scope to this one. This is -- not necessary if either scope is standard, or if the new scope is a -- child unit. if S /= Standard_Standard and then Scope (S) /= Standard_Standard and then not Is_Child_Unit (S) then if Nkind (E) not in N_Entity then return; end if; -- Copy categorization flags from Scope (S) to S, this is not done -- when Scope (S) is Standard_Standard since propagation is from -- library unit entity inwards. Copy other relevant attributes as -- well (Discard_Names in particular). -- We only propagate inwards for library level entities, -- inner level subprograms do not inherit the categorization. if Is_Library_Level_Entity (S) then Set_Is_Preelaborated (S, Is_Preelaborated (E)); Set_Is_Shared_Passive (S, Is_Shared_Passive (E)); Set_Discard_Names (S, Discard_Names (E)); Set_Suppress_Value_Tracking_On_Call (S, Suppress_Value_Tracking_On_Call (E)); Set_Categorization_From_Scope (E => S, Scop => E); end if; end if; if Is_Child_Unit (S) and then Present (E) and then Ekind_In (E, E_Package, E_Generic_Package) and then Nkind (Parent (Unit_Declaration_Node (E))) = N_Compilation_Unit then declare Aux : constant Node_Id := Aux_Decls_Node (Parent (Unit_Declaration_Node (E))); begin if Present (Default_Storage_Pool (Aux)) then Default_Pool := Default_Storage_Pool (Aux); end if; end; end if; end Push_Scope; --------------------- -- Premature_Usage -- --------------------- procedure Premature_Usage (N : Node_Id) is Kind : constant Node_Kind := Nkind (Parent (Entity (N))); E : Entity_Id := Entity (N); begin -- Within an instance, the analysis of the actual for a formal object -- does not see the name of the object itself. This is significant only -- if the object is an aggregate, where its analysis does not do any -- name resolution on component associations. (see 4717-008). In such a -- case, look for the visible homonym on the chain. if In_Instance and then Present (Homonym (E)) then E := Homonym (E); while Present (E) and then not In_Open_Scopes (Scope (E)) loop E := Homonym (E); end loop; if Present (E) then Set_Entity (N, E); Set_Etype (N, Etype (E)); return; end if; end if; if Kind = N_Component_Declaration then Error_Msg_N ("component&! cannot be used before end of record declaration", N); elsif Kind = N_Parameter_Specification then Error_Msg_N ("formal parameter&! cannot be used before end of specification", N); elsif Kind = N_Discriminant_Specification then Error_Msg_N ("discriminant&! cannot be used before end of discriminant part", N); elsif Kind = N_Procedure_Specification or else Kind = N_Function_Specification then Error_Msg_N ("subprogram&! cannot be used before end of its declaration", N); elsif Kind = N_Full_Type_Declaration then Error_Msg_N ("type& cannot be used before end of its declaration!", N); else Error_Msg_N ("object& cannot be used before end of its declaration!", N); end if; end Premature_Usage; ------------------------ -- Present_System_Aux -- ------------------------ function Present_System_Aux (N : Node_Id := Empty) return Boolean is Loc : Source_Ptr; Aux_Name : Unit_Name_Type; Unum : Unit_Number_Type; Withn : Node_Id; With_Sys : Node_Id; The_Unit : Node_Id; function Find_System (C_Unit : Node_Id) return Entity_Id; -- Scan context clause of compilation unit to find with_clause -- for System. ----------------- -- Find_System -- ----------------- function Find_System (C_Unit : Node_Id) return Entity_Id is With_Clause : Node_Id; begin With_Clause := First (Context_Items (C_Unit)); while Present (With_Clause) loop if (Nkind (With_Clause) = N_With_Clause and then Chars (Name (With_Clause)) = Name_System) and then Comes_From_Source (With_Clause) then return With_Clause; end if; Next (With_Clause); end loop; return Empty; end Find_System; -- Start of processing for Present_System_Aux begin -- The child unit may have been loaded and analyzed already if Present (System_Aux_Id) then return True; -- If no previous pragma for System.Aux, nothing to load elsif No (System_Extend_Unit) then return False; -- Use the unit name given in the pragma to retrieve the unit. -- Verify that System itself appears in the context clause of the -- current compilation. If System is not present, an error will -- have been reported already. else With_Sys := Find_System (Cunit (Current_Sem_Unit)); The_Unit := Unit (Cunit (Current_Sem_Unit)); if No (With_Sys) and then (Nkind (The_Unit) = N_Package_Body or else (Nkind (The_Unit) = N_Subprogram_Body and then not Acts_As_Spec (Cunit (Current_Sem_Unit)))) then With_Sys := Find_System (Library_Unit (Cunit (Current_Sem_Unit))); end if; if No (With_Sys) and then Present (N) then -- If we are compiling a subunit, we need to examine its -- context as well (Current_Sem_Unit is the parent unit); The_Unit := Parent (N); while Nkind (The_Unit) /= N_Compilation_Unit loop The_Unit := Parent (The_Unit); end loop; if Nkind (Unit (The_Unit)) = N_Subunit then With_Sys := Find_System (The_Unit); end if; end if; if No (With_Sys) then return False; end if; Loc := Sloc (With_Sys); Get_Name_String (Chars (Expression (System_Extend_Unit))); Name_Buffer (8 .. Name_Len + 7) := Name_Buffer (1 .. Name_Len); Name_Buffer (1 .. 7) := "system."; Name_Buffer (Name_Len + 8) := '%'; Name_Buffer (Name_Len + 9) := 's'; Name_Len := Name_Len + 9; Aux_Name := Name_Find; Unum := Load_Unit (Load_Name => Aux_Name, Required => False, Subunit => False, Error_Node => With_Sys); if Unum /= No_Unit then Semantics (Cunit (Unum)); System_Aux_Id := Defining_Entity (Specification (Unit (Cunit (Unum)))); Withn := Make_With_Clause (Loc, Name => Make_Expanded_Name (Loc, Chars => Chars (System_Aux_Id), Prefix => New_Occurrence_Of (Scope (System_Aux_Id), Loc), Selector_Name => New_Occurrence_Of (System_Aux_Id, Loc))); Set_Entity (Name (Withn), System_Aux_Id); Set_Library_Unit (Withn, Cunit (Unum)); Set_Corresponding_Spec (Withn, System_Aux_Id); Set_First_Name (Withn, True); Set_Implicit_With (Withn, True); Insert_After (With_Sys, Withn); Mark_Rewrite_Insertion (Withn); Set_Context_Installed (Withn); return True; -- Here if unit load failed else Error_Msg_Name_1 := Name_System; Error_Msg_Name_2 := Chars (Expression (System_Extend_Unit)); Error_Msg_N ("extension package `%.%` does not exist", Opt.System_Extend_Unit); return False; end if; end if; end Present_System_Aux; ------------------------- -- Restore_Scope_Stack -- ------------------------- procedure Restore_Scope_Stack (List : Elist_Id; Handle_Use : Boolean := True) is SS_Last : constant Int := Scope_Stack.Last; Elmt : Elmt_Id; begin -- Restore visibility of previous scope stack, if any, using the list -- we saved (we use Remove, since this list will not be used again). loop Elmt := Last_Elmt (List); exit when Elmt = No_Elmt; Set_Is_Immediately_Visible (Node (Elmt)); Remove_Last_Elmt (List); end loop; -- Restore use clauses if SS_Last >= Scope_Stack.First and then Scope_Stack.Table (SS_Last).Entity /= Standard_Standard and then Handle_Use then Install_Use_Clauses (Scope_Stack.Table (SS_Last).First_Use_Clause); end if; end Restore_Scope_Stack; ---------------------- -- Save_Scope_Stack -- ---------------------- -- Save_Scope_Stack/Restore_Scope_Stack were originally designed to avoid -- consuming any memory. That is, Save_Scope_Stack took care of removing -- from immediate visibility entities and Restore_Scope_Stack took care -- of restoring their visibility analyzing the context of each entity. The -- problem of such approach is that it was fragile and caused unexpected -- visibility problems, and indeed one test was found where there was a -- real problem. -- Furthermore, the following experiment was carried out: -- - Save_Scope_Stack was modified to store in an Elist1 all those -- entities whose attribute Is_Immediately_Visible is modified -- from True to False. -- - Restore_Scope_Stack was modified to store in another Elist2 -- all the entities whose attribute Is_Immediately_Visible is -- modified from False to True. -- - Extra code was added to verify that all the elements of Elist1 -- are found in Elist2 -- This test shows that there may be more occurrences of this problem which -- have not yet been detected. As a result, we replaced that approach by -- the current one in which Save_Scope_Stack returns the list of entities -- whose visibility is changed, and that list is passed to Restore_Scope_ -- Stack to undo that change. This approach is simpler and safer, although -- it consumes more memory. function Save_Scope_Stack (Handle_Use : Boolean := True) return Elist_Id is Result : constant Elist_Id := New_Elmt_List; E : Entity_Id; S : Entity_Id; SS_Last : constant Int := Scope_Stack.Last; procedure Remove_From_Visibility (E : Entity_Id); -- If E is immediately visible then append it to the result and remove -- it temporarily from visibility. ---------------------------- -- Remove_From_Visibility -- ---------------------------- procedure Remove_From_Visibility (E : Entity_Id) is begin if Is_Immediately_Visible (E) then Append_Elmt (E, Result); Set_Is_Immediately_Visible (E, False); end if; end Remove_From_Visibility; -- Start of processing for Save_Scope_Stack begin if SS_Last >= Scope_Stack.First and then Scope_Stack.Table (SS_Last).Entity /= Standard_Standard then if Handle_Use then End_Use_Clauses (Scope_Stack.Table (SS_Last).First_Use_Clause); end if; -- If the call is from within a compilation unit, as when called from -- Rtsfind, make current entries in scope stack invisible while we -- analyze the new unit. for J in reverse 0 .. SS_Last loop exit when Scope_Stack.Table (J).Entity = Standard_Standard or else No (Scope_Stack.Table (J).Entity); S := Scope_Stack.Table (J).Entity; Remove_From_Visibility (S); E := First_Entity (S); while Present (E) loop Remove_From_Visibility (E); Next_Entity (E); end loop; end loop; end if; return Result; end Save_Scope_Stack; ------------- -- Set_Use -- ------------- procedure Set_Use (L : List_Id) is Decl : Node_Id; Pack_Name : Node_Id; Pack : Entity_Id; Id : Entity_Id; begin if Present (L) then Decl := First (L); while Present (Decl) loop if Nkind (Decl) = N_Use_Package_Clause then Chain_Use_Clause (Decl); Pack_Name := First (Names (Decl)); while Present (Pack_Name) loop Pack := Entity (Pack_Name); if Ekind (Pack) = E_Package and then Applicable_Use (Pack_Name) then Use_One_Package (Pack, Decl); end if; Next (Pack_Name); end loop; elsif Nkind (Decl) = N_Use_Type_Clause then Chain_Use_Clause (Decl); Id := First (Subtype_Marks (Decl)); while Present (Id) loop if Entity (Id) /= Any_Type then Use_One_Type (Id); end if; Next (Id); end loop; end if; Next (Decl); end loop; end if; end Set_Use; --------------------- -- Use_One_Package -- --------------------- procedure Use_One_Package (P : Entity_Id; N : Node_Id) is Id : Entity_Id; Prev : Entity_Id; Current_Instance : Entity_Id := Empty; Real_P : Entity_Id; Private_With_OK : Boolean := False; begin if Ekind (P) /= E_Package then return; end if; Set_In_Use (P); Set_Current_Use_Clause (P, N); -- Ada 2005 (AI-50217): Check restriction if From_Limited_With (P) then Error_Msg_N ("limited withed package cannot appear in use clause", N); end if; -- Find enclosing instance, if any if In_Instance then Current_Instance := Current_Scope; while not Is_Generic_Instance (Current_Instance) loop Current_Instance := Scope (Current_Instance); end loop; if No (Hidden_By_Use_Clause (N)) then Set_Hidden_By_Use_Clause (N, New_Elmt_List); end if; end if; -- If unit is a package renaming, indicate that the renamed -- package is also in use (the flags on both entities must -- remain consistent, and a subsequent use of either of them -- should be recognized as redundant). if Present (Renamed_Object (P)) then Set_In_Use (Renamed_Object (P)); Set_Current_Use_Clause (Renamed_Object (P), N); Real_P := Renamed_Object (P); else Real_P := P; end if; -- Ada 2005 (AI-262): Check the use_clause of a private withed package -- found in the private part of a package specification if In_Private_Part (Current_Scope) and then Has_Private_With (P) and then Is_Child_Unit (Current_Scope) and then Is_Child_Unit (P) and then Is_Ancestor_Package (Scope (Current_Scope), P) then Private_With_OK := True; end if; -- Loop through entities in one package making them potentially -- use-visible. Id := First_Entity (P); while Present (Id) and then (Id /= First_Private_Entity (P) or else Private_With_OK) -- Ada 2005 (AI-262) loop Prev := Current_Entity (Id); while Present (Prev) loop if Is_Immediately_Visible (Prev) and then (not Is_Overloadable (Prev) or else not Is_Overloadable (Id) or else (Type_Conformant (Id, Prev))) then if No (Current_Instance) then -- Potentially use-visible entity remains hidden goto Next_Usable_Entity; -- A use clause within an instance hides outer global entities, -- which are not used to resolve local entities in the -- instance. Note that the predefined entities in Standard -- could not have been hidden in the generic by a use clause, -- and therefore remain visible. Other compilation units whose -- entities appear in Standard must be hidden in an instance. -- To determine whether an entity is external to the instance -- we compare the scope depth of its scope with that of the -- current instance. However, a generic actual of a subprogram -- instance is declared in the wrapper package but will not be -- hidden by a use-visible entity. similarly, an entity that is -- declared in an enclosing instance will not be hidden by an -- an entity declared in a generic actual, which can only have -- been use-visible in the generic and will not have hidden the -- entity in the generic parent. -- If Id is called Standard, the predefined package with the -- same name is in the homonym chain. It has to be ignored -- because it has no defined scope (being the only entity in -- the system with this mandated behavior). elsif not Is_Hidden (Id) and then Present (Scope (Prev)) and then not Is_Wrapper_Package (Scope (Prev)) and then Scope_Depth (Scope (Prev)) < Scope_Depth (Current_Instance) and then (Scope (Prev) /= Standard_Standard or else Sloc (Prev) > Standard_Location) then if In_Open_Scopes (Scope (Prev)) and then Is_Generic_Instance (Scope (Prev)) and then Present (Associated_Formal_Package (P)) then null; else Set_Is_Potentially_Use_Visible (Id); Set_Is_Immediately_Visible (Prev, False); Append_Elmt (Prev, Hidden_By_Use_Clause (N)); end if; end if; -- A user-defined operator is not use-visible if the predefined -- operator for the type is immediately visible, which is the case -- if the type of the operand is in an open scope. This does not -- apply to user-defined operators that have operands of different -- types, because the predefined mixed mode operations (multiply -- and divide) apply to universal types and do not hide anything. elsif Ekind (Prev) = E_Operator and then Operator_Matches_Spec (Prev, Id) and then In_Open_Scopes (Scope (Base_Type (Etype (First_Formal (Id))))) and then (No (Next_Formal (First_Formal (Id))) or else Etype (First_Formal (Id)) = Etype (Next_Formal (First_Formal (Id))) or else Chars (Prev) = Name_Op_Expon) then goto Next_Usable_Entity; -- In an instance, two homonyms may become use_visible through the -- actuals of distinct formal packages. In the generic, only the -- current one would have been visible, so make the other one -- not use_visible. elsif Present (Current_Instance) and then Is_Potentially_Use_Visible (Prev) and then not Is_Overloadable (Prev) and then Scope (Id) /= Scope (Prev) and then Used_As_Generic_Actual (Scope (Prev)) and then Used_As_Generic_Actual (Scope (Id)) and then not In_Same_List (Current_Use_Clause (Scope (Prev)), Current_Use_Clause (Scope (Id))) then Set_Is_Potentially_Use_Visible (Prev, False); Append_Elmt (Prev, Hidden_By_Use_Clause (N)); end if; Prev := Homonym (Prev); end loop; -- On exit, we know entity is not hidden, unless it is private if not Is_Hidden (Id) and then ((not Is_Child_Unit (Id)) or else Is_Visible_Lib_Unit (Id)) then Set_Is_Potentially_Use_Visible (Id); if Is_Private_Type (Id) and then Present (Full_View (Id)) then Set_Is_Potentially_Use_Visible (Full_View (Id)); end if; end if; <<Next_Usable_Entity>> Next_Entity (Id); end loop; -- Child units are also made use-visible by a use clause, but they may -- appear after all visible declarations in the parent entity list. while Present (Id) loop if Is_Child_Unit (Id) and then Is_Visible_Lib_Unit (Id) then Set_Is_Potentially_Use_Visible (Id); end if; Next_Entity (Id); end loop; if Chars (Real_P) = Name_System and then Scope (Real_P) = Standard_Standard and then Present_System_Aux (N) then Use_One_Package (System_Aux_Id, N); end if; end Use_One_Package; ------------------ -- Use_One_Type -- ------------------ procedure Use_One_Type (Id : Node_Id; Installed : Boolean := False) is Elmt : Elmt_Id; Is_Known_Used : Boolean; Op_List : Elist_Id; T : Entity_Id; function Spec_Reloaded_For_Body return Boolean; -- Determine whether the compilation unit is a package body and the use -- type clause is in the spec of the same package. Even though the spec -- was analyzed first, its context is reloaded when analysing the body. procedure Use_Class_Wide_Operations (Typ : Entity_Id); -- AI05-150: if the use_type_clause carries the "all" qualifier, -- class-wide operations of ancestor types are use-visible if the -- ancestor type is visible. ---------------------------- -- Spec_Reloaded_For_Body -- ---------------------------- function Spec_Reloaded_For_Body return Boolean is begin if Nkind (Unit (Cunit (Current_Sem_Unit))) = N_Package_Body then declare Spec : constant Node_Id := Parent (List_Containing (Parent (Id))); begin -- Check whether type is declared in a package specification, -- and current unit is the corresponding package body. The -- use clauses themselves may be within a nested package. return Nkind (Spec) = N_Package_Specification and then In_Same_Source_Unit (Corresponding_Body (Parent (Spec)), Cunit_Entity (Current_Sem_Unit)); end; end if; return False; end Spec_Reloaded_For_Body; ------------------------------- -- Use_Class_Wide_Operations -- ------------------------------- procedure Use_Class_Wide_Operations (Typ : Entity_Id) is Scop : Entity_Id; Ent : Entity_Id; function Is_Class_Wide_Operation_Of (Op : Entity_Id; T : Entity_Id) return Boolean; -- Determine whether a subprogram has a class-wide parameter or -- result that is T'Class. --------------------------------- -- Is_Class_Wide_Operation_Of -- --------------------------------- function Is_Class_Wide_Operation_Of (Op : Entity_Id; T : Entity_Id) return Boolean is Formal : Entity_Id; begin Formal := First_Formal (Op); while Present (Formal) loop if Etype (Formal) = Class_Wide_Type (T) then return True; end if; Next_Formal (Formal); end loop; if Etype (Op) = Class_Wide_Type (T) then return True; end if; return False; end Is_Class_Wide_Operation_Of; -- Start of processing for Use_Class_Wide_Operations begin Scop := Scope (Typ); if not Is_Hidden (Scop) then Ent := First_Entity (Scop); while Present (Ent) loop if Is_Overloadable (Ent) and then Is_Class_Wide_Operation_Of (Ent, Typ) and then not Is_Potentially_Use_Visible (Ent) then Set_Is_Potentially_Use_Visible (Ent); Append_Elmt (Ent, Used_Operations (Parent (Id))); end if; Next_Entity (Ent); end loop; end if; if Is_Derived_Type (Typ) then Use_Class_Wide_Operations (Etype (Base_Type (Typ))); end if; end Use_Class_Wide_Operations; -- Start of processing for Use_One_Type begin -- It is the type determined by the subtype mark (8.4(8)) whose -- operations become potentially use-visible. T := Base_Type (Entity (Id)); -- Either the type itself is used, the package where it is declared -- is in use or the entity is declared in the current package, thus -- use-visible. Is_Known_Used := In_Use (T) or else In_Use (Scope (T)) or else Scope (T) = Current_Scope; Set_Redundant_Use (Id, Is_Known_Used or else Is_Potentially_Use_Visible (T)); if Ekind (T) = E_Incomplete_Type then Error_Msg_N ("premature usage of incomplete type", Id); elsif In_Open_Scopes (Scope (T)) then null; -- A limited view cannot appear in a use_type clause. However, an access -- type whose designated type is limited has the flag but is not itself -- a limited view unless we only have a limited view of its enclosing -- package. elsif From_Limited_With (T) and then From_Limited_With (Scope (T)) then Error_Msg_N ("incomplete type from limited view " & "cannot appear in use clause", Id); -- If the subtype mark designates a subtype in a different package, -- we have to check that the parent type is visible, otherwise the -- use type clause is a noop. Not clear how to do that??? elsif not Redundant_Use (Id) then Set_In_Use (T); -- If T is tagged, primitive operators on class-wide operands -- are also available. if Is_Tagged_Type (T) then Set_In_Use (Class_Wide_Type (T)); end if; Set_Current_Use_Clause (T, Parent (Id)); -- Iterate over primitive operations of the type. If an operation is -- already use_visible, it is the result of a previous use_clause, -- and already appears on the corresponding entity chain. If the -- clause is being reinstalled, operations are already use-visible. if Installed then null; else Op_List := Collect_Primitive_Operations (T); Elmt := First_Elmt (Op_List); while Present (Elmt) loop if (Nkind (Node (Elmt)) = N_Defining_Operator_Symbol or else Chars (Node (Elmt)) in Any_Operator_Name) and then not Is_Hidden (Node (Elmt)) and then not Is_Potentially_Use_Visible (Node (Elmt)) then Set_Is_Potentially_Use_Visible (Node (Elmt)); Append_Elmt (Node (Elmt), Used_Operations (Parent (Id))); elsif Ada_Version >= Ada_2012 and then All_Present (Parent (Id)) and then not Is_Hidden (Node (Elmt)) and then not Is_Potentially_Use_Visible (Node (Elmt)) then Set_Is_Potentially_Use_Visible (Node (Elmt)); Append_Elmt (Node (Elmt), Used_Operations (Parent (Id))); end if; Next_Elmt (Elmt); end loop; end if; if Ada_Version >= Ada_2012 and then All_Present (Parent (Id)) and then Is_Tagged_Type (T) then Use_Class_Wide_Operations (T); end if; end if; -- If warning on redundant constructs, check for unnecessary WITH if Warn_On_Redundant_Constructs and then Is_Known_Used -- with P; with P; use P; -- package P is package X is package body X is -- type T ... use P.T; -- The compilation unit is the body of X. GNAT first compiles the -- spec of X, then proceeds to the body. At that point P is marked -- as use visible. The analysis then reinstalls the spec along with -- its context. The use clause P.T is now recognized as redundant, -- but in the wrong context. Do not emit a warning in such cases. -- Do not emit a warning either if we are in an instance, there is -- no redundancy between an outer use_clause and one that appears -- within the generic. and then not Spec_Reloaded_For_Body and then not In_Instance then -- The type already has a use clause if In_Use (T) then -- Case where we know the current use clause for the type if Present (Current_Use_Clause (T)) then Use_Clause_Known : declare Clause1 : constant Node_Id := Parent (Id); Clause2 : constant Node_Id := Current_Use_Clause (T); Ent1 : Entity_Id; Ent2 : Entity_Id; Err_No : Node_Id; Unit1 : Node_Id; Unit2 : Node_Id; function Entity_Of_Unit (U : Node_Id) return Entity_Id; -- Return the appropriate entity for determining which unit -- has a deeper scope: the defining entity for U, unless U -- is a package instance, in which case we retrieve the -- entity of the instance spec. -------------------- -- Entity_Of_Unit -- -------------------- function Entity_Of_Unit (U : Node_Id) return Entity_Id is begin if Nkind (U) = N_Package_Instantiation and then Analyzed (U) then return Defining_Entity (Instance_Spec (U)); else return Defining_Entity (U); end if; end Entity_Of_Unit; -- Start of processing for Use_Clause_Known begin -- If both current use type clause and the use type clause -- for the type are at the compilation unit level, one of -- the units must be an ancestor of the other, and the -- warning belongs on the descendant. if Nkind (Parent (Clause1)) = N_Compilation_Unit and then Nkind (Parent (Clause2)) = N_Compilation_Unit then -- If the unit is a subprogram body that acts as spec, -- the context clause is shared with the constructed -- subprogram spec. Clearly there is no redundancy. if Clause1 = Clause2 then return; end if; Unit1 := Unit (Parent (Clause1)); Unit2 := Unit (Parent (Clause2)); -- If both clauses are on same unit, or one is the body -- of the other, or one of them is in a subunit, report -- redundancy on the later one. if Unit1 = Unit2 then Error_Msg_Sloc := Sloc (Current_Use_Clause (T)); Error_Msg_NE -- CODEFIX ("& is already use-visible through previous " & "use_type_clause #??", Clause1, T); return; elsif Nkind (Unit1) = N_Subunit then Error_Msg_Sloc := Sloc (Current_Use_Clause (T)); Error_Msg_NE -- CODEFIX ("& is already use-visible through previous " & "use_type_clause #??", Clause1, T); return; elsif Nkind_In (Unit2, N_Package_Body, N_Subprogram_Body) and then Nkind (Unit1) /= Nkind (Unit2) and then Nkind (Unit1) /= N_Subunit then Error_Msg_Sloc := Sloc (Clause1); Error_Msg_NE -- CODEFIX ("& is already use-visible through previous " & "use_type_clause #??", Current_Use_Clause (T), T); return; end if; -- There is a redundant use type clause in a child unit. -- Determine which of the units is more deeply nested. -- If a unit is a package instance, retrieve the entity -- and its scope from the instance spec. Ent1 := Entity_Of_Unit (Unit1); Ent2 := Entity_Of_Unit (Unit2); if Scope (Ent2) = Standard_Standard then Error_Msg_Sloc := Sloc (Current_Use_Clause (T)); Err_No := Clause1; elsif Scope (Ent1) = Standard_Standard then Error_Msg_Sloc := Sloc (Id); Err_No := Clause2; -- If both units are child units, we determine which one -- is the descendant by the scope distance to the -- ultimate parent unit. else declare S1, S2 : Entity_Id; begin S1 := Scope (Ent1); S2 := Scope (Ent2); while Present (S1) and then Present (S2) and then S1 /= Standard_Standard and then S2 /= Standard_Standard loop S1 := Scope (S1); S2 := Scope (S2); end loop; if S1 = Standard_Standard then Error_Msg_Sloc := Sloc (Id); Err_No := Clause2; else Error_Msg_Sloc := Sloc (Current_Use_Clause (T)); Err_No := Clause1; end if; end; end if; Error_Msg_NE -- CODEFIX ("& is already use-visible through previous " & "use_type_clause #??", Err_No, Id); -- Case where current use type clause and the use type -- clause for the type are not both at the compilation unit -- level. In this case we don't have location information. else Error_Msg_NE -- CODEFIX ("& is already use-visible through previous " & "use type clause??", Id, T); end if; end Use_Clause_Known; -- Here if Current_Use_Clause is not set for T, another case -- where we do not have the location information available. else Error_Msg_NE -- CODEFIX ("& is already use-visible through previous " & "use type clause??", Id, T); end if; -- The package where T is declared is already used elsif In_Use (Scope (T)) then Error_Msg_Sloc := Sloc (Current_Use_Clause (Scope (T))); Error_Msg_NE -- CODEFIX ("& is already use-visible through package use clause #??", Id, T); -- The current scope is the package where T is declared else Error_Msg_Node_2 := Scope (T); Error_Msg_NE -- CODEFIX ("& is already use-visible inside package &??", Id, T); end if; end if; end Use_One_Type; ---------------- -- Write_Info -- ---------------- procedure Write_Info is Id : Entity_Id := First_Entity (Current_Scope); begin -- No point in dumping standard entities if Current_Scope = Standard_Standard then return; end if; Write_Str ("========================================================"); Write_Eol; Write_Str (" Defined Entities in "); Write_Name (Chars (Current_Scope)); Write_Eol; Write_Str ("========================================================"); Write_Eol; if No (Id) then Write_Str ("-- none --"); Write_Eol; else while Present (Id) loop Write_Entity_Info (Id, " "); Next_Entity (Id); end loop; end if; if Scope (Current_Scope) = Standard_Standard then -- Print information on the current unit itself Write_Entity_Info (Current_Scope, " "); end if; Write_Eol; end Write_Info; -------- -- ws -- -------- procedure ws is S : Entity_Id; begin for J in reverse 1 .. Scope_Stack.Last loop S := Scope_Stack.Table (J).Entity; Write_Int (Int (S)); Write_Str (" === "); Write_Name (Chars (S)); Write_Eol; end loop; end ws; -------- -- we -- -------- procedure we (S : Entity_Id) is E : Entity_Id; begin E := First_Entity (S); while Present (E) loop Write_Int (Int (E)); Write_Str (" === "); Write_Name (Chars (E)); Write_Eol; Next_Entity (E); end loop; end we; end Sem_Ch8;
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" with Ada.Strings.UTF_Encoding.Strings; with Ada.Strings.UTF_Encoding.Wide_Strings; with Ada.Strings.UTF_Encoding.Wide_Wide_Strings; with Text.Builder; package body Yaml.Lexer.Evaluation is ----------------------------------------------------------------------------- -- constant UTF-8 strings that may be generated from escape sequences ----------------------------------------------------------------------------- function Next_Line return Ada.Strings.UTF_Encoding.UTF_8_String is (Ada.Strings.UTF_Encoding.Strings.Encode ("" & Character'Val (16#85#))); function Non_Breaking_Space return Ada.Strings.UTF_Encoding.UTF_8_String is (Ada.Strings.UTF_Encoding.Strings.Encode ("" & Character'Val (16#A0#))); function Line_Separator return Ada.Strings.UTF_Encoding.UTF_8_String is (Ada.Strings.UTF_Encoding.Wide_Strings.Encode ("" & Wide_Character'Val (16#2028#))); function Paragraph_Separator return Ada.Strings.UTF_Encoding.UTF_8_String is (Ada.Strings.UTF_Encoding.Wide_Strings.Encode ("" & Wide_Character'Val (16#2029#))); ----------------------------------------------------------------------------- -- implementation ----------------------------------------------------------------------------- procedure Read_Plain_Scalar (L : in out Instance; T : out Token) is Target : Text.Builder.Reference := Text.Builder.Create (L.Pool); After_Newline_State : constant State_Type := (if L.Flow_Depth + L.Annotation_Depth = 0 then Line_Indentation'Access else Flow_Line_Indentation'Access); Line_Start_Pos : Positive; begin L.Seen_Multiline := False; Start_Token (L); if L.Proposed_Indentation /= -1 then L.Indentation := L.Proposed_Indentation; L.Proposed_Indentation := -1; end if; T := (Start_Pos => L.Token_Start_Mark, End_Pos => <>, Kind => Plain_Scalar); Multiline_Loop : loop Line_Start_Pos := L.Pos - 1; Inline_Loop : loop L.Cur := Next (L); case L.Cur is when ' ' => T.End_Pos := Cur_Mark (L); declare Space_Start : constant Positive := L.Pos - 1; begin Space_Loop : loop L.Cur := Next (L); case L.Cur is when Line_Feed | Carriage_Return => Target.Append (L.Buffer (Line_Start_Pos .. Space_Start - 1)); exit Inline_Loop; when End_Of_Input => Target.Append (L.Buffer (Line_Start_Pos .. Space_Start - 1)); L.State := Stream_End'Access; exit Multiline_Loop; when '#' => Target.Append (L.Buffer (Line_Start_Pos .. Space_Start - 1)); L.State := Expect_Line_End'Access; exit Multiline_Loop; when ':' => if not Next_Is_Plain_Safe (L) then Target.Append (L.Buffer (Line_Start_Pos .. Space_Start - 1)); L.State := Inside_Line'Access; exit Multiline_Loop; end if; exit Space_Loop; when Flow_Indicator => if L.Flow_Depth + L.Annotation_Depth > 0 then Target.Append (L.Buffer (Line_Start_Pos .. Space_Start - 1)); L.State := Inside_Line'Access; exit Multiline_Loop; end if; exit Space_Loop; when ')' => if L.Annotation_Depth > 0 then Target.Append (L.Buffer (Line_Start_Pos .. Space_Start - 1)); L.State := Inside_Line'Access; exit Multiline_Loop; end if; exit Space_Loop; when ' ' => null; when others => exit Space_Loop; end case; end loop Space_Loop; end; when ':' => if not Next_Is_Plain_Safe (L) then Target.Append (L.Buffer (Line_Start_Pos .. L.Pos - 2)); T.End_Pos := Cur_Mark (L); L.State := Inside_Line'Access; exit Multiline_Loop; end if; when Flow_Indicator => if L.Flow_Depth + L.Annotation_Depth > 0 then Target.Append (L.Buffer (Line_Start_Pos .. L.Pos - 2)); T.End_Pos := Cur_Mark (L); L.State := Inside_Line'Access; exit Multiline_Loop; end if; when ')' => if L.Annotation_Depth > 0 then Target.Append (L.Buffer (Line_Start_Pos .. L.Pos - 2)); T.End_Pos := Cur_Mark (L); L.State := Inside_Line'Access; exit Multiline_Loop; end if; when Line_Feed | Carriage_Return => Target.Append (L.Buffer (Line_Start_Pos .. L.Pos - 2)); T.End_Pos := Cur_Mark (L); exit Inline_Loop; when End_Of_Input => Target.Append (L.Buffer (Line_Start_Pos .. L.Pos - 2)); if L.Pos /= L.Line_Start then T.End_Pos := Cur_Mark (L); end if; L.State := Stream_End'Access; exit Multiline_Loop; when others => null; end case; end loop Inline_Loop; End_Line (L); declare Newlines : Positive := 1; begin Newline_Loop : loop case Start_Line (L) is when Content => if L.Pos - L.Line_Start - 1 <= L.Indentation then L.State := After_Newline_State; exit Multiline_Loop; end if; exit Newline_Loop; when Directives_End_Marker => L.State := Line_Dir_End'Access; exit Multiline_Loop; when Document_End_Marker => L.State := Line_Doc_End'Access; exit Multiline_Loop; when Stream_End => exit Multiline_Loop; when Comment => End_Line (L); L.State := Line_Start'Access; exit Multiline_Loop; when Newline => End_Line (L); end case; Newlines := Newlines + 1; end loop Newline_Loop; if (L.Cur = ':' and then not Next_Is_Plain_Safe (L)) or else L.Cur = '#' or else (L.Cur in Flow_Indicator and L.Flow_Depth + L.Annotation_Depth > 0) or else (L.Cur = ')' and L.Annotation_Depth > 0) then L.State := After_Newline_State; exit Multiline_Loop; end if; L.Seen_Multiline := True; if Newlines = 1 then Target.Append (' '); else Target.Append ((1 .. Newlines - 1 => Line_Feed)); end if; end; end loop Multiline_Loop; L.Value := Target.Lock; end Read_Plain_Scalar; procedure Process_Quoted_Whitespace (L : in out Instance; Init : Natural; Target : in out Text.Builder.Reference) is Newlines : Natural := Init; First_Space : constant Positive := L.Pos - 1; begin loop case L.Cur is when ' ' => null; when Line_Feed => Handle_LF (L); L.Cur := L.Next; exit; when Carriage_Return => Handle_CR (L); L.Cur := L.Next; exit; when others => Target.Append (L.Buffer (First_Space .. L.Pos - 2)); return; end case; L.Cur := Next (L); end loop; L.Seen_Multiline := True; loop case Start_Line (L) is when Content | Comment => exit; when Directives_End_Marker => raise Lexer_Error with "Illegal '---' within quoted scalar"; when Document_End_Marker => raise Lexer_Error with "Illegal '...' within quoted scalar"; when Newline => End_Line (L); when Stream_End => raise Lexer_Error with "Unexpected end of input (quoted string not closed)"; end case; Newlines := Newlines + 1; end loop; if Newlines = 0 then null; elsif Newlines = 1 then Target.Append (' '); else Target.Append ((1 .. Newlines - 1 => Line_Feed)); end if; end Process_Quoted_Whitespace; procedure Read_Single_Quoted_Scalar (L : in out Instance; T : out Token) is Target : Text.Builder.Reference := Text.Builder.Create (L.Pool); Literal_Start : Positive; begin L.Seen_Multiline := False; Start_Token (L); if L.Proposed_Indentation /= -1 then L.Indentation := L.Proposed_Indentation; L.Proposed_Indentation := -1; end if; Literal_Start := L.Pos; L.Cur := Next (L); loop case L.Cur is when End_Of_Input => raise Lexer_Error with "Unexpected end of input (quoted string not closed)"; when ''' => Target.Append (L.Buffer (Literal_Start .. L.Pos - 2)); L.Cur := Next (L); if L.Cur = ''' then Target.Append ('''); Literal_Start := L.Pos; L.Cur := Next (L); else exit; end if; when ' ' | Line_Feed | Carriage_Return => Target.Append (L.Buffer (Literal_Start .. L.Pos - 2)); Process_Quoted_Whitespace (L, 1, Target); Literal_Start := L.Pos - 1; when others => L.Cur := Next (L); end case; end loop; T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Single_Quoted_Scalar); L.Value := Target.Lock; end Read_Single_Quoted_Scalar; subtype Hex_Code_Point is Natural range 0 .. 16#1FFFFF#; procedure Read_Hex_Sequence (L : in out Instance; Length : Positive; Target : in out Text.Builder.Reference) is Char_Pos : Hex_Code_Point := 0; Start_Pos : constant Positive := L.Pos; begin -- first, we make sure that this is a valid escape sequence. it is -- important to not calculate its value directly because that may lead -- to an overflow before we checked that the escape sequence is -- syntactically correct. We only want to report that the value is out of -- range if it is a valid escape sequence. for I in 0 .. Length - 1 loop if not (L.Buffer (Start_Pos + I) in Digit | 'a' .. 'f' | 'A' .. 'F') then raise Lexer_Error with "Invalid character in hex escape sequence: " & Escaped (L.Buffer (Start_Pos + I)); end if; end loop; for Exponent in reverse 0 .. Length - 1 loop L.Cur := Next (L); case L.Cur is when Digit => Char_Pos := Char_Pos + (16 ** Exponent) * (Character'Pos (L.Cur) - Character'Pos ('0')); when 'a' .. 'f' => Char_Pos := Char_Pos + (16 ** Exponent) * (Character'Pos (L.Cur) - Character'Pos ('a') + 10); when 'A' .. 'F' => Char_Pos := Char_Pos + (16 ** Exponent) * (Character'Pos (L.Cur) - Character'Pos ('A') + 10); when others => null; -- cannot happen because of the check above end case; end loop; Target.Append (Ada.Strings.UTF_Encoding.Wide_Wide_Strings.Encode ( "" & Wide_Wide_Character'Val (Char_Pos))); exception when Constraint_Error => raise Lexer_Error with "Invalid hex escape sequence (value too large): " & L.Buffer (Start_Pos .. Start_Pos + Length - 1); end Read_Hex_Sequence; procedure Read_Double_Quoted_Scalar (L : in out Instance; T : out Token) is Target : Text.Builder.Reference := Text.Builder.Create (L.Pool); Literal_Start : Positive; begin L.Seen_Multiline := False; Start_Token (L); if L.Proposed_Indentation /= -1 then L.Indentation := L.Proposed_Indentation; L.Proposed_Indentation := -1; end if; Literal_Start := L.Pos; L.Cur := Next (L); loop <<Handle_Char>> case L.Cur is when End_Of_Input => raise Lexer_Error with "Unexpected end of input (quoted string not closed)"; when '\' => Target.Append (L.Buffer (Literal_Start .. L.Pos - 2)); L.Cur := Next (L); Literal_Start := L.Pos; case L.Cur is when '0' => Target.Append (Character'Val (0)); when 'a' => Target.Append (Character'Val (7)); when 'b' => Target.Append (Character'Val (8)); when 't' | Character'Val (9) => Target.Append (Character'Val (9)); when 'n' => Target.Append (Line_Feed); when 'v' => Target.Append (Character'Val (11)); when 'f' => Target.Append (Character'Val (12)); when 'r' => Target.Append (Carriage_Return); when 'e' => Target.Append (Character'Val (27)); when ' ' | '"' | '/' | '\' => Target.Append (L.Cur); when 'N' => Target.Append (Next_Line); when '_' => Target.Append (Non_Breaking_Space); when 'L' => Target.Append (Line_Separator); when 'P' => Target.Append (Paragraph_Separator); when 'x' => Read_Hex_Sequence (L, 2, Target); Literal_Start := L.Pos; when 'u' => Read_Hex_Sequence (L, 4, Target); Literal_Start := L.Pos; when 'U' => Read_Hex_Sequence (L, 8, Target); Literal_Start := L.Pos; when Line_Feed | Carriage_Return => Process_Quoted_Whitespace (L, 0, Target); Literal_Start := L.Pos - 1; goto Handle_Char; when others => raise Lexer_Error with "Illegal character in escape sequence: " & Escaped (L.Cur); end case; when '"' => Target.Append (L.Buffer (Literal_Start .. L.Pos - 2)); exit; when ' ' | Line_Feed | Carriage_Return => Target.Append (L.Buffer (Literal_Start .. L.Pos - 2)); Process_Quoted_Whitespace (L, 1, Target); Literal_Start := L.Pos - 1; goto Handle_Char; when others => null; end case; L.Cur := Next (L); end loop; L.Cur := Next (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Double_Quoted_Scalar); L.Value := Target.Lock; end Read_Double_Quoted_Scalar; procedure Read_Block_Scalar (L : in out Instance; T : out Token) is type Chomp_Style is (Clip, Strip, Keep); Chomp : Chomp_Style := Clip; Indent : Natural := 0; Separation_Lines : Natural := 0; Content_Start : Positive; Target : Text.Builder.Reference := Text.Builder.Create (L.Pool); begin Start_Token (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => <>, Kind => (if L.Cur = '>' then Folded_Scalar else Literal_Scalar)); -- header loop L.Cur := Next (L); case L.Cur is when '+' => if Chomp /= Clip then raise Lexer_Error with "Multiple chomping indicators!"; end if; Chomp := Keep; when '-' => if Chomp /= Clip then raise Lexer_Error with "Multiple chomping indicators!"; end if; Chomp := Strip; when '1' .. '9' => if Indent /= 0 then raise Lexer_Error with "Multiple indentation indicators!"; end if; Indent := Natural'Max (0, L.Indentation) + Character'Pos (L.Cur) - Character'Pos ('0'); when ' ' => while L.Cur = ' ' loop L.Cur := Next (L); end loop; if not (L.Cur in Comment_Or_Line_End) then raise Lexer_Error with "Illegal character after block scalar header: " & Escaped (L.Cur); end if; exit; when Line_End => exit; when others => raise Lexer_Error with "Illegal character in block scalar header: " & Escaped (L.Cur); end case; end loop; End_Line (L); -- determining indentation and leading empty lines declare Max_Leading_Spaces : Natural := 0; begin loop if Indent = 0 then while L.Cur = ' ' loop L.Cur := Next (L); end loop; else Max_Leading_Spaces := L.Line_Start + Indent; while L.Cur = ' ' and L.Pos <= Max_Leading_Spaces loop L.Cur := Next (L); end loop; end if; case L.Cur is when Line_Feed | Carriage_Return => T.End_Pos := Cur_Mark (L); Max_Leading_Spaces := Natural'Max (Max_Leading_Spaces, L.Pos - 1 - L.Line_Start); End_Line (L); Separation_Lines := Separation_Lines + 1; when End_Of_Input => L.State := Stream_End'Access; goto End_Of_Input_Target; when others => if Indent = 0 then Indent := L.Pos - L.Line_Start - 1; if Indent <= Indentation_Type'Max (0, L.Indentation) then L.State := Line_Indentation'Access; goto Finalize; elsif Indent < Max_Leading_Spaces then raise Lexer_Error with "Leading all-spaces line contains too many spaces."; end if; elsif L.Pos - L.Line_Start - 1 < Indent then goto Finalize; end if; exit; end case; end loop; if Separation_Lines > 0 then Target.Append ((1 .. Separation_Lines => Line_Feed)); end if; end; -- read block scalar content Block_Content : loop -- content of line Content_Start := L.Pos - 1; while not (L.Cur in Line_End) loop L.Cur := Next (L); end loop; Target.Append (L.Buffer (Content_Start .. L.Pos - 2)); Separation_Lines := 0; if L.Cur = End_Of_Input then L.State := Stream_End'Access; goto End_Of_Input_Target; end if; Separation_Lines := Separation_Lines + 1; T.End_Pos := Cur_Mark (L); End_Line (L); -- empty lines and indentation of next line loop declare Indent_Pos : constant Natural := L.Line_Start + Indent; begin while L.Cur = ' ' and L.Pos - 1 < Indent_Pos loop L.Cur := Next (L); end loop; case L.Cur is when Carriage_Return | Line_Feed => T.End_Pos := Cur_Mark (L); Separation_Lines := Separation_Lines + 1; End_Line (L); when End_Of_Input => L.State := Stream_End'Access; goto End_Of_Input_Target; when others => if L.Pos - 1 < Indent_Pos then exit Block_Content; else exit; end if; end case; end; end loop; -- line folding if T.Kind = Literal_Scalar then Target.Append ((1 .. Separation_Lines => Line_Feed)); elsif Separation_Lines = 1 then Target.Append (' '); else Target.Append ((1 .. Separation_Lines - 1 => Line_Feed)); end if; end loop Block_Content; if L.Pos - L.Line_Start - 1 > Indentation_Type'Max (0, L.Indentation) then if L.Cur = '#' then L.State := Expect_Line_End'Access; else raise Lexer_Error with "This line at " & Escaped (L.Cur) & " is less indented than necessary." & L.Cur_Line'Img; end if; elsif L.Pos = L.Line_Start + 1 then L.State := Line_Start'Access; else L.State := Line_Indentation'Access; end if; <<Finalize>> T.End_Pos := Cur_Mark (L); goto Finish; <<End_Of_Input_Target>> -- if we encounter the stream end directly after a newline character, -- we must have stored the T.End_Pos beforehand because we cannot -- calculate it back (we do not know how long the recent line was). if L.Pos /= L.Line_Start + 1 then T.End_Pos := Cur_Mark (L); -- the generated End_Pos is *after* the stream end char, which is one -- too far; compensate here. T.End_Pos.Index := T.End_Pos.Index - 1; T.End_Pos.Column := T.End_Pos.Column - 1; end if; <<Finish>> T.End_Pos := Cur_Mark (L); -- handling trailing empty lines case Chomp is when Strip => null; when Clip => if Target.Length > 0 then Target.Append (Line_Feed); end if; when Keep => Target.Append ((1 .. Separation_Lines => Line_Feed)); end case; L.Value := Target.Lock; end Read_Block_Scalar; procedure Read_URI (L : in out Instance; Restricted : Boolean) is Target : Text.Builder.Reference := Text.Builder.Create (L.Pool); End_With_Space : constant Boolean := L.Cur /= '<'; Literal_Start : Positive; begin if End_With_Space then if (not Restricted) and L.Cur in '[' | ']' | ',' then raise Lexer_Error with "Flow indicator cannot start tag prefix"; end if; Literal_Start := L.Pos - 1; else Literal_Start := L.Pos; L.Cur := Next (L); end if; loop case L.Cur is when Space_Or_Line_End => if End_With_Space then Target.Append (L.Buffer (Literal_Start .. L.Pos - 2)); exit; else raise Lexer_Error with "Unclosed verbatim tag"; end if; when '%' => Target.Append (L.Buffer (Literal_Start .. L.Pos - 2)); Read_Hex_Sequence (L, 2, Target); Literal_Start := L.Pos; when Tag_Char => null; when '[' | ']' | ',' => if Restricted then Target.Append (L.Buffer (Literal_Start .. L.Pos - 2)); exit; end if; when '!' => if Restricted then raise Lexer_Error with "Illegal '!' in tag suffix!"; end if; when '>' => if End_With_Space then raise Lexer_Error with "Illegal character in URI: "">"""; else Target.Append (L.Buffer (Literal_Start .. L.Pos - 2)); L.Cur := Next (L); exit; end if; when others => raise Lexer_Error with "Illegal character in URI: " & Escaped (L.Cur); end case; L.Cur := Next (L); end loop; L.Value := Target.Lock; end Read_URI; end Yaml.Lexer.Evaluation;