content
stringlengths
23
1.05M
-- Ada_GUI implementation based on Gnoga. Adapted 2021 -- -- -- GNOGA - The GNU Omnificent GUI for Ada -- -- -- -- G N O G A . C L I E N T . S T O R A G E -- -- -- -- B o d y -- -- -- -- -- -- Copyright (C) 2014 David Botton -- -- -- -- 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 -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are -- -- granted additional permissions described in the GCC Runtime Library -- -- Exception, version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- 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. -- -- -- -- For more information please go to http://www.gnoga.com -- ------------------------------------------------------------------------------ with Ada_GUI.Gnoga.Server.Connection; package body Ada_GUI.Gnoga.Client_Storage is -- One local and one session storage is available across an entire -- scheme://domain:port. Give that there is no point in supporting access -- to non-Gnoga iFrames or Popups since if they are not form the same -- scheme://domain:port the browser security would not allow access -- anyways. procedure Execute (Storage : in out Storage_Type'Class; Method : in String); function Execute (Storage : Storage_Type'Class; Method : String) return String; -- Execute access to Storage on its Connection_ID ------------- -- Execute -- ------------- procedure Execute (Storage : in out Storage_Type'Class; Method : in String) is Message_Script : constant String := Storage.Script_Accessor & "." & Method; begin if Storage.Connection_ID = Gnoga.No_Connection then raise Program_Error with "Use of Storage without Connection"; end if; Gnoga.Server.Connection.Execute_Script (ID => Storage.Connection_ID, Script => Message_Script); end Execute; function Execute (Storage : Storage_Type'Class; Method : String) return String is Message_Script : constant String := Storage.Script_Accessor & "." & Method; begin if Storage.Connection_ID = Gnoga.No_Connection then raise Program_Error with "Use of Storage without Connection"; end if; return Gnoga.Server.Connection.Execute_Script (ID => Storage.Connection_ID, Script => Message_Script); end Execute; ------------ -- Length -- ------------ function Length (Storage : Storage_Type) return Natural is begin return Natural'Value (Execute (Storage, "length")); end Length; --------- -- Key -- --------- function Key (Storage : Storage_Type; Value : Positive) return String is JS_Value : constant Natural := Value - 1; begin return Execute (Storage, "key(" & JS_Value'Img & ")"); end Key; --------- -- Set -- --------- procedure Set (Storage : in out Storage_Type; Name, Value : String) is begin Execute (Storage, "setItem ('" & Escape_Quotes (Name) & "','" & Escape_Quotes (Value) & "')"); end Set; --------- -- Get -- --------- function Get (Storage : Storage_Type; Name : String) return String is begin return Execute (Storage, "getItem('" & Escape_Quotes (Name) & "')"); end Get; --------------------- -- Script_Accessor -- --------------------- function Script_Accessor (Storage : Storage_Type) return String is begin raise Program_Error with "Use Session_Storage_Type or Local_Storage_Type"; return ""; end Script_Accessor; ------------------- -- Local_Storage -- ------------------- function Local_Storage (Object : Gnoga.Gui.Base_Type'Class) return Local_Storage_Type is begin return Local_Storage_Type'(Connection_ID => Object.Connection_ID); end Local_Storage; --------------------- -- Script_Accessor -- --------------------- overriding function Script_Accessor (Storage : Local_Storage_Type) return String is pragma Unreferenced (Storage); begin return "localStorage"; end Script_Accessor; --------------------- -- Session_Storage -- --------------------- function Session_Storage (Object : Gnoga.Gui.Base_Type'Class) return Session_Storage_Type is begin return Session_Storage_Type'(Connection_ID => Object.Connection_ID); end Session_Storage; --------------------- -- Script_Accessor -- --------------------- overriding function Script_Accessor (Storage : Session_Storage_Type) return String is pragma Unreferenced (Storage); begin return "sessionStorage"; end Script_Accessor; end Ada_GUI.Gnoga.Client_Storage;
package body ENGLISH_SUPPORT_PACKAGE is --use EWDS_DIRECT_IO; use TEXT_IO; package body EWDS_RECORD_IO is package INTEGER_IO is new TEXT_IO.INTEGER_IO(INTEGER); use PART_OF_SPEECH_TYPE_IO; use FREQUENCY_TYPE_IO; use TEXT_IO; use INTEGER_IO; SPACER : CHARACTER := ' '; NWIDTH : constant := 5; procedure GET(F : in TEXT_IO.FILE_TYPE; P : out EWDS_RECORD) is begin GET(F, P.W); GET(F, SPACER); GET(F, P.AUX); GET(F, SPACER); GET(F, P.N); GET(F, SPACER); GET(F, P.POFS); GET(F, SPACER); GET(F, P.FREQ); GET(F, SPACER); GET(F, P.SEMI); GET(F, SPACER); GET(F, P.KIND); GET(F, SPACER); GET(F, P.RANK); end GET; procedure GET(P : out EWDS_RECORD) is begin GET(P.W); GET(SPACER); GET(P.AUX); GET(SPACER); GET(P.N); GET(SPACER); GET(P.POFS); GET(SPACER); GET(P.FREQ); GET(SPACER); GET(P.SEMI); GET(SPACER); GET(P.KIND); GET(SPACER); GET(P.RANK); end GET; procedure PUT(F : in TEXT_IO.FILE_TYPE; P : in EWDS_RECORD) is begin PUT(F, P.W); PUT(F, ' '); PUT(F, P.AUX); PUT(F, ' '); PUT(F, P.N); PUT(F, ' '); PUT(F, P.POFS); PUT(F, ' '); PUT(F, P.FREQ); PUT(F, ' '); PUT(F, P.SEMI, NWIDTH); PUT(F, ' '); PUT(F, P.KIND, NWIDTH); PUT(F, ' '); PUT(F, P.RANK, NWIDTH); end PUT; procedure PUT(P : in EWDS_RECORD) is begin PUT(P.W); PUT(' '); PUT(P.AUX); PUT(' '); PUT(P.N); PUT(' '); PUT(P.POFS); PUT(' '); PUT(P.FREQ); PUT(' '); PUT(P.SEMI, NWIDTH); PUT(' '); PUT(P.KIND, NWIDTH); PUT(' '); PUT(P.RANK, NWIDTH); end PUT; procedure GET(S : in STRING; P : out EWDS_RECORD; LAST : out INTEGER) is L : INTEGER := S'FIRST - 1; begin P.W := S(L+1..L+EWORD_SIZE); L := L + EWORD_SIZE + 1; P.AUX := S(L+1..L+AUX_WORD_SIZE); L := L + AUX_WORD_SIZE + 1; GET(S(L+1..S'LAST), P.N, L); L := L + 1; GET(S(L+1..S'LAST), P.POFS, L); L := L + 1; GET(S(L+1..S'LAST), P.FREQ, L); L := L + 1; GET(S(L+1..S'LAST), P.SEMI, L); L := L + 1; GET(S(L+1..S'LAST), P.KIND, L); L := L + 1; GET(S(L+1..S'LAST), P.RANK, LAST); end GET; procedure PUT(S : out STRING; P : in EWDS_RECORD) is L : INTEGER := S'FIRST - 1; M : INTEGER := 0; begin M := L + EWORD_SIZE; S(L+1..M) := P.W; L := M + 1; S(L) := ' '; M := L + AUX_WORD_SIZE; S(L+1..M) := P.AUX; L := M + 1; S(L) := ' '; M := L + LINE_NUMBER_WIDTH; PUT(S(L+1..M), P.N); S(L) := ' '; M := L + PART_OF_SPEECH_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.POFS); S(L) := ' '; M := L + FREQUENCY_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.FREQ); S(L) := ' '; M := L + PRIORITY_WIDTH; PUT(S(L+1..M), P.SEMI, NWIDTH); S(L) := ' '; M := L + PRIORITY_WIDTH; PUT(S(L+1..M), P.KIND, NWIDTH); S(L) := ' '; M := L + PRIORITY_WIDTH; PUT(S(L+1..M), P.RANK, NWIDTH); S(M+1..S'LAST) := (others => ' '); end PUT; end EWDS_RECORD_IO; end ENGLISH_SUPPORT_PACKAGE;
with Gtk.Window; use Gtk.Window; with Gtk.Widget; use Gtk.Widget; with Gtk.Handlers; with Gtk.Main; procedure Windowed_Application is Window : Gtk_Window; package Handlers is new Gtk.Handlers.Callback (Gtk_Widget_Record); package Return_Handlers is new Gtk.Handlers.Return_Callback (Gtk_Widget_Record, Boolean); function Delete_Event (Widget : access Gtk_Widget_Record'Class) return Boolean is begin return False; end Delete_Event; procedure Destroy (Widget : access Gtk_Widget_Record'Class) is begin Gtk.Main.Main_Quit; end Destroy; begin Gtk.Main.Init; Gtk.Window.Gtk_New (Window); Return_Handlers.Connect ( Window, "delete_event", Return_Handlers.To_Marshaller (Delete_Event'Access) ); Handlers.Connect ( Window, "destroy", Handlers.To_Marshaller (Destroy'Access) ); Show (Window); Gtk.Main.Main; end Windowed_Application;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2017, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- This demo uses four channels of a single timer to make four LEDs blink -- at four different rates, without requiring periodic tasks to drive them. -- Because it uses four LEDs it runs on the STM32F4_Discovery board. Using -- a board with fewer LEDs is possible but less interesting. In that case, -- change the number of channels driven (and interrupts generated) to match -- the number of LEDs available. -- The file declares the interrupt handler and the timer values for the -- demonstration. with Ada.Interrupts.Names; use Ada.Interrupts.Names; with STM32; use STM32; with STM32.Device; use STM32.Device; with STM32.Timers; use STM32.Timers; with HAL; use HAL; package STM32F4_Timer_Interrupts is -- These values are set so that we get the four LEDs blinking at the -- desired rates indicated below. The specific LEDs (colors) associated -- with the rates are arbitrary (i.e., different LEDs could be associated -- with the channels). By controlling the rates at which the channels -- generate the interrupts we control the rates at which the LEDs blink. SystemCoreClock : constant UInt32 := System_Clock_Frequencies.SYSCLK; Prescaler : constant UInt16 := UInt16 (((SystemCoreClock / 2) / 6000) - 1); Channel_1_Period : constant := 6000 - 1; -- 1 sec Channel_2_Period : constant := ((Channel_1_Period + 1) / 2) - 1; -- 1/2 sec Channel_3_Period : constant := ((Channel_2_Period + 1) / 2) - 1; -- 1/4 sec Channel_4_Period : constant := ((Channel_3_Period + 1) / 2) - 1; -- 1/8 sec -- A convenience array for the sake of using a loop to configure the timer -- channels Channel_Periods : constant array (Timer_Channel) of UInt32 := (Channel_1_Period, Channel_2_Period, Channel_3_Period, Channel_4_Period); -- The interrupt handling PO. There is no client API so there is nothing -- declared in the visible part. This declaration could reasonably be -- moved to the package body, but we leave it here to emphasize the -- design approach using interrupts. protected Handler is pragma Interrupt_Priority; private -- Whenever the timer interrupt occurs, the handler determines which -- channel has caused the interrupt and toggles the corresponding LED. -- It then increments the channel's compare value so that the timer -- will generate another interrupt on that channel after the required -- interval specific to that channel. procedure IRQ_Handler; pragma Attach_Handler (IRQ_Handler, TIM3_Interrupt); end Handler; end STM32F4_Timer_Interrupts;
package HIL.Devices is type Device_Type_SPI is (NONE); type Device_Type_GPIO is (NONE); type Device_Type_I2C is (NONE); type Device_Type_UART is (NONE); end HIL.Devices;
with AUnit.Test_Cases; with AUnit.Test_Fixtures; with AUnit.Test_Suites; with GNAT.Source_Info; private with Ada.Finalization; private with Ada.Strings.Unbounded; generic type Fixture is new AUnit.Test_Fixtures.Test_Fixture with private; package AUnit.Suite_Builders_Generic is type Builder is tagged limited private; -- -- Simplifies the construction of a test suite for an AUnit Test Fixture by -- wrapping the Test_Caller. -- -- The builder ensures all tests are added with a consistent naming -- convention including the suite name as a prefix. function To_Suite (This : in Builder) return not null AUnit.Test_Suites.Access_Test_Suite; -- -- Returns the constructed test suite. procedure Set_Suite_Name (This : in out Builder; Name : in String); -- -- Override the default suite name. -- Normally this operation should not need to be used as the suite name is -- derived from the context of the generic instantiation. procedure Add (This : in out Builder; Name : in String; Test : access procedure (T : in out Fixture)); -- -- Add a single test operation to the suite. procedure Add (This : in out Builder; Test : not null access AUnit.Test_Cases.Test_Case'Class); -- -- Add a test case to the suite. -- Exceptions: None procedure Add (This : in out Builder; Suite : not null access AUnit.Test_Suites.Test_Suite'Class); -- -- Adds a nested test suite. private type Builder is limited new Ada.Finalization.Limited_Controlled with record M_Prefix : Ada.Strings.Unbounded.Unbounded_String := Ada.Strings.Unbounded.To_Unbounded_String (GNAT.Source_Info.Enclosing_Entity); M_Suite : AUnit.Test_Suites.Access_Test_Suite; end record; overriding procedure Initialize (This : in out Builder); end AUnit.Suite_Builders_Generic;
-- SFML - Simple and Fast Multimedia Library -- Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) -- This software is provided 'as-is', without any express or implied warranty. -- In no event will the authors be held liable for any damages arising from the use of this software. -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it freely, -- subject to the following restrictions: -- 1. The origin of this software must not be misrepresented; -- you must not claim that you wrote the original software. -- If you use this software in a product, an acknowledgment -- in the product documentation would be appreciated but is not required. -- 2. Altered source versions must be plainly marked as such, -- and must not be misrepresented as being the original software. -- 3. This notice may not be removed or altered from any source distribution. --////////////////////////////////////////////////////////// --////////////////////////////////////////////////////////// with Sf.System.Vector2; with Sf.Graphics.Transform; with Sf.Graphics.Rect; with Sf.Graphics.Color; package Sf.Graphics.RectangleShape is --////////////////////////////////////////////////////////// --/ @brief Create a new rectangle shape --/ --/ @return A new sfRectangleShape object, or NULL if it failed --/ --////////////////////////////////////////////////////////// function create return sfRectangleShape_Ptr; --////////////////////////////////////////////////////////// --/ @brief Copy an existing rectangle shape --/ --/ @param shape Shape to copy --/ --/ @return Copied object --/ --////////////////////////////////////////////////////////// function copy (shape : sfRectangleShape_Ptr) return sfRectangleShape_Ptr; --////////////////////////////////////////////////////////// --/ @brief Destroy an existing rectangle shape --/ --/ @param shape Shape to delete --/ --////////////////////////////////////////////////////////// procedure destroy (shape : sfRectangleShape_Ptr); --////////////////////////////////////////////////////////// --/ @brief Set the position of a rectangle shape --/ --/ This function completely overwrites the previous position. --/ See sfRectangleShape_move to apply an offset based on the previous position instead. --/ The default position of a circle Shape object is (0, 0). --/ --/ @param shape Shape object --/ @param position New position --/ --////////////////////////////////////////////////////////// procedure setPosition (shape : sfRectangleShape_Ptr; position : Sf.System.Vector2.sfVector2f); --////////////////////////////////////////////////////////// --/ @brief Set the orientation of a rectangle shape --/ --/ This function completely overwrites the previous rotation. --/ See sfRectangleShape_rotate to add an angle based on the previous rotation instead. --/ The default rotation of a circle Shape object is 0. --/ --/ @param shape Shape object --/ @param angle New rotation, in degrees --/ --////////////////////////////////////////////////////////// procedure setRotation (shape : sfRectangleShape_Ptr; angle : float); --////////////////////////////////////////////////////////// --/ @brief Set the scale factors of a rectangle shape --/ --/ This function completely overwrites the previous scale. --/ See sfRectangleShape_scale to add a factor based on the previous scale instead. --/ The default scale of a circle Shape object is (1, 1). --/ --/ @param shape Shape object --/ @param scale New scale factors --/ --////////////////////////////////////////////////////////// procedure setScale (shape : sfRectangleShape_Ptr; scale : Sf.System.Vector2.sfVector2f); --////////////////////////////////////////////////////////// --/ @brief Set the local origin of a rectangle shape --/ --/ The origin of an object defines the center point for --/ all transformations (position, scale, rotation). --/ The coordinates of this point must be relative to the --/ top-left corner of the object, and ignore all --/ transformations (position, scale, rotation). --/ The default origin of a circle Shape object is (0, 0). --/ --/ @param shape Shape object --/ @param origin New origin --/ --////////////////////////////////////////////////////////// procedure setOrigin (shape : sfRectangleShape_Ptr; origin : Sf.System.Vector2.sfVector2f); --////////////////////////////////////////////////////////// --/ @brief Get the position of a rectangle shape --/ --/ @param shape Shape object --/ --/ @return Current position --/ --////////////////////////////////////////////////////////// function getPosition (shape : sfRectangleShape_Ptr) return Sf.System.Vector2.sfVector2f; --////////////////////////////////////////////////////////// --/ @brief Get the orientation of a rectangle shape --/ --/ The rotation is always in the range [0, 360]. --/ --/ @param shape Shape object --/ --/ @return Current rotation, in degrees --/ --////////////////////////////////////////////////////////// function getRotation (shape : sfRectangleShape_Ptr) return float; --////////////////////////////////////////////////////////// --/ @brief Get the current scale of a rectangle shape --/ --/ @param shape Shape object --/ --/ @return Current scale factors --/ --////////////////////////////////////////////////////////// function getScale (shape : sfRectangleShape_Ptr) return Sf.System.Vector2.sfVector2f; --////////////////////////////////////////////////////////// --/ @brief Get the local origin of a rectangle shape --/ --/ @param shape Shape object --/ --/ @return Current origin --/ --////////////////////////////////////////////////////////// function getOrigin (shape : sfRectangleShape_Ptr) return Sf.System.Vector2.sfVector2f; --////////////////////////////////////////////////////////// --/ @brief Move a rectangle shape by a given offset --/ --/ This function adds to the current position of the object, --/ unlike sfRectangleShape_setPosition which overwrites it. --/ --/ @param shape Shape object --/ @param offset Offset --/ --////////////////////////////////////////////////////////// procedure move (shape : sfRectangleShape_Ptr; offset : Sf.System.Vector2.sfVector2f); --////////////////////////////////////////////////////////// --/ @brief Rotate a rectangle shape --/ --/ This function adds to the current rotation of the object, --/ unlike sfRectangleShape_setRotation which overwrites it. --/ --/ @param shape Shape object --/ @param angle Angle of rotation, in degrees --/ --////////////////////////////////////////////////////////// procedure rotate (shape : sfRectangleShape_Ptr; angle : float); --////////////////////////////////////////////////////////// --/ @brief Scale a rectangle shape --/ --/ This function multiplies the current scale of the object, --/ unlike sfRectangleShape_setScale which overwrites it. --/ --/ @param shape Shape object --/ @param factors Scale factors --/ --////////////////////////////////////////////////////////// procedure scale (shape : sfRectangleShape_Ptr; factors : Sf.System.Vector2.sfVector2f); --////////////////////////////////////////////////////////// --/ @brief Get the combined transform of a rectangle shape --/ --/ @param shape shape object --/ --/ @return Transform combining the position/rotation/scale/origin of the object --/ --////////////////////////////////////////////////////////// function getTransform (shape : sfRectangleShape_Ptr) return Sf.Graphics.Transform.sfTransform; --////////////////////////////////////////////////////////// --/ @brief Get the inverse of the combined transform of a rectangle shape --/ --/ @param shape shape object --/ --/ @return Inverse of the combined transformations applied to the object --/ --////////////////////////////////////////////////////////// function getInverseTransform (shape : sfRectangleShape_Ptr) return Sf.Graphics.Transform.sfTransform; --////////////////////////////////////////////////////////// --/ @brief Change the source texture of a rectangle shape --/ --/ The @a texture argument refers to a texture that must --/ exist as long as the shape uses it. Indeed, the shape --/ doesn't store its own copy of the texture, but rather keeps --/ a pointer to the one that you passed to this function. --/ If the source texture is destroyed and the shape tries to --/ use it, the behaviour is undefined. --/ @a texture can be NULL to disable texturing. --/ If @a resetRect is true, the TextureRect property of --/ the shape is automatically adjusted to the size of the new --/ texture. If it is false, the texture rect is left unchanged. --/ --/ @param shape Shape object --/ @param texture New texture --/ @param resetRect Should the texture rect be reset to the size of the new texture? --/ --////////////////////////////////////////////////////////// procedure setTexture (shape : sfRectangleShape_Ptr; texture : sfTexture_Ptr; resetRect : sfBool); --////////////////////////////////////////////////////////// --/ @brief Set the sub-rectangle of the texture that a rectangle shape will display --/ --/ The texture rect is useful when you don't want to display --/ the whole texture, but rather a part of it. --/ By default, the texture rect covers the entire texture. --/ --/ @param shape Shape object --/ @param rect Rectangle defining the region of the texture to display --/ --////////////////////////////////////////////////////////// procedure setTextureRect (shape : sfRectangleShape_Ptr; rect : Sf.Graphics.Rect.sfIntRect); --////////////////////////////////////////////////////////// --/ @brief Set the fill color of a rectangle shape --/ --/ This color is modulated (multiplied) with the shape's --/ texture if any. It can be used to colorize the shape, --/ or change its global opacity. --/ You can use sfTransparent to make the inside of --/ the shape transparent, and have the outline alone. --/ By default, the shape's fill color is opaque white. --/ --/ @param shape Shape object --/ @param color New color of the shape --/ --////////////////////////////////////////////////////////// procedure setFillColor (shape : sfRectangleShape_Ptr; color : Sf.Graphics.Color.sfColor); --////////////////////////////////////////////////////////// --/ @brief Set the outline color of a rectangle shape --/ --/ You can use sfTransparent to disable the outline. --/ By default, the shape's outline color is opaque white. --/ --/ @param shape Shape object --/ @param color New outline color of the shape --/ --////////////////////////////////////////////////////////// procedure setOutlineColor (shape : sfRectangleShape_Ptr; color : Sf.Graphics.Color.sfColor); --////////////////////////////////////////////////////////// --/ @brief Set the thickness of a rectangle shape's outline --/ --/ This number cannot be negative. Using zero disables --/ the outline. --/ By default, the outline thickness is 0. --/ --/ @param shape Shape object --/ @param thickness New outline thickness --/ --////////////////////////////////////////////////////////// procedure setOutlineThickness (shape : sfRectangleShape_Ptr; thickness : float); --////////////////////////////////////////////////////////// --/ @brief Get the source texture of a rectangle shape --/ --/ If the shape has no source texture, a NULL pointer is returned. --/ The returned pointer is const, which means that you can't --/ modify the texture when you retrieve it with this function. --/ --/ @param shape Shape object --/ --/ @return Pointer to the shape's texture --/ --////////////////////////////////////////////////////////// function getTexture (shape : sfRectangleShape_Ptr) return sfTexture_Ptr; --////////////////////////////////////////////////////////// --/ @brief Get the sub-rectangle of the texture displayed by a rectangle shape --/ --/ @param shape Shape object --/ --/ @return Texture rectangle of the shape --/ --////////////////////////////////////////////////////////// function getTextureRect (shape : sfRectangleShape_Ptr) return Sf.Graphics.Rect.sfIntRect; --////////////////////////////////////////////////////////// --/ @brief Get the fill color of a rectangle shape --/ --/ @param shape Shape object --/ --/ @return Fill color of the shape --/ --////////////////////////////////////////////////////////// function getFillColor (shape : sfRectangleShape_Ptr) return Sf.Graphics.Color.sfColor; --////////////////////////////////////////////////////////// --/ @brief Get the outline color of a rectangle shape --/ --/ @param shape Shape object --/ --/ @return Outline color of the shape --/ --////////////////////////////////////////////////////////// function getOutlineColor (shape : sfRectangleShape_Ptr) return Sf.Graphics.Color.sfColor; --////////////////////////////////////////////////////////// --/ @brief Get the outline thickness of a rectangle shape --/ --/ @param shape Shape object --/ --/ @return Outline thickness of the shape --/ --////////////////////////////////////////////////////////// function getOutlineThickness (shape : sfRectangleShape_Ptr) return float; --////////////////////////////////////////////////////////// --/ @brief Get the total number of points of a rectangle shape --/ --/ @param shape Shape object --/ --/ @return Number of points of the shape --/ --////////////////////////////////////////////////////////// function getPointCount (shape : sfRectangleShape_Ptr) return sfSize_t; --////////////////////////////////////////////////////////// --/ @brief Get a point of a rectangle shape --/ --/ The result is undefined if @a index is out of the valid range. --/ --/ @param shape Shape object --/ @param index Index of the point to get, in range [0 .. getPointCount() - 1] --/ --/ @return Index-th point of the shape --/ --////////////////////////////////////////////////////////// function getPoint (shape : sfRectangleShape_Ptr; index : sfSize_t) return Sf.System.Vector2.sfVector2f; --////////////////////////////////////////////////////////// --/ @brief Set the size of a rectangle shape --/ --/ @param shape Shape object --/ @param size New size of the rectangle --/ --////////////////////////////////////////////////////////// procedure setSize (shape : sfRectangleShape_Ptr; size : Sf.System.Vector2.sfVector2f); --////////////////////////////////////////////////////////// --/ @brief Get the size of a rectangle shape --/ --/ @param shape Shape object --/ @return height Size of the rectangle --/ --////////////////////////////////////////////////////////// function getSize (shape : sfRectangleShape_Ptr) return Sf.System.Vector2.sfVector2f; --////////////////////////////////////////////////////////// --/ @brief Get the local bounding rectangle of a rectangle shape --/ --/ The returned rectangle is in local coordinates, which means --/ that it ignores the transformations (translation, rotation, --/ scale, ...) that are applied to the entity. --/ In other words, this function returns the bounds of the --/ entity in the entity's coordinate system. --/ --/ @param shape Shape object --/ --/ @return Local bounding rectangle of the entity --/ --////////////////////////////////////////////////////////// function getLocalBounds (shape : sfRectangleShape_Ptr) return Sf.Graphics.Rect.sfFloatRect; --////////////////////////////////////////////////////////// --/ @brief Get the global bounding rectangle of a rectangle shape --/ --/ The returned rectangle is in global coordinates, which means --/ that it takes in account the transformations (translation, --/ rotation, scale, ...) that are applied to the entity. --/ In other words, this function returns the bounds of the --/ sprite in the global 2D world's coordinate system. --/ --/ @param shape Shape object --/ --/ @return Global bounding rectangle of the entity --/ --////////////////////////////////////////////////////////// function getGlobalBounds (shape : sfRectangleShape_Ptr) return Sf.Graphics.Rect.sfFloatRect; private pragma Import (C, create, "sfRectangleShape_create"); pragma Import (C, copy, "sfRectangleShape_copy"); pragma Import (C, destroy, "sfRectangleShape_destroy"); pragma Import (C, setPosition, "sfRectangleShape_setPosition"); pragma Import (C, setRotation, "sfRectangleShape_setRotation"); pragma Import (C, setScale, "sfRectangleShape_setScale"); pragma Import (C, setOrigin, "sfRectangleShape_setOrigin"); pragma Import (C, getPosition, "sfRectangleShape_getPosition"); pragma Import (C, getRotation, "sfRectangleShape_getRotation"); pragma Import (C, getScale, "sfRectangleShape_getScale"); pragma Import (C, getOrigin, "sfRectangleShape_getOrigin"); pragma Import (C, move, "sfRectangleShape_move"); pragma Import (C, rotate, "sfRectangleShape_rotate"); pragma Import (C, scale, "sfRectangleShape_scale"); pragma Import (C, getTransform, "sfRectangleShape_getTransform"); pragma Import (C, getInverseTransform, "sfRectangleShape_getInverseTransform"); pragma Import (C, setTexture, "sfRectangleShape_setTexture"); pragma Import (C, setTextureRect, "sfRectangleShape_setTextureRect"); pragma Import (C, setFillColor, "sfRectangleShape_setFillColor"); pragma Import (C, setOutlineColor, "sfRectangleShape_setOutlineColor"); pragma Import (C, setOutlineThickness, "sfRectangleShape_setOutlineThickness"); pragma Import (C, getTexture, "sfRectangleShape_getTexture"); pragma Import (C, getTextureRect, "sfRectangleShape_getTextureRect"); pragma Import (C, getFillColor, "sfRectangleShape_getFillColor"); pragma Import (C, getOutlineColor, "sfRectangleShape_getOutlineColor"); pragma Import (C, getOutlineThickness, "sfRectangleShape_getOutlineThickness"); pragma Import (C, getPointCount, "sfRectangleShape_getPointCount"); pragma Import (C, getPoint, "sfRectangleShape_getPoint"); pragma Import (C, setSize, "sfRectangleShape_setSize"); pragma Import (C, getSize, "sfRectangleShape_getSize"); pragma Import (C, getLocalBounds, "sfRectangleShape_getLocalBounds"); pragma Import (C, getGlobalBounds, "sfRectangleShape_getGlobalBounds"); end Sf.Graphics.RectangleShape;
with Globals_Example1; package Md_Example3 is type Record_With_Integer_Rtype is record Attribute : Globals_Example1.Itype; end record; function Unrelated (The_I : Globals_Example1.Itype) return Globals_Example1.Itype; end Md_Example3;
with GNAT.Regexp; use GNAT.Regexp; with Ada.Directories; with Ada.Characters.Conversions; with Ada.Text_IO; with GNATCOLL.Mmap; with Templates_Parser; with GNAT.Strings; with Ada.Strings.Fixed; with Globals; with Ada.Exceptions; use Ada.Exceptions; with Linereader; with Ada.Strings; with Ada.Strings.Maps; with Ada.Strings.Maps.Constants; with Ada.Strings.Unbounded; package body Generator.Frontmatter is use Ada.Characters.Conversions; use Ada.Text_IO; use GNATCOLL.Mmap; use Ada.Strings.Maps; use Ada.Strings.Maps.Constants; use GNAT.Strings; package FIX renames Ada.Strings.Fixed; package DIR renames Ada.Directories; package CC renames Ada.Characters.Conversions; whitespace : constant Character_Set := To_Set (' ' & ASCII.LF & ASCII.HT & ASCII.CR & Character'val(0)); useless_characters : constant Character_Set := Control_Set and To_Set (' '); WW_HT : constant Wide_Wide_Character := To_Wide_Wide_Character (ASCII.HT); WW_LF : constant Wide_Wide_Character := To_Wide_Wide_Character (ASCII.LF); WW_CR : constant Wide_Wide_Character := To_Wide_Wide_Character (ASCII.CR); WW_Colon : constant Wide_Wide_Character := To_Wide_Wide_Character (ASCII.Colon); package LR is new Linereader(Ada.Strings.Unbounded.To_String(Globals.Current_Lineending)); use LR; function Read_Excerpt ( Content : String; Excerpt_Separator : String) return String is begin if Excerpt_Separator /= "" and then Ada.Strings.Fixed.Index (Content, Excerpt_Separator) /= 0 then return Ada.Strings.Fixed.Head (Content, Ada.Strings.Fixed.Index (Content, Excerpt_Separator)); elsif Ada.Strings.Fixed.Index (Content, Globals.Excerpt_Separator) /= 0 then return Ada.Strings.Fixed.Head (Content, Ada.Strings.Fixed.Index (Content, Globals.Excerpt_Separator)); end if; return Ada.Strings.Fixed.Head (Content, Ada.Strings.Fixed.Index (Content, "" & ASCII.LF)); end Read_Excerpt; function Read_CreateDate (Filename : String) return String is Re : constant Regexp := Compile ("([0-9]{4})-?(1[0-2]|0[1-9])", Glob => True); begin if Match (Filename, Re) then return Filename (Filename'First .. Filename'First + 10); end if; return ""; end Read_CreateDate; function Is_Frontmatter (Line : String) return Boolean is Last : Natural := Line'First+Globals.Front_Matter_Prefix'Length - 1; Prefix : String Renames Line(Line'First .. Last); begin return Prefix'Length >= Globals.Front_Matter_Prefix'Length And then Prefix = Globals.Front_Matter_Prefix; end Is_Frontmatter; procedure Read_Content (Filepath : String; T : in out Translate_Set) is Basename : constant String := DIR.Base_Name (Filepath); Created_Date : constant String := Read_CreateDate (Basename); Source_File : constant Mapped_File := Open_Read (Filepath); Source_Region : constant Mapped_Region := Read (File => Source_File, Advice => Use_Sequential, Mutable => False); L : constant Natural := Natural (Length (Source_File)); Source_ptr : constant Str_Access := Data (Source_Region); R : LR.Reader (Source_ptr, L); begin loop exit when R.End_Of_Input; R.Backup; declare A_Line : constant String := R.Get_Line; begin exit when not Is_Frontmatter (A_Line); declare First : Positive := A_Line'First + Globals.Front_Matter_Prefix'Length; Frontmatter : String renames A_Line (First .. A_Line'Last); Separator_Position : Natural := FIX.Index (Frontmatter, Globals.Front_Matter_Separator); -- Index(Source, Maps.To_Set(Space), Outside, Going) First_Nonblank_Position : Natural := FIX.Index_Non_Blank (Frontmatter, Ada.Strings.Forward); Last_Nonblank_Position : Natural := FIX.Index_Non_Blank (Frontmatter, Ada.Strings.Backward); begin if Separator_Position /= 0 and then First_Nonblank_Position < Separator_Position then Insert (T, Assoc (FIX.Trim(Frontmatter (First_Nonblank_Position .. Separator_Position-1), whitespace,whitespace), FIX.Trim(Frontmatter (Separator_Position+1 .. Last_Nonblank_Position), whitespace,whitespace) ) ); end if; end; exception when E : others => Put_Line (Exception_Message (E)); end; end loop; if not R.End_Of_Input then R.Restore; Insert (T, Assoc ("content", R.Get_Remainder)); end if; Insert (T, Assoc ("summary", Read_Excerpt (Generator.Read_From_Set (T, "content"), Generator.Read_From_Set (T, "excerpt_separator")) ) ); if Generator.Read_From_Set (T, "created") = "" then if Created_Date /= "" then Insert (T, Assoc ("created", Created_Date)); end if; end if; if Generator.Read_From_Set (T, "updated") = "" then Insert (T, Assoc ("updated", Generator.Read_From_Set (T, "created") )); end if; end Read_Content; ---------- -- Read -- ---------- function Read ( Filepath : String; Targetpath : String; Linkpath : String) return Document is aDocument : Document; Containing_Directory : constant String := Ada.Directories.Containing_Directory (Targetpath); Base_Name : constant String := Ada.Directories.Base_Name (Targetpath); Targetname : constant String := Ada.Directories.Compose (Containing_Directory, Base_Name, Globals.HTML_Filetype); Filename : constant String := Ada.Directories.Compose ("", Base_Name, "html"); begin aDocument.Filepath := To_XString (To_Wide_Wide_String (Filepath)); aDocument.Targetpath := To_XString (To_Wide_Wide_String (Targetname)); aDocument.Filename := To_XString (To_Wide_Wide_String (Filename)); aDocument.Linkpath := To_XString (To_Wide_Wide_String (Linkpath)); aDocument.Basename := To_XString (To_Wide_Wide_String (Base_Name)); if Ada.Directories.Exists (Filepath) then Read_Content (Filepath, aDocument.T); declare Layout : String := Read_From_Set(aDocument.T, "layout"); begin if Layout'Length = 0 then Ada.Text_IO.Put_Line ("File " & Layout & " has no layout defined in frontmatter"); else aDocument.Layout := To_XString ( To_Wide_Wide_String (Layout)); end if; end; else Ada.Text_IO.Put_Line ("File " & Filepath & " does not exist"); end if; Insert (aDocument.T, Assoc ("basename", Base_Name)); Insert (aDocument.T, Assoc ("filename", Filename)); Insert (aDocument.T, Assoc ("targetname", Targetname)); Insert (aDocument.T, Assoc ("linkpath", Ada.Strings.Fixed.Trim (Linkpath, Generator.Slash, Generator.Slash))); Insert (aDocument.T, Assoc ("filepath", Filepath)); return aDocument; end Read; end Generator.Frontmatter;
-- { dg-do run } with System.Storage_Elements; use System.Storage_Elements; procedure Discr39 is type Rec (Has_Src : Boolean) is record case Has_Src is when True => Src : aliased Integer; when False => null; end case; end record; pragma Pack(Rec); for Rec'Alignment use Integer'Alignment; R : Rec (Has_Src => True); begin if R.Src'Address mod Integer'Alignment /= 0 then raise Program_Error; end if; end;
with lace.Any; private with lace.make_Subject, lace.make_Observer, ada.Strings.unbounded; package chat.Client.local -- -- Provides a local client. -- Names must be unique. -- is type Item is limited new lace.Any.limited_item and chat.Client .item with private; type View is access all Item'Class; -- Forge -- function to_Client (Name : in String) return Item; -- Attributes -- overriding function Name (Self : in Item) return String; overriding function as_Observer (Self : access Item) return lace.Observer.view; overriding function as_Subject (Self : access Item) return lace.Subject.view; -- Operations -- procedure start (Self : in out chat.Client.local.item); overriding procedure register_Client (Self : in out Item; other_Client : in Client.view); overriding procedure deregister_Client (Self : in out Item; other_Client_as_Observer : in lace.Observer.view; other_Client_Name : in String); overriding procedure Registrar_has_shutdown (Self : in out Item); private package Observer is new lace.make_Observer (lace.Any.limited_item); package Subject is new lace.make_Subject (Observer .item); use ada.Strings.unbounded; type Item is limited new Subject .item and chat.Client.item with record Name : unbounded_String; Registrar_has_shutdown : Boolean := False; Registrar_is_dead : Boolean := False; end record; end chat.Client.local;
with Ada.Text_IO; with Ada.Integer_Text_IO; procedure Day_01 is function Fuel(Mass: Natural) return Natural is Result: constant Integer := Mass / 3 - 2; begin if Result <= 0 then return 0; else return Result + Fuel(Result); end if; end Fuel; Total_Fuel: Natural := 0; Module_Mass: Natural; begin while (not Ada.Text_IO.End_Of_File) loop Ada.Integer_Text_IO.Get(Module_Mass); Total_Fuel := Total_Fuel + Fuel(Module_Mass); end loop; Ada.Integer_Text_IO.Put(Total_Fuel); end Day_01;
with MPFR.Root_FR; package body MPC.Generic_C is use type Imaginary_FR.MP_Float; function Rounding return MPC.Rounding is begin return Compose ( Real_FR.Rounding, Imaginary_FR.Rounding); end Rounding; function i return MP_Imaginary is begin return To_MP_Float (1.0); end i; function Re (X : MP_Complex) return Real_FR.MP_Float is begin return Real_FR.MP_Float (Root_C.Re (Root_C.MP_Complex (X))); end Re; function Im (X : MP_Complex) return Imaginary_FR.MP_Float is begin return Imaginary_FR.MP_Float (Root_C.Im (Root_C.MP_Complex (X))); end Im; function Compose (Re : Real_FR.MP_Float; Im : Imaginary_FR.MP_Float) return MP_Complex is begin return Compose (MPFR.Root_FR.MP_Float (Re), MPFR.Root_FR.MP_Float (Im)); end Compose; function Image (Value : MP_Complex; Base : Number_Base := 10) return String is begin return Image (Value, Base, Rounding); end Image; function Value (Image : String; Base : Number_Base := 10) return MP_Complex is begin return Value ( Image => Image, Base => Base, Real_Precision => Real_FR.Precision, Imaginary_Precision => Imaginary_FR.Precision, Rounding => Rounding); end Value; function "+" (Right : MP_Complex) return MP_Complex is begin return Copy ( Right, Real_Precision => Real_FR.Precision, Imaginary_Precision => Imaginary_FR.Precision, Rounding => Rounding); end "+"; function "-" (Right : MP_Complex) return MP_Complex is begin return Negative ( Right, Real_Precision => Real_FR.Precision, Imaginary_Precision => Imaginary_FR.Precision, Rounding => Rounding); end "-"; function "+" (Left, Right : MP_Complex) return MP_Complex is begin return Add ( Left, Right, Real_Precision => Real_FR.Precision, Imaginary_Precision => Imaginary_FR.Precision, Rounding => Rounding); end "+"; function "+" (Left : Long_Long_Float; Right : MP_Imaginary) return MP_Complex is begin return Compose (Left, Real_FR.Precision, MPFR.Root_FR.MP_Float (Right)); end "+"; function "-" (Left, Right : MP_Complex) return MP_Complex is begin return Subtract ( Left, Right, Real_Precision => Real_FR.Precision, Imaginary_Precision => Imaginary_FR.Precision, Rounding => Rounding); end "-"; function "-" (Left : Long_Long_Float; Right : MP_Imaginary) return MP_Complex is begin return Compose (Left, Real_FR.Precision, MPFR.Root_FR.MP_Float (-Right)); end "-"; function "*" (Left, Right : MP_Complex) return MP_Complex is begin return Multiply ( Left, Right, Real_Precision => Real_FR.Precision, Imaginary_Precision => Imaginary_FR.Precision, Rounding => Rounding); end "*"; function "/" (Left, Right : MP_Complex) return MP_Complex is begin return Divide ( Left, Right, Real_Precision => Real_FR.Precision, Imaginary_Precision => Imaginary_FR.Precision, Rounding => Rounding); end "/"; function "**" (Left : MP_Complex; Right : Integer) return MP_Complex is begin return Power ( Left, Right, Real_Precision => Real_FR.Precision, Imaginary_Precision => Imaginary_FR.Precision, Rounding => Rounding); end "**"; function "*" (Left : Long_Long_Float; Right : MP_Imaginary) return MP_Imaginary is begin return MP_Imaginary (Left * Imaginary_FR.MP_Float (Right)); end "*"; end MPC.Generic_C;
-- package pc_1_coeff_18 -- -- Predictor_Rule : Integration_Rule renames Predictor_32_18; -- -- Corrector_Rule : Integration_Rule renames Corrector_33_18; -- -- Final_Step_Corrector : Real renames Final_Step_Corrector_33_18; generic type Real is digits <>; package pc_1_coeff_18 is subtype PC_Rule_Range is Integer range 0..31; type Integration_Rule is array(PC_Rule_Range) of Real; Extrap_Factor: constant Real := 1.0 / 17.0; -- rt val unknown Predictor_32_18 : constant Integration_Rule := ( 1.66693917711765153632463639650433701E-1 , -1.75882036261426735242686595779447371E+0 , 7.69395839339962961992199684962940441E+0 , -1.71028191416251712138557489026011682E+1 , 1.71474396593984559606253555137762564E+1 , 2.16495205707454898551570427827818813E+0 , -1.74604716002055504831780081671942869E+1 , 4.23071847866746765124859100751348830E-1 , 1.73663062233814703429990546034022438E+1 , 3.18706564375901735752852401702804016E+0 , -1.65512889968133647242925196901095747E+1 , -1.01117881753875144155405638174500690E+1 , 1.21278497313337200035801114454930874E+1 , 1.69790652748968177818495612273408204E+1 , -2.87685259360020735330410048670562381E+0 , -1.95607469462888756500804147947638933E+1 , -9.03825453288123253165369706044793861E+0 , 1.52146890999152944426689134276336280E+1 , 1.90964147317258101883921088460497549E+1 , -5.01356129965029049374787754470692094E+0 , -2.37593216192323803500122039859415837E+1 , -7.05593052013130453777683705531083640E+0 , 2.32752973130191857503394320365419067E+1 , 1.71864849573423565023361798418409680E+1 , -2.19502786972464078691515704186912537E+1 , -2.35962697025447869611864815971458832E+1 , 2.76779497559864309753355137231991811E+1 , 2.11366858691505000770656586631072821E+1 , -5.18148110210355987645413056471094053E+1 , 3.98741045525696080537435326242641017E+1 , -1.65527431042229994290735250543333781E+1 , 4.48592928494859416916275034231964401E+0 ); Predictor_32_17 : constant Integration_Rule := ( -1.62472980947547285227912948691595204E-1 , 1.51846575484458773430336413812753196E+0 , -5.68313970441214142340495425745202565E+0 , 1.00050734670521388742024808461071612E+1 , -5.61854336297953874414035267260123444E+0 , -6.41511270402391939529842383747530560E+0 , 6.59402419366119591267336173438292271E+0 , 6.73389647814116072687447173034733748E+0 , -4.86700881396898624573986118676698199E+0 , -8.64478706711790617969744057119346501E+0 , 6.63950727514010549784482933422989055E-1 , 9.20584617745705343258283037112855880E+0 , 5.19291395136070380968021848017215355E+0 , -5.96875633034033333049422865420452374E+0 , -9.72525166371917802502970850620895075E+0 , -9.95483190234079632968918740363838844E-1 , 9.52700922317356348545779899395211586E+0 , 8.36629002979632377094330540813030109E+0 , -3.85140687351134092395168103549558921E+0 , -1.19484970796233066876477705100278548E+1 , -4.44168726638781250188880979736295583E+0 , 1.01593092041960707363001655682217274E+1 , 1.14434446021422622131134674483204015E+1 , -5.04683008000810008640273594832825778E+0 , -1.56394540669719939074019577890952650E+1 , 4.58226091321959434664888304431326364E-1 , 1.90978849948879625945213856074456873E+1 , -1.62929715322749462770004952327020878E+0 , -2.47069184123582886764830758984010759E+1 , 2.64970064547578370104165815171826716E+1 , -1.32754569867641443423432949584113725E+1 , 4.15676238628928173030237375397761510E+0 ); Corrector_33_18 : constant Integration_Rule := ( -4.29063799602363300332554290338226295E-3 , 4.38930332480966809796959379076409981E-2 , -1.84407586326769458272582523016445115E-1 , 3.86018410068741543924126535404563539E-1 , -3.39672522737244306236877595500955353E-1 , -1.15641698427106085154098431312500252E-1 , 3.67714580948230418726334597592131207E-1 , 8.51130013530862502298476133473910856E-2 , -3.54666284501439138817890595269239766E-1 , -1.81416311108832538094079171518532074E-1 , 2.88833826526463644786676422021725394E-1 , 3.22344332863848596675379797234396480E-1 , -1.21000123850099483378649506353159374E-1 , -4.05936344466723412585600990426609324E-1 , -1.33568166316278517562718545082911589E-1 , 3.36386586562306821405499326466245392E-1 , 3.72313509686552044866666445265398842E-1 , -9.84025206013759090927347524342649613E-2 , -4.67682460545670749579065020203992459E-1 , -2.14997145748892282681215582758083950E-1 , 3.66795460695756672861508217500605439E-1 , 4.70583855446769988483400163170587136E-1 , -1.30277395110943088424372240845988236E-1 , -6.01970902280695395288554055750991530E-1 , -1.23767834937687118949723498842400676E-1 , 6.63435227624153102184263640709067511E-1 , 2.88648820827314256520865647122187408E-1 , -8.20338185422574932346236812125224486E-1 , -1.72358326182689102131382649210764114E-1 , 1.25220166246515912046347289775591826E+0 , -1.34961004668931826085713491119588305E+0 , 1.29052692128136021194977625758860908E+0 ); Final_Step_Corrector_33_18 : constant Real := 2.85195263652524058398728925664860798E-1; Predictor_Rule : Integration_Rule renames Predictor_32_18; Corrector_Rule : Integration_Rule renames Corrector_33_18; Final_Step_Corrector : Real renames Final_Step_Corrector_33_18; end pc_1_coeff_18;
with Ada.Text_IO, Ada.Integer_Text_IO; use Ada; procedure math_test is num1 : Integer; num2 : Integer; sum : Integer; begin num1 := 3; num2 := 5; sum := num1 + num2; Integer_Text_IO.put(sum); end math_test;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015-2016, 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 League.Calendars.ISO_8601; with League.String_Vectors; package body Matreshka.RFC2616_Dates is procedure Parse_Time (Text : League.Strings.Universal_String; Hour : out League.Calendars.ISO_8601.Hour_Number; Minute : out League.Calendars.ISO_8601.Minute_Number; Second : out League.Calendars.ISO_8601.Second_Number); procedure Parse_ANSI_Date (Self : Format'Class; Text : League.Strings.Universal_String; Value : out League.Calendars.Date_Time; Success : out Boolean); procedure Parse_RFC_1123_Date (Self : Format'Class; Text : League.Strings.Universal_String; Value : out League.Calendars.Date_Time; Success : out Boolean); procedure Parse_RFC_850_Date (Self : Format'Class; Text : League.Strings.Universal_String; Value : out League.Calendars.Date_Time; Success : out Boolean); ----------------- -- From_String -- ----------------- procedure From_String (Self : Format; Text : League.Strings.Universal_String; Value : out League.Calendars.Date_Time; Success : out Boolean) is Char_4 : constant Wide_Wide_Character := Text.Element (4).To_Wide_Wide_Character; begin if Char_4 = ',' then Self.Parse_RFC_1123_Date (Text, Value, Success); elsif Char_4 = ' ' then Self.Parse_ANSI_Date (Text, Value, Success); else Self.Parse_RFC_850_Date (Text, Value, Success); end if; end From_String; --------------------- -- Parse_ANSI_Date -- --------------------- procedure Parse_ANSI_Date (Self : Format'Class; Text : League.Strings.Universal_String; Value : out League.Calendars.Date_Time; Success : out Boolean) is use League.Calendars.ISO_8601; List : constant League.String_Vectors.Universal_String_Vector := Text.Split (' ', League.Strings.Skip_Empty); Year : Year_Number; Month : Month_Number; Day : Day_Number; Hour : Hour_Number; Minute : Minute_Number; Second : Second_Number; begin -- Text example: Sun Nov 6 08:49:37 1994 Year := Year_Number'Wide_Wide_Value (List.Element (5).To_Wide_Wide_String); Month := Month_Number (Self.Month_List.Index (List.Element (2)) / 3); Day := Day_Number'Wide_Wide_Value (List.Element (3).To_Wide_Wide_String); Parse_Time (List.Element (4), Hour, Minute, Second); Value := Create (Year, Month, Day, Hour, Minute, Second, 0); Success := True; exception when Constraint_Error => Success := False; end Parse_ANSI_Date; ------------------------- -- Parse_RFC_1123_Date -- ------------------------- procedure Parse_RFC_1123_Date (Self : Format'Class; Text : League.Strings.Universal_String; Value : out League.Calendars.Date_Time; Success : out Boolean) is use League.Calendars.ISO_8601; use type League.Strings.Universal_String; List : constant League.String_Vectors.Universal_String_Vector := Text.Split (' '); Year : Year_Number; Month : Month_Number; Day : Day_Number; Hour : Hour_Number; Minute : Minute_Number; Second : Second_Number; begin -- Text example: Sun, 06 Nov 1994 08:49:37 GMT Year := Year_Number'Wide_Wide_Value (List.Element (4).To_Wide_Wide_String); Month := Month_Number (Self.Month_List.Index (List.Element (3)) / 3); Day := Day_Number'Wide_Wide_Value (List.Element (2).To_Wide_Wide_String); Success := List.Element (6) = Self.GMT; Parse_Time (List.Element (5), Hour, Minute, Second); Value := Create (Year, Month, Day, Hour, Minute, Second, 0); exception when Constraint_Error => Success := False; end Parse_RFC_1123_Date; ------------------------ -- Parse_RFC_850_Date -- ------------------------ procedure Parse_RFC_850_Date (Self : Format'Class; Text : League.Strings.Universal_String; Value : out League.Calendars.Date_Time; Success : out Boolean) is use League.Calendars.ISO_8601; use type League.Strings.Universal_String; List : constant League.String_Vectors.Universal_String_Vector := Text.Split (' '); Date : League.Strings.Universal_String; Year : Year_Number; Month : Month_Number; Day : Day_Number; Hour : Hour_Number; Minute : Minute_Number; Second : Second_Number; begin -- Text example: Sunday, 06-Nov-94 08:49:37 GMT Date := List.Element (2); Year := Year_Number'Wide_Wide_Value (Date.Tail_From (8).To_Wide_Wide_String); if Year in 0 .. 49 then Year := Year + 2000; else Year := Year + 1900; end if; Month := Month_Number (Self.Month_List.Index (Date.Slice (4, 6)) / 3); Day := Day_Number'Wide_Wide_Value (Date.Head_To (2).To_Wide_Wide_String); Success := List.Element (4) = Self.GMT; Parse_Time (List.Element (3), Hour, Minute, Second); Value := Create (Year, Month, Day, Hour, Minute, Second, 0); exception when Constraint_Error => Success := False; end Parse_RFC_850_Date; ---------------- -- Parse_Time -- ---------------- procedure Parse_Time (Text : League.Strings.Universal_String; Hour : out League.Calendars.ISO_8601.Hour_Number; Minute : out League.Calendars.ISO_8601.Minute_Number; Second : out League.Calendars.ISO_8601.Second_Number) is use League.Calendars.ISO_8601; Time : constant League.String_Vectors.Universal_String_Vector := Text.Split (':'); begin Hour := Hour_Number'Wide_Wide_Value (Time.Element (1).To_Wide_Wide_String); Minute := Minute_Number'Wide_Wide_Value (Time.Element (2).To_Wide_Wide_String); Second := Second_Number'Wide_Wide_Value (Time.Element (3).To_Wide_Wide_String); end Parse_Time; --------------- -- To_String -- --------------- function To_String (Self : Format; Value : League.Calendars.Date_Time) return League.Strings.Universal_String is Result : League.Strings.Universal_String; begin Result := League.Calendars.ISO_8601.Image (Self.Pattern, Value); Result.Append (Self.GMT); return Result; end To_String; end Matreshka.RFC2616_Dates;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web 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$ ------------------------------------------------------------------------------ with Ada.Numerics.Discrete_Random; with Ada.Streams; with GNAT.SHA1; with Interfaces; with League.Calendars.ISO_8601; with League.Stream_Element_Vectors.Internals; with League.Text_Codecs; with Matreshka.Internals.Stream_Element_Vectors; package body Web_Services.SOAP.Security.Password_Digest_Utilities is package Unsigned_64_Random is new Ada.Numerics.Discrete_Random (Interfaces.Unsigned_64); Format : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("yyyy-MM-ddTHH:mm:ss"); -- Format of Created field in header, except 'Z' at the end, due to 'Z' is -- pattern symbol UTF8_Codec : constant League.Text_Codecs.Text_Codec := League.Text_Codecs.Codec (League.Strings.To_Universal_String ("utf-8")); -- Text codec to convert strings into UTF8 representation. Generator : Unsigned_64_Random.Generator; function To_Binary_Message_Digest (Item : String) return Ada.Streams.Stream_Element_Array; -- Converts string into array of stream elements. Note: this subprogram is -- needed for GNAT GPL 2012 only, because it doesn't provide -- GNAT.SHA1.Digest subprogram which returns Binary_Message_Digest. -------------------- -- Compute_Digest -- -------------------- function Compute_Digest (Password : League.Strings.Universal_String; Nonce : League.Stream_Element_Vectors.Stream_Element_Vector; Created : League.Strings.Universal_String) return League.Stream_Element_Vectors.Stream_Element_Vector is Data : League.Stream_Element_Vectors.Stream_Element_Vector; begin Data.Append (Nonce); Data.Append (UTF8_Codec.Encode (Created)); Data.Append (UTF8_Codec.Encode (Password)); return League.Stream_Element_Vectors.To_Stream_Element_Vector (To_Binary_Message_Digest (GNAT.SHA1.Digest (Data.To_Stream_Element_Array))); end Compute_Digest; ---------------------- -- Generate_Created -- ---------------------- function Generate_Created return League.Strings.Universal_String is begin return Result : League.Strings.Universal_String do Result := League.Calendars.ISO_8601.Image (Format, League.Calendars.Clock); Result.Append ('Z'); end return; end Generate_Created; -------------------- -- Generate_Nonce -- -------------------- function Generate_Nonce return League.Stream_Element_Vectors.Stream_Element_Vector is Result : constant Matreshka.Internals.Stream_Element_Vectors. Shared_Stream_Element_Vector_Access := Matreshka.Internals.Stream_Element_Vectors.Allocate (16); Value : array (Natural range 0 .. 1) of Interfaces.Unsigned_64; for Value'Address use Result.Value'Address; pragma Import (Ada, Value); begin Value (0) := Unsigned_64_Random.Random (Generator); Value (1) := Unsigned_64_Random.Random (Generator); Result.Length := 16; return League.Stream_Element_Vectors.Internals.Wrap (Result); end Generate_Nonce; ---------------- -- Initialize -- ---------------- procedure Initialize is begin Unsigned_64_Random.Reset (Generator); end Initialize; ------------------------------ -- To_Binary_Message_Digest -- ------------------------------ function To_Binary_Message_Digest (Item : String) return Ada.Streams.Stream_Element_Array is use type Ada.Streams.Stream_Element; use type Ada.Streams.Stream_Element_Offset; function Decode (Item : Character) return Ada.Streams.Stream_Element; ------------ -- Decode -- ------------ function Decode (Item : Character) return Ada.Streams.Stream_Element is begin case Item is when '0' .. '9' => return Character'Pos (Item) - Character'Pos ('0'); when 'a' .. 'f' => return Character'Pos (Item) - Character'Pos ('a') + 10; when 'A' .. 'F' => return Character'Pos (Item) - Character'Pos ('A') + 10; when others => raise Constraint_Error; end case; end Decode; Result : Ada.Streams.Stream_Element_Array (1 .. Item'Length / 2); First : Natural := Item'First; Unused : Ada.Streams.Stream_Element_Offset := Result'First; begin while Item'Last - First > 0 loop Result (Unused) := (Decode (Item (First)) * 16) or Decode (Item (First + 1)); Unused := Unused + 1; First := First + 2; end loop; return Result; end To_Binary_Message_Digest; end Web_Services.SOAP.Security.Password_Digest_Utilities;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2018 onox <denkpadje@gmail.com> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Ada.Containers.Indefinite_Hashed_Maps; with Ada.Strings.Hash; package Orka.Resources.Managers is pragma Preelaborate; type Manager is tagged limited private; function Contains (Object : Manager; Name : String) return Boolean; function Resource (Object : Manager; Name : String) return Resource_Ptr; procedure Add_Resource (Object : in out Manager; Name : String; Resource : Resource_Ptr); procedure Remove_Resource (Object : in out Manager; Name : String); type Manager_Ptr is not null access Manager; function Create_Manager return Manager_Ptr; private package Resource_Maps is new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String, Element_Type => Resource_Ptr, Hash => Ada.Strings.Hash, Equivalent_Keys => "="); type Manager is tagged limited record Resources : Resource_Maps.Map; end record; end Orka.Resources.Managers;
----------------------------------------------------------------------- -- are-testsuite -- Testsuite for are -- Copyright (C) 2021 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Text_IO; with Ada.Characters.Handling; with Util.Log.Loggers; with Util.Files; with Util.Processes; with Util.Strings.Vectors; with Util.Streams.Pipes; with Util.Streams.Buffered; with Are.Generator.Tests; with Are.Tests; package body Are.Testsuite is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Are.Testsuite"); Tests : aliased Util.Tests.Test_Suite; function Suite return Util.Tests.Access_Test_Suite is begin Are.Generator.Tests.Add_Tests (Tests'Access); Are.Tests.Add_Tests (Tests'Access); return Tests'Access; end Suite; -- ------------------------------ -- Execute the command and get the output in a string. -- ------------------------------ procedure Execute (T : in out Test; Command : in String; Result : out Ada.Strings.Unbounded.Unbounded_String; Status : in Natural := 0) is P : aliased Util.Streams.Pipes.Pipe_Stream; Buffer : Util.Streams.Buffered.Input_Buffer_Stream; begin Log.Info ("Execute: {0}", Command); P.Open (Command, Util.Processes.READ_ALL); -- Write on the process input stream. Result := Ada.Strings.Unbounded.Null_Unbounded_String; Buffer.Initialize (P'Unchecked_Access, 8192); Buffer.Read (Result); P.Close; Ada.Text_IO.Put_Line (Ada.Strings.Unbounded.To_String (Result)); Log.Info ("Command result: {0}", Result); Util.Tests.Assert_Equals (T, Status, P.Get_Exit_Status, "Command '" & Command & "' failed"); end Execute; -- ------------------------------ -- Check that two generated files are almost equal. While doing the comparison, -- we ignore some generated timestamps in the form '1622183646'. -- ------------------------------ procedure Assert_Equal_Files (T : in Test'Class; Expect : in String; Test : in String; Message : in String := "Test failed"; Source : String := GNAT.Source_Info.File; Line : Natural := GNAT.Source_Info.Line) is use Util.Files; use type Util.Strings.Vectors.Vector; use Ada.Characters.Handling; function Is_Almost_Equal (Line1, Line2 : in String) return Boolean; function Is_Almost_Equal (Line1, Line2 : in String) return Boolean is Pos1 : Natural := Line1'First; Pos2 : Natural := Line2'First; Digit_Count : Natural := 0; Digit_Error : Boolean := False; begin loop if Pos1 > Line1'Last then return Pos2 > Line2'Last; end if; exit when Pos2 > Line2'Last; if Line1 (Pos1) = Line2 (Pos2) then if Is_Digit (Line1 (Pos1)) then Digit_Count := Digit_Count + 1; else -- Accept a difference only on numbers with 10 digits (ie, timestamp). exit when Digit_Error and Digit_Count /= 10; Digit_Count := 0; Digit_Error := False; end if; Pos1 := Pos1 + 1; Pos2 := Pos2 + 1; else exit when not Is_Digit (Line1 (Pos1)); exit when not Is_Digit (Line2 (Pos2)); Digit_Count := Digit_Count + 1; Digit_Error := True; Pos1 := Pos1 + 1; Pos2 := Pos2 + 1; end if; end loop; return False; end Is_Almost_Equal; Expect_File : Util.Strings.Vectors.Vector; Test_File : Util.Strings.Vectors.Vector; Same : Boolean; begin if not Ada.Directories.Exists (Expect) then T.Assert (Condition => False, Message => "Expect file '" & Expect & "' does not exist", Source => Source, Line => Line); end if; Read_File (Path => Expect, Into => Expect_File); Read_File (Path => Test, Into => Test_File); -- Check that both files have the same number of lines. Util.Tests.Assert_Equals (T => T, Expect => Natural (Expect_File.Length), Value => Natural (Test_File.Length), Message => Message & ": Invalid number of lines", Source => Source, Line => Line); Same := Expect_File = Test_File; if Same then return; end if; for Pos in 1 .. Natural (Expect_File.Length) loop declare Expect : constant String := Expect_File.Element (Pos); Test_Line : constant String := Test_File.Element (Pos); begin if not Is_Almost_Equal (Expect, Test_Line) then Util.Tests.Fail (T => T, Message => Message & ": Content is different at line " & Util.Strings.Image (Pos), Source => Source, Line => Line); return; end if; end; end loop; end Assert_Equal_Files; end Are.Testsuite;
with Ada.Streams; package YAML.Streams is pragma Preelaborate; function Create ( Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Parser; function Create ( Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Emitter; end YAML.Streams;
package access3 is type IT is limited interface; type T is limited new IT with null record; type T2 is tagged limited null record; procedure Op (Obj_T2 : in out T2; Obj_IT : not null access IT'Class); end access3;
package body dpila is procedure pvacia(p: out pila) is top: pnodo renames p.top; begin top := null; end pvacia; function estavacia(p: in pila) return boolean is top: pnodo renames p.top; begin return top = null; end estavacia; function cima(p: in pila) return elem is top: pnodo renames p.top; begin return top.x; exception when Constraint_Error => raise mal_uso; end cima; procedure empila(p: in out pila; x: in elem) is top: pnodo renames p.top; r: pnodo; begin r := new nodo; r.all := (x, top); top := r; exception when Storage_Error => raise espacio_desbordado; end empila; procedure desempila(p: in out pila) is top: pnodo renames p.top; begin top := top.sig; exception when Constraint_Error => raise mal_uso; end desempila; end dpila;
-- -- 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 GNATCOLL.Readline; with Setup; with Readline_Helper; package body Interactive is History_File : constant String := Setup.Program_Name & ".history"; procedure Initialize is begin GNATCOLL.Readline.Initialize (Appname => Setup.Program_Name, History_File => History_File, Completer => Readline_Helper.Completer'Access); end Initialize; procedure Finalize is begin GNATCOLL.Readline.Finalize (History_File); end Finalize; function Get_Line return String is begin return GNATCOLL.Readline.Get_Line ("TODO$ "); end Get_Line; end Interactive;
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with Definitions; use Definitions; private with Ada.Text_IO; package Port_Specification.Makefile is -- This generates a makefile from the specification based on given parameters -- The variant must be "standard" or one of the specified variants -- The output_file must be blank (stdout) or a file to (over)write a file with output. procedure generator (specs : Portspecs; variant : String; opsys : supported_opsys; arch : supported_arch; output_file : String ); private package TIO renames Ada.Text_IO; dev_error : exception; -- Given a string GITHUB/account:project:tag(:directory) return a standard -- distname per github rules. Also works for GITHUB_PRIVATE and GHPRIV function generate_github_distname (download_site : String) return String; -- Given a string GITLAB/account:project:tag return a standard distname. -- Rare characters in account/project may have to be URL encoded function generate_gitlab_distname (download_site : String) return String; -- Given a string CRATES/project:version return a standard distname. function generate_crates_distname (download_site : String) return String; -- Used for non-custom (and not invalid) licenses, returns the full license name function standard_license_names (license : license_type) return String; procedure handle_github_relocations (specs : Portspecs; makefile : TIO.File_Type); -- Returns true if USES module should be omitted from Makefile USES definition function passive_uses_module (value : String) return Boolean; end Port_Specification.Makefile;
-- ___ _ ___ _ _ -- -- / __| |/ (_) | | Common SKilL implementation -- -- \__ \ ' <| | | |__ skills vector container implementation -- -- |___/_|\_\_|_|____| by: Dennis Przytarski, Timm Felden -- -- -- pragma Ada_2012; with Ada.Containers.Hashed_Sets; with Ada.Finalization; with Ada.Unchecked_Conversion; with Skill.Types; with Ada.Containers; -- sets used by skill; those are basically ada hashed sets with template aware boxing generic type T is private; with function Hash (Element : T) return Ada.Containers.Hash_Type is <>; with function Equals (Left, Right : T) return Boolean is <>; with function "=" (Left, Right : T) return Boolean is <>; package Skill.Containers.Sets is pragma Warnings (Off); use Skill.Types; function Cast is new Ada.Unchecked_Conversion (Box, T); function Cast is new Ada.Unchecked_Conversion (T, Box); package HS is new Ada.Containers.Hashed_Sets (T, Hash, Equals, "="); type Iterator_T is new Set_Iterator_T with record Cursor : Hs.Cursor; end record; function Has_Next (This : access Iterator_T) return Boolean is (Hs.Has_Element(This.Cursor)); function Next (This : access Iterator_T) return Skill.Types.Box; procedure Free (This : access Iterator_T); type Set_T is new Boxed_Set_T with record This : HS.Set; end record; type Ref is access Set_T; procedure Add (This : access Set_T; V : Skill.Types.Box); function Contains (This : access Set_T; V : Skill.Types.Box) return Boolean is (This.This.Contains (Cast (V))); function Length (This : access Set_T) return Natural is (Natural (This.This.Length)); overriding function Iterator (This : access Set_T) return Set_Iterator is (new Iterator_T'(Cursor => This.This.First)); -- create a new container function Make return Ref; -- turn a box into a container of right type function Unboxed is new Ada.Unchecked_Conversion (Box, Ref); end Skill.Containers.Sets;
with p4; with Assume_Call; procedure Main with SPARK_Mode is begin --Assume_Call.Caller; p4.foo; end Main;
with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; with Ada.Unchecked_Conversion; with Interfaces.C.Pointers; with PaTest_TooManySines_Types; use PaTest_TooManySines_Types; package body PaTest_TooManySines_Callbacks is package Float_Ptrs is new Interfaces.C.Pointers (Index => Integer, Element => Float, Element_Array => Float_Array, Default_Terminator => 0.0); use type Float_Ptrs.Pointer; subtype Float_Star is Float_Ptrs.Pointer; function Convert is new Ada.Unchecked_Conversion (System.Address, Float_Star); function Convert is new Ada.Unchecked_Conversion (System.Address, paTestData_Ptr); -------------------- -- paTestCallback -- -------------------- function paTestCallback (inputBuffer : System.Address; outputBuffer : System.Address; framesPerBuffer : Interfaces.C.unsigned_long; timeInfo : access PA_Stream_Callback_Time_Info; statusFlags : PA_Stream_Callback_Flags; userData : System.Address) return PA_Stream_Callback_Result is pragma Unreferenced (inputBuffer); pragma Unreferenced (timeInfo); pragma Unreferenced (statusFlags); oBuff : Float_Star := Convert (outputBuffer); lData : constant paTestData_Ptr := Convert (userData); begin for i in 1 .. Integer (framesPerBuffer) loop declare output : Float := 0.0; phaseInc : Long_Float := 0.02; phase : Long_Float; begin for j in 1 .. lData.all.numSines loop -- Advance phase of next oscillator. phase := lData.all.phases (j); phase := phase + phaseInc; if phase > Two_Pi then phase := phase - Two_Pi; end if; phaseInc := phaseInc * 1.02; if phaseInc > 0.5 then phaseInc := phaseInc * 0.5; end if; -- This is not a very efficient way to calc sines. output := output + Sin (Float (phase)); lData.all.phases (j) := phase; end loop; oBuff.all := output / Float (lData.all.numSines); Float_Ptrs.Increment (oBuff); end; end loop; return paContinue; end paTestCallback; end PaTest_TooManySines_Callbacks;
-- General Profiler -- Author: Emanuel Regnath (emanuel.regnath@tum.de) -- -- Description: measures execution time between 'start' and 'stop'. -- Stores maximum execution time. -- -- Usage: enter loop, call 'start', execute code, call 'stop'. -- call 'get_Max' outside of loop to retrieve longest execution time. -- ToDo: Add middle stops with Ada.Real_Time; use Ada.Real_Time; package Profiler with SPARK_Mode is type Profile_Tag is tagged private; CFG_PROFILER_PROFILING : constant Boolean := True; CFG_PROFILER_LOGGING : constant Boolean := True; procedure enableProfiling; procedure disableProfiling; procedure init(Self : in out Profile_Tag; name : String); procedure reset(Self : in out Profile_Tag); procedure start(Self : in out Profile_Tag); procedure stop(Self : in out Profile_Tag); procedure log(Self : in Profile_Tag); function get_Name(Self : in Profile_Tag) return String; function get_Start(Self : in Profile_Tag) return Time; function get_Stop(Self : in Profile_Tag) return Time; -- elapsed time before stop or last measurement time after stop function get_Elapsed(Self : in Profile_Tag) return Time_Span; function get_Max(Self : in Profile_Tag) return Time_Span; private subtype Name_Length_Type is Integer range 0 .. 30; subtype Name_Type is String(1 .. 30); type Profile_Tag is tagged record name : Name_Type := (others => ' '); name_length : Name_Length_Type := 0; max_duration : Time_Span := Milliseconds( 0 ); start_Time : Time := Time_First; stop_Time : Time := Time_First; end record; type State_Type is record isEnabled : Boolean := False; end record; G_state : State_Type; procedure Read_From_Memory(Self : in out Profile_Tag); procedure Write_To_Memory(Self : in out Profile_Tag); end Profiler;
with GL.lean, Interfaces.C.Strings, System; package GL.Pointers -- -- Provides pointer conversions. -- is use Interfaces; function to_GLvoid_access (From : in system.Address) return access GLvoid; function to_GLvoid_access (From : access C.unsigned_char) return access GLvoid; function to_GLchar_access (From : in C.Strings.chars_ptr) return access lean.GLchar; function to_GLchar_Pointer_access (From : access C.Strings.chars_ptr_array) return access lean.GLchar_Pointer; function "+" (From : in system.Address) return access GLvoid renames to_GLvoid_access; function "+" (From : access C.unsigned_char) return access GLvoid renames to_GLvoid_access; function "+" (From : in C.Strings.chars_ptr) return access lean.GLchar renames to_GLchar_access; end GL.Pointers;
-- C45331A.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT FOR FIXED POINT TYPES THE OPERATORS "+" AND "-" PRODUCE -- CORRECT RESULTS WHEN: -- (A) A, B, A+B, AND A-B ARE ALL MODEL NUMBERS. -- (B) A IS A MODEL NUMBER BUT B, A+B, AND A-B ARE NOT. -- (C) A, B, A+B, AND A-B ARE ALL MODEL NUMBERS WITH DIFFERENT -- SUBTYPES. -- CASE A: BASIC TYPES THAT FIT THE CHARACTERISTICS OF DURATION'BASE. -- WRG 8/27/86 -- KAS 11/14/95 REDUCE EXPECTATION FOR T'SMALL -- KAS 11/30/95 ONE MORE CHANGE... -- PWN 02/28/96 CLEANED COMMENTS FOR RELEASE -- KAS 03/18/96 ELIDED TWO 'SMALL CASES FOR 2.1 WITH REPORT; USE REPORT; PROCEDURE C45331A IS TYPE LIKE_DURATION IS DELTA 0.020 RANGE -86_400.0 .. 86_400.0; -- 'MANTISSA = 23. SUBTYPE F IS LIKE_DURATION DELTA 0.25 RANGE -1000.0 .. 1000.0; SUBTYPE ST_F1 IS LIKE_DURATION DELTA 0.5 RANGE -4.0 .. 3.0; SUBTYPE ST_F2 IS LIKE_DURATION DELTA 1.0 / 16 RANGE -13.0 / 16 .. 5.0 + 1.0 / 16; BEGIN TEST ("C45331A", "CHECK THAT FOR FIXED POINT TYPES THE " & "OPERATORS ""+"" AND ""-"" PRODUCE CORRECT " & "RESULTS - BASIC TYPES"); ------------------------------------------------------------------- A: DECLARE SMALL, MAX, MIN, ZERO : F := 0.5; X : F := 0.0; BEGIN -- INITIALIZE "CONSTANTS": IF EQUAL (3, 3) THEN SMALL := F'SMALL; MAX := F'LAST; -- BECAUSE F'LAST < F'LARGE AND F'LAST -- IS A MODEL NUMBER. MIN := F'FIRST; -- F'FIRST IS A MODEL NUMBER. ZERO := 0.0; END IF; -- CHECK SMALL + OR - ZERO = SMALL: IF "+"(LEFT => SMALL, RIGHT => ZERO) /= SMALL OR 0.0 + SMALL /= SMALL THEN FAILED ("F'SMALL + 0.0 /= F'SMALL"); END IF; IF "-"(LEFT => SMALL, RIGHT => ZERO) /= SMALL OR SMALL - 0.0 /= SMALL THEN FAILED ("F'SMALL - 0.0 /= F'SMALL"); END IF; -- CHECK MAX + OR - ZERO = MAX: IF MAX + ZERO /= MAX OR 0.0 + MAX /= MAX THEN FAILED ("F'LAST + 0.0 /= F'LAST"); END IF; IF MAX - ZERO /= MAX OR MAX - 0.0 /= MAX THEN FAILED ("F'LAST - 0.0 /= F'LAST"); END IF; -- CHECK SMALL - SMALL = 0.0: IF EQUAL (3, 3) THEN X := SMALL; END IF; IF SMALL - X /= 0.0 OR SMALL - SMALL /= 0.0 OR F'SMALL - F'SMALL /= 0.0 THEN FAILED ("F'SMALL - F'SMALL /= 0.0"); END IF; -- CHECK MAX - MAX = 0.0: IF EQUAL (3, 3) THEN X := MAX; END IF; IF MAX - X /= 0.0 OR MAX - MAX /= 0.0 OR F'LAST - F'LAST /= 0.0 THEN FAILED ("F'LAST - F'LAST /= 0.0"); END IF; -- CHECK ZERO - MAX = MIN, MIN - MIN = 0.0, -- AND MIN + MAX = 0.0: IF EQUAL (3, 3) THEN X := ZERO - MAX; END IF; IF X /= MIN THEN FAILED ("0.0 - 1000.0 /= -1000.0"); END IF; IF EQUAL (3, 3) THEN X := MIN; END IF; IF MIN - X /= 0.0 OR MIN - MIN /= 0.0 OR F'FIRST - F'FIRST /= 0.0 THEN FAILED ("F'FIRST - F'FIRST /= 0.0"); END IF; IF MIN + MAX /= 0.0 OR MAX + MIN /= 0.0 OR F'FIRST + F'LAST /= 0.0 THEN FAILED ("-1000.0 + 1000.0 /= 0.0"); END IF; -- CHECK ADDITION AND SUBTRACTION FOR ARBITRARY MID-RANGE -- NUMBERS: IF EQUAL (3, 3) THEN X := 100.75; END IF; IF (X + SMALL) /= (SMALL + X) OR (X + SMALL) > (X + 0.25) THEN -- X + SMALL SB <= X + DELTA FAILED("X + SMALL DELIVERED BAD RESULT"); END IF; -- CHECK (MAX - SMALL) + SMALL = MAX: IF EQUAL (3, 3) THEN X := MAX - SMALL; END IF; IF X + SMALL /= MAX THEN FAILED("(MAX - SMALL) + SMALL /= MAX"); END IF; EXCEPTION WHEN OTHERS => FAILED ("EXCEPTION RAISED - A"); END A; ------------------------------------------------------------------- B: DECLARE NON_MODEL_CONST : CONSTANT := 2.0 / 3; NON_MODEL_VAR : F := 0.0; SMALL, MAX, MIN, ZERO : F := 0.5; X : F := 0.0; BEGIN -- INITIALIZE "CONSTANTS": IF EQUAL (3, 3) THEN SMALL := F'SMALL; MAX := F'LAST; -- BECAUSE F'LAST < F'LARGE AND -- F'LAST IS A MODEL NUMBER. MIN := F'FIRST; -- F'FIRST IS A MODEL NUMBER. ZERO := 0.0; NON_MODEL_VAR := NON_MODEL_CONST; END IF; -- CHECK VALUE OF NON_MODEL_VAR: IF NON_MODEL_VAR NOT IN 0.5 .. 0.75 THEN FAILED ("VALUE OF NON_MODEL_VAR NOT IN CORRECT RANGE"); END IF; -- CHECK NON-MODEL VALUE + OR - ZERO: IF NON_MODEL_VAR + ZERO NOT IN 0.5 .. 0.75 OR F'(0.0) + NON_MODEL_CONST NOT IN 0.5 .. 0.75 THEN FAILED ("(2.0 / 3) + 0.0 NOT IN 0.5 .. 0.75"); END IF; IF NON_MODEL_VAR - ZERO NOT IN 0.5 .. 0.75 OR NON_MODEL_CONST - F'(0.0) NOT IN 0.5 .. 0.75 THEN FAILED ("(2.0 / 3) - 0.0 NOT IN 0.5 .. 0.75"); END IF; -- CHECK ZERO - NON-MODEL: IF F'(0.0) - NON_MODEL_CONST NOT IN -0.75 .. -0.5 THEN FAILED ("0.0 - (2.0 / 3) NOT IN -0.75 .. -0.5"); END IF; IF F'(1.0) - NON_MODEL_CONST NOT IN 0.25 .. 0.5 THEN FAILED ("1.0 - (2.0 / 3) NOT IN 0.25 .. 0.5"); END IF; -- CHECK ADDITION AND SUBTRACTION OF NON-MODEL NEAR MIN AND -- MAX: IF MIN + NON_MODEL_VAR NOT IN -999.5 .. -999.25 OR NON_MODEL_CONST + F'FIRST NOT IN -999.5 .. -999.25 THEN FAILED ("-1000.0 + (2.0 / 3) NOT IN -999.5 .. -999.25"); END IF; IF MAX - NON_MODEL_VAR NOT IN 999.25 .. 999.5 OR F'LAST - NON_MODEL_CONST NOT IN 999.25 .. 999.5 THEN FAILED ("1000.0 - (2.0 / 3) NOT IN 999.25 .. 999.5"); END IF; -- CHECK ADDITION AND SUBTRACTION FOR ARBITRARY MID-RANGE -- MODEL NUMBER WITH NON-MODEL: IF EQUAL (3, 3) THEN X := -213.25; END IF; IF X + NON_MODEL_CONST NOT IN -212.75 .. -212.5 THEN FAILED ("-213.25 + (2.0 / 3) NOT IN -212.75 .. -212.5"); END IF; IF NON_MODEL_VAR - X NOT IN 213.75 .. 214.0 THEN FAILED ("(2.0 / 3) - (-213.25) NOT IN 213.75 .. 214.0"); END IF; EXCEPTION WHEN OTHERS => FAILED ("EXCEPTION RAISED - B"); END B; ------------------------------------------------------------------- C: DECLARE A_SMALL, A_MAX, A_MIN : ST_F1 := 0.0; B_SMALL, B_MAX, B_MIN : ST_F2 := 0.0; X : F; BEGIN -- INITIALIZE "CONSTANTS": IF EQUAL (3, 3) THEN A_SMALL := ST_F1'SMALL; A_MAX := ST_F1'LAST; -- BECAUSE 'LAST < 'LARGE AND -- 'LAST IS A MODEL NUMBER. A_MIN := ST_F1'FIRST; -- 'FIRST IS A MODEL NUMBER. B_SMALL := ST_F2'SMALL; B_MAX := ST_F2'LAST; -- BECAUSE 'LAST <= 'LARGE AND -- 'LAST IS A MODEL NUMBER. B_MIN := ST_F2'FIRST; -- 'FIRST IS A MODEL NUMBER. END IF; IF A_MIN + B_MIN /= -4.8125 THEN FAILED ("-4.0 + (-0.8125) /= -4.8125"); END IF; IF A_MIN - B_MIN /= -3.1875 THEN FAILED ("-4.0 - (-0.8125) /= -3.1875"); END IF; IF (A_MIN + B_SMALL) NOT IN A_MIN .. -3.9375 THEN FAILED ("(A_MIN + B_SMALL) NOT IN A_MIN .. -3.9375"); END IF; IF (A_MIN - B_SMALL) NOT IN -4.0625 .. -4.0 THEN FAILED ("(A_MIN - B_SMALL) NOT IN -4.0 .. -4.0625"); END IF; IF A_MIN + B_MAX /= 1.0625 THEN FAILED ("-4.0 + 5.0625 /= 1.0625"); END IF; IF A_MIN - B_MAX /= -9.0625 THEN FAILED ("-4.0 - 5.0625 /= -9.0625"); END IF; IF (A_SMALL + B_MIN) NOT IN B_MIN..-0.3125 THEN FAILED ("(A_SMALL + B_MIN) NOT IN B_MIN..-0.3125"); END IF; IF (A_SMALL - B_MIN) NOT IN +0.8125 .. 1.3125 THEN FAILED ("(A_SMALL - B_MIN) NOT IN -0.8125 .. 1.3125"); END IF; IF (A_SMALL + B_MAX) NOT IN 5.0625 .. 5.5625 THEN FAILED ("(A_SMALL + B_MAX) NOT IN 5.0625 .. 5.5625"); END IF; IF (A_SMALL - B_MAX) NOT IN -5.0625 .. -4.5625 THEN FAILED ("(A_SMALL - B_MAX) NOT IN -5.0625 .. -4.5625"); END IF; IF A_MAX + B_MIN /= 2.1875 THEN FAILED ("3.0 + (-0.8125) /= 2.1875"); END IF; IF A_MAX - B_MIN /= 3.8125 THEN FAILED ("3.0 - (-0.8125) /= 3.8125"); END IF; IF (A_MAX + B_SMALL) NOT IN 3.0 .. 3.0625 THEN FAILED ("(A_MAX + B_SMALL) NOT IN 3.0 .. 3.0625"); END IF; IF (A_MAX - B_SMALL) NOT IN 2.9375..3.0 THEN FAILED ("(A_MAX - B_SMALL) NOT IN 2.9375..3.0"); END IF; IF A_MAX + B_MAX /= 8.0625 THEN FAILED ("3.0 + 5.0625 /= 8.0625"); END IF; IF A_MAX - B_MAX /= -2.0625 THEN FAILED ("3.0 - 5.0625 /= -2.0625"); END IF; X := B_MIN - A_MIN; IF X NOT IN 3.0 .. 3.25 THEN FAILED ("-0.8125 - (-4.0) NOT IN RANGE"); END IF; X := B_MIN - A_SMALL; IF X NOT IN -1.3125 .. -0.8125 THEN FAILED ("B_MIN - A_SMALL NOT IN RANGE"); END IF; X := B_MIN - A_MAX; IF X NOT IN -4.0 .. -3.75 THEN FAILED ("-0.8125 - 3.0 NOT IN RANGE"); END IF; X := B_SMALL - A_MIN; IF X NOT IN 4.0 .. 4.0625 THEN FAILED ("B_SMALL - A_MIN NOT IN RANGE"); END IF; X := B_SMALL - A_MAX; IF X NOT IN -3.0 .. -2.75 THEN FAILED ("B_SMALL - A_MAX NOT IN RANGE"); END IF; X := B_MAX - A_MIN; IF X NOT IN 9.0 .. 9.25 THEN FAILED ("5.0625 - (-4.0) NOT IN RANGE"); END IF; X := B_MAX - A_SMALL; IF X NOT IN 4.56 .. 5.0625 THEN FAILED ("5.0625 - 0.5 NOT IN RANGE"); END IF; X := B_MAX - A_MAX; IF X NOT IN 2.0 .. 2.25 THEN FAILED ("5.0625 - 3.0 NOT IN RANGE"); END IF; EXCEPTION WHEN OTHERS => FAILED ("EXCEPTION RAISED - C"); END C; ------------------------------------------------------------------- RESULT; END C45331A;
with Ada.Integer_Text_IO; with Ada.Text_IO; package body Problem_09 is package IO renames Ada.Text_IO; package I_IO renames Ada.Integer_Text_IO; procedure Solve is Squares : Array (1 .. 1000) of Positive; begin for index in Squares'Range loop Squares(index) := index * index; end loop; for a in 1 .. 332 loop for b in a + 1 .. 1000 - a loop declare c : constant Positive := 1000 - b - a; begin exit when c <= b; if Squares(a) + Squares(b) = Squares(c) then I_IO.put(a*b*c); IO.New_Line; end if; end; end loop; end loop; end Solve; end Problem_09;
--***************************************************************************** --* --* PROJECT: BingAda --* --* FILE: q_csv-q_read_file.adb --* --* AUTHOR: Javier Fuica Fernandez --* --***************************************************************************** with Ada.Exceptions; with Text_Io; package body Q_Csv.Q_Read_File is --================================================================== V_File : Text_Io.File_Type; --================================================================== procedure P_Read_Cards_In_Vector (V_File : Text_Io.File_Type; V_Cards : in out Q_Bingo_Cards.Vector) is V_Row : T_Row := F_Line (Text_Io.Get_Line (V_File)); V_First_Col : Boolean; V_Numbers : T_Numbers; V_Index : Positive := 1; V_Card_Name : T_Name; begin V_First_Col := V_Row.F_Next; V_Card_Name := V_Row.F_Item (T_Name'Range); while V_Row.F_Next loop V_Numbers (V_Index) := Q_Bingo.T_Number'Value (V_Row.F_Item); V_Index := V_Index + 1; end loop; V_Cards.Append ((R_Name => V_Card_Name, R_Numbers => V_Numbers)); end P_Read_Cards_In_Vector; --================================================================== procedure P_Read_Bingo_Cards (V_File_Name : String; V_Cards : out Q_Bingo_Cards.Vector) is begin Text_Io.Open (File => V_File, Mode => Text_Io.In_File, Name => V_File_Name); if Text_Io.Is_Open (V_File) then -- skip header -- Text_Io.Skip_Line (V_File); while not Text_Io.End_Of_File (V_File) loop P_Read_Cards_In_Vector (V_File => V_File, V_Cards => V_Cards); end loop; end if; Text_Io.Close (V_File); exception when V_Exception : others => -- No exception is raised because if the csv file is not correctly read -- the bingada can continue without cards to check. -- Text_Io.Close (V_File); Text_Io.Put_Line ("exception : " & Ada.Exceptions.Exception_Information (V_Exception)); end P_Read_Bingo_Cards; --================================================================== end Q_Csv.Q_Read_File;
private with STM32.GPIO, STM32.Device; package TTS_Example2 is procedure Main; private use STM32.GPIO, STM32.Device; Probe_TT_Point : GPIO_Point := PD2; Probe_ET_Point : GPIO_Point := PD6; end TTS_Example2;
with Ada.Text_IO; procedure Box_The_Compass is type Degrees is digits 5 range 0.00 .. 359.99; type Index_Type is mod 32; function Long_Name(Short: String) return String is function Char_To_Name(Char: Character) return String is begin case Char is when 'N' | 'n' => return Char & "orth"; when 'S' | 's' => return Char & "outh"; when 'E' | 'e' => return Char & "ast"; when 'W' | 'w' => return Char & "est"; when 'b' => return " by "; when '-' => return "-"; when others => raise Constraint_Error; end case; end Char_To_Name; begin if Short'Length = 0 or else Short(Short'First)=' ' then return ""; else return Char_To_Name(Short(Short'First)) & Long_Name(Short(Short'First+1 .. Short'Last)); end if; end Long_Name; procedure Put_Line(Angle: Degrees) is function Index(D: Degrees) return Index_Type is begin return Index_Type(Integer(Degrees'Rounding(D/11.25)) mod 32); end Index; I: Integer := Integer(Index(Angle))+1; package DIO is new Ada.Text_IO.Float_IO(Degrees); Abbr: constant array(Index_Type) of String(1 .. 4) := ("N ", "Nbe ", "N-ne", "Nebn", "Ne ", "Nebe", "E-ne", "Ebn ", "E ", "Ebs ", "E-se", "Sebe", "Se ", "Sebs", "S-se", "Sbe ", "S ", "Sbw ", "S-sw", "Swbs", "Sw ", "Swbw", "W-sw", "Wbs ", "W ", "Wbn ", "W-nw", "Nwbw", "Nw ", "Nwbn", "N-nw", "Nbw "); begin DIO.Put(Angle, Fore => 3, Aft => 2, Exp => 0); -- format "zzx.xx" Ada.Text_IO.Put(" |"); if I <= 9 then Ada.Text_IO.Put(" "); end if; Ada.Text_IO.Put_Line(" " & Integer'Image(I) & " | " & Long_Name(Abbr(Index(Angle)))); end Put_Line; Difference: constant array(0..2) of Degrees'Base := (0=> 0.0, 1=> +5.62, 2=> - 5.62); begin Ada.Text_IO.Put_Line(" angle | box | compass point"); Ada.Text_IO.Put_Line(" ---------------------------------"); for I in 0 .. 32 loop Put_Line(Degrees(Degrees'Base(I) * 11.25 + Difference(I mod 3))); end loop; end Box_The_Compass;
-- with Blade_Types; with C3GA; with C3GA_Draw; with GA_Maths; -- with GA_Utilities; with Metric; with Multivector_Utilities; package body Draw_1_1 is -- --------------------------------------------------------------------- function Draw_Circle (Render_Program : GL.Objects.Programs.Program; C1, C2, C3 : Normalized_Point) return Circle is OP : Multivector; aCircle : Circle; begin OP := Outer_Product (C1, Outer_Product (C2, C3)); aCircle := To_Circle (OP); C3GA_Draw.Draw (Render_Program, aCircle); return aCircle; end Draw_Circle; -- --------------------------------------------------------------------- function Draw_Line (Render_Program : GL.Objects.Programs.Program; P1, P2 : Normalized_Point) return Line is aLine : constant Line := C3GA.Set_Line (P1, P2); begin C3GA_Draw.Draw (Render_Program, aLine); return aLine; end Draw_Line; -- --------------------------------------------------------------------- procedure Draw_Plane (Render_Program : GL.Objects.Programs.Program; DP : Dual_Plane) is begin C3GA_Draw.Draw (Render_Program, DP); end Draw_Plane; -- --------------------------------------------------------------------- procedure Draw_Reflected_Circle (Render_Program : GL.Objects.Programs.Program; C : Circle; DP : Dual_Plane) is begin C3GA_Draw.Draw (Render_Program, Multivector_Utilities.Reflect (C, DP)); end Draw_Reflected_Circle; -- --------------------------------------------------------------------- procedure Draw_Reflected_Line (Render_Program : GL.Objects.Programs.Program; L : Line; DP : Dual_Plane) is begin C3GA_Draw.Draw (Render_Program, Multivector_Utilities.Reflect (L, DP)); end Draw_Reflected_Line; -- --------------------------------------------------------------------- function Draw_Rotated_Circle (Render_Program : GL.Objects.Programs.Program; C: Circle; RV : TR_Versor) return Circle is MV : constant Multivector := Multivector_Utilities.Rotate (Multivector (C), RV); RC : constant Circle := To_Circle (MV); begin C3GA_Draw.Draw (Render_Program, RC); return RC; end Draw_Rotated_Circle; -- -------------------------------------------------------------------- function New_Dual_Plane (P1 : Normalized_Point; Normal : E3GA.E3_Vector) return Dual_Plane is OP : Multivector := Outer_Product (E3GA.To_MV_Vector (Normal), C3GA.ni); begin OP := Left_Contraction (P1, OP, Metric.C3_Metric); -- Checked OK against C++ return To_Dual_Plane (OP); end New_Dual_Plane; -- --------------------------------------------------------------------- function New_TR_Versor (L1 : Line) return TR_Versor is use Metric; Phi : constant Float := 0.5 * GA_Maths.Pi; Exp_MV : constant Multivector := Exp (0.5 * Phi * Dual (L1, C3_Metric), C3_Metric); LR : constant Dual_Line := To_Dual_Line (Exp_MV); begin return To_TRversor (LR); end New_TR_Versor; -- --------------------------------------------------------------------- end Draw_1_1;
with AdaM.a_Type.ordinary_fixed_point_type, gtk.Widget; private with gtk.gEntry, gtk.Box, gtk.Label, gtk.Spin_Button, gtk.Button; package aIDE.Editor.of_fixed_type is type Item is new Editor.item with private; type View is access all Item'Class; package Forge is function to_Editor (the_Target : in AdaM.a_Type.ordinary_fixed_point_type.view) return View; end Forge; overriding function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget; private use gtk.Button, gtk.gEntry, gtk.Spin_Button, gtk.Label, gtk.Box; type Item is new Editor.item with record Target : AdaM.a_Type.ordinary_fixed_point_type.view; top_Box : gtk_Box; name_Entry : Gtk_Entry; delta_Entry : Gtk_Entry; first_Entry : Gtk_Entry; last_Entry : Gtk_Entry; rid_Button : gtk_Button; end record; overriding procedure freshen (Self : in out Item); end aIDE.Editor.of_fixed_type;
----------------------------------------------------------------------- -- city_mapping -- Example of serialization mapping for city CSV records -- Copyright (C) 2011 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Util.Beans.Objects; with Util.Serialize.Mappers.Record_Mapper; with Util.Serialize.Mappers.Vector_Mapper; with Util.Serialize.Mappers; with Ada.Containers.Vectors; package City_Mapping is use Ada.Strings.Unbounded; type City is record Country : Unbounded_String; City : Unbounded_String; Name : Unbounded_String; Region : Unbounded_String; Latitude : Float; Longitude : Float; end record; type City_Access is access all City; type City_Fields is (FIELD_COUNTRY, FIELD_CITY, FIELD_NAME, FIELD_REGION, FIELD_LATITUDE, FIELD_LONGITUDE); -- Set the name/value pair on the current object. procedure Set_Member (P : in out City; Field : in City_Fields; Value : in Util.Beans.Objects.Object); package City_Mapper is new Util.Serialize.Mappers.Record_Mapper (Element_Type => City, Element_Type_Access => City_Access, Fields => City_Fields, Set_Member => Set_Member); subtype City_Context is City_Mapper.Element_Data; package City_Vector is new Ada.Containers.Vectors (Element_Type => City, Index_Type => Positive); package City_Vector_Mapper is new Util.Serialize.Mappers.Vector_Mapper (Vectors => City_Vector, Element_Mapper => City_Mapper); subtype City_Vector_Context is City_Vector_Mapper.Vector_Data; -- Get the address mapper which describes how to load an Address. function Get_City_Mapper return Util.Serialize.Mappers.Mapper_Access; -- Get the person vector mapper which describes how to load a list of Person. function Get_City_Vector_Mapper return City_Vector_Mapper.Mapper_Access; end City_Mapping;
-- { dg-do run } -- { dg-options "-O2" } with Nested_Subtype_Byref; procedure Test_Nested_Subtype_Byref is begin Nested_Subtype_Byref.Check; end;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2013, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Internals.Element_Collections; with AMF.Internals.Tables.UTP_Element_Table; with AMF.Internals.Tables.UTP_Types; with AMF.Internals.Tables.Utp_Metamodel; with AMF.Internals.Utp_Coding_Rules; with AMF.Internals.Utp_Data_Partitions; with AMF.Internals.Utp_Data_Pools; with AMF.Internals.Utp_Data_Selectors; with AMF.Internals.Utp_Default_Applications; with AMF.Internals.Utp_Defaults; with AMF.Internals.Utp_Determ_Alts; with AMF.Internals.Utp_Finish_Actions; with AMF.Internals.Utp_Get_Timezone_Actions; with AMF.Internals.Utp_Literal_Anies; with AMF.Internals.Utp_Literal_Any_Or_Nulls; with AMF.Internals.Utp_Log_Actions; with AMF.Internals.Utp_Managed_Elements; with AMF.Internals.Utp_Read_Timer_Actions; with AMF.Internals.Utp_SUTs; with AMF.Internals.Utp_Set_Timezone_Actions; with AMF.Internals.Utp_Start_Timer_Actions; with AMF.Internals.Utp_Stop_Timer_Actions; with AMF.Internals.Utp_Test_Cases; with AMF.Internals.Utp_Test_Components; with AMF.Internals.Utp_Test_Contexts; with AMF.Internals.Utp_Test_Log_Applications; with AMF.Internals.Utp_Test_Logs; with AMF.Internals.Utp_Test_Objectives; with AMF.Internals.Utp_Test_Suites; with AMF.Internals.Utp_Time_Out_Actions; with AMF.Internals.Utp_Time_Out_Messages; with AMF.Internals.Utp_Time_Outs; with AMF.Internals.Utp_Timer_Running_Actions; with AMF.Internals.Utp_Validation_Actions; with AMF.Utp; with Matreshka.Internals.Strings; package body AMF.Internals.Tables.UTP_Constructors is use AMF.Internals.Tables; use type AMF.Internals.AMF_Collection_Of_Element; ---------------------------- -- Create_Utp_Coding_Rule -- ---------------------------- function Create_Utp_Coding_Rule return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Coding_Rule, Extent => 0, Proxy => new AMF.Internals.Utp_Coding_Rules.Utp_Coding_Rule_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 2 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_Namespace 3 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_Property 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_ValueSpecification 4 => (AMF.Internals.Tables.UTP_Types.M_String, Matreshka.Internals.Strings.Shared_Empty'Access), -- coding others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Coding_Rule; ------------------------------- -- Create_Utp_Data_Partition -- ------------------------------- function Create_Utp_Data_Partition return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Data_Partition, Extent => 0, Proxy => new AMF.Internals.Utp_Data_Partitions.Utp_Data_Partition_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_Classifier others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Data_Partition; -------------------------- -- Create_Utp_Data_Pool -- -------------------------- function Create_Utp_Data_Pool return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Data_Pool, Extent => 0, Proxy => new AMF.Internals.Utp_Data_Pools.Utp_Data_Pool_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_Classifier 2 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_Property others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Data_Pool; ------------------------------ -- Create_Utp_Data_Selector -- ------------------------------ function Create_Utp_Data_Selector return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Data_Selector, Extent => 0, Proxy => new AMF.Internals.Utp_Data_Selectors.Utp_Data_Selector_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_Operation others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Data_Selector; ------------------------ -- Create_Utp_Default -- ------------------------ function Create_Utp_Default return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Default, Extent => 0, Proxy => new AMF.Internals.Utp_Defaults.Utp_Default_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_Behavior others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Default; ------------------------------------ -- Create_Utp_Default_Application -- ------------------------------------ function Create_Utp_Default_Application return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Default_Application, Extent => 0, Proxy => new AMF.Internals.Utp_Default_Applications.Utp_Default_Application_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_Dependency 2 => (AMF.Internals.Tables.UTP_Types.M_Unlimited_Natural, (False, 0)), -- repetition others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Default_Application; --------------------------- -- Create_Utp_Determ_Alt -- --------------------------- function Create_Utp_Determ_Alt return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Determ_Alt, Extent => 0, Proxy => new AMF.Internals.Utp_Determ_Alts.Utp_Determ_Alt_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_CombinedFragment others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Determ_Alt; ------------------------------ -- Create_Utp_Finish_Action -- ------------------------------ function Create_Utp_Finish_Action return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Finish_Action, Extent => 0, Proxy => new AMF.Internals.Utp_Finish_Actions.Utp_Finish_Action_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 2 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_InvocationAction 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_OpaqueAction others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Finish_Action; ------------------------------------ -- Create_Utp_Get_Timezone_Action -- ------------------------------------ function Create_Utp_Get_Timezone_Action return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Get_Timezone_Action, Extent => 0, Proxy => new AMF.Internals.Utp_Get_Timezone_Actions.Utp_Get_Timezone_Action_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_ReadStructuralFeatureAction others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Get_Timezone_Action; ---------------------------- -- Create_Utp_Literal_Any -- ---------------------------- function Create_Utp_Literal_Any return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Literal_Any, Extent => 0, Proxy => new AMF.Internals.Utp_Literal_Anies.Utp_Literal_Any_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_LiteralSpecification others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Literal_Any; ------------------------------------ -- Create_Utp_Literal_Any_Or_Null -- ------------------------------------ function Create_Utp_Literal_Any_Or_Null return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Literal_Any_Or_Null, Extent => 0, Proxy => new AMF.Internals.Utp_Literal_Any_Or_Nulls.Utp_Literal_Any_Or_Null_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_LiteralSpecification others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Literal_Any_Or_Null; --------------------------- -- Create_Utp_Log_Action -- --------------------------- function Create_Utp_Log_Action return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Log_Action, Extent => 0, Proxy => new AMF.Internals.Utp_Log_Actions.Utp_Log_Action_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_SendObjectAction others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Log_Action; -------------------------------- -- Create_Utp_Managed_Element -- -------------------------------- function Create_Utp_Managed_Element return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Managed_Element, Extent => 0, Proxy => new AMF.Internals.Utp_Managed_Elements.Utp_Managed_Element_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_Element 5 => (AMF.Internals.Tables.UTP_Types.M_String, null), -- criticality 3 => (AMF.Internals.Tables.UTP_Types.M_String, null), -- description 2 => (AMF.Internals.Tables.UTP_Types.M_String, null), -- owner 4 => (AMF.Internals.Tables.UTP_Types.M_String, null), -- version others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Managed_Element; ---------------------------------- -- Create_Utp_Read_Timer_Action -- ---------------------------------- function Create_Utp_Read_Timer_Action return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Read_Timer_Action, Extent => 0, Proxy => new AMF.Internals.Utp_Read_Timer_Actions.Utp_Read_Timer_Action_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_CallOperationAction others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Read_Timer_Action; -------------------- -- Create_Utp_SUT -- -------------------- function Create_Utp_SUT return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_SUT, Extent => 0, Proxy => new AMF.Internals.Utp_SUTs.Utp_SUT_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_Property others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_SUT; ------------------------------------ -- Create_Utp_Set_Timezone_Action -- ------------------------------------ function Create_Utp_Set_Timezone_Action return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Set_Timezone_Action, Extent => 0, Proxy => new AMF.Internals.Utp_Set_Timezone_Actions.Utp_Set_Timezone_Action_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_WriteStructuralFeatureAction others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Set_Timezone_Action; ----------------------------------- -- Create_Utp_Start_Timer_Action -- ----------------------------------- function Create_Utp_Start_Timer_Action return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Start_Timer_Action, Extent => 0, Proxy => new AMF.Internals.Utp_Start_Timer_Actions.Utp_Start_Timer_Action_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_CallOperationAction others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Start_Timer_Action; ---------------------------------- -- Create_Utp_Stop_Timer_Action -- ---------------------------------- function Create_Utp_Stop_Timer_Action return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Stop_Timer_Action, Extent => 0, Proxy => new AMF.Internals.Utp_Stop_Timer_Actions.Utp_Stop_Timer_Action_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_CallOperationAction others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Stop_Timer_Action; -------------------------- -- Create_Utp_Test_Case -- -------------------------- function Create_Utp_Test_Case return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Test_Case, Extent => 0, Proxy => new AMF.Internals.Utp_Test_Cases.Utp_Test_Case_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 4 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_Behavior 5 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_Operation 2 => (AMF.Internals.Tables.UTP_Types.M_Collection_Of_String, 0), -- compatibleSUTVariant 1 => (AMF.Internals.Tables.UTP_Types.M_Collection_Of_String, 0), -- compatibleSUTVersion 3 => (AMF.Internals.Tables.UTP_Types.M_String, null), -- priority others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Test_Case; ------------------------------- -- Create_Utp_Test_Component -- ------------------------------- function Create_Utp_Test_Component return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Test_Component, Extent => 0, Proxy => new AMF.Internals.Utp_Test_Components.Utp_Test_Component_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 3 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_StructuredClassifier 2 => (AMF.Internals.Tables.UTP_Types.M_Collection_Of_String, 0), -- compatibleSUTVariant 1 => (AMF.Internals.Tables.UTP_Types.M_Collection_Of_String, 0), -- compatibleSUTVersion others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Test_Component; ----------------------------- -- Create_Utp_Test_Context -- ----------------------------- function Create_Utp_Test_Context return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Test_Context, Extent => 0, Proxy => new AMF.Internals.Utp_Test_Contexts.Utp_Test_Context_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 4 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_BehavioredClassifier 3 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_StructuredClassifier 2 => (AMF.Internals.Tables.UTP_Types.M_Collection_Of_String, 0), -- compatibleSUTVariant 1 => (AMF.Internals.Tables.UTP_Types.M_Collection_Of_String, 0), -- compatibleSUTVersion 5 => (AMF.Internals.Tables.UTP_Types.M_String, null), -- testLevel others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Test_Context; ------------------------- -- Create_Utp_Test_Log -- ------------------------- function Create_Utp_Test_Log return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Test_Log, Extent => 0, Proxy => new AMF.Internals.Utp_Test_Logs.Utp_Test_Log_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_Behavior 4 => (AMF.Internals.Tables.UTP_Types.M_String, null), -- duration 3 => (AMF.Internals.Tables.UTP_Types.M_String, null), -- executedAt 7 => (AMF.Internals.Tables.UTP_Types.M_String, null), -- sutVersion 2 => (AMF.Internals.Tables.UTP_Types.M_Collection_Of_String, 0), -- tester 5 => (AMF.Internals.Tables.UTP_Types.M_Verdict, AMF.Utp.None), -- verdict 6 => (AMF.Internals.Tables.UTP_Types.M_String, null), -- verdictReason others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Test_Log; ------------------------------------- -- Create_Utp_Test_Log_Application -- ------------------------------------- function Create_Utp_Test_Log_Application return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Test_Log_Application, Extent => 0, Proxy => new AMF.Internals.Utp_Test_Log_Applications.Utp_Test_Log_Application_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_Dependency others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Test_Log_Application; ------------------------------- -- Create_Utp_Test_Objective -- ------------------------------- function Create_Utp_Test_Objective return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Test_Objective, Extent => 0, Proxy => new AMF.Internals.Utp_Test_Objectives.Utp_Test_Objective_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_Dependency 3 => (AMF.Internals.Tables.UTP_Types.M_String, null), -- priority others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Test_Objective; --------------------------- -- Create_Utp_Test_Suite -- --------------------------- function Create_Utp_Test_Suite return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Test_Suite, Extent => 0, Proxy => new AMF.Internals.Utp_Test_Suites.Utp_Test_Suite_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_Behavior 3 => (AMF.Internals.Tables.UTP_Types.M_String, null), -- priority others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); -- testCase AMF.Internals.Element_Collections.Initialize_Set_Collection (Self, AMF.Internals.Tables.Utp_Metamodel.MP_Utp_Test_Suite_Test_Case, UTP_Element_Table.Table (Self).Member (0).Collection + 1); return Self; end Create_Utp_Test_Suite; ------------------------- -- Create_Utp_Time_Out -- ------------------------- function Create_Utp_Time_Out return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Time_Out, Extent => 0, Proxy => new AMF.Internals.Utp_Time_Outs.Utp_Time_Out_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_TimeEvent others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Time_Out; -------------------------------- -- Create_Utp_Time_Out_Action -- -------------------------------- function Create_Utp_Time_Out_Action return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Time_Out_Action, Extent => 0, Proxy => new AMF.Internals.Utp_Time_Out_Actions.Utp_Time_Out_Action_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_AcceptEventAction others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Time_Out_Action; --------------------------------- -- Create_Utp_Time_Out_Message -- --------------------------------- function Create_Utp_Time_Out_Message return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Time_Out_Message, Extent => 0, Proxy => new AMF.Internals.Utp_Time_Out_Messages.Utp_Time_Out_Message_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_Message others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Time_Out_Message; ------------------------------------- -- Create_Utp_Timer_Running_Action -- ------------------------------------- function Create_Utp_Timer_Running_Action return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Timer_Running_Action, Extent => 0, Proxy => new AMF.Internals.Utp_Timer_Running_Actions.Utp_Timer_Running_Action_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_ReadStructuralFeatureAction others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Timer_Running_Action; ---------------------------------- -- Create_Utp_Validation_Action -- ---------------------------------- function Create_Utp_Validation_Action return AMF.Internals.AMF_Element is Self : AMF.Internals.AMF_Element; begin UTP_Element_Table.Increment_Last; Self := UTP_Element_Table.Last; UTP_Element_Table.Table (Self).all := (Kind => AMF.Internals.Tables.UTP_Types.E_Utp_Validation_Action, Extent => 0, Proxy => new AMF.Internals.Utp_Validation_Actions.Utp_Validation_Action_Proxy'(Element => Self), Member => (0 => (Kind => AMF.Internals.Tables.UTP_Types.M_None), 1 => (AMF.Internals.Tables.UTP_Types.M_Element, No_AMF_Link), -- base_CallOperationAction others => (Kind => AMF.Internals.Tables.UTP_Types.M_None))); UTP_Element_Table.Table (Self).Member (0) := (AMF.Internals.Tables.UTP_Types.M_Collection_Of_Element, AMF.Internals.Element_Collections.Allocate_Collections (1)); return Self; end Create_Utp_Validation_Action; end AMF.Internals.Tables.UTP_Constructors;
with Decls.Dgenerals, Decls.Dtnode, Decls.D_Taula_De_Noms, Decls.D_Atribut, Decls.dtsimbols, Ada.Text_Io, Decls.dtdesc; use Decls.Dgenerals, Decls.Dtnode, Decls.D_Taula_De_Noms, Decls.D_Atribut, Decls.dtsimbols, Ada.Text_Io, Decls.dtdesc; package Semantica is --Definicions basiques type tInstruccio is (--1 operand Rtn, Call, Preamb, Params, Etiqueta, Branc_Inc, -- 2 operands Negacio, Op_Not, Copia, Paramc, --3 operands Suma, Resta, Producte, Divisio, Modul, Op_And, Op_Or, Consindex, Asigindex, Menor, Menorigual, Igual, Majorigual, Major, Diferent); type tCamp is (Proc, Var, Etiq, Const); type Camp(tc : tCamp:=Const) is record case Tc is when Proc => Idp : num_Proc; when Var => Idv : num_var; when Etiq => Ide : num_etiq; when Const => Idc : num_var; when others => null; end case; end record; type C3a is record Instr : tInstruccio; Camp1 : Camp; Camp2 : Camp; Camp3 : Camp; end record; type Tprocediment is (Intern, Extern); type Info_Proc (Tp : Tprocediment := Intern) is record Ocup_Param : Despl; case Tp is when Intern => Idn : Id_Nom; Prof : nprof; Ocup_Var : Despl; Etiq : Num_Etiq; when Extern => Etiq_extern : Id_Nom; end case; end record; Info_Proc_Nul : Info_Proc := (Intern, 0, Id_Nul, 0, 0, Etiq_Nul); type Taula_P is array (Num_Proc) of Info_Proc; type T_Procs is record Tp : Taula_P; Np : Num_Proc; end record; Tp : T_Procs; --Taula de variables type Info_Var is record Id : Id_Nom; Np : num_proc; Ocup : Despl; Desp : Despl; Tsub : Tipussubjacent; Param : Boolean; Const : Boolean; Valconst : Valor; end record; Info_Var_Nul : Info_Var := (Id => Id_Nul, Np => proc_nul, Ocup => 0, Desp => 0, Tsub => Tsnul, Param => False, Const => False, Valconst => 0); type taula_v is array (Num_Var) of Info_Var; type T_Vars is record Tv : taula_v; Nv : num_var; end record; Tv : T_Vars; Ne : Num_Etiq := 0; Arbre : Pnode; -- Per els brancaments Zero, MenysU : num_Var; -- Procediments procedure Abuit (P : out pnode); procedure creaNode_programa (P : out Atribut; A : in Atribut); procedure creaNode (p : out atribut; fe, fd : in atribut; tn : in Tipusnode); procedure creaNode (p : out atribut; fe, fc, fd : in atribut; tn : in Tipusnode); procedure creaNode (p : out atribut; fe, fce, fc, fd : in atribut; tn : in Tipusnode); procedure creaNode (p : out atribut; f : in atribut; tn : in Tipusnode); procedure creaNode (p : out atribut; fe, fd: in atribut; op : in operacio; tn : in Tipusnode); procedure creaNode (p : out atribut; f : in atribut; op : in operacio; tn : in Tipusnode); procedure CreaNode_ID (p : out atribut; id : in atribut; tn : in Tipusnode); procedure CreaNode_VAL (p : out atribut; a : in atribut; tn : in Tipusnode; S : in Valor); procedure CreaNode_MODE (P : out Atribut; M : in Mmode; Tn : in Tipusnode); procedure creaNode (P : out Atribut; Tn : in Tipusnode); procedure Remunta (P : out Atribut; A : in Atribut); procedure Cons_Tnode (P : in Pnode; Tn : out Tipusnode); -- Procediments per a les Taules procedure Noves_taules (Tp : out T_Procs; Tv : out T_Vars); -- Procediments per Taula de Procediments procedure Posa (Tp : in out T_Procs; Ip : in Info_Proc; Idp : out num_Proc); procedure Modif_Descripcio (Tp : in out T_Procs; Idp : in num_proc; Ip : in Info_Proc); -- Procediments per Taula de Variables procedure Posa (Tv : in out T_Vars; Iv : in Info_Var; Idv : out num_var); private Ts : Tsimbols; Tts: Ttsimbols; Tn : Taula_De_Noms; Nv : Num_Var; Np : Num_Proc; Id_Puts : Num_Proc; Id_Gets : Num_Proc; end Semantica;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2020, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of STMicroelectronics nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- -- -- -- This file is based on: -- -- -- -- @file stm32f4xx_hal_cortex.h -- -- @author MCD Application Team -- -- @version V1.1.0 -- -- @date 19-June-2014 -- -- @brief Header file of CORTEX HAL module. -- -- -- -- COPYRIGHT(c) 2014 STMicroelectronics -- ------------------------------------------------------------------------------ -- This file provides Nested Vector interrupt Controller definitions for the -- STM32F4 (ARM Cortex M4F) microcontrollers from ST Microelectronics. with System; with HAL; use HAL; package Cortex_M.NVIC is -- the Nested Vectored Interrupt Controller type Interrupt_ID is new Natural range 0 .. 240; type Interrupt_Priority is new UInt32; -- 0 bits for pre-emption priority; 4 bits for subpriority Priority_Group_0 : constant UInt32 := 16#00000007#; -- 1 bits for pre-emption priority; 3 bits for subpriority Priority_Group_1 : constant UInt32 := 16#00000006#; -- 2 bits for pre-emption priority; 2 bits for subpriority Priority_Group_2 : constant UInt32 := 16#00000005#; -- 3 bits for pre-emption priority; 1 bits for subpriority Priority_Group_3 : constant UInt32 := 16#00000004#; -- 4 bits for pre-emption priority; 0 bits for subpriority Priority_Group_4 : constant UInt32 := 16#00000003#; procedure Set_Priority_Grouping (Priority_Group : Interrupt_Priority) with Inline; function Priority_Grouping return Interrupt_Priority with Inline; procedure Set_Priority (IRQn : Interrupt_ID; Priority : Interrupt_Priority) with Inline; function Encoded_Priority (Priority_Group : Interrupt_Priority; Preempt_Priority : Interrupt_Priority; Subpriority : Interrupt_Priority) return Interrupt_Priority with Inline; procedure Set_Priority (IRQn : Interrupt_ID; Preempt_Priority : Interrupt_Priority; Subpriority : Interrupt_Priority) with Inline; -- A convenience routine that first encodes (Priority_Grouping(), -- Preempt_Priority, and Subpriority), and then calls the other -- Set_Priority with the resulting encoding for the Priority argument. procedure Enable_Interrupt (IRQn : Interrupt_ID) with Inline; procedure Disable_Interrupt (IRQn : Interrupt_ID) with Inline; function Active (IRQn : Interrupt_ID) return Boolean with Inline; function Pending (IRQn : Interrupt_ID) return Boolean with Inline; procedure Set_Pending (IRQn : Interrupt_ID) with Inline; procedure Clear_Pending (IRQn : Interrupt_ID) with Inline; procedure Reset_System; private type Words is array (Natural range <>) of UInt32; type UInt8s is array (Natural range <>) of UInt8; type Nested_Vectored_Interrupt_Controller is record ISER : Words (0 .. 7); -- Interrupt Set Enable Register Reserved0 : Words (0 .. 23); ICER : Words (0 .. 7); -- Interrupt Clear Enable Register Reserved1 : Words (0 .. 23); ISPR : Words (0 .. 7); -- Interrupt Set Pending Register Reserved2 : Words (0 .. 23); ICPR : Words (0 .. 7); -- Interrupt Clear Pending Register Reserved3 : Words (0 .. 23); IABR : Words (0 .. 7); -- Interrupt Active Bit Register Reserved4 : Words (0 .. 55); IP : UInt8s (0 .. 239); -- Interrupt Priority Register Reserved5 : Words (0 .. 643); STIR : UInt32; -- Software Trigger Interrupt Register (write-only) end record with Volatile; for Nested_Vectored_Interrupt_Controller use record ISER at 0 range 0 .. 255; -- 32 UInt8s Reserved0 at 32 range 0 .. 767; -- 96 UInt8s ICER at 128 range 0 .. 255; -- 32 UInt8s Reserved1 at 160 range 0 .. 767; -- 96 UInt8s ISPR at 256 range 0 .. 255; -- 32 UInt8s Reserved2 at 288 range 0 .. 767; -- 96 UInt8s ICPR at 384 range 0 .. 255; -- 32 UInt8s Reserved3 at 416 range 0 .. 767; -- 96 UInt8s IABR at 512 range 0 .. 255; -- 32 UInt8s Reserved4 at 544 range 0 .. 1791; -- 220 UInt8s IP at 768 range 0 .. 1919; -- 240 UInt8s Reserved5 at 1008 range 0 .. 20607; -- 2576 UInt8s STIR at 3584 range 0 .. 31; -- 4 UInt8s end record; type System_Control_Block is record CPUID : UInt32; -- CPUID Base Register (read-only) ICSR : UInt32; -- Interrupt Control and State Register VTOR : UInt32; -- Vector Table Offset Register AIRCR : UInt32; -- Application Interrupt and Reset Control Register SCR : UInt32; -- System Control Register CCR : UInt32; -- Configuration Control Register SHP : UInt8s (0 .. 11); -- System Handlers Priority Registers (4-7, 8-11, 12-15) SHCSR : UInt32; -- System Handler Control and State Register CFSR : UInt32; -- Configurable Fault Status Register HFSR : UInt32; -- HardFault Status Register DFSR : UInt32; -- Debug Fault Status Register MMFAR : UInt32; -- MemManage Fault Address Register BFAR : UInt32; -- BusFault Address Register AFSR : UInt32; -- Auxiliary Fault Status Register PFR : Words (0 .. 1); -- Processor Feature Register (read-only) DFR : UInt32; -- Debug Feature Register (read-only) ADR : UInt32; -- Auxiliary Feature Register (read-only) MMFR : Words (0 .. 3); -- Memory Model Feature Register (read-only) ISAR : Words (0 .. 4); -- Instruction Set Attributes Register (read-only) RESERVED0 : Words (0 .. 4); CPACR : UInt32; -- Coprocessor Access Control Register end record with Volatile; for System_Control_Block use record CPUID at 0 range 0 .. 31; -- Offset: 0x000 ICSR at 4 range 0 .. 31; -- Offset: 0x004 VTOR at 8 range 0 .. 31; -- Offset: 0x008 AIRCR at 12 range 0 .. 31; -- Offset: 0x00C SCR at 16 range 0 .. 31; -- Offset: 0x010 CCR at 20 range 0 .. 31; -- Offset: 0x014 SHP at 24 range 0 .. 95; -- Offset: 0x018 SHCSR at 36 range 0 .. 31; -- Offset: 0x024 CFSR at 40 range 0 .. 31; -- Offset: 0x028 HFSR at 44 range 0 .. 31; -- Offset: 0x02C DFSR at 48 range 0 .. 31; -- Offset: 0x030 MMFAR at 52 range 0 .. 31; -- Offset: 0x034 BFAR at 56 range 0 .. 31; -- Offset: 0x038 AFSR at 60 range 0 .. 31; -- Offset: 0x03C PFR at 64 range 0 .. 63; -- Offset: 0x040 DFR at 72 range 0 .. 31; -- Offset: 0x048 ADR at 76 range 0 .. 31; -- Offset: 0x04C MMFR at 80 range 0 .. 127; -- Offset: 0x050 ISAR at 96 range 0 .. 159; -- Offset: 0x060 RESERVED0 at 116 range 0 .. 159; CPACR at 136 range 0 .. 31; -- Offset: 0x088 end record; SCS_Base : constant := 16#E000_E000#; -- system control space base address NVIC_Base : constant := SCS_Base + 16#0100#; SCB_Base : constant := SCS_Base + 16#0D00#; -- System Control Block base address SCB : System_Control_Block with Volatile, Address => System'To_Address (SCB_Base); pragma Import (Ada, SCB); NVIC : Nested_Vectored_Interrupt_Controller with Volatile, Address => System'To_Address (NVIC_Base); pragma Import (Ada, NVIC); SCB_AIRCR_PRIGROUP_Pos : constant := 8; SCB_AIRCR_PRIGROUP_Mask : constant UInt32 := Shift_Left (7, SCB_AIRCR_PRIGROUP_Pos); SCB_AIRCR_VECTKEY_Pos : constant := 16; SCB_AIRCR_VECTKEY_Mask : constant UInt32 := Shift_Left (16#FFFF#, SCB_AIRCR_VECTKEY_Pos); SCB_AIRCR_SYSRESETREQ_Pos : constant := 2; SCB_AIRCR_SYSRESETREQ_Mask : constant UInt32 := Shift_Left (1, SCB_AIRCR_SYSRESETREQ_Pos); NVIC_PRIO_BITS : constant := 4; -- STM32F4XX uses 4 bits for the priority levels end Cortex_M.NVIC;
-- -- Jan & Uwe R. Zimmer, Australia, July 2011 -- package body Timing is Time_Keeper : Time := Clock; function Timer return Time_Span is Timed : constant Time_Span := Clock - Time_Keeper; begin Time_Keeper := Time_Keeper + Timed; return Timed; end Timer; end Timing;
-- C25001A.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT ALL CHARACTER LITERALS CAN BE WRITTEN. -- CASE A: THE BASIC CHARACTER SET. -- TBN 3/17/86 WITH REPORT; USE REPORT; PROCEDURE C25001A IS BEGIN TEST ("C25001A", "CHECK THAT EACH CHARACTER IN THE BASIC " & "CHARACTER SET CAN BE WRITTEN"); IF CHARACTER'POS('A') /= 65 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'A'"); END IF; IF CHARACTER'POS('B') /= 66 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'B'"); END IF; IF CHARACTER'POS('C') /= 67 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'C'"); END IF; IF CHARACTER'POS('D') /= 68 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'D'"); END IF; IF CHARACTER'POS('E') /= 69 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'E'"); END IF; IF CHARACTER'POS('F') /= 70 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'F'"); END IF; IF CHARACTER'POS('G') /= 71 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'G'"); END IF; IF CHARACTER'POS('H') /= 72 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'H'"); END IF; IF CHARACTER'POS('I') /= 73 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'I'"); END IF; IF CHARACTER'POS('J') /= 74 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'J'"); END IF; IF CHARACTER'POS('K') /= 75 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'K'"); END IF; IF CHARACTER'POS('L') /= 76 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'L'"); END IF; IF CHARACTER'POS('M') /= 77 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'M'"); END IF; IF CHARACTER'POS('N') /= 78 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'N'"); END IF; IF CHARACTER'POS('O') /= 79 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'O'"); END IF; IF CHARACTER'POS('P') /= 80 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'P'"); END IF; IF CHARACTER'POS('Q') /= 81 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'Q'"); END IF; IF CHARACTER'POS('R') /= 82 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'R'"); END IF; IF CHARACTER'POS('S') /= 83 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'S'"); END IF; IF CHARACTER'POS('T') /= 84 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'T'"); END IF; IF CHARACTER'POS('U') /= 85 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'U'"); END IF; IF CHARACTER'POS('V') /= 86 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'V'"); END IF; IF CHARACTER'POS('W') /= 87 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'W'"); END IF; IF CHARACTER'POS('X') /= 88 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'X'"); END IF; IF CHARACTER'POS('Y') /= 89 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'Y'"); END IF; IF CHARACTER'POS('Z') /= 90 THEN FAILED ("INCORRECT POSITION NUMBER FOR 'Z'"); END IF; IF CHARACTER'POS('0') /= 48 THEN FAILED ("INCORRECT POSITION NUMBER FOR '0'"); END IF; IF CHARACTER'POS('1') /= 49 THEN FAILED ("INCORRECT POSITION NUMBER FOR '1'"); END IF; IF CHARACTER'POS('2') /= 50 THEN FAILED ("INCORRECT POSITION NUMBER FOR '2'"); END IF; IF CHARACTER'POS('3') /= 51 THEN FAILED ("INCORRECT POSITION NUMBER FOR '3'"); END IF; IF CHARACTER'POS('4') /= 52 THEN FAILED ("INCORRECT POSITION NUMBER FOR '4'"); END IF; IF CHARACTER'POS('5') /= 53 THEN FAILED ("INCORRECT POSITION NUMBER FOR '5'"); END IF; IF CHARACTER'POS('6') /= 54 THEN FAILED ("INCORRECT POSITION NUMBER FOR '6'"); END IF; IF CHARACTER'POS('7') /= 55 THEN FAILED ("INCORRECT POSITION NUMBER FOR '7'"); END IF; IF CHARACTER'POS('8') /= 56 THEN FAILED ("INCORRECT POSITION NUMBER FOR '8'"); END IF; IF CHARACTER'POS('9') /= 57 THEN FAILED ("INCORRECT POSITION NUMBER FOR '9'"); END IF; IF CHARACTER'POS('"') /= 34 THEN FAILED ("INCORRECT POSITION NUMBER FOR '""'"); END IF; IF CHARACTER'POS('#') /= 35 THEN FAILED ("INCORRECT POSITION NUMBER FOR '#'"); END IF; IF CHARACTER'POS('&') /= 38 THEN FAILED ("INCORRECT POSITION NUMBER FOR '&'"); END IF; IF CHARACTER'POS(''') /= 39 THEN FAILED ("INCORRECT POSITION NUMBER FOR '''"); END IF; IF CHARACTER'POS('(') /= 40 THEN FAILED ("INCORRECT POSITION NUMBER FOR '('"); END IF; IF CHARACTER'POS(')') /= 41 THEN FAILED ("INCORRECT POSITION NUMBER FOR ')'"); END IF; IF CHARACTER'POS('*') /= 42 THEN FAILED ("INCORRECT POSITION NUMBER FOR '*'"); END IF; IF CHARACTER'POS('+') /= 43 THEN FAILED ("INCORRECT POSITION NUMBER FOR '+'"); END IF; IF CHARACTER'POS(',') /= 44 THEN FAILED ("INCORRECT POSITION NUMBER FOR ','"); END IF; IF CHARACTER'POS('-') /= 45 THEN FAILED ("INCORRECT POSITION NUMBER FOR '-'"); END IF; IF CHARACTER'POS('.') /= 46 THEN FAILED ("INCORRECT POSITION NUMBER FOR '.'"); END IF; IF CHARACTER'POS('/') /= 47 THEN FAILED ("INCORRECT POSITION NUMBER FOR '/'"); END IF; IF CHARACTER'POS(':') /= 58 THEN FAILED ("INCORRECT POSITION NUMBER FOR ':'"); END IF; IF CHARACTER'POS(';') /= 59 THEN FAILED ("INCORRECT POSITION NUMBER FOR ';'"); END IF; IF CHARACTER'POS('<') /= 60 THEN FAILED ("INCORRECT POSITION NUMBER FOR '<'"); END IF; IF CHARACTER'POS('=') /= 61 THEN FAILED ("INCORRECT POSITION NUMBER FOR '='"); END IF; IF CHARACTER'POS('>') /= 62 THEN FAILED ("INCORRECT POSITION NUMBER FOR '>'"); END IF; IF CHARACTER'POS('_') /= 95 THEN FAILED ("INCORRECT POSITION NUMBER FOR '_'"); END IF; IF CHARACTER'POS('|') /= 124 THEN FAILED ("INCORRECT POSITION NUMBER FOR '|'"); END IF; IF CHARACTER'POS(' ') /= 32 THEN FAILED ("INCORRECT POSITION NUMBER FOR ' '"); END IF; RESULT; END C25001A;
package Pig is type Dice_Score is range 1 .. 6; type Player is tagged private; function Recent(P: Player) return Natural; function All_Recent(P: Player) return Natural; function Score(P: Player) return Natural; type Actor is abstract tagged null record; function Roll_More(A: Actor; Self, Opponent: Player'Class) return Boolean is abstract; procedure Play(First, Second: Actor'Class; First_Wins: out Boolean); private type Player is tagged record Score: Natural := 0; All_Recent: Natural := 0; Recent_Roll: Dice_Score := 1; end record; end Pig;
----------------------------------------------------------------------- -- util-events-timers-tests -- Unit tests for timers -- Copyright (C) 2017, 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 Util.Test_Caller; package body Util.Events.Timers.Tests is use Util.Tests; use type Ada.Real_Time.Time; package Caller is new Util.Test_Caller (Test, "Events.Timers"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Events.Timers.Is_Scheduled", Test_Empty_Timer'Access); Caller.Add_Test (Suite, "Test Util.Events.Timers.Process", Test_Timer_Event'Access); Caller.Add_Test (Suite, "Test Util.Events.Timers.Repeat", Test_Repeat_Timer'Access); Caller.Add_Test (Suite, "Test Util.Events.Timers.Repeat+Process", Test_Many_Timers'Access); end Add_Tests; overriding procedure Time_Handler (Sub : in out Test; Event : in out Timer_Ref'Class) is begin Sub.Count := Sub.Count + 1; if Sub.Repeat > 1 then Sub.Repeat := Sub.Repeat - 1; Event.Repeat (Ada.Real_Time.Milliseconds (1)); end if; end Time_Handler; -- ----------------------- -- Test empty timers. -- ----------------------- procedure Test_Empty_Timer (T : in out Test) is M : Timer_List; R : Timer_Ref; Deadline : Ada.Real_Time.Time; begin T.Assert (not R.Is_Scheduled, "Empty timer should not be scheduled"); T.Assert (R.Time_Of_Event = Ada.Real_Time.Time_Last, "Time_Of_Event returned invalid value"); R.Cancel; M.Process (Deadline); T.Assert (Deadline = Ada.Real_Time.Time_Last, "The Process operation returned invalid deadline"); end Test_Empty_Timer; procedure Test_Timer_Event (T : in out Test) is M : Timer_List; R : Timer_Ref; Start : constant Ada.Real_Time.Time := Ada.Real_Time.Clock; Deadline : Ada.Real_Time.Time; Now : Ada.Real_Time.Time; begin for Retry in 1 .. 10 loop M.Set_Timer (T'Unchecked_Access, R, Start + Ada.Real_Time.Milliseconds (10)); M.Process (Deadline); Now := Ada.Real_Time.Clock; exit when Now < Deadline; end loop; T.Assert (Now < Deadline, "The timer deadline is not correct"); delay until Deadline; M.Process (Deadline); Assert_Equals (T, 1, T.Count, "The timer handler was not called"); end Test_Timer_Event; -- ----------------------- -- Test repeating timers. -- ----------------------- procedure Test_Repeat_Timer (T : in out Test) is M : Timer_List; R : Timer_Ref; Start : constant Ada.Real_Time.Time := Ada.Real_Time.Clock; Deadline : Ada.Real_Time.Time; Now : Ada.Real_Time.Time; begin T.Count := 0; T.Repeat := 5; for Retry in 1 .. 10 loop M.Set_Timer (T'Unchecked_Access, R, Start + Ada.Real_Time.Milliseconds (10)); M.Process (Deadline); Now := Ada.Real_Time.Clock; exit when Now < Deadline; end loop; T.Assert (Now < Deadline, "The timer deadline is not correct"); loop delay until Deadline; M.Process (Deadline); exit when Deadline >= Now + Ada.Real_Time.Seconds (1); end loop; Assert_Equals (T, 5, T.Count, "The timer handler was not repeated"); end Test_Repeat_Timer; -- ----------------------- -- Test executing several timers. -- ----------------------- procedure Test_Many_Timers (T : in out Test) is Timer_Count : constant Positive := 30; type Timer_Ref_Array is array (1 .. Timer_Count) of Timer_Ref; type Test_Ref_Array is array (1 .. Timer_Count) of aliased Test; M : Timer_List; Start : constant Ada.Real_Time.Time := Ada.Real_Time.Clock; Deadline : Ada.Real_Time.Time; R : Timer_Ref_Array; D : Test_Ref_Array; Dt : Ada.Real_Time.Time_Span; Count : Natural := 0; begin for I in R'Range loop D (I).Count := 0; D (I).Repeat := 4; if I mod 2 = 0 then Dt := Ada.Real_Time.Milliseconds (40); else Dt := Ada.Real_Time.Milliseconds (20); end if; M.Set_Timer (D (I)'Unchecked_Access, R (I), Start + Dt); end loop; loop M.Process (Deadline); exit when Deadline >= Start + Ada.Real_Time.Seconds (10); Count := Count + 1; delay until Deadline; end loop; -- Depending on the load we can have different values for Count. T.Assert (Count <= 8, "Count of Process"); T.Assert (Count >= 2, "Count of Process"); for I in D'Range loop Util.Tests.Assert_Equals (T, 4, D (I).Count, "Invalid count for timer at " & Natural'Image (I) & " " & Natural'Image (Count)); end loop; end Test_Many_Timers; end Util.Events.Timers.Tests;
with Ada.Text_IO; package body RCP.Control is protected body Controller is entry Demand (Res : out Resource_T; Req : Request_T) when Free > 0 is -- we accept the request if we have spare resources to offer begin -- but we satisfy it ONLY if have enough for it if Req <= Free then -- the lucky user has got all the items -- that it wanted the first time round! Res.Granted := Req; Free := Free - Req; else -- otherwise we transfer the request to an internal queue -- after keeping record of the smallest request that -- we were unable to satisfy -- (this value will help us update the guard to -- the private channel Assign) if Req < Min_Request then Min_Request := Req; end if; -- with this statement we transfer the current request -- to the queue of the private channel Assign -- (the transfer is executed directly, -- WITHOUT evaluating the guard associated to Assign -- because the target is the queue, NOT the channel itself) requeue Assign; -- try and see what would happen if we used an EXTERNAL requeue -- to the same target: -- requeue Controller.Assign; end if; end Demand; ------------- entry Assign (Res : out Resource_T; Req : Request_T) when Available is -- users will enter this service only if there are -- enough spare resources (Available = True) -- AND those users had previously been denied service --+--------- -- THE PROTOCOL ASSUMES (and requires) FIFO QUEUEING begin -- one less request in queue Considered := Considered - 1; -- was this call the last one in the Assign queue? if Considered = 0 then -- then we close the guard to this channel Available := False; -- at this point we should update Min_Request! end if; -- can we now satisfy this request? if Req <= Free then -- yes, this requeued user can now be granted -- what it initially wanted Res.Granted := Req; Free := Free - Req; else -- otherwise we must requeue the unlucky user -- again and update the record of the smallest -- pending request if Req < Min_Request then Min_Request := Req; end if; requeue Assign; -- try and see what would happen if we used an EXTERNAL requeue -- to the same target: -- requeue Controller.Assign; end if; end Assign; ------------- procedure Release (Res : Resource_T) is begin -- this service is executed when a user -- returns its allocation of resources Free := Free + Res.Granted; -- as the level of reserve has now increased -- we should take a look at the requests that -- are awaiting in the Assign queue if Free > Min_Request and then Assign'Count > 0 then -- since we do NOT know which user placed the smallest demand -- we simply take note of the number of requests -- currently enqueued at Assign and open the guard to it -- ===> IS THIS CLEVER? <=== Considered := Assign'Count; Available := True; -- and finally we reset the value of Min_Request -- so that it may be recomputed by the execution of Assign Min_Request := Request_T'Last; end if; end Release; function Query return Request_T is begin return Free; end Query; end Controller; ------------------------- begin Ada.Text_IO.Put_Line ("The system starts with " & RCP.Control.Controller.Query'Img & " free resources"); Ada.Text_IO.Put_Line ("-----+---------+------------+--------"); Ada.Text_IO.Put_Line ("User | Request | Allocation | Release"); Ada.Text_IO.Put_Line ("-----+---------+------------+--------"); end RCP.Control;
-- -- This library is free software; you can redistribute it and/or modify -- it under the terms of the GNU Library General Public License as -- published by the Free Software Foundation; either version 3 of the -- License; or (at your option) any later version. package body Unbounded_Sequential_Queues is ------------ -- Insert -- ------------ procedure Insert (Into : in out Queue; Item : in Element) is Ptr : Link; begin Ptr := new Node'(Data => Item, Next => null); if Into.Count = 0 then -- initial case Into.Rear := Ptr; Into.Front := Into.Rear; Into.Count := 1; else -- nodes already in list Into.Rear.Next := Ptr; Into.Rear := Ptr; Into.Count := Into.Count + 1; end if; exception when Storage_Error => raise Overflow; end Insert; ------------ -- Remove -- ------------ procedure Remove (From : in out Queue; Item : out Element) is begin if From.Count > 0 then -- have data items to Remove Item := From.Front.Data; From.Front := From.Front.Next; From.Count := From.Count - 1; else -- user didn't check raise Underflow; end if; end Remove; ----------- -- Empty -- ----------- function Empty (Q : Queue) return Boolean is begin return Q.Count = 0; end Empty; ---------- -- Size -- ---------- function Size (Q : Queue) return Natural is begin return Q.Count; end Size; --------------- -- Iteration -- --------------- procedure Iteration (Over : in Queue) is Ptr : Link := Over.Front; Enabled : Boolean := True; begin while Ptr /= null and Enabled loop Process (Ptr.Data, Enabled); Ptr := Ptr.Next; end loop; end Iteration; end Unbounded_Sequential_Queues;
------------------------------------------------------------------------ -- Copyright (C) 2004-2020 by <ada.rocks@jlfencey.com> -- -- -- -- This work is free. You can redistribute it and/or modify it under -- -- the terms of the Do What The Fuck You Want To Public License, -- -- Version 2, as published by Sam Hocevar. See the LICENSE file for -- -- more details. -- ------------------------------------------------------------------------ pragma License (Unrestricted); ------------------------------------------------------------------------ -- AMD Élan(tm) SC 520 embedded microprocessor -- -- Memory Mapped Configuration Registers (MMCR) -- ------------------------------------------------------------------------ with System.Storage_Elements; -- we need address conversions with Elan520.CPU_Registers; with Elan520.GP_Bus_Controller_Registers; with Elan520.GP_Timer_Registers; with Elan520.Programmable_Address_Region; with Elan520.Registers; with Elan520.Reset_Generation_Registers; with Elan520.SDRAM_Controller_Registers; with Elan520.SDRAM_Buffer_Control; with Elan520.Software_Timer_Registers; package Elan520.MMCR is use type System.Storage_Elements.Integer_Address; MMCR_BASE : constant System.Storage_Elements.Integer_Address := 16#FFFE_F000#; --------------------------------------------------------------------- -- CHAPTER 2 - System Address Mapping Registers --------------------- --------------------------------------------------------------------- --------------------------------------------------------------------- Add_Dec_Ctl : Registers.Address_Decode_Control; pragma Atomic (Add_Dec_Ctl); pragma Import (Convention => Assembler, Entity => Add_Dec_Ctl); for Add_Dec_Ctl'Address use System.Storage_Elements.To_Address (MMCR_BASE + Registers.MMCR_OFFSET_ADDRESS_DECODE_CONTROL); --------------------------------------------------------------------- PAR : Programmable_Address_Region.PAR_Info; -- pragma Atomic_Components (PAR); pragma Volatile (PAR); pragma Import (Convention => Assembler, Entity => PAR); for PAR'Address use System.Storage_Elements.To_Address (MMCR_BASE + Programmable_Address_Region.MMCR_OFFSET_PAR_INFO); --------------------------------------------------------------------- -- CHAPTER 3 - Reset Generation Registers --------------------------- --------------------------------------------------------------------- --------------------------------------------------------------------- Sys_Info : Reset_Generation_Registers.System_Board_Information; pragma Atomic (Sys_Info); pragma Import (Convention => Assembler, Entity => Sys_Info); for Sys_Info'Address use System.Storage_Elements.To_Address (MMCR_BASE + Reset_Generation_Registers.MMCR_OFFSET_SYS_INFO); --------------------------------------------------------------------- Res_Cfg : Reset_Generation_Registers.Reset_Configuration; pragma Atomic (Res_Cfg); pragma Import (Convention => Assembler, Entity => Res_Cfg); for Res_Cfg'Address use System.Storage_Elements.To_Address (MMCR_BASE + Reset_Generation_Registers.MMCR_OFFSET_RES_CFG); --------------------------------------------------------------------- Res_Sta : Reset_Generation_Registers.Reset_Status; pragma Atomic (Res_Sta); pragma Import (Convention => Assembler, Entity => Res_Sta); for Res_Sta'Address use System.Storage_Elements.To_Address (MMCR_BASE + Reset_Generation_Registers.MMCR_OFFSET_RES_STA); --------------------------------------------------------------------- -- CHAPTER 4 - Am5x86 CPU MMCR Registers ---------------------------- --------------------------------------------------------------------- --------------------------------------------------------------------- Rev_Id : CPU_Registers.Revision_Id; pragma Atomic (Rev_Id); pragma Import (Convention => Assembler, Entity => Rev_Id); for Rev_Id'Address use System.Storage_Elements.To_Address (MMCR_BASE + CPU_Registers.MMCR_OFFSET_REVISION_ID); --------------------------------------------------------------------- CPU_Ctl : CPU_Registers.CPU_Control; pragma Atomic (CPU_Ctl); pragma Import (Convention => Assembler, Entity => CPU_Ctl); for CPU_Ctl'Address use System.Storage_Elements.To_Address (MMCR_BASE + CPU_Registers.MMCR_OFFSET_CPU_CONTROL); --------------------------------------------------------------------- -- CHAPTER 7 - SDRAM Controller Registers --------------------------- --------------------------------------------------------------------- --------------------------------------------------------------------- DRC_Ctl : SDRAM_Controller_Registers.SDRAM_Control; pragma Atomic (DRC_Ctl); pragma Import (Convention => Assembler, Entity => DRC_Ctl); for DRC_Ctl'Address use System.Storage_Elements.To_Address (MMCR_BASE + SDRAM_Controller_Registers.MMCR_OFFSET_SDRAM_CONTROL); --------------------------------------------------------------------- DRC_Tm_Ctl : SDRAM_Controller_Registers.SDRAM_Timing_Control; pragma Atomic (DRC_Tm_Ctl); pragma Import (Convention => Assembler, Entity => DRC_Tm_Ctl); for DRC_Tm_Ctl'Address use System.Storage_Elements.To_Address (MMCR_BASE + SDRAM_Controller_Registers. MMCR_OFFSET_SDRAM_TIMING_CONTROL); --------------------------------------------------------------------- DRC_Cfg : SDRAM_Controller_Registers.SDRAM_Bank_Configuration; pragma Atomic (DRC_Cfg); pragma Import (Convention => Assembler, Entity => DRC_Cfg); for DRC_Cfg'Address use System.Storage_Elements.To_Address (MMCR_BASE + SDRAM_Controller_Registers. MMCR_OFFSET_SDRAM_BANK_CONFIGURATION); --------------------------------------------------------------------- DRC_B_End_Adr : SDRAM_Controller_Registers.SDRAM_Bank_Ending_Address; pragma Atomic (DRC_B_End_Adr); pragma Import (Convention => Assembler, Entity => DRC_B_End_Adr); for DRC_B_End_Adr'Address use System.Storage_Elements.To_Address (MMCR_BASE + SDRAM_Controller_Registers. MMCR_OFFSET_SDRAM_BANK_ENDING_ADDRESS); --------------------------------------------------------------------- ECC_Ctl : SDRAM_Controller_Registers.ECC_Control; pragma Atomic (ECC_Ctl); pragma Import (Convention => Assembler, Entity => ECC_Ctl); for ECC_Ctl'Address use System.Storage_Elements.To_Address (MMCR_BASE + SDRAM_Controller_Registers.MMCR_OFFSET_ECC_CONTROL); --------------------------------------------------------------------- ECC_Sta : SDRAM_Controller_Registers.ECC_Status; pragma Atomic (ECC_Sta); pragma Import (Convention => Assembler, Entity => ECC_Sta); for ECC_Sta'Address use System.Storage_Elements.To_Address (MMCR_BASE + SDRAM_Controller_Registers.MMCR_OFFSET_ECC_STATUS); --------------------------------------------------------------------- ECC_Ck_B_Pos : SDRAM_Controller_Registers.ECC_Check_Bit_Position; pragma Atomic (ECC_Ck_B_Pos); pragma Import (Convention => Assembler, Entity => ECC_Ck_B_Pos); for ECC_Ck_B_Pos'Address use System.Storage_Elements.To_Address (MMCR_BASE + SDRAM_Controller_Registers. MMCR_OFFSET_ECC_CHECK_BIT_POSITION); --------------------------------------------------------------------- ECC_Ck_Test : SDRAM_Controller_Registers.ECC_Check_Code_Test; pragma Atomic (ECC_Ck_Test); pragma Import (Convention => Assembler, Entity => ECC_Ck_Test); for ECC_Ck_Test'Address use System.Storage_Elements.To_Address (MMCR_BASE + SDRAM_Controller_Registers.MMCR_OFFSET_ECC_CHECK_CODE_TEST); --------------------------------------------------------------------- ECC_SB_Add : SDRAM_Controller_Registers.ECC_Single_Bit_Error_Address; pragma Atomic (ECC_SB_Add); pragma Import (Convention => Assembler, Entity => ECC_SB_Add); for ECC_SB_Add'Address use System.Storage_Elements.To_Address (MMCR_BASE + SDRAM_Controller_Registers. MMCR_OFFSET_ECC_SINGLE_BIT_ERROR_ADDRESS); --------------------------------------------------------------------- ECC_MB_Add : SDRAM_Controller_Registers.ECC_Multi_Bit_Error_Address; pragma Atomic (ECC_MB_Add); pragma Import (Convention => Assembler, Entity => ECC_MB_Add); for ECC_MB_Add'Address use System.Storage_Elements.To_Address (MMCR_BASE + SDRAM_Controller_Registers. MMCR_OFFSET_ECC_MULTI_BIT_ERROR_ADDRESS); --------------------------------------------------------------------- -- CHAPTER 8 - Write Buffer and Read Buffer Registers --------------- --------------------------------------------------------------------- --------------------------------------------------------------------- DB_Ctl : SDRAM_Buffer_Control.SDRAM_Buffer_Control; pragma Atomic (DB_Ctl); pragma Import (Convention => Assembler, Entity => DB_Ctl); for DB_Ctl'Address use System.Storage_Elements.To_Address (MMCR_BASE + SDRAM_Buffer_Control.MMCR_OFFSET_SDRAM_BUFFER_CONTROL); --------------------------------------------------------------------- -- CHAPTER 10 - General-Purpose Bus Controller Registers ------------ --------------------------------------------------------------------- --------------------------------------------------------------------- GP_Echo : GP_Bus_Controller_Registers.GP_Echo_Mode; pragma Atomic (GP_Echo); pragma Import (Convention => Assembler, Entity => GP_Echo); for GP_Echo'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Bus_Controller_Registers.MMCR_OFFSET_GP_ECHO_MODE); --------------------------------------------------------------------- GP_CS_Dw : GP_Bus_Controller_Registers.GP_CS_Data_Width; pragma Atomic (GP_CS_Dw); pragma Import (Convention => Assembler, Entity => GP_CS_Dw); for GP_CS_Dw'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Bus_Controller_Registers.MMCR_OFFSET_GP_CS_DATA_WIDTH); --------------------------------------------------------------------- GP_CS_Qual : GP_Bus_Controller_Registers.GP_CS_Qualification; pragma Atomic (GP_CS_Qual); pragma Import (Convention => Assembler, Entity => GP_CS_Qual); for GP_CS_Qual'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Bus_Controller_Registers. MMCR_OFFSET_GP_CS_QUALIFICATION); --------------------------------------------------------------------- GP_CS_Rt : GP_Bus_Controller_Registers.GP_CS_Recovery_Time; pragma Atomic (GP_CS_Rt); pragma Import (Convention => Assembler, Entity => GP_CS_Rt); for GP_CS_Rt'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Bus_Controller_Registers. MMCR_OFFSET_GP_CS_RECOVERY_TIME); --------------------------------------------------------------------- GP_CS_Pw : GP_Bus_Controller_Registers.GP_CS_Pulse_Width; pragma Atomic (GP_CS_Pw); pragma Import (Convention => Assembler, Entity => GP_CS_Pw); for GP_CS_Pw'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Bus_Controller_Registers.MMCR_OFFSET_GP_CS_PULSE_WIDTH); --------------------------------------------------------------------- GP_CS_Off : GP_Bus_Controller_Registers.GP_CS_Offset; pragma Atomic (GP_CS_Off); pragma Import (Convention => Assembler, Entity => GP_CS_Off); for GP_CS_Off'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Bus_Controller_Registers.MMCR_OFFSET_GP_CS_OFFSET); --------------------------------------------------------------------- GP_Rd_W : GP_Bus_Controller_Registers.GP_Read_Pulse_Width; pragma Atomic (GP_Rd_W); pragma Import (Convention => Assembler, Entity => GP_Rd_W); for GP_Rd_W'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Bus_Controller_Registers. MMCR_OFFSET_GP_READ_PULSE_WIDTH); --------------------------------------------------------------------- GP_Rd_Off : GP_Bus_Controller_Registers.GP_Read_Offset; pragma Atomic (GP_Rd_Off); pragma Import (Convention => Assembler, Entity => GP_Rd_Off); for GP_Rd_Off'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Bus_Controller_Registers.MMCR_OFFSET_GP_READ_OFFSET); --------------------------------------------------------------------- GP_Wr_W : GP_Bus_Controller_Registers.GP_Write_Pulse_Width; pragma Atomic (GP_Wr_W); pragma Import (Convention => Assembler, Entity => GP_Wr_W); for GP_Wr_W'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Bus_Controller_Registers. MMCR_OFFSET_GP_WRITE_PULSE_WIDTH); --------------------------------------------------------------------- GP_Wr_Off : GP_Bus_Controller_Registers.GP_Write_Offset; pragma Atomic (GP_Wr_Off); pragma Import (Convention => Assembler, Entity => GP_Wr_Off); for GP_Wr_Off'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Bus_Controller_Registers.MMCR_OFFSET_GP_WRITE_OFFSET); --------------------------------------------------------------------- GP_Ale_W : GP_Bus_Controller_Registers.GP_ALE_Pulse_Width; pragma Atomic (GP_Ale_W); pragma Import (Convention => Assembler, Entity => GP_Ale_W); for GP_Ale_W'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Bus_Controller_Registers.MMCR_OFFSET_GP_ALE_PULSE_WIDTH); --------------------------------------------------------------------- GP_Ale_Off : GP_Bus_Controller_Registers.GP_ALE_Offset; pragma Atomic (GP_Ale_Off); pragma Import (Convention => Assembler, Entity => GP_Ale_Off); for GP_Ale_Off'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Bus_Controller_Registers.MMCR_OFFSET_GP_ALE_OFFSET); --------------------------------------------------------------------- -- CHAPTER 14 - General Purpose Timer Registers --------------------- --------------------------------------------------------------------- --------------------------------------------------------------------- GP_Tmr_Sta : GP_Timer_Registers.Status; pragma Atomic (GP_Tmr_Sta); pragma Import (Convention => Assembler, Entity => GP_Tmr_Sta); for GP_Tmr_Sta'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Timer_Registers.MMCR_OFFSET_STATUS); --------------------------------------------------------------------- GP_Tmr_0_Ctl : GP_Timer_Registers.Control; pragma Atomic (GP_Tmr_0_Ctl); pragma Import (Convention => Assembler, Entity => GP_Tmr_0_Ctl); for GP_Tmr_0_Ctl'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Timer_Registers.MMCR_OFFSET_T0_CONTROL); --------------------------------------------------------------------- GP_Tmr_0_Cnt : GP_Timer_Registers.Count; pragma Atomic (GP_Tmr_0_Cnt); pragma Import (Convention => Assembler, Entity => GP_Tmr_0_Cnt); for GP_Tmr_0_Cnt'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Timer_Registers.MMCR_OFFSET_T0_COUNT); --------------------------------------------------------------------- GP_Tmr_0_Max_Cmp_A : GP_Timer_Registers.Count; pragma Atomic (GP_Tmr_0_Max_Cmp_A); pragma Import (Convention => Assembler, Entity => GP_Tmr_0_Max_Cmp_A); for GP_Tmr_0_Max_Cmp_A'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Timer_Registers.MMCR_OFFSET_T0_MAX_A); --------------------------------------------------------------------- GP_Tmr_0_Max_Cmp_B : GP_Timer_Registers.Count; pragma Atomic (GP_Tmr_0_Max_Cmp_B); pragma Import (Convention => Assembler, Entity => GP_Tmr_0_Max_Cmp_B); for GP_Tmr_0_Max_Cmp_B'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Timer_Registers.MMCR_OFFSET_T0_MAX_B); --------------------------------------------------------------------- GP_Tmr_1_Ctl : GP_Timer_Registers.Control; pragma Atomic (GP_Tmr_1_Ctl); pragma Import (Convention => Assembler, Entity => GP_Tmr_1_Ctl); for GP_Tmr_1_Ctl'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Timer_Registers.MMCR_OFFSET_T1_CONTROL); --------------------------------------------------------------------- GP_Tmr_1_Cnt : GP_Timer_Registers.Count; pragma Atomic (GP_Tmr_1_Cnt); pragma Import (Convention => Assembler, Entity => GP_Tmr_1_Cnt); for GP_Tmr_1_Cnt'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Timer_Registers.MMCR_OFFSET_T1_COUNT); --------------------------------------------------------------------- GP_Tmr_1_Max_Cmp_A : GP_Timer_Registers.Count; pragma Atomic (GP_Tmr_1_Max_Cmp_A); pragma Import (Convention => Assembler, Entity => GP_Tmr_1_Max_Cmp_A); for GP_Tmr_1_Max_Cmp_A'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Timer_Registers.MMCR_OFFSET_T1_MAX_A); --------------------------------------------------------------------- GP_Tmr_1_Max_Cmp_B : GP_Timer_Registers.Count; pragma Atomic (GP_Tmr_1_Max_Cmp_B); pragma Import (Convention => Assembler, Entity => GP_Tmr_1_Max_Cmp_B); for GP_Tmr_1_Max_Cmp_B'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Timer_Registers.MMCR_OFFSET_T1_MAX_B); --------------------------------------------------------------------- GP_Tmr_2_Ctl : GP_Timer_Registers.Control_2; pragma Atomic (GP_Tmr_2_Ctl); pragma Import (Convention => Assembler, Entity => GP_Tmr_2_Ctl); for GP_Tmr_2_Ctl'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Timer_Registers.MMCR_OFFSET_T2_CONTROL); --------------------------------------------------------------------- GP_Tmr_2_Cnt : GP_Timer_Registers.Count; pragma Atomic (GP_Tmr_2_Cnt); pragma Import (Convention => Assembler, Entity => GP_Tmr_2_Cnt); for GP_Tmr_2_Cnt'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Timer_Registers.MMCR_OFFSET_T2_COUNT); --------------------------------------------------------------------- GP_Tmr_2_Max_Cmp_A : GP_Timer_Registers.Count; pragma Atomic (GP_Tmr_2_Max_Cmp_A); pragma Import (Convention => Assembler, Entity => GP_Tmr_2_Max_Cmp_A); for GP_Tmr_2_Max_Cmp_A'Address use System.Storage_Elements.To_Address (MMCR_BASE + GP_Timer_Registers.MMCR_OFFSET_T2_MAX_A); --------------------------------------------------------------------- -- CHAPTER 15 - Software Timer Registers ---------------------------- --------------------------------------------------------------------- --------------------------------------------------------------------- Sw_Timer : Software_Timer_Registers.Timer; pragma Atomic (Sw_Timer); pragma Import (Convention => Assembler, Entity => Sw_Timer); for Sw_Timer'Address use System.Storage_Elements.To_Address (MMCR_BASE + Software_Timer_Registers.MMCR_OFFSET_TIMER); --------------------------------------------------------------------- Sw_Tmr_Cfg : Software_Timer_Registers.Configuration; pragma Atomic (Sw_Tmr_Cfg); pragma Import (Convention => Assembler, Entity => Sw_Tmr_Cfg); for Sw_Tmr_Cfg'Address use System.Storage_Elements.To_Address (MMCR_BASE + Software_Timer_Registers.MMCR_OFFSET_CONFIGURATION); end Elan520.MMCR;
with C.gc.gc; package body GC is use type C.unsigned_int; -- the version variable is not declared in header files GC_version : C.unsigned_int with Import, Convention => C, External_Name => "GC_version"; -- implementation function Version return String is Major : constant C.unsigned_int := C.Shift_Right (GC_version, 16); Minor : constant C.unsigned_int := C.Shift_Right (GC_version, 8) and (2 ** 8 - 1); Alpha : constant C.unsigned_int := GC_version and (2 ** 8 - 1); Major_Image : constant String := C.unsigned_int'Image (Major); Minor_Image : constant String := C.unsigned_int'Image (Minor); begin pragma Assert (Major_Image (Major_Image'First) = ' '); pragma Assert (Minor_Image (Minor_Image'First) = ' '); if Alpha /= 255 then declare Alpha_Image : constant String := C.unsigned_int'Image (Alpha); begin return Major_Image (Major_Image'First + 1 .. Major_Image'Last) & '.' & Minor_Image (Minor_Image'First + 1 .. Minor_Image'Last) & "alpha" & Alpha_Image (Alpha_Image'First + 1 .. Alpha_Image'Last); end; else return Major_Image (Major_Image'First + 1 .. Major_Image'Last) & '.' & Minor_Image (Minor_Image'First + 1 .. Minor_Image'Last); end if; end Version; function Heap_Size return System.Storage_Elements.Storage_Count is begin return System.Storage_Elements.Storage_Count (C.gc.gc.GC_get_heap_size); end Heap_Size; procedure Collect is begin C.gc.gc.GC_gcollect; end Collect; end GC;
with Ada.Numerics.Generic_Elementary_Functions; with Ada.Unchecked_Conversion; use Ada.Numerics; --use Ada.Numerics.Aux; package body Generic_Vector_Math is package Float_Functions is new Generic_Elementary_Functions (float); use Float_Functions; function BitCopyToTypeT is new Ada.Unchecked_Conversion(float, T); function ZeroT return T is begin return BitCopyToTypeT(0.0); end ZeroT; function min (a, b : T) return T is begin if a < b then return a; else return b; end if; end; function max (a, b : T) return T is begin if a >= b then return a; else return b; end if; end; function min (a, b, c : T) return T is begin if a < b and a < c then return a; elsif b < c and b < a then return b; else return c; end if; end; function max (a, b, c : T) return T is begin if a >= b and a >= c then return a; elsif b >= c and b >= a then return b; else return c; end if; end; function clamp(x,a,b : T) return T is begin return min(max(x,a),b); end clamp; function sqr(x : T) return T is begin return x*x; end sqr; function "+" (a, b : vector4) return vector4 is res : vector4; begin res.x := a.x + b.x; res.y := a.y + b.y; res.z := a.z + b.z; res.w := a.w + b.w; return res; end; function "+" (a, b : vector3) return vector3 is res : vector3; begin res.x := a.x + b.x; res.y := a.y + b.y; res.z := a.z + b.z; return res; end; function "-" (a, b : vector3) return vector3 is res : vector3; begin res.x := a.x - b.x; res.y := a.y - b.y; res.z := a.z - b.z; return res; end; function "*" (a, b : vector3) return vector3 is res : vector3; begin res.x := a.x * b.x; res.y := a.y * b.y; res.z := a.z * b.z; return res; end; function dot(a, b : vector3) return T is begin return a.x*b.x + a.y*b.y + a.z*b.z; end; function cross(a, b : vector3) return vector3 is res : vector3; begin res.x := a.y*b.z - b.y*a.z; res.y := a.z*b.x - b.z*a.x; res.z := a.x*b.y - b.x*a.y; return res; end; function min(a, b : vector3) return vector3 is res : vector3; begin res.x := min(a.x, b.x); res.y := min(a.y, b.y); res.z := min(a.z, b.z); return res; end; function max(a, b : vector3) return vector3 is begin return (max(a.x,b.x), max(a.y,b.y), max(a.z, b.z)); end; function clamp(x : vector3; a,b : T) return vector3 is begin return (clamp(x.x,a,b), clamp(x.y,a,b), clamp(x.z,a,b)); end; function clamp(x,a,b : vector3) return vector3 is begin return (clamp(x.x,a.x,b.x), clamp(x.y,a.y,b.y), clamp(x.z,a.z,b.z)); end; function "*" (a : vector3; k : T) return vector3 is begin return (k*a.x, k*a.y, k*a.z); end; function "*"(k: T; a : vector3) return vector3 is begin return (k*a.x, k*a.y, k*a.z); end; function "*"(v : vector3; m : Matrix4) return vector3 is res : vector3; begin res.x := v.x*m(0,0) + v.y*m(1,0) + v.z*m(2,0) + m(3,0); res.y := v.x*m(0,1) + v.y*m(1,1) + v.z*m(2,1) + m(3,1); res.z := v.x*m(0,2) + v.y*m(1,2) + v.z*m(2,2) + m(3,2); return res; end; function "*"(v : vector4; m : Matrix4) return vector4 is res : vector4; begin res.x := v.x*m(0,0) + v.y*m(1,0) + v.z*m(2,0) + v.w*m(3,0); res.y := v.x*m(0,1) + v.y*m(1,1) + v.z*m(2,1) + v.w*m(3,1); res.z := v.x*m(0,2) + v.y*m(1,2) + v.z*m(2,2) + v.w*m(3,2); res.w := v.x*m(0,3) + v.y*m(1,3) + v.z*m(2,3) + v.w*m(3,3); return res; end; function "*"(m : Matrix4; v : vector3) return vector3 is res : vector3; begin res.x := m(0,0)*v.x + m(0,1)*v.y + m(0,2)*v.z + m(0,3); res.y := m(1,0)*v.x + m(1,1)*v.y + m(1,2)*v.z + m(1,3); res.z := m(2,0)*v.x + m(2,1)*v.y + m(2,2)*v.z + m(2,3); return res; end; function "*"(m : Matrix4; v : vector4) return vector4 is res : vector4; begin res.x := m(0,0)*v.x + m(0,1)*v.y + m(0,2)*v.z + m(0,3)*v.w; res.y := m(1,0)*v.x + m(1,1)*v.y + m(1,2)*v.z + m(1,3)*v.w; res.z := m(2,0)*v.x + m(2,1)*v.y + m(2,2)*v.z + m(2,3)*v.w; res.w := m(3,0)*v.x + m(3,1)*v.y + m(3,2)*v.z + m(3,3)*v.w; return res; end; function GetRow(m : Matrix4; i : integer) return vector4 is res : vector4; begin res.x := m(i,0); res.y := m(i,1); res.z := m(i,2); res.w := m(i,3); return res; end GetRow; function GetCol(m : Matrix4; i : integer) return vector4 is res : vector4; begin res.x := m(0,i); res.y := m(1,i); res.z := m(2,i); res.w := m(3,i); return res; end GetCol; procedure SetRow(m : in out Matrix4; i : in integer; v : in vector4) is begin m(i,0) := v.x; m(i,1) := v.y; m(i,2) := v.z; m(i,3) := v.w; end SetRow; procedure SetCol(m : in out Matrix4; i : in integer; v : in vector4) is begin m(0,i) := v.x; m(1,i) := v.y; m(2,i) := v.z; m(3,i) := v.w; end SetCol; function "*"(m1 : Matrix4; m2 : Matrix4) return Matrix4 is m : Matrix4; begin m(0,0) := m1(0,0) * m2(0,0) + m1(0,1) * m2(1,0) + m1(0,2) * m2(2,0) + m1(0,3) * m2(3,0); m(0,1) := m1(0,0) * m2(0,1) + m1(0,1) * m2(1,1) + m1(0,2) * m2(2,1) + m1(0,3) * m2(3,1); m(0,2) := m1(0,0) * m2(0,2) + m1(0,1) * m2(1,2) + m1(0,2) * m2(2,2) + m1(0,3) * m2(3,2); m(0,3) := m1(0,0) * m2(0,3) + m1(0,1) * m2(1,3) + m1(0,2) * m2(2,3) + m1(0,3) * m2(3,3); m(1,0) := m1(1,0) * m2(0,0) + m1(1,1) * m2(1,0) + m1(1,2) * m2(2,0) + m1(1,3) * m2(3,0); m(1,1) := m1(1,0) * m2(0,1) + m1(1,1) * m2(1,1) + m1(1,2) * m2(2,1) + m1(1,3) * m2(3,1); m(1,2) := m1(1,0) * m2(0,2) + m1(1,1) * m2(1,2) + m1(1,2) * m2(2,2) + m1(1,3) * m2(3,2); m(1,3) := m1(1,0) * m2(0,3) + m1(1,1) * m2(1,3) + m1(1,2) * m2(2,3) + m1(1,3) * m2(3,3); m(2,0) := m1(2,0) * m2(0,0) + m1(2,1) * m2(1,0) + m1(2,2) * m2(2,0) + m1(2,3) * m2(3,0); m(2,1) := m1(2,0) * m2(0,1) + m1(2,1) * m2(1,1) + m1(2,2) * m2(2,1) + m1(2,3) * m2(3,1); m(2,2) := m1(2,0) * m2(0,2) + m1(2,1) * m2(1,2) + m1(2,2) * m2(2,2) + m1(2,3) * m2(3,2); m(2,3) := m1(2,0) * m2(0,3) + m1(2,1) * m2(1,3) + m1(2,2) * m2(2,3) + m1(2,3) * m2(3,3); m(3,0) := m1(3,0) * m2(0,0) + m1(3,1) * m2(1,0) + m1(3,2) * m2(2,0) + m1(3,3) * m2(3,0); m(3,1) := m1(3,0) * m2(0,1) + m1(3,1) * m2(1,1) + m1(3,2) * m2(2,1) + m1(3,3) * m2(3,1); m(3,2) := m1(3,0) * m2(0,2) + m1(3,1) * m2(1,2) + m1(3,2) * m2(2,2) + m1(3,3) * m2(3,2); m(3,3) := m1(3,0) * m2(0,3) + m1(3,1) * m2(1,3) + m1(3,2) * m2(2,3) + m1(3,3) * m2(3,3); return m; end; end Generic_Vector_Math;
----------------------------------------------------------------------- -- security-policies -- Security Policies -- Copyright (C) 2010, 2011, 2012, 2015, 2018 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Finalization; with Util.Beans.Objects; with Util.Beans.Objects.Vectors; with Util.Serialize.IO.XML; with Security.Permissions; with Util.Serialize.Mappers; limited with Security.Controllers; limited with Security.Contexts; -- = Security Policies = -- The Security Policy defines and implements the set of security rules that specify -- how to protect the system or resources. The `Policy_Manager` maintains -- the security policies. These policies are registered when an application starts, -- before reading the policy configuration files. -- -- [[images/PolicyModel.png]] -- -- While the policy configuration files are processed, the policy instances that have been -- registered will create a security controller and bind it to a given permission. After -- successful initialization, the `Policy_Manager` contains a list of securiy -- controllers which are associated with each permission defined by the application. -- -- == Authenticated Permission == -- The `auth-permission` is a pre-defined permission that can be configured in the XML -- configuration. Basically the permission is granted if the security context has a principal. -- Otherwise the permission is denied. The permission is assigned a name and is declared -- as follows: -- -- <policy-rules> -- <auth-permission> -- <name>view-profile</name> -- </auth-permission> -- </policy-rules> -- -- This example defines the `view-profile` permission. -- -- == Grant Permission == -- The `grant-permission` is another pre-defined permission that gives the permission whatever -- the security context. The permission is defined as follows: -- -- <policy-rules> -- <grant-permission> -- <name>anonymous</name> -- </grant-permission> -- </policy-rules> -- -- This example defines the `anonymous` permission. -- -- @include security-policies-roles.ads -- @include security-policies-urls.ads --- @include security-controllers.ads package Security.Policies is type Security_Context_Access is access all Contexts.Security_Context'Class; type Controller_Access is access all Security.Controllers.Controller'Class; type Controller_Access_Array is array (Permissions.Permission_Index range <>) of Controller_Access; type Policy_Index is new Positive; type Policy_Context is limited interface; type Policy_Context_Access is access all Policy_Context'Class; type Policy_Context_Array is array (Policy_Index range <>) of Policy_Context_Access; type Policy_Context_Array_Access is access Policy_Context_Array; -- ------------------------------ -- Security policy -- ------------------------------ type Policy is abstract new Ada.Finalization.Limited_Controlled with private; type Policy_Access is access all Policy'Class; -- Get the policy name. function Get_Name (From : in Policy) return String is abstract; -- Get the policy index. function Get_Policy_Index (From : in Policy'Class) return Policy_Index; pragma Inline (Get_Policy_Index); -- Prepare the XML parser to read the policy configuration. procedure Prepare_Config (Pol : in out Policy; Mapper : in out Util.Serialize.Mappers.Processing) is null; -- Finish reading the XML policy configuration. The security policy implementation can use -- this procedure to perform any configuration setup after the configuration is parsed. procedure Finish_Config (Into : in out Policy; Reader : in out Util.Serialize.IO.XML.Parser) is null; -- Add a permission under the given permission name and associated with the controller. -- To verify the permission, the controller will be called. procedure Add_Permission (Manager : in out Policy; Name : in String; Permission : in Controller_Access); Invalid_Name : exception; Policy_Error : exception; -- ------------------------------ -- Permission Manager -- ------------------------------ -- The <b>Permission_Manager</b> verifies through some policy that a permission -- is granted to a user. type Policy_Manager (Max_Policies : Policy_Index) is new Ada.Finalization.Limited_Controlled with private; type Policy_Manager_Access is access all Policy_Manager'Class; -- Get the policy with the name <b>Name</b> registered in the policy manager. -- Returns null if there is no such policy. function Get_Policy (Manager : in Policy_Manager; Name : in String) return Policy_Access; -- Add the policy to the policy manager. After a policy is added in the manager, -- it can participate in the security policy. -- Raises Policy_Error if the policy table is full. procedure Add_Policy (Manager : in out Policy_Manager; Policy : in Policy_Access); -- Add a permission under the given permission name and associated with the controller. -- To verify the permission, the controller will be called. procedure Add_Permission (Manager : in out Policy_Manager; Name : in String; Permission : in Controller_Access); -- Checks whether the permission defined by the <b>Permission</b> controller data is granted -- by the security context passed in <b>Context</b>. -- Returns true if such permission is granted. function Has_Permission (Manager : in Policy_Manager; Context : in Security.Contexts.Security_Context'Class; Permission : in Security.Permissions.Permission'Class) return Boolean; -- Returns True if the security controller is defined for the given permission index. function Has_Controller (Manager : in Policy_Manager; Index : in Permissions.Permission_Index) return Boolean; -- Create the policy contexts to be associated with the security context. function Create_Policy_Contexts (Manager : in Policy_Manager) return Policy_Context_Array_Access; -- Prepare the XML parser to read the policy configuration. procedure Prepare_Config (Manager : in out Policy_Manager; Mapper : in out Util.Serialize.Mappers.Processing); -- Finish reading the XML policy configuration. The security policy implementation can use -- this procedure to perform any configuration setup after the configuration is parsed. procedure Finish_Config (Manager : in out Policy_Manager; Reader : in out Util.Serialize.IO.XML.Parser); -- Read the policy file procedure Read_Policy (Manager : in out Policy_Manager; File : in String); -- Initialize the permission manager. overriding procedure Initialize (Manager : in out Policy_Manager); -- Finalize the permission manager. overriding procedure Finalize (Manager : in out Policy_Manager); -- ------------------------------ -- Policy Configuration -- ------------------------------ type Policy_Config is record Id : Natural := 0; Permissions : Util.Beans.Objects.Vectors.Vector; Patterns : Util.Beans.Objects.Vectors.Vector; Manager : Policy_Manager_Access; end record; type Policy_Config_Access is access all Policy_Config; -- Setup the XML parser to read the <b>policy</b> description. For example: -- -- <policy id='1'> -- <permission>create-workspace</permission> -- <permission>admin</permission> -- <url-pattern>/workspace/create</url-pattern> -- <url-pattern>/workspace/setup/*</url-pattern> -- </policy> -- -- This policy gives access to the URL that match one of the URL pattern if the -- security context has the permission <b>create-workspace</b> or <b>admin</b>. generic Reader : in out Util.Serialize.IO.XML.Parser; Manager : in Policy_Manager_Access; package Reader_Config is Config : aliased Policy_Config; end Reader_Config; private subtype Permission_Index is Permissions.Permission_Index; type Permission_Index_Array is array (Positive range <>) of Permissions.Permission_Index; type Controller_Access_Array_Access is access all Controller_Access_Array; type Policy_Access_Array is array (Policy_Index range <>) of Policy_Access; type Policy is abstract new Ada.Finalization.Limited_Controlled with record Manager : Policy_Manager_Access; Index : Policy_Index := Policy_Index'First; end record; type Policy_Manager (Max_Policies : Policy_Index) is new Ada.Finalization.Limited_Controlled with record Permissions : Controller_Access_Array_Access; Last_Index : Permission_Index := Permission_Index'First; -- The security policies. Policies : Policy_Access_Array (1 .. Max_Policies); end record; end Security.Policies;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Ada.Text_IO; with Slim.Messages.cont; package body Slim.Players.Play_Files_Visiters is ---------- -- BUTN -- ---------- overriding procedure BUTN (Self : in out Visiter; Message : not null access Slim.Messages.BUTN.BUTN_Message) is Player : Players.Player renames Self.Player.all; Button : constant Slim.Messages.BUTN.Button_Kind := Message.Button; begin case Button is when Slim.Messages.BUTN.Forward => Player.Play_Next_File; when Slim.Messages.BUTN.Rewind => Player.Play_Previous_File; when Slim.Messages.BUTN.Pause => Slim.Players.Common_Play_Visiters.Visiter (Self).BUTN (Message); if Player.State.Play_State.Paused then Player.Save_Position; end if; when others => Slim.Players.Common_Play_Visiters.Visiter (Self).BUTN (Message); end case; end BUTN; ---------- -- RESP -- ---------- overriding procedure RESP (Self : in out Visiter; Message : not null access Slim.Messages.RESP.RESP_Message) is pragma Unreferenced (Message); Player : Players.Player renames Self.Player.all; Cont : Slim.Messages.cont.Cont_Message; begin Cont.Set_Metaint (0); Write_Message (Player.Socket, Cont); end RESP; ---------- -- STAT -- ---------- overriding procedure STAT (Self : in out Visiter; Message : not null access Slim.Messages.STAT.STAT_Message) is Player : Players.Player renames Self.Player.all; begin Player.WiFi := Message.WiFi_Level; if Message.Event (1 .. 3) /= "STM" then return; elsif Message.Event = "STMd" then -- Decoder ready. Instruct server that we are ready for the next -- track (if any). Player.Play_Next_File (Immediate => False); elsif Message.Event = "STMu" then -- Underrun. Normal end of playback. Player.Stop; elsif Message.Event = "STMt" and then Player.State.Kind = Play_Files then Player.State.Play_State.Seconds := Message.Elapsed_Seconds; elsif not Player.State.Play_State.Current_Song.Is_Empty then null; elsif Message.Event = "STMc" then Player.State.Play_State.Current_Song.Clear; Player.State.Play_State.Current_Song.Append ("Connecting..."); elsif Message.Event = "STMe" then Player.State.Play_State.Current_Song.Clear; Player.State.Play_State.Current_Song.Append ("Connected"); end if; Slim.Players.Common_Play_Visiters.Update_Display (Player); if Message.Event /= "STMt" then Ada.Text_IO.Put_Line (Message.Event); end if; end STAT; end Slim.Players.Play_Files_Visiters;
pragma Ada_2012; package body BitOperations.Search.Axiom.Most_Significant_Bit with SPARK_Mode => Off is ----------------------- -- Result_Is_Correct -- ----------------------- procedure Result_Is_Correct (Value : Modular; Index : Bit_Position) is null; procedure Order_Preservation_Value_To_Index(Value1, Value2 : Modular; Index1, Index2 : Bit_Position) is null; procedure Order_Preservation_Index_To_Value(Value1, Value2 : Modular; Index1, Index2 : Bit_Position) is null; end BitOperations.Search.Axiom.Most_Significant_Bit;
with Ada.Numerics.Generic_Elementary_Functions; package body goertzel with SPARK_Mode => On is package Ef is new Ada.Numerics.Generic_Elementary_Functions(Value); use Ef; function Calc_Koef(F, Fs: Value) return Value is (2.0 * Cos(2.0 * Ada.Numerics.Pi * F / Fs)) with Pre => (Fs < 100_000.0) and (F < Fs / 2.0) and (Fs > 0.0); procedure Reset(Vn: out Vn2) is begin Vn.m1 := 0.0; Vn.m2 := 0.0; end; function Make(F, Fs: Value) return Filter is ( F, Fs, Calc_Koef(F, Fs), (0.0, 0.0) ); procedure Reset(Flt: in out Filter) is begin Reset(Flt.Vn); end; procedure Kernel(Sample: Samples; K: Value; Vn: in out Vn2) is T: Value; begin for I in Sample'Range loop T := K * Vn.m1 - Vn.m2 + Sample(I); Vn.m2 := Vn.m1; Vn.m1 := T; end loop; end; function Power(Koef: Value; Vn: Vn2; N: Sample_Count) return Value is Rslt: Value; begin Rslt := Vn.m1 * Vn.m1 + Vn.m2* Vn.m2 - Koef * Vn.m1 * Vn.m2; if Rslt < Value'Model_Epsilon then Rslt := Value'Model_Epsilon; end if; return Rslt / Value(N*N); end Power; function DBm(Power: Value) return Value is (10.0 * Log(2.0 * Power * 1000.0 / 600.0, 10.0)); procedure Process(Flt: in out Filter; Sample: Samples; Rslt: out Value) is begin Kernel(Sample, Flt.Koef, Flt.Vn); Rslt := Power(Flt.Koef, Flt.Vn, Sample'Length); end Process; end goertzel;
package body BSSNBase.Coords is function x_coord (i : Integer) return Real is begin return Real(i-1)*dx; end x_coord; function y_coord (j : Integer) return Real is begin return Real(j-1)*dy; end y_coord; function z_coord (k : Integer) return Real is begin return Real(k-1)*dz; end z_coord; end BSSNBase.Coords;
with Ada.Text_IO; use Ada.Text_IO; package body I_Am_Ada_Too is procedure Ada_Procedure_Too is begin Put_Line(" Hello, I am Ada code too."); end Ada_Procedure_Too; end I_Am_Ada_Too;
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr> -- MIT license. Please refer to the LICENSE file. package body Apsepp.Test_Node_Class.Private_Test_Reporter is ---------------------------------------------------------------------------- procedure Run_Instance_Process_Primitive is begin Shared_Instance.Instance.Process; end Run_Instance_Process_Primitive; ---------------------------------------------------------------------------- function Test_Reporter return Test_Reporter_Access is (Test_Reporter_Access (Shared_Instance_Fallback_Switch.Instance_FS)); ---------------------------------------------------------------------------- end Apsepp.Test_Node_Class.Private_Test_Reporter;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . A T O M I C _ C O U N T E R S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2011-2015, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package provides atomic counter on platforms where it is supported: -- - all Alpha platforms -- - all ia64 platforms -- - all PowerPC platforms -- - all SPARC V9 platforms -- - all x86 platforms -- - all x86_64 platforms package System.Atomic_Counters is pragma Pure; pragma Preelaborate; type Atomic_Counter is limited private; -- Type for atomic counter objects. Note, initial value of the counter is -- one. This allows using an atomic counter as member of record types when -- object of these types are created at library level in preelaborable -- compilation units. -- -- Atomic_Counter is declared as private limited type to provide highest -- level of protection from unexpected use. All available operations are -- declared below, and this set should be as small as possible. -- Increment/Decrement operations for this type raise Program_Error on -- platforms not supporting the atomic primitives. procedure Increment (Item : in out Atomic_Counter); pragma Inline_Always (Increment); -- Increments value of atomic counter. function Decrement (Item : in out Atomic_Counter) return Boolean; pragma Inline_Always (Decrement); -- Decrements value of atomic counter, returns True when value reach zero function Is_One (Item : Atomic_Counter) return Boolean; pragma Inline_Always (Is_One); -- Returns True when value of the atomic counter is one procedure Initialize (Item : out Atomic_Counter); pragma Inline_Always (Initialize); -- Initialize counter by setting its value to one. This subprogram is -- intended to be used in special cases when the counter object cannot be -- initialized in standard way. type Atomic_Unsigned is mod 2 ** 32 with Default_Value => 0, Atomic; -- Modular compatible atomic unsigned type. -- Increment/Decrement operations for this type are atomic only on -- supported platforms. See top of the file. procedure Increment (Item : aliased in out Atomic_Unsigned) with Inline_Always; -- Increments value of atomic counter function Decrement (Item : aliased in out Atomic_Unsigned) return Boolean with Inline_Always; procedure Decrement (Item : aliased in out Atomic_Unsigned) with Inline_Always; -- Decrements value of atomic counter -- The "+" and "-" abstract routine provided below to disable BT := BT + 1 -- constructions. function "+" (Left, Right : Atomic_Unsigned) return Atomic_Unsigned is abstract; function "-" (Left, Right : Atomic_Unsigned) return Atomic_Unsigned is abstract; private type Atomic_Counter is record Value : aliased Atomic_Unsigned := 1; pragma Atomic (Value); end record; end System.Atomic_Counters;
-- WORDS, a Latin dictionary, by Colonel William Whitaker (USAF, Retired) -- -- Copyright William A. Whitaker (1936–2010) -- -- This is a free program, which means it is proper to copy it and pass -- it on to your friends. Consider it a developmental item for which -- there is no charge. However, just for form, it is Copyrighted -- (c). Permission is hereby freely given for any and all use of program -- and data. You can sell it as your own, but at least tell me. -- -- This version is distributed without obligation, but the developer -- would appreciate comments and suggestions. -- -- All parts of the WORDS system, source code and data files, are made freely -- available to anyone who wishes to use them, for whatever purpose. with Latin_Utils.Strings_Package; use Latin_Utils.Strings_Package; with Latin_Utils.Latin_File_Names; use Latin_Utils.Latin_File_Names; with Latin_Utils.Config; use Latin_Utils.Config; with Latin_Utils.Preface; use Latin_Utils; pragma Elaborate (Latin_Utils.Preface); package body Support_Utils.Word_Parameters is use Ada.Text_IO; type Help_Type is array (Natural range <>) of String (1 .. 70); Blank_Help_Line : constant String (1 .. 70) := (others => ' '); No_Help : constant Help_Type := (2 .. 1 => Blank_Help_Line); type Reply_Type is (N, Y); package Reply_Type_Io is new Ada.Text_IO.Enumeration_IO (Reply_Type); Reply : constant array (Boolean) of Reply_Type := (N, Y); Mode_Of_Reply : constant array (Reply_Type) of Boolean := (False, True); Blank_Input : exception; -- The default modes are set in the body so that they can be changed -- with only this being recompiled, not the rest of the with'ing system Default_Mode_Array : constant Mode_Array := ( Trim_Output => True, Have_Output_File => False, Write_Output_To_File => False, Do_Unknowns_Only => False, Write_Unknowns_To_File => False, Ignore_Unknown_Names => True, Ignore_Unknown_Caps => True, Do_Compounds => True, Do_Fixes => True, Do_Tricks => True, Do_Dictionary_Forms => True, Show_Age => False, Show_Frequency => False, Do_Examples => False, Do_Only_Meanings => False, Do_Stems_For_Unknown => False); Bad_Mode_File : exception; -- FIXME: this help text seems to duplicate what's in developer_parameters Trim_Output_Help : constant Help_Type := ( "This option instructs the program to remove from the Output list of ", "possible constructs those which are least likely. There is now a fair", "amount of trimming, killing LOC and VOC plus removing Uncommon and ", "non-classical (Archaic/Medieval) when more common results are found ", "and this action is requested (turn it off in MDV (!) parameters). ", "When a TRIM has been done, Output is usually followed by asterix (*). ", "The asterix may be missing depending on where the TRIM is done. ", "There certainly is no absolute assurence that the items removed are ", "not correct, just that they are statistically less likely. ", "Note that poets are likely to employ unusual words and inflections for", "various reasons. These may be trimmed out if this parameter in on. ", "When in English mode, trim just reduces the Output to the top six ", "results, if there are that many. Asterix means there are more. ", " The default is Y(es) "); Have_Output_File_Help : constant Help_Type := ( "This option instructs the program to Create a file which can hold the ", "Output for later study, otherwise the results are just displayed on ", "the screen. The Output file is named " & Output_Full_Name & (39 + Output_Full_Name'Length .. 70 => ' '), "This means that one run will necessarily overWrite a previous run, ", "unless the previous results are renamed or copied to a file of another", "name. This is available if the METHOD is INTERACTIVE, no parameters. ", "The default is N(o), since this prevents the program from overwriting ", "previous work unintentionally. Y(es) Creates the Output file. "); Write_Output_To_File_Help : constant Help_Type := ( "This option instructs the program, when HAVE_OUTPUT_FILE is on, to ", "Write results to the file " & Output_Full_Name & (27 + Output_Full_Name'Length .. 70 => ' '), "This option may be turned on and off during running of the program, ", "thereby capturing only certain desired results. If the option ", "HAVE_OUTPUT_FILE is off, the user will not be given a chance to turn ", "this one on. Only for INTERACTIVE running. Default is N(o). ", "This works in English mode, but Output in somewhat different so far. "); Do_Unknowns_Only_Help : constant Help_Type := ( "This option instructs the program to only Output those words that it ", "cannot resolve. Of course, it has to do processing on all words, but ", "those that are found (with prefix/suffix, if that option in on) will ", "be ignored. The purpose of this option is to allow a quick look to ", "determine if the dictionary and process is going to do an acceptable ", "job on the current text. It also allows the user to assemble a list ", "of unknown words to look up manually, and perhaps augment the system ", "dictionary. For those purposes, the system is usually run with the ", "MINIMIZE_OUTPUT option, just producing a list. Another use is to run ", "without MINIMIZE to an Output file. This gives a list of the Input ", "text with the unknown words, by line. This functions as a spelling ", "checker for Latin texts. The default is N(o). ", "This does not work in English mode, but may in the future. "); Write_Unknowns_To_File_Help : constant Help_Type := ( "This option instructs the program to Write all unresolved words to a ", "UNKNOWNS file named " & Unknowns_Full_Name & (21 + Unknowns_Full_Name'Length .. 70 => ' '), "With this option on, the file of unknowns is written, even though ", "the main Output contains both known and unknown (unresolved) words. ", "One may wish to save the unknowns for later analysis, testing, or to ", "form the basis for dictionary additions. When this option is turned ", "on, the UNKNOWNS file is written, destroying any file from a previous ", "run. However, the Write may be turned on and off during a single run ", "without destroying the information written in that run. ", "This option is for specialized use, so its default is N(o). ", "This does not work in English mode, but may in the future. "); Ignore_Unknown_Names_Help : constant Help_Type := ( "This option instructs the program to assume that any capitalized word ", "longer than three letters is a proper name. As no dictionary can be ", "expected to account for many proper names, many such occur that would ", "be called UNKNOWN. This contaminates the Output in most cases, and ", "it is often convenient to ignore these spurious UNKNOWN hits. This ", "option implements that mode, and calls such words proper names. ", "Any proper names that are in the dictionary are handled in the normal ", "manner. The default is Y(es). "); Ignore_Unknown_Caps_Help : constant Help_Type := ( "This option instructs the program to assume that any all caps word ", "is a proper name or similar designation. This convention is often ", "used to designate speakers in a discussion or play. No dictionary can", "claim to be exhaustive on proper names, so many such occur that would ", "be called UNKNOWN. This contaminates the Output in most cases, and ", "it is often convenient to ignore these spurious UNKNOWN hits. This ", "option implements that mode, and calls such words names. Any similar ", "designations that are in the dictionary are handled in the normal ", "manner, as are normal words in all caps. The default is Y(es). "); Do_Compounds_Help : constant Help_Type := ( "This option instructs the program to look ahead for the verb TO_BE (or", "iri) when it finds a verb participle, with the expectation of finding ", "a compound perfect tense or periphrastic. This option can also be a ", "trimming of the output, in that VPAR that do not fit (not NOM) will be", "excluded, possible interpretations are lost. Default choice is Y(es).", "This processing is turned off with the choice of N(o). "); Do_Fixes_Help : constant Help_Type := ( "This option instructs the program, when it is unable to find a proper ", "match in the dictionary, to attach various prefixes and suffixes and ", "try again. This effort is successful in about a quarter of the cases ", "which would otherwise give UNKNOWN results, or so it seems in limited ", "tests. For those cases in which a result is produced, about half give", "easily interpreted Output; many of the rest are etymologically True, ", "but not necessarily obvious; about a tenth give entirely spurious ", "derivations. The user must proceed with caution. ", "The default choice is Y(es), since the results are generally useful. ", "This processing can be turned off with the choice of N(o). "); Do_Tricks_Help : constant Help_Type := ( "This option instructs the program, when it is unable to find a proper ", "match in the dictionary, and after various prefixes and suffixes, to ", "try every dirty Latin trick it can think of, mainly common letter ", "replacements like cl -> cul, vul -> vol, ads -> ass, inp -> imp, etc. ", "Together these tricks are useful, but may give False Positives (>10%).", "They provide for recognized variants in classical spelling. Most of ", "the texts with which this program will be used have been well edited ", "and standardized in spelling. Now, moreover, the dictionary is being", "populated to such a state that the hit rate on tricks has fallen to a ", "low level. It is very seldom productive, and it is always expensive. ", "The only excuse for keeping it as default is that now the dictionary ", "is quite extensive and misses are rare. Default is now Y(es). "); Do_Dictionary_Forms_Help : constant Help_Type := ( "This option instructs the program to Output a line with the forms ", "normally associated with a dictionary entry (NOM and GEN of a noun, ", "the four principal parts of a verb, M-F-N NOM of an adjective, ...). ", "This occurs when there is other Output (i.e., not with UNKNOWNS_ONLY).", "The default choice is N(o), but it can be turned on with a Y(es). "); Show_Age_Help : constant Help_Type := ( "This option causes a flag, like '<Late>' to appear for inflection or ", "form in the Output. The AGE indicates when this word/inflection was ", "in use, at least from indications is dictionary citations. It is ", "just an indication, not controlling, useful when there are choices. ", "No indication means that it is common throughout all periods. ", "The default choice is Y(es), but it can be turned off with a N(o). "); Show_Frequency_Help : constant Help_Type := ( "This option causes a flag, like '<rare>' to appear for inflection or ", "form in the Output. The FREQ is indicates the relative usage of the ", "word or inflection, from indications is dictionary citations. It is ", "just an indication, not controlling, useful when there are choices. ", "No indication means that it is common throughout all periods. ", "The default choice is Y(es), but it can be turned off with a N(o). "); Do_Examples_Help : constant Help_Type := ( "This option instructs the program to provide examples of usage of the ", "cases/tenses/etc. that were constructed. The default choice is N(o). ", "This produces lengthy Output and is turned on with the choice Y(es). "); Do_Only_Meanings_Help : constant Help_Type := ( "This option instructs the program to only Output the MEANING for a ", "word, and omit the inflection details. This is primarily used in ", "analyzing new dictionary material, comparing with the existing. ", "However it may be of use for the translator who knows most all of ", "the words and just needs a little reminder for a few. ", "The default choice is N(o), but it can be turned on with a Y(es). "); Do_Stems_For_Unknown_Help : constant Help_Type := ( "This option instructs the program, when it is unable to find a proper ", "match in the dictionary, and after various prefixes and suffixes, to ", "list the dictionary entries around the unknown. This will likely ", "catch a substantive for which only the ADJ stem appears in dictionary,", "an ADJ for which there is only a N stem, etc. This option should ", "probably only be used with individual UNKNOWN words, and off-line ", "from full translations, therefore the default choice is N(o). ", "This processing can be turned on with the choice of Y(es). "); Save_Parameters_Help : constant Help_Type := ( "This option instructs the program, to save the current parameters, as ", "just established by the user, in a file WORD.MOD. If such a file ", "exists, the program will load those parameters at the start. If no ", "such file can be found in the current subdirectory, the program will ", "start with a default set of parameters. Since this parameter file is ", "human-readable ASCII, it may also be Created with a text editor. If ", "the file found has been improperly Created, is in the wrong format, or", "otherwise uninterpretable by the program, it will be ignored and the ", "default parameters used, until a proper parameter file in written by ", "the program. Since one may want to make temporary changes during a ", "run, but revert to the usual set, the default is N(o). "); procedure Put (Help : Help_Type) is begin New_Line; for I in Help'First .. Help'Last loop Put_Line (Help (I)); end loop; New_Line; end Put; procedure Put_Modes is use Mode_Type_Io; use Reply_Type_Io; begin if Is_Open (Mode_File) then Close (Mode_File); end if; Create (Mode_File, Out_File, Mode_Full_Name); for I in Words_Mode'Range loop Put (Mode_File, I); Set_Col (Mode_File, 35); Put (Mode_File, Reply (Words_Mode (I))); New_Line (Mode_File); end loop; Close (Mode_File); end Put_Modes; procedure Get_Modes is --(M : out MODE_ARRAY) is use Mode_Type_Io; use Reply_Type_Io; Mo : Mode_Type; Rep : Reply_Type; begin Open (Mode_File, In_File, Path (Mode_Full_Name)); while not End_Of_File (Mode_File) loop Get (Mode_File, Mo); Get (Mode_File, Rep); Words_Mode (Mo) := Mode_Of_Reply (Rep); end loop; Close (Mode_File); exception when Name_Error => raise; when others => raise Bad_Mode_File; end Get_Modes; procedure Inquire (Mo : Mode_Type; Help : in Help_Type := No_Help) is use Mode_Type_Io; use Reply_Type_Io; L1 : String (1 .. 100) := (others => ' '); Ll : Natural; R : Reply_Type; begin Put (Mo); Put (" ? "); Set_Col (45); Put ("(Currently "); Put (Reply (Words_Mode (Mo))); Put (" =>"); Get_Line (L1, Ll); if Ll /= 0 then if Trim (L1 (1 .. Ll)) = "" then Put_Line ("Blank Input, skipping the rest of CHANGE_PARAMETERS"); raise Blank_Input; elsif L1 (1) = '?' then Put (Help); Inquire (Mo, Help); else Get (L1 (1 .. Ll), R, Ll); Words_Mode (Mo) := Mode_Of_Reply (R); end if; end if; New_Line; end Inquire; procedure Change_Parameters is L1 : String (1 .. 100) := (others => ' '); Ll : Natural; R : Reply_Type; begin Put_Line ("To set/change parameters reply Y/y or N/n" & ". Return accepts current value."); Put_Line ("A '?' reply gives information/help on that parameter." & " A space skips the rest."); New_Line; -- Interactive mode - lets you do things on unknown words -- You can say it is a noun and then look at the endings -- Or look all the endings and guess what part of speech -- You can look at the dictionary items that are Close to the word -- There may be cases in which the stem is found but is not of right part -- So maybe the word list is deficient and that root goes also to a ADJ -- even if it is listed only for a N. -- One can also look for ADV here with ending 'e', etc. -- You can look up the word in a paper dictionary (with the help -- of ending) -- And then enter the word into DICT.LOC, so it will hit next time -- All unknowns could be recorded in a file for later reference -- A '?' gives information (help) about the item in question -- One can change the symbol that the main program uses for change -- and file -- One can save the new parameters or let them revert to previous -- There should be a basic set of parameters that one can always go to -- There should be moods of translation, maybe to switch dictionaries -- Maybe to turn on or off pre/suffix -- Maybe to allow the user to look at just all the prefixes that match Inquire (Trim_Output, Trim_Output_Help); Inquire (Have_Output_File, Have_Output_File_Help); if Is_Open (Output) and then not Words_Mode (Have_Output_File) then Close (Output); Words_Mode (Write_Output_To_File) := False; end if; if not Is_Open (Output) and then Words_Mode (Have_Output_File) then begin Create (Output, Out_File, Output_Full_Name); exception when others => Put_Line ("Cannot CREATE WORD.OUT - Check if it is in use elsewhere"); end; end if; if Words_Mode (Have_Output_File) then Inquire (Write_Output_To_File, Write_Output_To_File_Help); end if; Inquire (Do_Unknowns_Only, Do_Unknowns_Only_Help); Inquire (Write_Unknowns_To_File, Write_Unknowns_To_File_Help); -- If there is an Open file then OK -- If not Open and you now want to start writing to UNKNOWNS, the CREATE if not Is_Open (Unknowns) and then Words_Mode (Write_Unknowns_To_File) then begin Create (Unknowns, Out_File, Unknowns_Full_Name); exception when others => Put_Line ("Cannot CREATE WORD.UNK - Check if it is in use elsewhere"); end; end if; Inquire (Ignore_Unknown_Names, Ignore_Unknown_Names_Help); Inquire (Ignore_Unknown_Caps, Ignore_Unknown_Caps_Help); Inquire (Do_Compounds, Do_Compounds_Help); Inquire (Do_Fixes, Do_Fixes_Help); Inquire (Do_Tricks, Do_Tricks_Help); Inquire (Do_Dictionary_Forms, Do_Dictionary_Forms_Help); Inquire (Show_Age, Show_Age_Help); Inquire (Show_Frequency, Show_Frequency_Help); Inquire (Do_Examples, Do_Examples_Help); Inquire (Do_Only_Meanings, Do_Only_Meanings_Help); Inquire (Do_Stems_For_Unknown, Do_Stems_For_Unknown_Help); Put ("Do you wish to save this set of parameters? Y or N (Default) "); Put (" =>"); Get_Line (L1, Ll); if Ll /= 0 then if L1 (1) = '?' then Put (Save_Parameters_Help); Put ("Do you wish to save this set of parameters? Y or N (Default) "); Put (" =>"); Get_Line (L1, Ll); end if; Reply_Type_Io.Get (L1 (1 .. Ll), R, Ll); if Mode_Of_Reply (R) then Put_Modes; Put_Line ("MODE_ARRAY saved in file " & Mode_Full_Name); end if; end if; New_Line; exception when Blank_Input => null; when others => Put_Line ("Bad Input - terminating CHANGE_PARAMETERS"); end Change_Parameters; procedure Initialize_Word_Parameters is begin Words_Mode := Default_Mode_Array; --TEXT_IO.PUT_LINE ("Initializing WORD_PARAMETERS"); Do_Mode_File : begin -- Read the mode file Get_Modes; --(WORDS_MODE); Preface.Put_Line ("MODE_FILE found - Using those modes and parameters"); exception -- If there is any problem -- Put that the mode file is corrupted and the options are: -- to proceed with default parameters -- to set parameters with a CHANGE (SET) PARAMETERS and save -- to examine the mode file with a text editor and try to repair it when Name_Error => Words_Mode := Default_Mode_Array; when Bad_Mode_File => Put_Line ("MODE_FILE exists, but empty or corupted - Default modes used"); Put_Line ("You can set new parameters with CHANGE PARAMETERS and save."); Words_Mode := Default_Mode_Array; when others => Put_Line ("MODE_FILE others ERROR"); Words_Mode := Default_Mode_Array; end Do_Mode_File; if ((Method = Interactive) or (Method = Command_Line_Input)) and then (not Ada.Text_IO.Is_Open (Output)) and then (Words_Mode (Have_Output_File)) then Ada.Text_IO.Create (Output, Ada.Text_IO.Out_File, Output_Full_Name); --TEXT_IO.PUT_LINE ("WORD.OUT Created at Initialization"); Preface.Put_Line ("WORD.OUT Created at Initialization"); end if; if not Ada.Text_IO.Is_Open (Unknowns) and then Words_Mode (Write_Unknowns_To_File) then Ada.Text_IO.Create (Unknowns, Ada.Text_IO.Out_File, Unknowns_Full_Name); Preface.Put_Line ("WORD.UNK Created at Initialization"); end if; end Initialize_Word_Parameters; end Support_Utils.Word_Parameters;
pragma Style_Checks (Off); -- -- Copyright (c) 2009, 2012 Tero Koskinen <tero.koskinen@iki.fi> -- -- Permission to use, copy, modify, and distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- with Ada.Strings.Unbounded; with Interfaces.C; package SQLite3 is type SQLite3_DB is private; type SQLite3_Statement is private; type Error_Code is new Long_Integer; subtype SQL_Parameter_Index is Integer range 1 .. Integer'Last; subtype SQL_Column_Index is Integer; type Int is new Interfaces.C.Int; SQLITE_OK : constant Error_Code := 0; SQLITE_ERROR : constant Error_Code := 1; SQLITE_ROW : constant Error_Code := 100; SQLITE_DONE : constant Error_Code := 101; SQLITE_TRANSIENT : constant := -1; procedure Open (Filename : in String; Handle : out SQLite3_DB; Status : out Error_Code); procedure Close (Handle : in out SQLite3_DB; Status : out Error_Code); procedure Prepare (Handle : SQLite3_DB; Sql : String; SQL_Handle : out SQLite3_Statement; Status : out Error_Code); procedure Step (SQL_Handle : SQLite3_Statement; Status : out Error_Code); procedure Finish (SQL_Handle : SQLite3_Statement; Status : out Error_Code); procedure Reset (SQL_Handle : SQLite3_Statement; Status : out Error_Code); procedure Clear_Bindings (SQL_Handle : SQLite3_Statement; Status : out Error_Code); procedure Bind (SQL_Handle : SQLite3_Statement; Index : SQL_Parameter_Index; Value : Integer; Status : out Error_Code); procedure Bind (SQL_Handle : SQLite3_Statement; Index : SQL_Parameter_Index; Value : Long_Integer; Status : out Error_Code); procedure Bind (SQL_Handle : SQLite3_Statement; Index : SQL_Parameter_Index; Value : Ada.Strings.Unbounded.Unbounded_String; Status : out Error_Code); procedure Bind (SQL_Handle : SQLite3_Statement; Index : SQL_Parameter_Index; Value : String; Status : out Error_Code); procedure Bind (SQL_Handle : SQLite3_Statement; Index : SQL_Parameter_Index; Value : Interfaces.C.double; Status : out Error_Code); procedure Column (SQL_Handle : SQLite3_Statement; Index : SQL_Column_Index; Value : out Int); procedure Column (SQL_Handle : SQLite3_Statement; Index : SQL_Column_Index; Value : out Ada.Strings.Unbounded.Unbounded_String); procedure Busy_Timeout (Handle : SQLite3_DB; ms : Interfaces.C.int; Status : out Error_Code); function Error_Message (Handle : SQLite3_DB) return String; private type DB_Private is null record; type DB_Private_Access is access all DB_Private; type SQLite3_DB is record Ptr : aliased DB_Private_Access; end record; type Statement_Private is null record; type Statement_Private_Access is access all Statement_Private; type SQLite3_Statement is record Ptr : aliased Statement_Private_Access; end record; end SQLite3;
-- 程序名稱必須跟檔案名稱相同 procedure Basic is -- 這個區塊是一個叫做 basic 的程序 begin -- 由此開始 null; end Basic; -- 由此結束
------------------------------------------------------------------------------ -- A d a r u n - t i m e s p e c i f i c a t i o n -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of ada.ads file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $ package Standard is pragma Pure (Standard); type Boolean is (False, True); -- The predefined relational operators for this type are as follows: -- function "=" (Left, Right : Boolean'Base) return Boolean; -- function "/=" (Left, Right : Boolean'Base) return Boolean; -- function "<" (Left, Right : Boolean'Base) return Boolean; -- function "<=" (Left, Right : Boolean'Base) return Boolean; -- function ">" (Left, Right : Boolean'Base) return Boolean; -- function ">=" (Left, Right : Boolean'Base) return Boolean; -- The predefined logical operators and the predefined logical -- negation operator are as follows: -- function "and" (Left, Right : Boolean'Base) return Boolean; -- function "or" (Left, Right : Boolean'Base) return Boolean; -- function "xor" (Left, Right : Boolean'Base) return Boolean; -- function "not" (Right : Boolean'Base) return Boolean; -- The integer type root_integer and the -- corresponding universal type universal_integer are predefined. type Integer is range implementation-defined .. implementation-defined; subtype Natural is Integer range 0 .. Integer'Last; subtype Positive is Integer range 1 .. Integer'Last; -- The predefined operators for type Integer are as follows: -- function "=" (Left, Right : Integer'Base) return Boolean; -- function "/=" (Left, Right : Integer'Base) return Boolean; -- function "<" (Left, Right : Integer'Base) return Boolean; -- function "<=" (Left, Right : Integer'Base) return Boolean; -- function ">" (Left, Right : Integer'Base) return Boolean; -- function ">=" (Left, Right : Integer'Base) return Boolean; -- function "+" (Right : Integer'Base) return Integer'Base; -- function "-" (Right : Integer'Base) return Integer'Base; -- function "abs" (Right : Integer'Base) return Integer'Base; -- function "+" (Left, Right : Integer'Base) return Integer'Base; -- function "-" (Left, Right : Integer'Base) return Integer'Base; -- function "*" (Left, Right : Integer'Base) return Integer'Base; -- function "/" (Left, Right : Integer'Base) return Integer'Base; -- function "rem" (Left, Right : Integer'Base) return Integer'Base; -- function "mod" (Left, Right : Integer'Base) return Integer'Base; -- function "**" (Left : Integer'Base; Right : Natural) -- return Integer'Base; -- The specification of each operator for the type -- root_integer, or for any additional predefined integer -- type, is obtained by replacing Integer by the name of the type -- in the specification of the corresponding operator of the type -- Integer. The right operand of the exponentiation operator -- remains as subtype Natural. -- The floating point type root_real and the -- corresponding universal type universal_real are predefined. type Float is digits implementation-defined; -- The predefined operators for this type are as follows: -- function "=" (Left, Right : Float) return Boolean; -- function "/=" (Left, Right : Float) return Boolean; -- function "<" (Left, Right : Float) return Boolean; -- function "<=" (Left, Right : Float) return Boolean; -- function ">" (Left, Right : Float) return Boolean; -- function ">=" (Left, Right : Float) return Boolean; -- function "+" (Right : Float) return Float; -- function "-" (Right : Float) return Float; -- function "abs" (Right : Float) return Float; -- function "+" (Left, Right : Float) return Float; -- function "-" (Left, Right : Float) return Float; -- function "*" (Left, Right : Float) return Float; -- function "/" (Left, Right : Float) return Float; -- function "**" (Left : Float; Right : Integer'Base) return Float; -- The specification of each operator for the type root_real, or for -- any additional predefined floating point type, is obtained by -- replacing Float by the name of the type in the specification of the -- corresponding operator of the type Float. -- In addition, the following operators are predefined for the root -- numeric types: -- function "*" (Left : root_integer; Right : root_real) -- return root_real; -- function "*" (Left : root_real; Right : root_integer) -- return root_real; -- function "/" (Left : root_real; Right : root_integer) -- return root_real; -- The type universal_fixed is predefined. -- The only multiplying operators defined between -- fixed point types are -- function "*" (Left : universal_fixed; Right : universal_fixed) -- return universal_fixed; -- function "/" (Left : universal_fixed; Right : universal_fixed) -- return universal_fixed; -- The type universal_access is predefined. -- The following equality operators are predefined: -- function "=" (Left, Right: universal_access) return Boolean; -- function "/=" (Left, Right: universal_access) return Boolean; -- The declaration of type Character is based on the standard ISO 8859-1 -- character set. -- There are no character literals corresponding to the positions for -- control characters. -- They are indicated in italics in this definition. See 3.5.2. type Character is ('x'); -- The predefined operators for the type Character are the same as for -- any enumeration type. -- The declaration of type Wide_Character is based on the standard -- ISO/IEC 10646:2003 BMP character set. -- The first 256 positions have the same contents as type Character. -- See 3.5.2. type Wide_Character is ('x'); -- The declaration of type Wide_Wide_Character is based on the full -- ISO/IEC 10646:2003 character set. The first 65536 positions have the -- same contents as type Wide_Character. See 3.5.2. type Wide_Wide_Character is ('x'); for Wide_Wide_Character'Size use 32; package ASCII is -- Obsolescent; see J.5 -- Control characters: NUL : constant Character := Character'Val(0); SOH : constant Character := Character'Val(1); STX : constant Character := Character'Val(2); ETX : constant Character := Character'Val(3); EOT : constant Character := Character'Val(4); ENQ : constant Character := Character'Val(5); ACK : constant Character := Character'Val(6); BEL : constant Character := Character'Val(7); BS : constant Character := Character'Val(8); HT : constant Character := Character'Val(9); LF : constant Character := Character'Val(10); VT : constant Character := Character'Val(11); FF : constant Character := Character'Val(12); CR : constant Character := Character'Val(13); SO : constant Character := Character'Val(14); SI : constant Character := Character'Val(15); DLE : constant Character := Character'Val(16); DC1 : constant Character := Character'Val(17); DC2 : constant Character := Character'Val(18); DC3 : constant Character := Character'Val(19); DC4 : constant Character := Character'Val(20); NAK : constant Character := Character'Val(21); SYN : constant Character := Character'Val(22); ETB : constant Character := Character'Val(23); CAN : constant Character := Character'Val(24); EM : constant Character := Character'Val(25); SUB : constant Character := Character'Val(26); ESC : constant Character := Character'Val(27); FS : constant Character := Character'Val(28); GS : constant Character := Character'Val(29); RS : constant Character := Character'Val(30); US : constant Character := Character'Val(31); DEL : constant Character := Character'Val(127); -- Other characters: Exclam : constant Character:= '!'; Quotation : constant Character:= '"'; Sharp : constant Character:= '#'; Dollar : constant Character:= '$'; Percent : constant Character:= '%'; Ampersand : constant Character:= '&'; Colon : constant Character:= ':'; Semicolon : constant Character:= ';'; Query : constant Character:= '?'; At_Sign : constant Character:= '@'; L_Bracket : constant Character:= '['; Back_Slash : constant Character:= '\'; R_Bracket : constant Character:= ']'; Circumflex : constant Character:= '^'; Underline : constant Character:= '_'; Grave : constant Character:= '`'; L_Brace : constant Character:= '{'; Bar : constant Character:= '|'; R_Brace : constant Character:= '}'; Tilde : constant Character:= '~'; -- Lower case letters: LC_A : constant Character:= 'a'; LC_B : constant Character:= 'b'; LC_C : constant Character:= 'c'; LC_D : constant Character:= 'd'; LC_E : constant Character:= 'e'; LC_F : constant Character:= 'f'; LC_G : constant Character:= 'g'; LC_H : constant Character:= 'h'; LC_I : constant Character:= 'i'; LC_J : constant Character:= 'j'; LC_K : constant Character:= 'k'; LC_L : constant Character:= 'l'; LC_M : constant Character:= 'm'; LC_N : constant Character:= 'n'; LC_O : constant Character:= 'o'; LC_P : constant Character:= 'p'; LC_Q : constant Character:= 'q'; LC_R : constant Character:= 'r'; LC_S : constant Character:= 's'; LC_T : constant Character:= 't'; LC_U : constant Character:= 'u'; LC_V : constant Character:= 'v'; LC_W : constant Character:= 'w'; LC_X : constant Character:= 'x'; LC_Y : constant Character:= 'y'; LC_Z : constant Character:= 'z'; end ASCII; -- Predefined string types: type String is array (Positive range <>) of Character; pragma Pack (String); -- The predefined operators for this type are as follows: -- function "=" (Left, Right: String) return Boolean; -- function "/=" (Left, Right: String) return Boolean; -- function "<" (Left, Right: String) return Boolean; -- function "<=" (Left, Right: String) return Boolean; -- function ">" (Left, Right: String) return Boolean; -- function ">=" (Left, Right: String) return Boolean; -- function "&" (Left: String; Right: String) return String; -- function "&" (Left: Character; Right: String) return String; -- function "&" (Left: String; Right: Character) return String; -- function "&" (Left: Character; Right: Character) return String; type Wide_String is array (Positive range <>) of Wide_Character; pragma Pack (Wide_String); -- The predefined operators for this type correspond to those for String type Wide_Wide_String is array (Positive range <>) of Wide_Wide_Character; pragma Pack (Wide_Wide_String); -- The predefined operators for this type correspond to those for String. type Duration is delta implementation-defined range implementation-defined .. implementation-defined; -- The predefined operators for the type Duration are the same as for -- any fixed point type. -- The predefined exceptions: Constraint_Error : exception; Program_Error : exception; Storage_Error : exception; Tasking_Error : exception; -- Obsolescent; see J.6 Numeric_Error: Numeric_Error : exception renames Constraint_Error; end Standard;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- -- -- Trivial implementation compilation unit base class with Ada.Strings.Wide_Wide_Unbounded; with Program.Compilation_Units; with Program.Compilations; with Program.Elements; with Program.Element_Vectors; private package Program.Units is pragma Preelaborate; type Unit is abstract limited new Program.Compilation_Units.Compilation_Unit with private; procedure Initialize (Self : in out Unit'Class; Compilation : Program.Compilations.Compilation_Access; Full_Name : Text; Context_Clause : Program.Element_Vectors.Element_Vector_Access; Unit_Declaration : not null Program.Elements.Element_Access); private type Unit is abstract limited new Program.Compilation_Units.Compilation_Unit with record Compilation : Program.Compilations.Compilation_Access; Full_Name : Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String; Context_Clause : Program.Element_Vectors.Element_Vector_Access; Unit_Declaration : Program.Elements.Element_Access; end record; overriding function Compilation (Self : access Unit) return Program.Compilations.Compilation_Access; overriding function Full_Name (Self : access Unit) return Text; overriding function Context_Clause_Elements (Self : access Unit) return Program.Element_Vectors.Element_Vector_Access; overriding function Unit_Declaration (Self : access Unit) return not null Program.Elements.Element_Access; overriding function Is_Subunit_Unit (Self : Unit) return Boolean; overriding function Is_Library_Item_Unit (Self : Unit) return Boolean; overriding function Is_Library_Unit_Body_Unit (Self : Unit) return Boolean; overriding function Is_Library_Unit_Declaration_Unit (Self : Unit) return Boolean; end Program.Units;
package freetype_c.FT_BBox is type Item is record xMin : aliased FT_Pos; yMin : aliased FT_Pos; xMax : aliased FT_Pos; yMax : aliased FT_Pos; end record; type Item_array is array (C.Size_t range <>) of aliased FT_BBox.Item; type Pointer is access all FT_BBox.Item; type Pointer_array is array (C.Size_t range <>) of aliased FT_BBox.Pointer; type pointer_Pointer is access all FT_BBox.Pointer; end freetype_c.FT_BBox;
with Ada.Text_IO; use Ada.Text_IO; generic N, H : in Natural; package Data is type Vector is array(Integer range <>) of Integer; Subtype VectorN is Vector(1..N); Subtype Vector4H is Vector(1..4 * H); Subtype Vector3H is Vector(1..3 * H); Subtype Vector2H is Vector(1..2 * H); Subtype VectorH is Vector(1..H); type Matrix is array(Integer range <>) of VectorN; Subtype MatrixN is Matrix(1..N); Subtype Matrix4H is Matrix(1..4 * H); Subtype Matrix3H is Matrix(1..3 * H); Subtype Matrix2H is Matrix(1..2 * H); Subtype MatrixH is Matrix(1..H); procedure Input ( V : out Vector; Value : in Integer); procedure Input ( MA : out Matrix; Value : in Integer); procedure Output (V : in VectorN); procedure Output (MA : in Matrix); procedure FindMinZ (V : in VectorH; minZi : out Integer); function Min (A, B: Integer) return Integer; function Calculation (X : in VectorN; MA : in MatrixN; MS : in MatrixH; q : in Integer; R : in VectorN; MF: in MatrixH) return VectorH; end Data;
with openGL.Visual, openGL.Model.Billboard. textured, openGL.Model.Billboard.colored_textured, openGL.Palette, openGL.Demo; procedure launch_render_Billboards -- -- Exercise the render of billboard models. -- is use openGL, openGL.Model, openGL.Math, openGL.linear_Algebra_3d; the_Texture : constant openGL.asset_Name := to_Asset ("assets/opengl/texture/Face1.bmp"); begin Demo.print_Usage; Demo.define ("openGL 'Render Billboards' Demo"); Demo.Camera.Position_is ((0.0, 0.0, 10.0), y_Rotation_from (to_Radians (0.0))); declare -- The Models. -- the_Billboard_Model : constant Model.Billboard.textured.view := Model.Billboard.textured.forge.new_Billboard (Scale => (1.0, 1.0, 1.0), Plane => Billboard.xy, Texture => the_Texture); the_colored_Billboard_Model : constant Model.Billboard.colored_textured.view := Model.Billboard.colored_textured.new_Billboard (Scale => (1.0, 1.0, 1.0), Plane => Billboard.xy, Color => (Palette.Green, Opaque), Texture => the_Texture); -- The Sprites. -- use openGL.Visual.Forge; the_Sprites : constant openGL.Visual.views := (new_Visual ( the_Billboard_Model.all'Access), new_Visual (the_colored_Billboard_Model.all'Access)); begin the_Sprites (2).Site_is ((3.0, 0.0, 0.0)); -- Main loop. -- while not Demo.Done loop -- Handle user commands. -- Demo.Dolly.evolve; Demo.Done := Demo.Dolly.quit_Requested; -- Render the sprites. -- Demo.Camera.render (the_Sprites); while not Demo.Camera.cull_Completed loop delay Duration'Small; end loop; Demo.Renderer.render; Demo.FPS_Counter.increment; -- Frames per second display. end loop; end; Demo.destroy; end launch_render_Billboards;
----------------------------------------------------------------------- -- util-encoders-base16 -- Encode/Decode a stream in hexadecimal -- Copyright (C) 2009, 2010, 2011, 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Util.Encoders.Base16 is package body Encoding is type Code is mod 2**32; function To_Output_Char (Ch : Input_Char) return Code; type Conv_Table is array (0 .. 15) of Output_Char; Conversion : constant Conv_Table := (0 => Output_Char'Val (Character'Pos ('0')), 1 => Output_Char'Val (Character'Pos ('1')), 2 => Output_Char'Val (Character'Pos ('2')), 3 => Output_Char'Val (Character'Pos ('3')), 4 => Output_Char'Val (Character'Pos ('4')), 5 => Output_Char'Val (Character'Pos ('5')), 6 => Output_Char'Val (Character'Pos ('6')), 7 => Output_Char'Val (Character'Pos ('7')), 8 => Output_Char'Val (Character'Pos ('8')), 9 => Output_Char'Val (Character'Pos ('9')), 10 => Output_Char'Val (Character'Pos ('A')), 11 => Output_Char'Val (Character'Pos ('B')), 12 => Output_Char'Val (Character'Pos ('C')), 13 => Output_Char'Val (Character'Pos ('D')), 14 => Output_Char'Val (Character'Pos ('E')), 15 => Output_Char'Val (Character'Pos ('F'))); -- Encode the input stream in hexadecimal and write the result -- in the output stream procedure Encode (From : in Input; Into : in out Output; Last : out Output_Index; Encoded : out Index) is N : constant Output_Index := (Input_Char'Size / 8) * 2; Pos : Output_Index := Into'First; begin for I in From'Range loop if Pos + N > Into'Last + 1 then Last := Pos - 1; Encoded := I - 1; return; end if; declare Value : Code := Input_Char'Pos (From (I)); P : Code; begin Pos := Pos + N; for J in 1 .. N / 2 loop P := Value; Value := Value / 16; Into (Pos - J) := Conversion (Natural (P and 16#0F#)); P := Value; Into (Pos - J - 1) := Conversion (Natural (P and 16#0F#)); Value := Value / 16; end loop; end; end loop; Last := Pos - 1; Encoded := From'Last; end Encode; function To_Output_Char (Ch : Input_Char) return Code is C : constant Code := Input_Char'Pos (Ch); begin if C >= Character'Pos ('a') and C <= Character'Pos ('f') then return C - Character'Pos ('a') + 10; elsif C >= Character'Pos ('A') and C <= Character'Pos ('F') then return C - Character'Pos ('A') + 10; elsif C >= Character'Pos ('0') and C <= Character'Pos ('9') then return C - Character'Pos ('0'); else raise Encoding_Error with "Invalid character: " & Character'Val (C); end if; end To_Output_Char; procedure Decode (From : in Input; Into : in out Output; Last : out Output_Index; Encoded : out Index) is First : Boolean := True; Pos : Output_Index := Into'First; Value : Code; begin if Into'Length < From'Length / 2 then Encoded := Into'Length * 2; elsif From'Last mod 2 /= 0 then Encoded := From'Last - 1; else Encoded := From'Last; end if; if Encoded < From'First then raise Encoding_Error with "Hexadecimal stream is too short"; end if; for I in From'First .. Encoded loop if First then Value := To_Output_Char (From (I)); First := False; else Value := Value * 16 + To_Output_Char (From (I)); Into (Pos) := Output_Char'Val (Value); Pos := Pos + 1; First := True; end if; end loop; Last := Pos - 1; end Decode; end Encoding; package Encoding_Stream is new Encoding (Output => Ada.Streams.Stream_Element_Array, Index => Ada.Streams.Stream_Element_Offset, Output_Index => Ada.Streams.Stream_Element_Offset, Input_Char => Ada.Streams.Stream_Element, Output_Char => Ada.Streams.Stream_Element, Input => Ada.Streams.Stream_Element_Array); -- ------------------------------ -- Encodes the binary input stream represented by <b>Data</b> into -- the a base16 (hexadecimal) output stream <b>Into</b>. -- -- If the transformer does not have enough room to write the result, -- it must return in <b>Encoded</b> the index of the last encoded -- position in the <b>Data</b> stream. -- -- The transformer returns in <b>Last</b> the last valid position -- in the output stream <b>Into</b>. -- -- The <b>Encoding_Error</b> exception is raised if the input -- stream cannot be transformed. -- ------------------------------ overriding procedure Transform (E : in out Encoder; Data : in Ada.Streams.Stream_Element_Array; Into : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; Encoded : out Ada.Streams.Stream_Element_Offset) is pragma Unreferenced (E); begin Encoding_Stream.Encode (Data, Into, Last, Encoded); end Transform; -- ------------------------------ -- Decodes the base16 input stream represented by <b>Data</b> into -- the binary output stream <b>Into</b>. -- -- If the transformer does not have enough room to write the result, -- it must return in <b>Encoded</b> the index of the last encoded -- position in the <b>Data</b> stream. -- -- The transformer returns in <b>Last</b> the last valid position -- in the output stream <b>Into</b>. -- -- The <b>Encoding_Error</b> exception is raised if the input -- stream cannot be transformed. -- ------------------------------ overriding procedure Transform (E : in out Decoder; Data : in Ada.Streams.Stream_Element_Array; Into : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; Encoded : out Ada.Streams.Stream_Element_Offset) is pragma Unreferenced (E); begin Encoding_Stream.Decode (Data, Into, Last, Encoded); end Transform; end Util.Encoders.Base16;
with PixelArray; use PixelArray; package body Morphology is function maxPixel(image: PixelArray.ImagePlane; x, y: Natural; size: Positive) return PixelArray.Pixel is result: PixelArray.Pixel; begin result := image.get(x, y); for py in y - size / 2 .. y + size / 2 loop for px in x - size / 2 .. x + size / 2 loop if image.isInside(px, py) then result := PixelArray.Pixel'Max(result, image.get(px, py)); if result = PixelArray.Pixel'Last then return result; end if; end if; end loop; end loop; return result; end maxPixel; function minPixel(image: PixelArray.ImagePlane; x, y: Natural; size: Positive) return PixelArray.Pixel is result: PixelArray.Pixel; begin result := image.get(x, y); for py in y - size / 2 .. y + size / 2 loop for px in x - size / 2 .. x + size / 2 loop if image.isInside(px, py) then result := PixelArray.Pixel'Min(result, image.get(px, py)); if result = PixelArray.Pixel'First then return result; end if; end if; end loop; end loop; return result; end minPixel; function dilate(image: PixelArray.ImagePlane; size: Positive) return PixelArray.ImagePlane is begin return result: PixelArray.ImagePlane := PixelArray.allocate(image.width, image.height) do for py in 0 .. image.height - 1 loop for px in 0 .. image.width - 1 loop result.set(px, py, maxPixel(image, px, py, size)); end loop; end loop; end return; end dilate; function erode(image: PixelArray.ImagePlane; size: Positive) return PixelArray.ImagePlane is begin return result: PixelArray.ImagePlane := PixelArray.allocate(image.width, image.height) do for py in 0 .. image.height - 1 loop for px in 0 .. image.width - 1 loop result.set(px, py, minPixel(image, px, py, size)); end loop; end loop; end return; end erode; end Morphology;
with Ada.Real_Time; use Ada.Real_Time; package mylog with SPARK_Mode is type msgtype is (NONE, TEXT, GPS); type logmsg (typ : msgtype := NONE) is record t : Time := Time_First; case typ is when NONE => null; when TEXT => txt : String (1 .. 128) := (others => Character'Val (0)); txt_last : Integer := 0; when GPS => lat : Float := 0.0; lon : Float := 0.0; end case; end record; type msgarray is array (Positive range <>) of logmsg; -- primitive ops procedure Print (m : logmsg); end mylog;
with decls.dgenerals, Ada.Text_IO; use decls.dgenerals, Ada.Text_IO; package Semantica.Missatges is type Terror is (paramsPprincipal, id_existent, idProgDiferents, tipusParam, paramRepetit, enregArg, tipusInexistent, tipusSubIncorrecte, rang_sobrepassat, idCampRecordExistent, TsubjRangDif, TsubjDifTipus, ValEsqMajorDret, ValEsqMenor, ValDretMajor, TsubNoValid, argNoProc, tipusSubDiferents, posaIdxArray, TipusIdxErroniArray, Tsub_No_Bool, Tops_Diferents, Tsubs_Diferents, Tsub_No_Escalar, Tsub_No_Sencer, Tipus_No_Desc, Id_No_Reconegut, Id_No_Cridaproc, Assig_Tipus_Diferents, Exp_No_Bool, Rec_No_Cridaproc, Falta_Param_Proc, Refvar_No_Proc, Falta_Param_Array, Reccamp_No_Valid, Idrec_No_Valid, Sobren_Parametres, Tparam_No_Coincident, Tipus_No_Array, Tproc_No_Param); procedure Obre_Fitxer (nomFitxer: in String); procedure Tanca_Fitxer; procedure Error (Te : in Terror; L, C : in Natural; Id : String); procedure Error (Te : in Terror; Id : String); procedure Impressio (Msj : in String); private Log_File : File_Type; end Semantica.Missatges;
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- ncurses -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright 2018,2020 Thomas E. Dickey -- -- Copyright 2000-2007,2008 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000 -- Version Control -- $Revision: 1.11 $ -- $Date: 2020/02/02 23:34:34 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ -- TODO use Default_Character where appropriate -- This is an Ada version of ncurses -- I translated this because it tests the most features. with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Terminal_Interface.Curses.Trace; use Terminal_Interface.Curses.Trace; with Ada.Text_IO; use Ada.Text_IO; with Ada.Characters.Latin_1; with Ada.Command_Line; use Ada.Command_Line; with Ada.Strings.Unbounded; with ncurses2.util; use ncurses2.util; with ncurses2.getch_test; with ncurses2.attr_test; with ncurses2.color_test; with ncurses2.demo_panels; with ncurses2.color_edit; with ncurses2.slk_test; with ncurses2.acs_display; with ncurses2.acs_and_scroll; with ncurses2.flushinp_test; with ncurses2.test_sgr_attributes; with ncurses2.menu_test; with ncurses2.demo_pad; with ncurses2.demo_forms; with ncurses2.overlap_test; with ncurses2.trace_set; with ncurses2.getopt; use ncurses2.getopt; package body ncurses2.m is function To_trace (n : Integer) return Trace_Attribute_Set; procedure usage; procedure Set_Terminal_Modes; function Do_Single_Test (c : Character) return Boolean; function To_trace (n : Integer) return Trace_Attribute_Set is a : Trace_Attribute_Set := (others => False); m : Integer; rest : Integer; begin m := n mod 2; if 1 = m then a.Times := True; end if; rest := n / 2; m := rest mod 2; if 1 = m then a.Tputs := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.Update := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.Cursor_Move := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.Character_Output := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.Calls := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.Virtual_Puts := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.Input_Events := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.TTY_State := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.Internal_Calls := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.Character_Calls := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.Termcap_TermInfo := True; end if; return a; end To_trace; -- these are type Stdscr_Init_Proc; function rip_footer ( Win : Window; Columns : Column_Count) return Integer; pragma Convention (C, rip_footer); function rip_footer ( Win : Window; Columns : Column_Count) return Integer is begin Set_Background (Win, (Ch => ' ', Attr => (Reverse_Video => True, others => False), Color => 0)); Erase (Win); Move_Cursor (Win, 0, 0); Add (Win, "footer:" & Columns'Img & " columns"); Refresh_Without_Update (Win); return 0; -- Curses_OK; end rip_footer; function rip_header ( Win : Window; Columns : Column_Count) return Integer; pragma Convention (C, rip_header); function rip_header ( Win : Window; Columns : Column_Count) return Integer is begin Set_Background (Win, (Ch => ' ', Attr => (Reverse_Video => True, others => False), Color => 0)); Erase (Win); Move_Cursor (Win, 0, 0); Add (Win, "header:" & Columns'Img & " columns"); -- 'Img is a GNAT extension Refresh_Without_Update (Win); return 0; -- Curses_OK; end rip_header; procedure usage is -- type Stringa is access String; use Ada.Strings.Unbounded; -- tbl : constant array (Positive range <>) of Stringa := ( tbl : constant array (Positive range <>) of Unbounded_String := ( To_Unbounded_String ("Usage: ncurses [options]"), To_Unbounded_String (""), To_Unbounded_String ("Options:"), To_Unbounded_String (" -a f,b set default-colors " & "(assumed white-on-black)"), To_Unbounded_String (" -d use default-colors if terminal " & "supports them"), To_Unbounded_String (" -e fmt specify format for soft-keys " & "test (e)"), To_Unbounded_String (" -f rip-off footer line " & "(can repeat)"), To_Unbounded_String (" -h rip-off header line " & "(can repeat)"), To_Unbounded_String (" -s msec specify nominal time for " & "panel-demo (default: 1, to hold)"), To_Unbounded_String (" -t mask specify default trace-level " & "(may toggle with ^T)") ); begin for n in tbl'Range loop Put_Line (Standard_Error, To_String (tbl (n))); end loop; -- exit(EXIT_FAILURE); -- TODO should we use Set_Exit_Status and throw and exception? end usage; procedure Set_Terminal_Modes is begin Set_Raw_Mode (SwitchOn => False); Set_Cbreak_Mode (SwitchOn => True); Set_Echo_Mode (SwitchOn => False); Allow_Scrolling (Mode => True); Use_Insert_Delete_Line (Do_Idl => True); Set_KeyPad_Mode (SwitchOn => True); end Set_Terminal_Modes; nap_msec : Integer := 1; function Do_Single_Test (c : Character) return Boolean is begin case c is when 'a' => getch_test; when 'b' => attr_test; when 'c' => if not Has_Colors then Cannot ("does not support color."); else color_test; end if; when 'd' => if not Has_Colors then Cannot ("does not support color."); elsif not Can_Change_Color then Cannot ("has hardwired color values."); else color_edit; end if; when 'e' => slk_test; when 'f' => acs_display; when 'o' => demo_panels (nap_msec); when 'g' => acs_and_scroll; when 'i' => flushinp_test (Standard_Window); when 'k' => test_sgr_attributes; when 'm' => menu_test; when 'p' => demo_pad; when 'r' => demo_forms; when 's' => overlap_test; when 't' => trace_set; when '?' => null; when others => return False; end case; return True; end Do_Single_Test; command : Character; my_e_param : Soft_Label_Key_Format := Four_Four; assumed_colors : Boolean := False; default_colors : Boolean := False; default_fg : Color_Number := White; default_bg : Color_Number := Black; -- nap_msec was an unsigned long integer in the C version, -- yet napms only takes an int! c : Integer; c2 : Character; optind : Integer := 1; -- must be initialized to one. optarg : getopt.stringa; length : Integer; tmpi : Integer; package myio is new Ada.Text_IO.Integer_IO (Integer); save_trace : Integer := 0; save_trace_set : Trace_Attribute_Set; function main return Integer is begin loop Qgetopt (c, Argument_Count, Argument'Access, "a:de:fhs:t:", optind, optarg); exit when c = -1; c2 := Character'Val (c); case c2 is when 'a' => -- Ada doesn't have scanf, it doesn't even have a -- regular expression library. assumed_colors := True; myio.Get (optarg.all, Integer (default_fg), length); myio.Get (optarg.all (length + 2 .. optarg.all'Length), Integer (default_bg), length); when 'd' => default_colors := True; when 'e' => myio.Get (optarg.all, tmpi, length); if tmpi > 3 then usage; return 1; end if; my_e_param := Soft_Label_Key_Format'Val (tmpi); when 'f' => Rip_Off_Lines (-1, rip_footer'Access); when 'h' => Rip_Off_Lines (1, rip_header'Access); when 's' => myio.Get (optarg.all, nap_msec, length); when 't' => myio.Get (optarg.all, save_trace, length); when others => usage; return 1; end case; end loop; -- the C version had a bunch of macros here. -- if (!isatty(fileno(stdin))) -- isatty is not available in the standard Ada so skip it. save_trace_set := To_trace (save_trace); Trace_On (save_trace_set); Init_Soft_Label_Keys (my_e_param); Init_Screen; Set_Background (Ch => (Ch => Blank, Attr => Normal_Video, Color => Color_Pair'First)); if Has_Colors then Start_Color; if default_colors then Use_Default_Colors; elsif assumed_colors then Assume_Default_Colors (default_fg, default_bg); end if; end if; Set_Terminal_Modes; Save_Curses_Mode (Curses); End_Windows; -- TODO add macro #if blocks. Put_Line ("Welcome to " & Curses_Version & ". Press ? for help."); loop Put_Line ("This is the ncurses main menu"); Put_Line ("a = keyboard and mouse input test"); Put_Line ("b = character attribute test"); Put_Line ("c = color test pattern"); Put_Line ("d = edit RGB color values"); Put_Line ("e = exercise soft keys"); Put_Line ("f = display ACS characters"); Put_Line ("g = display windows and scrolling"); Put_Line ("i = test of flushinp()"); Put_Line ("k = display character attributes"); Put_Line ("m = menu code test"); Put_Line ("o = exercise panels library"); Put_Line ("p = exercise pad features"); Put_Line ("q = quit"); Put_Line ("r = exercise forms code"); Put_Line ("s = overlapping-refresh test"); Put_Line ("t = set trace level"); Put_Line ("? = repeat this command summary"); Put ("> "); Flush; command := Ada.Characters.Latin_1.NUL; -- get_input: -- loop declare Ch : Character; begin Get (Ch); -- TODO if read(ch) <= 0 -- TODO ada doesn't have an Is_Space function command := Ch; -- TODO if ch = '\n' or '\r' are these in Ada? end; -- end loop get_input; declare begin if Do_Single_Test (command) then Flush_Input; Set_Terminal_Modes; Reset_Curses_Mode (Curses); Clear; Refresh; End_Windows; if command = '?' then Put_Line ("This is the ncurses capability tester."); Put_Line ("You may select a test from the main menu by " & "typing the"); Put_Line ("key letter of the choice (the letter to left " & "of the =)"); Put_Line ("at the > prompt. The commands `x' or `q' will " & "exit."); end if; -- continue; --why continue in the C version? end if; exception when Curses_Exception => End_Windows; end; exit when command = 'q'; end loop; Curses_Free_All; return 0; -- TODO ExitProgram(EXIT_SUCCESS); end main; end ncurses2.m;
with Ada.Text_IO; use Ada.Text_IO; with Simple_Blockchain.Block; with Simple_Blockchain.Blockchain; use Simple_Blockchain; function Simple_Blockchain_Demo return Integer is The_Blockchain : Blockchain.Object := Blockchain.Make (Difficulty => 6); begin Put_Line ("Simple blockchain demo"); New_Line; Put_Line ("Mining first block..."); Blockchain.Mine_Block (The_Blockchain, Data => "First block"); Put_Line ("Block mined."); New_Line; Put_Line ("Mining second block..."); Blockchain.Mine_Block (The_Blockchain, Data => "Second block"); Put_Line ("Block mined."); New_Line; Put_Line ("Mining third block..."); Blockchain.Mine_Block (The_Blockchain, Data => "Third block"); Put_Line ("Block mined."); New_Line; Put_Line ("Is blockchain valid? " & Blockchain.Is_Valid (The_Blockchain)'Image); New_Line; Put_Line ("Printing blockchain..."); Put_Line (Blockchain.Image (The_Blockchain)); return 0; end Simple_Blockchain_Demo;
With NSO.Helpers, Ada.Text_IO, Config, INI, GNAT.Sockets.Server, GNAT.Sockets.SMTP.Client.Synchronous; Procedure Send_Report(Text : String:= ""; Params : INI.Instance:= INI.Empty) is use all type GNAT.Sockets.SMTP.Client.Mail; Use GNAT.Sockets.SMTP.Client, GNAT.Sockets.Server; DEBUG : Constant Boolean:= False; EMAIL : Constant Boolean:= True; Recpipant : Constant String:= (if DEBUG then "<efish@nmsu.edu>" -- Developer's e-mail address. else "report_ops@sp.nso.edu" -- The reporting mail-list; note: SP.NSO.EDU ); Function Test_Message return String is Use NSO.Helpers; CRLF : Constant String := (ASCII.CR, ASCII.LF); -- Wraps the given text in CRLF. Function "+"(Text : String) return String is (CRLF & Text & CRLF) with Inline; Function "+"(Left, Right: String) return String is (CRLF & Left & (+Right)) with Inline; MaxWide: Constant String := "maxwidth: 120em;"; Head : Constant String := HTML_Tag("head", ""); Content: Constant String := HTML_Tag("body", Text, "Style", MaxWide); -- Prolog : Constant String := "<HTML><head></head><body style=""maxwidth: 120em;"">"; -- Epilog : Constant String := "</body></HTML>"; -- Function As_HTML(HTML_Body : String) return String is -- ( Prolog & CRLF & HTML_Body & CRLF & Epilog) with Inline; Begin Return Result : Constant String := HTML_Tag("HTML", Head + Content) do --As_HTML(Text) do if DEBUG then Ada.Text_IO.Put_Line( Result ); end if; End return; End; Message : Mail renames Create (Mime => "text/html", Subject => "EMAIL-REPORT" & (if DEBUG then " [DEBUG]" else ""), From => "<LVTT@NSO.EDU>", To => Recpipant, Contents => Test_Message -- Cc => , -- Bcc => , -- Date => ); Buffer : Constant := 1024 * 2; Factory : aliased Connections_Factory; Server : aliased Connections_Server (Factory'Access, 0); Client : Connection_Ptr := new SMTP_Client ( Listener => Server'Unchecked_Access, Reply_Length => Buffer, Input_Size => 80, Output_Size => Buffer ); -- This procedure **DOES NOT** work! Procedure Async_Send is use type Config.Pascal_String; Begin Set_Credentials (SMTP_Client (Client.all), User => +Config.User, Password => +Config.Password ); Send( SMTP_Client (Client.all), Message ); Connect( Listener => Server, Client => Client, Host => +Config.Host, Port => GNAT.Sockets.SMTP.SMTP_Port ); end Async_Send; -- This procedure **WORKS**!! Procedure Synch_Send is use GNAT.Sockets.SMTP.Client.Synchronous, Config; Begin Send( Server => Server, Host => +Config.Host, -- Currently: "mail.nso.edu" Message => Message, User => +Config.User, -- User of the mail-system. Password => +Config.Password, -- Their password. Timeout => 10.0 ); end Synch_Send; Begin if EMAIL and Text /= "" then Synch_Send; end if; End Send_Report;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . S H A R E D _ S T O R A G E -- -- -- -- S p e c -- -- -- -- Copyright (C) 1998-2006, 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 manages the shared/persistant storage required for -- full implementation of variables in Shared_Passive packages, more -- precisely variables whose enclosing dynamic scope is a shared -- passive package. This implementation is specific to GNAT and GLADE -- provides a more general implementation not dedicated to file -- storage. -- This unit (and shared passive partitions) are supported on all -- GNAT implementations except on OpenVMS (where problems arise from -- trying to share files, and with version numbers of files) -- -------------------------- -- -- Shared Storage Model -- -- -------------------------- -- The basic model used is that each partition that references the -- Shared_Passive package has a local copy of the package data that -- is initialized in accordance with the declarations of the package -- in the normal manner. The routines in System.Shared_Storage are -- then used to ensure that the values in these separate copies are -- properly synchronized with the state of the overall system. -- In the GNAT implementation, this synchronization is ensured by -- maintaining a set of files, in a designated directory. The -- directory is designated by setting the environment variable -- SHARED_MEMORY_DIRECTORY. This variable must be set for all -- partitions. If the environment variable is not defined, then the -- current directory is used. -- There is one storage for each variable. The name is the fully -- qualified name of the variable with all letters forced to lower -- case. For example, the variable Var in the shared passive package -- Pkg results in the storage name pkg.var. -- If the storage does not exist, it indicates that no partition has -- assigned a new value, so that the initial value is the correct -- one. This is the critical component of the model. It means that -- there is no system-wide synchronization required for initializing -- the package, since the shared storages need not (and do not) -- reflect the initial state. There is therefore no issue of -- synchronizing initialization and read/write access. -- ----------------------- -- -- Read/Write Access -- -- ----------------------- -- The approach is as follows: -- For each shared variable, var, an access routine varR is created whose -- body has the following form (this example is for Pkg.Var): -- procedure varR is -- S : Ada.Streams.Stream_IO.Stream_Access; -- begin -- S := Shared_Var_ROpen ("pkg.var"); -- if S /= null then -- typ'Read (S); -- Shared_Var_Close (S); -- end if; -- end varR; -- The routine Shared_Var_ROpen in package System.Shared_Storage -- either returns null if the storage does not exist, or otherwise a -- Stream_Access value that references the corresponding shared -- storage, ready to read the current value. -- Each reference to the shared variable, var, is preceded by a -- call to the corresponding varR procedure, which either leaves the -- initial value unchanged if the storage does not exist, or reads -- the current value from the shared storage. -- In addition, for each shared variable, var, an assignment routine -- is created whose body has the following form (again for Pkg.Var) -- procedure VarA is -- S : Ada.Streams.Stream_IO.Stream_Access; -- begin -- S := Shared_Var_WOpen ("pkg.var"); -- typ'Write (S, var); -- Shared_Var_Close (S); -- end VarA; -- The routine Shared_Var_WOpen in package System.Shared_Storage -- returns a Stream_Access value that references the corresponding -- shared storage, ready to write the new value. -- Each assignment to the shared variable, var, is followed by a call -- to the corresponding varA procedure, which writes the new value to -- the shared storage. -- Note that there is no general synchronization for these storage -- read and write operations, since it is assumed that a correctly -- operating programs will provide appropriate synchronization. In -- particular, variables can be protected using protected types with -- no entries. -- The routine Shared_Var_Close is called to indicate the end of a -- read/write operations. This can be useful even in the context of -- the GNAT implementation. For instance, when a read operation and a -- write operation occur at the same time on the same partition, as -- the same stream is used simultaneously, both operations can -- terminate abruptly by raising exception Mode_Error because the -- stream has been opened in read mode and then in write mode and at -- least used by the read opartion. To avoid this unexpected -- behaviour, we introduce a synchronization at the partition level. -- Note: a special circuit allows the use of stream attributes Read and -- Write for limited types (using the corresponding attribute for the -- full type), but there are limitations on the data that can be placed -- in shared passive partitions. See sem_smem.ads/adb for details. -- ---------------------------------------------------------------- -- -- Handling of Protected Objects in Shared Passive Partitions -- -- ---------------------------------------------------------------- -- In the context of GNAT, during the execution of a protected -- subprogram call, access is locked out using a locking mechanism -- per protected object, as provided by the GNAT.Lock_Files -- capability in the specific case of GNAT. This package contains the -- lock and unlock calls, and the expander generates a call to the -- lock routine before the protected call and a call to the unlock -- routine after the protected call. -- Within the code of the protected subprogram, the access to the -- protected object itself uses the local copy, without any special -- synchronization. Since global access is locked out, no other task -- or partition can attempt to read or write this data as long as the -- lock is held. -- The data in the local copy does however need synchronizing with -- the global values in the shared storage. This is achieved as -- follows: -- The protected object generates a read and assignment routine as -- described for other shared passive variables. The code for the -- 'Read and 'Write attributes (not normally allowed, but allowed -- in this special case) simply reads or writes the values of the -- components in the protected record. -- The lock call is followed by a call to the shared read routine to -- synchronize the local copy to contain the proper global value. -- The unlock call in the procedure case only is preceded by a call -- to the shared assign routine to synchronize the global shared -- storages with the (possibly modified) local copy. -- These calls to the read and assign routines, as well as the lock -- and unlock routines, are inserted by the expander (see exp_smem.adb). with Ada.Streams.Stream_IO; package System.Shared_Storage is package SIO renames Ada.Streams.Stream_IO; function Shared_Var_ROpen (Var : String) return SIO.Stream_Access; -- As described above, this routine returns null if the -- corresponding shared storage does not exist, and otherwise, if -- the storage does exist, a Stream_Access value that references -- the shared storage, ready to read the current value. function Shared_Var_WOpen (Var : String) return SIO.Stream_Access; -- As described above, this routine returns a Stream_Access value -- that references the shared storage, ready to write the new -- value. The storage is created by this call if it does not -- already exist. procedure Shared_Var_Close (Var : SIO.Stream_Access); -- This routine signals the end of a read/assign operation. It can -- be useful to embrace a read/write operation between a call to -- open and a call to close which protect the whole operation. -- Otherwise, two simultaneous operations can result in the -- raising of exception Data_Error by setting the access mode of -- the variable in an incorrect mode. procedure Shared_Var_Lock (Var : String); -- This procedure claims the shared storage lock. It is used for -- protected types in shared passive packages. A call to this -- locking routine is generated as the first operation in the code -- for the body of a protected subprogram, and it busy waits if -- the lock is busy. procedure Shared_Var_Unlock (Var : String); -- This procedure releases the shared storage lock obtaind by a -- prior call to the Shared_Mem_Lock procedure, and is to be -- generated as the last operation in the body of a protected -- subprogram. end System.Shared_Storage;
pragma License (Unrestricted); -- implementation unit required by compiler package System.Fat_Flt is pragma Pure; package Attr_Float is -- required for Float'Adjacent by compiler (s-fatgen.ads) function Adjacent (X, Towards : Float) return Float with Import, Convention => Intrinsic, External_Name => "__builtin_nextafterf"; -- required for Float'Ceiling by compiler (s-fatgen.ads) function Ceiling (X : Float) return Float with Import, Convention => Intrinsic, External_Name => "__builtin_ceilf"; -- required for Float'Compose by compiler (s-fatgen.ads) function Compose (Fraction : Float; Exponent : Integer) return Float; -- required for Float'Copy_Sign by compiler (s-fatgen.ads) function Copy_Sign (X, Y : Float) return Float with Import, Convention => Intrinsic, External_Name => "__builtin_copysignf"; -- required for Float'Exponent by compiler (s-fatgen.ads) function Exponent (X : Float) return Integer; -- required for Float'Floor by compiler (s-fatgen.ads) function Floor (X : Float) return Float with Import, Convention => Intrinsic, External_Name => "__builtin_floorf"; -- required for Float'Fraction by compiler (s-fatgen.ads) function Fraction (X : Float) return Float; -- required for Float'Leading_Part by compiler (s-fatgen.ads) function Leading_Part (X : Float; Radix_Digits : Integer) return Float; -- required for Float'Machine by compiler (s-fatgen.ads) function Machine (X : Float) return Float; -- required for Float'Machine_Rounding by compiler (s-fatgen.ads) function Machine_Rounding (X : Float) return Float with Import, Convention => Intrinsic, External_Name => "__builtin_nearbyintf"; -- required for Float'Model by compiler (s-fatgen.ads) function Model (X : Float) return Float renames Machine; -- required for Float'Pred by compiler (s-fatgen.ads) function Pred (X : Float) return Float; -- required for Float'Remainder by compiler (s-fatgen.ads) function Remainder (X, Y : Float) return Float with Import, Convention => Intrinsic, External_Name => "__builtin_remainderf"; -- required for Float'Rounding by compiler (s-fatgen.ads) function Rounding (X : Float) return Float with Import, Convention => Intrinsic, External_Name => "__builtin_roundf"; -- required for Float'Scaling by compiler (s-fatgen.ads) function Scaling (X : Float; Adjustment : Integer) return Float with Import, Convention => Intrinsic, External_Name => "__builtin_ldexpf"; -- required for Float'Succ by compiler (s-fatgen.ads) function Succ (X : Float) return Float; -- required for Float'Truncation by compiler (s-fatgen.ads) function Truncation (X : Float) return Float with Import, Convention => Intrinsic, External_Name => "__builtin_truncf"; -- required for Float'Unbiased_Rounding by compiler (s-fatgen.ads) function Unbiased_Rounding (X : Float) return Float; -- required for Float'Valid by compiler (s-fatgen.ads) function Valid (X : not null access Float) return Boolean; type S is new String (1 .. Float'Size / Character'Size); type P is access all S; for P'Storage_Size use 0; end Attr_Float; end System.Fat_Flt;
with Ada.Text_IO; use Ada.Text_IO; procedure OwO is begin Put_Line ("OwO"); end OwO;
-- C97301A.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT A TIMED_ENTRY_CALL DELAYS FOR AT LEAST THE SPECIFIED -- AMOUNT OF TIME IF A RENDEVOUS IS NOT POSSIBLE. -- CASE A: THE TASK TO BE CALLED HAS NOT YET BEEN ACTIVATED AS OF THE -- MOMENT OF CALL. -- RJW 3/31/86 with Impdef; WITH REPORT; USE REPORT; WITH CALENDAR; USE CALENDAR; PROCEDURE C97301A IS WAIT_TIME : CONSTANT DURATION := 10.0 * Impdef.One_Second; OR_BRANCH_TAKEN : INTEGER := 3; BEGIN TEST ("C97301A", "CHECK THAT A TIMED_ENTRY_CALL DELAYS FOR AT " & "LEAST THE SPECIFIED AMOUNT OF TIME WHEN THE " & "CALLED TASK IS NOT ACTIVE" ); ------------------------------------------------------------------ DECLARE TASK T IS ENTRY DO_IT_NOW_OR_WAIT ( AUTHORIZED : IN BOOLEAN ); END T; TASK BODY T IS PACKAGE SECOND_ATTEMPT IS END SECOND_ATTEMPT; PACKAGE BODY SECOND_ATTEMPT IS START_TIME : TIME; BEGIN START_TIME := CLOCK; SELECT DO_IT_NOW_OR_WAIT (FALSE); --CALLING OWN ENTRY. OR -- THEREFORE THIS BRANCH -- MUST BE CHOSEN. DELAY WAIT_TIME; IF CLOCK >= (WAIT_TIME + START_TIME) THEN NULL; ELSE FAILED ( "INSUFFICIENT DELAY (#2)" ); END IF; OR_BRANCH_TAKEN := 2 * OR_BRANCH_TAKEN; COMMENT( "OR_BRANCH TAKEN (#2)" ); END SELECT; END SECOND_ATTEMPT; BEGIN ACCEPT DO_IT_NOW_OR_WAIT ( AUTHORIZED : IN BOOLEAN ) DO IF AUTHORIZED THEN COMMENT( "AUTHORIZED ENTRY_CALL" ); ELSE FAILED( "UNAUTHORIZED ENTRY_CALL" ); END IF; END DO_IT_NOW_OR_WAIT; END T; PACKAGE FIRST_ATTEMPT IS END FIRST_ATTEMPT; PACKAGE BODY FIRST_ATTEMPT IS START_TIME : TIME; BEGIN START_TIME := CLOCK; SELECT T.DO_IT_NOW_OR_WAIT (FALSE); OR -- THIS BRANCH MUST BE CHOSEN. DELAY WAIT_TIME; IF CLOCK >= (WAIT_TIME + START_TIME) THEN NULL; ELSE FAILED ( "INSUFFICIENT DELAY (#1)" ); END IF; OR_BRANCH_TAKEN := 1 + OR_BRANCH_TAKEN; COMMENT( "OR_BRANCH TAKEN (#1)" ); END SELECT; END FIRST_ATTEMPT; BEGIN T.DO_IT_NOW_OR_WAIT ( TRUE ); -- TO SATISFY THE SERVER'S -- WAIT FOR SUCH A CALL. EXCEPTION WHEN TASKING_ERROR => FAILED( "TASKING ERROR" ); END ; ------------------------------------------------------------------ -- BY NOW, THE TASK IS TERMINATED (AND THE NONLOCALS UPDATED). CASE OR_BRANCH_TAKEN IS WHEN 3 => FAILED( "NO 'OR'; BOTH (?) RENDEZVOUS ATTEMPTED?" ); WHEN 4 => FAILED( "'OR' #1 ONLY; RENDEZVOUS (#2) ATTEMPTED?" ); WHEN 6 => FAILED( "'OR' #2 ONLY; RENDEZVOUS (#1) ATTEMPTED?" ); WHEN 7 => FAILED( "WRONG ORDER FOR 'OR': #2,#1" ); WHEN 8 => NULL; WHEN OTHERS => FAILED( "WRONG CASE_VALUE" ); END CASE; RESULT; END C97301A;
-- { dg-do run } -- { dg-options "-O2" } procedure Derived_Aggregate is type Int is range 1 .. 10; type Str is array (Int range <>) of Character; type Parent (D1, D2 : Int; B : Boolean) is record S : Str (D1 .. D2); case B is when False => C1 : Integer; when True => C2 : Float; end case; end record; for Parent'Alignment use 8; type Derived (D : Int) is new Parent (D1 => D, D2 => D, B => False); function Ident (I : Integer) return integer is begin return I; end; Y : Derived := (D => 7, S => "b", C1 => Ident (32)); begin if Parent(Y).D1 /= 7 then raise Program_Error; end if; end;
-- Abstract : -- -- Parser for Wisi grammar files, producing Ada source -- files for a parser. -- -- Copyright (C) 2012 - 2015, 2017 - 2019 Free Software Foundation, Inc. -- -- The WisiToken package 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 MERCHANTABILITY or FITNESS FOR A -- PARTICULAR PURPOSE. -- -- As a special exception under Section 7 of GPL version 3, you are granted -- additional permissions described in the GCC Runtime Library Exception, -- version 3.1, as published by the Free Software Foundation. pragma License (Modified_GPL); with Ada.Command_Line; with Ada.Directories; with Ada.Exceptions; with Ada.Real_Time; with Ada.Strings.Fixed; with Ada.Strings.Maps; with Ada.Strings.Unbounded; with Ada.Text_IO; with GNAT.Traceback.Symbolic; with WisiToken.BNF.Generate_Utils; with WisiToken.BNF.Output_Ada; with WisiToken.BNF.Output_Ada_Common; with WisiToken.BNF.Output_Ada_Emacs; with WisiToken.BNF.Output_Elisp_Common; with WisiToken.Generate.LR.LALR_Generate; with WisiToken.Generate.LR.LR1_Generate; with WisiToken.Generate.Packrat; with WisiToken.Parse.LR.Parser_No_Recover; -- for reading BNF file with WisiToken.Productions; with WisiToken.Syntax_Trees; with WisiToken.Text_IO_Trace; with WisiToken_Grammar_Runtime; with Wisitoken_Grammar_Actions; with Wisitoken_Grammar_Main; procedure WisiToken.BNF.Generate is procedure Put_Usage is use Ada.Text_IO; First : Boolean := True; begin -- verbosity meaning is actually determined by output choice; -- they should be consistent with this description. Put_Line (Standard_Error, "version 1.3.0"); Put_Line (Standard_Error, "wisitoken-bnf-generate [options] {wisi grammar file}"); Put_Line (Standard_Error, "Generate source code implementing a parser for the grammar."); New_Line (Standard_Error); Put_Line (Standard_Error, "The following grammar file directives control parser generation:"); Put_Line (Standard_Error, "%generate <algorithm> <output language> [<lexer>] [<interface>] [text_rep]"); Put_Line (Standard_Error, " specify one of each generate parameter. May be repeated."); Put (Standard_Error, " algorithm: "); for I of Generate_Algorithm_Image loop if First then First := False; else Put (Standard_Error, " | "); end if; Put (Standard_Error, I.all); end loop; New_Line (Standard_Error); Put (Standard_Error, " output language: "); First := True; for I of Output_Language_Image loop if First then First := False; else Put (Standard_Error, " | "); end if; Put (Standard_Error, I.all); end loop; New_Line (Standard_Error); Put_Line (Standard_Error, " interface: interface Process | Module"); Put_Line (Standard_Error, " only valid with Ada_Emacs:"); Put_Line (Standard_Error, " Process is for an external subprocess communicating with Emacs."); Put_Line (Standard_Error, " Module is for a dynamically loaded Emacs module."); Put (Standard_Error, " lexer: "); First := True; for I of Output_Language_Image loop if First then First := False; else Put (Standard_Error, " | "); end if; Put (Standard_Error, I.all); end loop; New_Line (Standard_Error); Put_Line (Standard_Error, " text_rep: output LR parse table in a text file, not as source code; for large tables"); New_Line (Standard_Error); Put_Line (Standard_Error, "options:"); Put_Line (Standard_Error, " --help: show this help"); Put_Line (Standard_Error, " -v level: sets verbosity (default 0):"); Put_Line (Standard_Error, " 0 - only error messages to standard error"); Put_Line (Standard_Error, " 1 - add diagnostics to standard out"); Put_Line (Standard_Error, " 2 - more diagnostics to standard out, ignore unused tokens, unknown conflicts"); Put_Line (Standard_Error, " --generate ...: override grammar file %generate directive"); Put_Line (Standard_Error, " --output_bnf <file_name> : output translated BNF source to file_name"); Put_Line (Standard_Error, " --suffix <string>; appended to grammar file name"); Put_Line (Standard_Error, " --ignore_conflicts; ignore excess/unknown conflicts"); Put_Line (Standard_Error, " --test_main; generate standalone main program for running the generated parser, modify file names"); Put_Line (Standard_Error, " --time; output execution time of various stages"); end Put_Usage; Language_Name : Ada.Strings.Unbounded.Unbounded_String; -- The language the grammar defines Output_File_Name_Root : Ada.Strings.Unbounded.Unbounded_String; Suffix : Ada.Strings.Unbounded.Unbounded_String; BNF_File_Name : Ada.Strings.Unbounded.Unbounded_String; Output_BNF : Boolean := False; Ignore_Conflicts : Boolean := False; Test_Main : Boolean := False; Command_Generate_Set : Generate_Set_Access; -- override grammar file declarations Trace : aliased WisiToken.Text_IO_Trace.Trace (Wisitoken_Grammar_Actions.Descriptor'Access); Input_Data : aliased WisiToken_Grammar_Runtime.User_Data_Type; Grammar_Parser : WisiToken.Parse.LR.Parser_No_Recover.Parser; Do_Time : Boolean := False; procedure Use_Input_File (File_Name : in String) is use Ada.Strings.Unbounded; use Ada.Text_IO; begin Output_File_Name_Root := +Ada.Directories.Base_Name (File_Name) & Suffix; Wisitoken_Grammar_Main.Create_Parser (Parser => Grammar_Parser, Trace => Trace'Unchecked_Access, User_Data => Input_Data'Unchecked_Access); Grammar_Parser.Lexer.Reset_With_File (File_Name); declare Language_Name_Dir : constant Integer := Ada.Strings.Fixed.Index (File_Name, Ada.Strings.Maps.To_Set ("/\"), Going => Ada.Strings.Backward); Language_Name_Ext : constant Integer := Ada.Strings.Fixed.Index (File_Name, ".wy"); begin Language_Name := +WisiToken.BNF.Output_Elisp_Common.Elisp_Name_To_Ada (File_Name ((if Language_Name_Dir = 0 then File_Name'First else Language_Name_Dir + 1) .. Language_Name_Ext - 1), Append_ID => False, Trim => 0); end; exception when Name_Error | Use_Error => raise Name_Error with "input file '" & File_Name & "' could not be opened."; end Use_Input_File; begin declare use Ada.Command_Line; Arg_Next : Integer := 1; begin loop exit when Argument (Arg_Next)(1) /= '-'; -- --help, -v first, then alphabetical if Argument (Arg_Next) = "--help" then Put_Usage; return; elsif Argument (Arg_Next) = "-v" then Arg_Next := Arg_Next + 1; WisiToken.Trace_Generate := Integer'Value (Argument (Arg_Next)); Arg_Next := Arg_Next + 1; elsif Argument (Arg_Next) = "--ignore_conflicts" then Ignore_Conflicts := True; Arg_Next := Arg_Next + 1; elsif Argument (Arg_Next) = "--generate" then Arg_Next := Arg_Next + 1; declare Tuple : Generate_Tuple; Done : Boolean := False; begin begin Tuple.Gen_Alg := Generate_Algorithm'Value (Argument (Arg_Next)); Arg_Next := Arg_Next + 1; exception when Constraint_Error => raise User_Error with "invalid value for generator_algorithm: '" & Argument (Arg_Next) & ";"; end; if Tuple.Gen_Alg /= None then begin Tuple.Out_Lang := To_Output_Language (Argument (Arg_Next)); Arg_Next := Arg_Next + 1; end; loop exit when Done; declare Text : constant String := Argument (Arg_Next); begin if Text = "text_rep" then Tuple.Text_Rep := True; Arg_Next := Arg_Next + 1; elsif (for some I of Lexer_Image => To_Lower (Text) = I.all) then Tuple.Lexer := To_Lexer (Text); Arg_Next := Arg_Next + 1; elsif (for some I in Valid_Interface => To_Lower (Text) = To_Lower (Valid_Interface'Image (I))) then Tuple.Interface_Kind := WisiToken.BNF.Valid_Interface'Value (Text); Arg_Next := Arg_Next + 1; else Done := True; end if; end; end loop; end if; Add (Command_Generate_Set, Tuple); end; elsif Argument (Arg_Next) = "--output_bnf" then Output_BNF := True; Arg_Next := Arg_Next + 1; BNF_File_Name := +Argument (Arg_Next); Arg_Next := Arg_Next + 1; elsif Argument (Arg_Next) = "--suffix" then Arg_Next := Arg_Next + 1; Suffix := +Argument (Arg_Next); Arg_Next := Arg_Next + 1; elsif Argument (Arg_Next) = "--test_main" then Arg_Next := Arg_Next + 1; Test_Main := True; elsif Argument (Arg_Next) = "--time" then Arg_Next := Arg_Next + 1; Do_Time := True; else raise User_Error with "invalid argument '" & Argument (Arg_Next) & "'"; end if; end loop; Use_Input_File (Argument (Arg_Next)); if Arg_Next /= Argument_Count then raise User_Error with "arg count" & Integer'Image (Argument_Count) & " different from expected count" & Integer'Image (Arg_Next); end if; end; begin Grammar_Parser.Parse; exception when WisiToken.Syntax_Error => Grammar_Parser.Put_Errors; raise; when E : WisiToken.Parse_Error => WisiToken.Generate.Put_Error (Ada.Exceptions.Exception_Message (E)); raise; end; declare use all type Ada.Strings.Unbounded.Unbounded_String; use Ada.Text_IO; -- Create a .parse_table file unless verbosity > 0 Parse_Table_File : File_Type; Generate_Set : Generate_Set_Access; Multiple_Tuples : Boolean; Lexer_Done : Lexer_Set := (others => False); -- In general, all of the data in Generate_Utils.Generate_Data -- depends on the generate tuple parameters. However, if -- 'If_Lexer_Present' is false, then they don't depend on the lexer, -- and if 'If_Parser_Present' is false, then they don't depend on the -- Gen_Alg, except for the parser table. But it's not worth trying to -- cache results in those cases; they only happen in test grammars, -- which are small. procedure Parse_Check (Lexer : in Lexer_Type; Parser : in Generate_Algorithm; Phase : in WisiToken_Grammar_Runtime.Action_Phase) is use all type Ada.Containers.Count_Type; use all type WisiToken_Grammar_Runtime.Action_Phase; use all type WisiToken_Grammar_Runtime.Meta_Syntax; begin Input_Data.User_Parser := Parser; Input_Data.User_Lexer := Lexer; -- Specifying the parser and lexer can change the parsed grammar, due -- to %if {parser | lexer}. Input_Data.Reset; -- only resets Other data Input_Data.Phase := Phase; Grammar_Parser.Execute_Actions; case Phase is when Meta => case Input_Data.Meta_Syntax is when Unknown => Input_Data.Meta_Syntax := BNF_Syntax; when BNF_Syntax => null; when EBNF_Syntax => declare Tree : WisiToken.Syntax_Trees.Tree renames Grammar_Parser.Parsers.First_State_Ref.Tree; begin if Trace_Generate > Outline then Ada.Text_IO.Put_Line ("Translate EBNF tree to BNF"); end if; if Trace_Generate > Detail then Ada.Text_IO.Put_Line ("EBNF tree:"); Tree.Print_Tree (Wisitoken_Grammar_Actions.Descriptor); Ada.Text_IO.New_Line; end if; WisiToken_Grammar_Runtime.Translate_EBNF_To_BNF (Tree, Input_Data); if Trace_Generate > Detail then Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line ("BNF tree:"); Tree.Print_Tree (Wisitoken_Grammar_Actions.Descriptor); end if; if Output_BNF then WisiToken_Grammar_Runtime.Print_Source (-BNF_File_Name, Tree, Input_Data); end if; if WisiToken.Generate.Error then raise WisiToken.Grammar_Error with "errors during translating EBNF to BNF: aborting"; end if; end; end case; when Other => if Input_Data.Rule_Count = 0 or Input_Data.Tokens.Rules.Length = 0 then raise WisiToken.Grammar_Error with "no rules"; end if; end case; exception when E : WisiToken.Syntax_Error | WisiToken.Parse_Error => Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, Ada.Exceptions.Exception_Message (E)); Grammar_Parser.Put_Errors; raise; end Parse_Check; begin -- Get the the input file quads, translate EBNF Parse_Check (None, None, WisiToken_Grammar_Runtime.Meta); if Command_Generate_Set = null then if Input_Data.Generate_Set = null then raise User_Error with WisiToken.Generate.Error_Message (Input_Data.Grammar_Lexer.File_Name, 1, "generate algorithm, output_language, lexer, interface not specified"); end if; Generate_Set := Input_Data.Generate_Set; else Generate_Set := Command_Generate_Set; end if; Multiple_Tuples := Generate_Set'Length > 1; for Tuple of Generate_Set.all loop Parse_Check (Lexer => Tuple.Lexer, Parser => Tuple.Gen_Alg, Phase => WisiToken_Grammar_Runtime.Other); declare use Ada.Real_Time; Time_Start : Time; Time_End : Time; Generate_Data : aliased WisiToken.BNF.Generate_Utils.Generate_Data := WisiToken.BNF.Generate_Utils.Initialize (Input_Data, Ignore_Conflicts); Packrat_Data : WisiToken.Generate.Packrat.Data (Generate_Data.Descriptor.First_Terminal, Generate_Data.Descriptor.First_Nonterminal, Generate_Data.Descriptor.Last_Nonterminal); Do_Parse_Table_File : constant Boolean := WisiToken.Trace_Generate = 0 and Tuple.Gen_Alg in LALR .. Packrat_Proc; begin if not Lexer_Done (Input_Data.User_Lexer) then Lexer_Done (Input_Data.User_Lexer) := True; case Input_Data.User_Lexer is when re2c_Lexer => WisiToken.BNF.Output_Ada_Common.Create_re2c (Input_Data, Tuple, Generate_Data, -Output_File_Name_Root); when others => null; end case; end if; if Do_Parse_Table_File then Create (Parse_Table_File, Out_File, -Output_File_Name_Root & "_" & To_Lower (Generate_Algorithm'Image (Tuple.Gen_Alg)) & (if Input_Data.If_Lexer_Present then "_" & Lexer_Image (Input_Data.User_Lexer).all else "") & ".parse_table"); Set_Output (Parse_Table_File); end if; case Tuple.Gen_Alg is when None => -- Just translate EBNF to BNF, done in Parse_Check null; when LALR => Time_Start := Clock; Generate_Data.LR_Parse_Table := WisiToken.Generate.LR.LALR_Generate.Generate (Generate_Data.Grammar, Generate_Data.Descriptor.all, Generate_Utils.To_Conflicts (Generate_Data, Input_Data.Conflicts, Input_Data.Grammar_Lexer.File_Name), Generate_Utils.To_McKenzie_Param (Generate_Data, Input_Data.McKenzie_Recover), Put_Parse_Table => True, Include_Extra => Test_Main, Ignore_Conflicts => Ignore_Conflicts, Partial_Recursion => Input_Data.Language_Params.Partial_Recursion); if Do_Time then Time_End := Clock; Put_Line (Standard_Error, "LALR " & Lexer_Image (Tuple.Lexer).all & " generate time:" & Duration'Image (To_Duration (Time_End - Time_Start))); end if; Generate_Data.Parser_State_Count := Generate_Data.LR_Parse_Table.State_Last - Generate_Data.LR_Parse_Table.State_First + 1; WisiToken.BNF.Generate_Utils.Put_Stats (Input_Data, Generate_Data); when LR1 => Time_Start := Clock; Generate_Data.LR_Parse_Table := WisiToken.Generate.LR.LR1_Generate.Generate (Generate_Data.Grammar, Generate_Data.Descriptor.all, Generate_Utils.To_Conflicts (Generate_Data, Input_Data.Conflicts, Input_Data.Grammar_Lexer.File_Name), Generate_Utils.To_McKenzie_Param (Generate_Data, Input_Data.McKenzie_Recover), Put_Parse_Table => True, Include_Extra => Test_Main, Ignore_Conflicts => Ignore_Conflicts, Partial_Recursion => Input_Data.Language_Params.Partial_Recursion); if Do_Time then Time_End := Clock; Put_Line (Standard_Error, "LR1 " & Lexer_Image (Tuple.Lexer).all & " generate time:" & Duration'Image (To_Duration (Time_End - Time_Start))); end if; Generate_Data.Parser_State_Count := Generate_Data.LR_Parse_Table.State_Last - Generate_Data.LR_Parse_Table.State_First + 1; WisiToken.BNF.Generate_Utils.Put_Stats (Input_Data, Generate_Data); when Packrat_Generate_Algorithm => -- The only significant computation done for Packrat is First, done -- in Initialize; not worth timing. Packrat_Data := WisiToken.Generate.Packrat.Initialize (Input_Data.Grammar_Lexer.File_Name, Generate_Data.Grammar, Generate_Data.Source_Line_Map, Generate_Data.Descriptor.First_Terminal); Put_Line ("Tokens:"); WisiToken.Put_Tokens (Generate_Data.Descriptor.all); New_Line; Put_Line ("Productions:"); WisiToken.Productions.Put (Generate_Data.Grammar, Generate_Data.Descriptor.all); Packrat_Data.Check_All (Generate_Data.Descriptor.all); when External => null; end case; if Do_Parse_Table_File then Set_Output (Standard_Output); Close (Parse_Table_File); end if; if WisiToken.Generate.Error then raise WisiToken.Grammar_Error with "errors: aborting"; end if; case Tuple.Gen_Alg is when LR_Generate_Algorithm => if Tuple.Text_Rep then WisiToken.Generate.LR.Put_Text_Rep (Generate_Data.LR_Parse_Table.all, -Output_File_Name_Root & "_" & To_Lower (Generate_Algorithm_Image (Tuple.Gen_Alg).all) & "_parse_table.txt", Generate_Data.Action_Names.all, Generate_Data.Check_Names.all); end if; when others => null; end case; if Tuple.Gen_Alg /= None then case Tuple.Out_Lang is when Ada_Lang => WisiToken.BNF.Output_Ada (Input_Data, -Output_File_Name_Root, Generate_Data, Packrat_Data, Tuple, Test_Main, Multiple_Tuples); when Ada_Emacs_Lang => WisiToken.BNF.Output_Ada_Emacs (Input_Data, -Output_File_Name_Root, Generate_Data, Packrat_Data, Tuple, Test_Main, Multiple_Tuples, -Language_Name); end case; if WisiToken.Generate.Error then raise WisiToken.Grammar_Error with "errors: aborting"; end if; end if; end; end loop; end; exception when WisiToken.Syntax_Error | WisiToken.Parse_Error => -- error message already output Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when E : User_Error => declare use Ada.Command_Line; use Ada.Exceptions; use Ada.Text_IO; begin Put_Line (Standard_Error, Exception_Message (E)); Put_Command_Line (Ada_Comment); Set_Exit_Status (Failure); Put_Usage; end; when E : WisiToken.Grammar_Error => -- error message not already output declare use Ada.Command_Line; use Ada.Exceptions; use Ada.Text_IO; begin Put_Line (Standard_Error, Exception_Message (E)); Set_Exit_Status (Failure); end; when E : others => -- IMPROVEME: for some exceptions, Error message already output via wisi.utils.Put_Error declare use Ada.Text_IO; use Ada.Exceptions; use Ada.Command_Line; begin Put_Line (Standard_Error, Exception_Name (E) & ": " & Exception_Message (E)); Put_Line (Standard_Error, GNAT.Traceback.Symbolic.Symbolic_Traceback (E)); Set_Exit_Status (Failure); end; end WisiToken.BNF.Generate;
with Ada.Text_IO; use Ada.Text_IO; procedure Greet_5b is I : Integer := 1; -- Variable declaration -- ^ Type -- ^ Initial value begin loop Put_Line ("Hello, World!" & Integer'Image (I)); exit when I = 5; -- Exit statement -- ^ Boolean condition -- Assignment I := I + 1; -- There is no i++ short form to increment a variable end loop; end Greet_5b;
with Ada.Text_IO; with GNATCOLL.JSON; procedure JSON_Test is use Ada.Text_IO; use GNATCOLL.JSON; JSON_String : constant String := "{""name"":""Pingu"",""born"":1986}"; Penguin : JSON_Value := Create_Object; Parents : JSON_Array; begin Penguin.Set_Field (Field_Name => "name", Field => "Linux"); Penguin.Set_Field (Field_Name => "born", Field => 1992); Append (Parents, Create ("Linus Torvalds")); Append (Parents, Create ("Alan Cox")); Append (Parents, Create ("Greg Kroah-Hartman")); Penguin.Set_Field (Field_Name => "parents", Field => Parents); Put_Line (Penguin.Write); Penguin := Read (JSON_String, "json.errors"); Penguin.Set_Field (Field_Name => "born", Field => 1986); Parents := Empty_Array; Append (Parents, Create ("Otmar Gutmann")); Append (Parents, Create ("Silvio Mazzola")); Penguin.Set_Field (Field_Name => "parents", Field => Parents); Put_Line (Penguin.Write); end JSON_Test;
with Pointer_Discr1_Pkg2; package Pointer_Discr1_Pkg1 is type Arr is array (1..4) of Pointer_Discr1_Pkg2.T_WINDOW; Window : Arr; end Pointer_Discr1_Pkg1;
pragma License (Unrestricted); with Ada.Characters.Handling; package GNAT.Case_Util is pragma Preelaborate; -- Ada.Characters.Handling is not pure. function To_Lower (A : Character) return Character renames Ada.Characters.Handling.To_Lower; procedure To_Lower (A : in out String); end GNAT.Case_Util;
package Array26_Pkg is subtype Outer_Type is String (1 .. 4); subtype Inner_Type is String (1 .. 3); function F return Inner_Type; end Array26_Pkg;
----------------------------------------------------------------------- -- tool-main -- Main tool program -- Copyright (C) 2018 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Command_Line; with Util.Log.Loggers; with Tool.Data; procedure Tool.Main is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Tool.Main"); begin Util.Log.Loggers.Initialize ("tool.properties"); for I in 1 .. Ada.Command_Line.Argument_Count loop Tool.Data.Read (Ada.Command_Line.Argument (I)); end loop; Tool.Data.Save ("result.dat", "sqlite,mysql,postgresql", "Ada,Python,Java"); Tool.Data.Save_Memory ("memory.dat", "Ada,Python,Java"); Tool.Data.Save_Excel ("result.xls"); exception when E : others => Log.Error (Message => "Internal error:", E => E, Trace => True); end Tool.Main;
pragma License (Unrestricted); -- extended unit with Ada.Environment_Encoding.Generic_Strings; package Ada.Environment_Encoding.Wide_Strings is new Generic_Strings ( Wide_Character, Wide_String); -- Encoding / decoding between Wide_String and various encodings. pragma Preelaborate (Ada.Environment_Encoding.Wide_Strings);
----------------------------------------------------------------------- -- asf-converters-sizes -- Size converter -- Copyright (C) 2012 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Exceptions; with Ada.Strings.Unbounded; with Util.Locales; with Util.Strings; with Util.Properties.Bundles; with ASF.Locales; with ASF.Utils; with ASF.Applications.Main; package body ASF.Converters.Sizes is ONE_KB : constant Long_Long_Integer := 1_024; ONE_MB : constant Long_Long_Integer := ONE_KB * 1_024; ONE_GB : constant Long_Long_Integer := ONE_MB * 1_024; UNIT_GB : aliased constant String := "size_giga_bytes"; UNIT_MB : aliased constant String := "size_mega_bytes"; UNIT_KB : aliased constant String := "size_kilo_bytes"; UNIT_B : aliased constant String := "size_bytes"; -- ------------------------------ -- 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 Size_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); Bundle : ASF.Locales.Bundle; Locale : constant Util.Locales.Locale := Context.Get_Locale; begin begin ASF.Applications.Main.Load_Bundle (Context.Get_Application.all, Name => "sizes", Locale => Util.Locales.To_String (Locale), Bundle => Bundle); exception when E : Util.Properties.Bundles.NO_BUNDLE => Component.Log_Error ("Cannot localize sizes: {0}", Ada.Exceptions.Exception_Message (E)); end; -- Convert the value as an integer here so that we can raise -- the Invalid_Conversion exception. declare Size : constant Long_Long_Integer := Util.Beans.Objects.To_Long_Long_Integer (Value); Val : Integer; Values : ASF.Utils.Object_Array (1 .. 1); Result : Ada.Strings.Unbounded.Unbounded_String; Unit : Util.Strings.Name_Access; begin if Size >= ONE_GB then Val := Integer ((Size + ONE_GB / 2) / ONE_GB); Unit := UNIT_GB'Access; elsif Size >= ONE_MB then Val := Integer ((Size + ONE_MB / 2) / ONE_MB); Unit := UNIT_MB'Access; elsif Size >= ONE_KB then Val := Integer ((Size + ONE_KB / 2) / ONE_KB); Unit := UNIT_KB'Access; else Val := Integer (Size); Unit := UNIT_B'Access; end if; Values (1) := Util.Beans.Objects.To_Object (Val); ASF.Utils.Formats.Format (Bundle.Get (Unit.all), Values, Result); return Ada.Strings.Unbounded.To_String (Result); end; exception when E : others => raise ASF.Converters.Invalid_Conversion with Ada.Exceptions.Exception_Message (E); end To_String; -- ------------------------------ -- Convert the date 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 Size_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, Value); begin Component.Log_Error ("Conversion of string to a size is not implemented"); raise ASF.Converters.Invalid_Conversion with "Not implemented"; return Util.Beans.Objects.Null_Object; end To_Object; end ASF.Converters.Sizes;
with AVTAS.LMCP.Types; use AVTAS.LMCP.Types; package String_Utils is function To_String (Input : Int32) return String; function To_String (Input : Int64) return String; function To_String (Input : UInt32) return String; end String_Utils;
package Subtypes is subtype small is Integer range -10 .. 10; end Subtypes;
with Ada.Text_IO; package body AOC.AOC_2019.Day01 is function Create return Day.Access_Day is begin return new Day_01' (others => <>); end Create; procedure Init (D : in out Day_01; Root : String) is use Ada.Text_IO; File : File_Type; begin Open (File => File, Mode => In_File, Name => Root & "/input/2019/day01.txt"); while not End_Of_File (File) loop declare Current_Mass : Mass := Mass (Integer'Value (Get_Line (File))); begin D.Total_Fuel := D.Total_Fuel + Calc_Fuel (Current_Mass); D.Abhorrent_Total_Fuel := D.Abhorrent_Total_Fuel + Calc_Abhorrent_Fuel (Current_Mass); end; end loop; Close (File); end Init; function Part_1 (D : Day_01) return String is begin return D.Total_Fuel'Image; end Part_1; function Part_2 (D : Day_01) return String is begin return D.Abhorrent_Total_Fuel'Image; end Part_2; function Calc_Fuel (M : Mass) return Fuel is Result : Integer; begin Result := Integer (M) / 3 - 2; return Fuel (if Result < 0 then 0 else Result); end Calc_Fuel; function Calc_Abhorrent_Fuel (M : Mass) return Fuel is Abhorrent_Current_Fuel : Fuel := Calc_Fuel (M); Abhorrent_Total_Fuel : Fuel := 0; begin while Abhorrent_Current_Fuel > 0 loop Abhorrent_Total_Fuel := Abhorrent_Total_Fuel + Abhorrent_Current_Fuel; Abhorrent_Current_Fuel := Calc_Fuel (Abhorrent_Current_Fuel); end loop; return Abhorrent_Total_Fuel; end Calc_Abhorrent_Fuel; end AOC.AOC_2019.Day01;
------------------------------------------------------------------------------ -- Copyright (c) 2015, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- NOTE: the current implementation might be considered ugly for -- -- duplicating the detection of path, query and fragment. The reason it is -- -- left that way is that these part are conceptually independent, and there -- -- no constraint of having the same allowed character group. More -- -- pragmatically that means that while they are currently identical, it -- -- might not stay that way (e.g. restricting the allowed character set in -- -- the fragment identifier, checking query syntax, etc. -- ------------------------------------------------------------------------------ function Natools.Web.Is_Valid_URL (Data : String) return Boolean is subtype Hex is Character with Static_Predicate => Hex in '0' .. '9' | 'a' .. 'f' | 'A' .. 'F'; subtype Unreserved is Character with Static_Predicate => Unreserved in 'a' .. 'z' | 'A' .. 'Z' -- alpha | '0' .. '9' -- digit | '$' | '-' | '_' | '.' | '+' -- safe | '!' | '*' | ''' | '(' | ')' | ',' -- extra | ';' | ':' | '@' | '&' | '='; -- HTTP specials Index : Natural := Data'First; begin -- Check optional HTTP or HTTPS scheme if Index + 6 in Data'Range and then Data (Index) in 'h' | 'H' and then Data (Index + 1) in 't' | 'T' and then Data (Index + 2) in 't' | 'T' and then Data (Index + 3) in 'p' | 'P' then if Data (Index + 4) = ':' then Index := Index + 5; elsif Data (Index + 4) in 's' | 'S' and then Data (Index + 5) = ':' then Index := Index + 6; end if; end if; -- Hierarchical part must start with an authority if Index + 2 not in Data'Range or else Data (Index) /= '/' or else Data (Index + 1) /= '/' then return False; end if; Index := Index + 2; -- Currently specifying user name and password is not support -- and leads to URL rejection. -- This is a laxist check on hostname validity Check_Hostname : while Index in Data'Range and then Data (Index) in 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '-' | '.' loop Index := Index + 1; end loop Check_Hostname; if Index not in Data'Range then return True; end if; -- Check the optinal port number if Data (Index) = ':' and then Index + 1 in Data'Range and then Data (Index + 1) in '0' .. '9' then Index := Index + 2; while Index in Data'Range and then Data (Index) in '0' .. '9' loop Index := Index + 1; end loop; if Index not in Data'Range then return True; end if; end if; -- Check the path part if Data (Index) /= '/' then return False; end if; Check_Path : loop Index := Index + 1; if Index not in Data'Range then return True; end if; if Data (Index) = '%' then if not (Index + 2 in Data'Range and then Data (Index + 1) in Hex and then Data (Index + 2) in Hex) then return False; end if; elsif Data (Index) not in Unreserved and then Data (Index) /= '/' then exit Check_Path; end if; end loop Check_Path; -- Check the query part if Data (Index) = '?' then Check_Query : loop Index := Index + 1; if Index not in Data'Range then return True; end if; if Data (Index) = '%' then if not (Index + 2 in Data'Range and then Data (Index + 1) in Hex and then Data (Index + 2) in Hex) then return False; end if; elsif Data (Index) not in Unreserved then exit Check_Query; end if; end loop Check_Query; end if; -- Check the anchor part if Data (Index) = '#' then Check_Fragment : loop Index := Index + 1; if Index not in Data'Range then return True; end if; if Data (Index) = '%' then if not (Index + 2 in Data'Range and then Data (Index + 1) in Hex and then Data (Index + 2) in Hex) then return False; end if; elsif Data (Index) not in Unreserved then exit Check_Fragment; end if; end loop Check_Fragment; end if; return False; end Natools.Web.Is_Valid_URL;
-- generated parser support file. -- command line: wisitoken-bnf-generate.exe --generate LR1 Ada_Emacs re2c PROCESS gpr.wy -- -- Copyright (C) 2013 - 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, or (at -- your option) any later version. -- -- This software 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>. with WisiToken.Syntax_Trees; with WisiToken.Lexer; with WisiToken.Semantic_Checks; package Gpr_Process_Actions is Descriptor : aliased WisiToken.Descriptor := (First_Terminal => 3, Last_Terminal => 39, First_Nonterminal => 40, Last_Nonterminal => 73, EOI_ID => 39, Accept_ID => 40, Case_Insensitive => True, New_Line_ID => 1, String_1_ID => 2147483647, String_2_ID => 38, Image => (new String'("WHITESPACE"), new String'("NEW_LINE"), new String'("COMMENT"), new String'("ABSTRACT"), new String'("AT"), new String'("AGGREGATE"), new String'("CASE"), new String'("CONFIGURATION"), new String'("END"), new String'("EXTENDS"), new String'("EXTERNAL"), new String'("EXTERNAL_AS_LIST"), new String'("FOR"), new String'("IS"), new String'("LEFT_PAREN"), new String'("LIBRARY"), new String'("NULL"), new String'("OTHERS"), new String'("PACKAGE"), new String'("PROJECT"), new String'("RENAMES"), new String'("RIGHT_PAREN"), new String'("STANDARD"), new String'("TYPE"), new String'("USE"), new String'("WHEN"), new String'("WITH"), new String'("AMPERSAND"), new String'("COLON"), new String'("COLON_EQUALS"), new String'("COMMA"), new String'("DOT"), new String'("EQUAL_GREATER"), new String'("QUOTE"), new String'("SEMICOLON"), new String'("VERTICAL_BAR"), new String'("NUMERIC_LITERAL"), new String'("IDENTIFIER"), new String'("STRING_LITERAL"), new String'("Wisi_EOI"), new String'("wisitoken_accept"), new String'("aggregate_g"), new String'("attribute_declaration"), new String'("attribute_prefix"), new String'("attribute_reference"), new String'("case_statement"), new String'("case_item"), new String'("case_items"), new String'("compilation_unit"), new String'("context_clause"), new String'("context_clause_opt"), new String'("declarative_item"), new String'("declarative_items"), new String'("declarative_items_opt"), new String'("discrete_choice"), new String'("discrete_choice_list"), new String'("expression"), new String'("external_value"), new String'("identifier_opt"), new String'("name"), new String'("package_declaration"), new String'("package_spec"), new String'("package_extension"), new String'("package_renaming"), new String'("project_declaration_opt"), new String'("project_extension"), new String'("project_qualifier_opt"), new String'("simple_declarative_item"), new String'("simple_project_declaration"), new String'("string_primary"), new String'("string_list"), new String'("term"), new String'("typed_string_declaration"), new String'("with_clause")), Terminal_Image_Width => 16, Image_Width => 26, Last_Lookahead => 39); type Token_Enum_ID is (WHITESPACE_ID, NEW_LINE_ID, COMMENT_ID, ABSTRACT_ID, AT_ID, AGGREGATE_ID, CASE_ID, CONFIGURATION_ID, END_ID, EXTENDS_ID, EXTERNAL_ID, EXTERNAL_AS_LIST_ID, FOR_ID, IS_ID, LEFT_PAREN_ID, LIBRARY_ID, NULL_ID, OTHERS_ID, PACKAGE_ID, PROJECT_ID, RENAMES_ID, RIGHT_PAREN_ID, STANDARD_ID, TYPE_ID, USE_ID, WHEN_ID, WITH_ID, AMPERSAND_ID, COLON_ID, COLON_EQUALS_ID, COMMA_ID, DOT_ID, EQUAL_GREATER_ID, QUOTE_ID, SEMICOLON_ID, VERTICAL_BAR_ID, NUMERIC_LITERAL_ID, IDENTIFIER_ID, STRING_LITERAL_ID, Wisi_EOI_ID, wisitoken_accept_ID, aggregate_g_ID, attribute_declaration_ID, attribute_prefix_ID, attribute_reference_ID, case_statement_ID, case_item_ID, case_items_ID, compilation_unit_ID, context_clause_ID, context_clause_opt_ID, declarative_item_ID, declarative_items_ID, declarative_items_opt_ID, discrete_choice_ID, discrete_choice_list_ID, expression_ID, external_value_ID, identifier_opt_ID, name_ID, package_declaration_ID, package_spec_ID, package_extension_ID, package_renaming_ID, project_declaration_opt_ID, project_extension_ID, project_qualifier_opt_ID, simple_declarative_item_ID, simple_project_declaration_ID, string_primary_ID, string_list_ID, term_ID, typed_string_declaration_ID, with_clause_ID); type Token_Enum_ID_Array is array (Positive range <>) of Token_Enum_ID; use all type WisiToken.Token_ID; function "+" (Item : in Token_Enum_ID) return WisiToken.Token_ID is (WisiToken.Token_ID'First + Token_Enum_ID'Pos (Item)); function To_Token_Enum (Item : in WisiToken.Token_ID) return Token_Enum_ID is (Token_Enum_ID'Val (Item - WisiToken.Token_ID'First)); function "-" (Item : in WisiToken.Token_ID) return Token_Enum_ID renames To_Token_Enum; procedure aggregate_g_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Valid_Node_Index; Tokens : in WisiToken.Valid_Node_Index_Array); procedure attribute_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Valid_Node_Index; Tokens : in WisiToken.Valid_Node_Index_Array); procedure attribute_declaration_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Valid_Node_Index; Tokens : in WisiToken.Valid_Node_Index_Array); procedure attribute_declaration_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Valid_Node_Index; Tokens : in WisiToken.Valid_Node_Index_Array); procedure attribute_declaration_3 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Valid_Node_Index; Tokens : in WisiToken.Valid_Node_Index_Array); procedure case_statement_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Valid_Node_Index; Tokens : in WisiToken.Valid_Node_Index_Array); procedure case_item_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Valid_Node_Index; Tokens : in WisiToken.Valid_Node_Index_Array); procedure compilation_unit_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Valid_Node_Index; Tokens : in WisiToken.Valid_Node_Index_Array); procedure package_spec_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Valid_Node_Index; Tokens : in WisiToken.Valid_Node_Index_Array); procedure package_extension_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Valid_Node_Index; Tokens : in WisiToken.Valid_Node_Index_Array); procedure package_renaming_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Valid_Node_Index; Tokens : in WisiToken.Valid_Node_Index_Array); procedure project_extension_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Valid_Node_Index; Tokens : in WisiToken.Valid_Node_Index_Array); procedure simple_declarative_item_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Valid_Node_Index; Tokens : in WisiToken.Valid_Node_Index_Array); procedure simple_declarative_item_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Valid_Node_Index; Tokens : in WisiToken.Valid_Node_Index_Array); procedure simple_declarative_item_4 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Valid_Node_Index; Tokens : in WisiToken.Valid_Node_Index_Array); procedure simple_project_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Valid_Node_Index; Tokens : in WisiToken.Valid_Node_Index_Array); procedure typed_string_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Valid_Node_Index; Tokens : in WisiToken.Valid_Node_Index_Array); function identifier_opt_1_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function package_spec_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function package_extension_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function project_extension_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function simple_project_declaration_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; Partial_Parse_Active : Boolean := False; end Gpr_Process_Actions;
----------------------------------------------------------------------- -- nodes-facelets -- Facelets composition nodes -- Copyright (C) 2009, 2010, 2011, 2012, 2013 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- -- The <b>ASF.Views.Nodes.Facelets</b> package defines some pre-defined -- tags for composing a view. -- -- xmlns:ui="http://java.sun.com/jsf/facelets" -- -- The following Facelets core elements are defined: -- <ui:include src="..."/> -- <ui:decorate view="..."/> -- <ui:define name="..."/> -- <ui:insert name="..."/> -- <ui:param name="..." value="..."/> -- <ui:composition .../> -- with Ada.Strings.Hash; with ASF.Factory; with Ada.Containers.Indefinite_Hashed_Maps; package ASF.Views.Nodes.Facelets is -- Tag factory for nodes defined in this package. function Definition return ASF.Factory.Factory_Bindings_Access; -- ------------------------------ -- Include Tag -- ------------------------------ -- The <ui:include src="..."/> type Include_Tag_Node is new Tag_Node with private; type Include_Tag_Node_Access is access all Include_Tag_Node'Class; -- Create the Include Tag function Create_Include_Tag_Node (Binding : in Binding_Access; Line : in Line_Info; Parent : in Tag_Node_Access; Attributes : in Tag_Attribute_Array_Access) return Tag_Node_Access; -- Build the component tree from the tag node and attach it as -- the last child of the given parent. Calls recursively the -- method to create children. overriding procedure Build_Components (Node : access Include_Tag_Node; Parent : in UIComponent_Access; Context : in out Facelet_Context'Class); -- ------------------------------ -- Composition Tag -- ------------------------------ -- The <ui:composition template="..."/> type Composition_Tag_Node is new Tag_Node with private; type Composition_Tag_Node_Access is access all Composition_Tag_Node'Class; -- Create the Composition Tag function Create_Composition_Tag_Node (Binding : in Binding_Access; Line : in Line_Info; Parent : in Tag_Node_Access; Attributes : in Tag_Attribute_Array_Access) return Tag_Node_Access; -- Build the component tree from the tag node and attach it as -- the last child of the given parent. Calls recursively the -- method to create children. overriding procedure Build_Components (Node : access Composition_Tag_Node; Parent : in UIComponent_Access; Context : in out Facelet_Context'Class); -- Freeze the tag node tree and perform any initialization steps -- necessary to build the components efficiently. After this call -- the tag node tree should not be modified and it represents a read-only -- tree. overriding procedure Freeze (Node : access Composition_Tag_Node); -- Include in the component tree the definition identified by the name. -- Upon completion, return in <b>Found</b> whether the definition was found -- within this composition context. procedure Include_Definition (Node : access Composition_Tag_Node; Parent : in UIComponent_Access; Context : in out Facelet_Context'Class; Name : in Unbounded_String; Found : out Boolean); -- ------------------------------ -- Debug Tag -- ------------------------------ -- The <ui:debug/> type Debug_Tag_Node is new Tag_Node with private; type Debug_Tag_Node_Access is access all Debug_Tag_Node'Class; -- Create the Debug Tag function Create_Debug_Tag_Node (Binding : in Binding_Access; Line : in Line_Info; Parent : in Tag_Node_Access; Attributes : in Tag_Attribute_Array_Access) return Tag_Node_Access; -- Build the component tree from the tag node and attach it as -- the last child of the given parent. Calls recursively the -- method to create children. overriding procedure Build_Components (Node : access Debug_Tag_Node; Parent : in UIComponent_Access; Context : in out Facelet_Context'Class); -- ------------------------------ -- Decorate Tag -- ------------------------------ -- The <ui:decorate template="...">...</ui:decorate> type Decorate_Tag_Node is new Composition_Tag_Node with private; type Decorate_Tag_Node_Access is access all Decorate_Tag_Node'Class; -- Create the Decorate Tag function Create_Decorate_Tag_Node (Binding : in Binding_Access; Line : in Line_Info; Parent : in Tag_Node_Access; Attributes : in Tag_Attribute_Array_Access) return Tag_Node_Access; -- ------------------------------ -- Define Tag -- ------------------------------ -- The <ui:define name="...">...</ui:define> type Define_Tag_Node is new Tag_Node with private; type Define_Tag_Node_Access is access all Define_Tag_Node'Class; -- Create the Define Tag function Create_Define_Tag_Node (Binding : in Binding_Access; Line : in Line_Info; Parent : in Tag_Node_Access; Attributes : in Tag_Attribute_Array_Access) return Tag_Node_Access; -- Build the component tree from the tag node and attach it as -- the last child of the given parent. Calls recursively the -- method to create children. overriding procedure Build_Components (Node : access Define_Tag_Node; Parent : in UIComponent_Access; Context : in out Facelet_Context'Class); -- ------------------------------ -- Insert Tag -- ------------------------------ -- The <ui:insert name="...">...</ui:insert> type Insert_Tag_Node is new Tag_Node with private; type Insert_Tag_Node_Access is access all Insert_Tag_Node'Class; -- Create the Insert Tag function Create_Insert_Tag_Node (Binding : in Binding_Access; Line : in Line_Info; Parent : in Tag_Node_Access; Attributes : in Tag_Attribute_Array_Access) return Tag_Node_Access; -- Build the component tree from the tag node and attach it as -- the last child of the given parent. Calls recursively the -- method to create children. overriding procedure Build_Components (Node : access Insert_Tag_Node; Parent : in UIComponent_Access; Context : in out Facelet_Context'Class); -- ------------------------------ -- Param Tag -- ------------------------------ -- The <ui:param name="name" value="#{expr}"/> parameter creation. -- The parameter is created in the faces context. type Param_Tag_Node is new Tag_Node with private; type Param_Tag_Node_Access is access all Param_Tag_Node'Class; -- Create the Param Tag function Create_Param_Tag_Node (Binding : in Binding_Access; Line : in Line_Info; Parent : in Tag_Node_Access; Attributes : in Tag_Attribute_Array_Access) return Tag_Node_Access; -- Build the component tree from the tag node and attach it as -- the last child of the given parent. Calls recursively the -- method to create children. overriding procedure Build_Components (Node : access Param_Tag_Node; Parent : in UIComponent_Access; Context : in out Facelet_Context'Class); -- ------------------------------ -- Comment Tag -- ------------------------------ -- The <ui:comment condition="...">...</ui:comment> type Comment_Tag_Node is new Tag_Node with private; type Comment_Tag_Node_Access is access all Comment_Tag_Node'Class; -- Create the Comment Tag function Create_Comment_Tag_Node (Binding : in Binding_Access; Line : in Line_Info; Parent : in Tag_Node_Access; Attributes : in Tag_Attribute_Array_Access) return Tag_Node_Access; -- Build the component tree from the tag node and attach it as -- the last child of the given parent. Calls recursively the -- method to create children. overriding procedure Build_Components (Node : access Comment_Tag_Node; Parent : in UIComponent_Access; Context : in out Facelet_Context'Class); private -- Tag library map indexed on the library namespace. package Define_Maps is new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String, Element_Type => Define_Tag_Node_Access, Hash => Ada.Strings.Hash, Equivalent_Keys => "="); type Include_Tag_Node is new Tag_Node with record Source : Tag_Attribute_Access; end record; type Composition_Tag_Node is new Tag_Node with record Template : Tag_Attribute_Access; Defines : Define_Maps.Map; end record; type Debug_Tag_Node is new Tag_Node with record Source : Tag_Attribute_Access; end record; type Decorate_Tag_Node is new Composition_Tag_Node with null record; type Define_Tag_Node is new Tag_Node with record Define_Name : Unbounded_String; end record; type Insert_Tag_Node is new Tag_Node with record Insert_Name : Tag_Attribute_Access; end record; type Param_Tag_Node is new Tag_Node with record Var : Tag_Attribute_Access; Value : Tag_Attribute_Access; end record; type Comment_Tag_Node is new Tag_Node with record Condition : Tag_Attribute_Access; end record; end ASF.Views.Nodes.Facelets;
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Cross_Reference_Updaters; with Program.Elements.Identifiers; with Program.Simple_Resolvers; with Program.Symbol_Lists; with Program.Error_Listeners; private package Program.Plain_Contexts.Unit_Name_Resolvers is pragma Preelaborate; type Unit_Name_Resolver (Lists : not null Program.Symbol_Lists.Symbol_List_Table_Access; Errors : not null Program.Error_Listeners.Error_Listener_Access; Declarations : not null Unit_Vector_Access; Bodies : not null Unit_Vector_Access) is new Program.Simple_Resolvers.Simple_Resolver with null record; type Unit_Name_Resolver_Access is access all Unit_Name_Resolver'Class with Storage_Size => 0; overriding procedure Resolve_Identifier (Self : Unit_Name_Resolver; Name : not null Program.Elements.Identifiers.Identifier_Access; Setter : not null Program.Cross_Reference_Updaters.Cross_Reference_Updater_Access); end Program.Plain_Contexts.Unit_Name_Resolvers;
with Ada.Real_Time; use type Ada.Real_Time.Time; use Ada; with AdaCar.Organizador_Movimiento; with AdaCar.Sensor_Proximidad; package body AdaCar.Seguimiento_Sensor is ---------------------- -- Seguimiento_Task -- ---------------------- task body Seguimiento_Task is Tseg: constant Duration:= Parametros.Periodo_Seguimiento_Task; Periodo: constant Real_Time.Time_Span:= Real_Time.To_Time_Span(Tseg); Next: Real_Time.Time:= Real_Time.Clock; Valor_Sensor: Unidades_Distancia; begin loop Valor_Sensor:= Sensor_Proximidad.Leer_Entrada_Sensor; Organizador_Movimiento.Nueva_Distancia_Sensor(Valor_Sensor); Next:= Next+Periodo; delay until Next; end loop; end Seguimiento_Task; end AdaCar.Seguimiento_Sensor;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of STMicroelectronics nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- -- -- -- This file is based on: -- -- -- -- @file stm32f407xx.h et al. -- -- @author MCD Application Team -- -- @version V1.1.0 -- -- @date 19-June-2014 -- -- @brief CMSIS STM32F407xx Device Peripheral Access Layer Header File. -- -- -- -- COPYRIGHT(c) 2014 STMicroelectronics -- ------------------------------------------------------------------------------ -- This file provides register definitions for the STM32 (ARM Cortex M4/7F) -- microcontrollers from ST Microelectronics. package STM32.EXTI is type External_Line_Number is (EXTI_Line_0, -- GPIO EXTI_Line_1, -- GPIO EXTI_Line_2, -- GPIO EXTI_Line_3, -- GPIO EXTI_Line_4, -- GPIO EXTI_Line_5, -- GPIO EXTI_Line_6, -- GPIO EXTI_Line_7, -- GPIO EXTI_Line_8, -- GPIO EXTI_Line_9, -- GPIO EXTI_Line_10, -- GPIO EXTI_Line_11, -- GPIO EXTI_Line_12, -- GPIO EXTI_Line_13, -- GPIO EXTI_Line_14, -- GPIO EXTI_Line_15, -- GPIO EXTI_Line_16, -- PVD and AVD EXTI_Line_17, -- RTC Alarms EXTI_Line_18, -- RTC tamper and Timestamp and RCC LSECSS EXTI_Line_19, -- RTC wakeup timer EXTI_Line_20, -- COMP1 EXTI_Line_21, -- COMP2 EXTI_Line_22, -- I2C1 wakeup EXTI_Line_23, -- I2C2 wakeup EXTI_Line_24, -- I2C3 wakeup EXTI_Line_25, -- I2C4 wakeup EXTI_Line_26, -- USART1 wakeup EXTI_Line_27, -- USART2 wakeup EXTI_Line_28, -- USART3 wakeup EXTI_Line_29, -- USART6 wakeup EXTI_Line_30, -- UART4 wakeup EXTI_Line_31, -- UART5 wakeup EXTI_Line_32, -- UART7 wakeup EXTI_Line_33, -- UART8 wakeup EXTI_Line_34, -- LPUART1 RX wakeup EXTI_Line_35, -- LPUART1 TX wakeup EXTI_Line_36, -- SPI1 wakeup EXTI_Line_37, -- SPI2 wakeup EXTI_Line_38, -- SPI3 wakeup EXTI_Line_39, -- SPI4 wakeup EXTI_Line_40, -- SPI5 wakeup EXTI_Line_41, -- SPI6 wakeup EXTI_Line_42, -- MDIO wakeup EXTI_Line_43, -- USB1 wakeup EXTI_Line_44, -- USB2 wakeup EXTI_Line_47, -- LPTIM1 wakeup EXTI_Line_48, -- LPTIM2 wakeup EXTI_Line_49, -- LPTIM2 output EXTI_Line_50, -- LPTIM3 wakeup EXTI_Line_51, -- LPTIM3 output EXTI_Line_52, -- LPTIM4 wakeup EXTI_Line_53, -- LPTIM5 wakeup EXTI_Line_54, -- SWPMI wakeup EXTI_Line_55, -- WKUP1 EXTI_Line_56, -- WKUP2 EXTI_Line_57, -- WKUP3 EXTI_Line_58, -- WKUP4 EXTI_Line_59, -- WKUP5 EXTI_Line_60, -- WKUP6 EXTI_Line_61, -- RCC interrupt EXTI_Line_62, -- I2C4 Event interrupt EXTI_Line_63, -- I2C4 Error interrupt EXTI_Line_64, -- LPUART1 global interrupt EXTI_Line_65, -- SPI6 interrupt EXTI_Line_66, -- BDMA CH0 interrupt EXTI_Line_67, -- BDMA CH1 interrupt EXTI_Line_68, -- BDMA CH2 interrupt EXTI_Line_69, -- BDMA CH3 interrupt EXTI_Line_70, -- BDMA CH4 interrupt EXTI_Line_71, -- BDMA CH5 interrupt EXTI_Line_72, -- BDMA CH6 interrupt EXTI_Line_73, -- BDMA CH7 interrupt EXTI_Line_74, -- DMAMUX2 interrupt EXTI_Line_75, -- ADC3 interrupt EXTI_Line_76, -- SAI4 interrupt EXTI_Line_85, -- HDMI-CEC wakeup EXTI_Line_86, -- ETHERNET wakeup EXTI_Line_87); -- HSECSS interrupt -- See RM0433 rev 7 chapter 20.4 table 146 for EXTI event input mapping. for External_Line_Number use (EXTI_Line_0 => 0, EXTI_Line_1 => 1, EXTI_Line_2 => 2, EXTI_Line_3 => 3, EXTI_Line_4 => 4, EXTI_Line_5 => 5, EXTI_Line_6 => 6, EXTI_Line_7 => 7, EXTI_Line_8 => 8, EXTI_Line_9 => 9, EXTI_Line_10 => 10, EXTI_Line_11 => 11, EXTI_Line_12 => 12, EXTI_Line_13 => 13, EXTI_Line_14 => 14, EXTI_Line_15 => 15, EXTI_Line_16 => 16, EXTI_Line_17 => 17, EXTI_Line_18 => 18, EXTI_Line_19 => 19, EXTI_Line_20 => 20, EXTI_Line_21 => 21, EXTI_Line_22 => 22, EXTI_Line_23 => 23, EXTI_Line_24 => 24, EXTI_Line_25 => 25, EXTI_Line_26 => 26, EXTI_Line_27 => 27, EXTI_Line_28 => 28, EXTI_Line_29 => 29, EXTI_Line_30 => 30, EXTI_Line_31 => 31, EXTI_Line_32 => 32, EXTI_Line_33 => 33, EXTI_Line_34 => 34, EXTI_Line_35 => 35, EXTI_Line_36 => 36, EXTI_Line_37 => 37, EXTI_Line_38 => 38, EXTI_Line_39 => 39, EXTI_Line_40 => 40, EXTI_Line_41 => 41, EXTI_Line_42 => 42, EXTI_Line_43 => 43, EXTI_Line_44 => 44, EXTI_Line_47 => 47, EXTI_Line_48 => 48, EXTI_Line_49 => 49, EXTI_Line_50 => 50, EXTI_Line_51 => 51, EXTI_Line_52 => 52, EXTI_Line_53 => 53, EXTI_Line_54 => 54, EXTI_Line_55 => 55, EXTI_Line_56 => 56, EXTI_Line_57 => 57, EXTI_Line_58 => 58, EXTI_Line_59 => 59, EXTI_Line_60 => 60, EXTI_Line_61 => 61, EXTI_Line_62 => 62, EXTI_Line_63 => 63, EXTI_Line_64 => 64, EXTI_Line_65 => 65, EXTI_Line_66 => 66, EXTI_Line_67 => 67, EXTI_Line_68 => 68, EXTI_Line_69 => 69, EXTI_Line_70 => 70, EXTI_Line_71 => 71, EXTI_Line_72 => 72, EXTI_Line_73 => 73, EXTI_Line_74 => 74, EXTI_Line_75 => 75, EXTI_Line_76 => 76, EXTI_Line_85 => 85, EXTI_Line_86 => 86, EXTI_Line_87 => 87); type External_Triggers is (Interrupt_Rising_Edge, Interrupt_Falling_Edge, Interrupt_Rising_Falling_Edge, Event_Rising_Edge, Event_Falling_Edge, Event_Rising_Falling_Edge); subtype Interrupt_Triggers is External_Triggers range Interrupt_Rising_Edge .. Interrupt_Rising_Falling_Edge; subtype Event_Triggers is External_Triggers range Event_Rising_Edge .. Event_Rising_Falling_Edge; procedure Enable_External_Interrupt (Line : External_Line_Number; Trigger : Interrupt_Triggers) with Inline; procedure Disable_External_Interrupt (Line : External_Line_Number) with Inline; procedure Enable_External_Event (Line : External_Line_Number; Trigger : Event_Triggers) with Inline; procedure Disable_External_Event (Line : External_Line_Number) with Inline; procedure Generate_SWI (Line : External_Line_Number) with Inline; function External_Interrupt_Pending (Line : External_Line_Number) return Boolean with Inline; procedure Clear_External_Interrupt (Line : External_Line_Number) with Inline; end STM32.EXTI;
----------------------------------------------------------------------- -- awa_command - Tests for AWA command -- 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 Util.Commands; with Util.Tests; with AWA.Tests; with AWA.Commands.Drivers; with AWA.Commands.List; with AWA.Commands.Start; with AWA.Commands.Stop; with Servlet.Server; with AWA.Tests; with ADO.Drivers; with AWA.Testsuite; procedure AWA_Command is package Server_Commands is new AWA.Commands.Drivers (Driver_Name => "awa", Container_Type => Servlet.Server.Container); package List_Command is new AWA.Commands.List (Server_Commands); package Start_Command is new AWA.Commands.Start (Server_Commands); package Stop_Command is new AWA.Commands.Stop (Server_Commands); App : aliased AWA.Tests.Test_Application; Context : AWA.Commands.Context_Type; Arguments : Util.Commands.Dynamic_Argument_List; Suite : Util.Tests.Access_Test_Suite := AWA.Testsuite.Suite; begin ADO.Drivers.Initialize; Server_Commands.WS.Register_Application ("/test", App'Unchecked_Access); Server_Commands.Run (Context, Arguments); end AWA_Command;
-- { dg-do compile } -- { dg-options "-O -gnatws" } -- PR middle-end/35136 pragma Extend_System(AUX_DEC); with System; procedure Loop_Address is function Y(E : Integer) return String is begin return ""; end Y; function X(C : in System.Address) return String is D : Integer; for D use at C; begin return Y(D); end X; A : System.Address; B : String := ""; begin for I in 0..1 loop B := X(System."+"(A, I)); end loop; end;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- U N A M E -- -- -- -- 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. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Types; use Types; package Uname is --------------------------- -- Unit Name Conventions -- --------------------------- -- Units are associated with a unique ASCII name as follows. First we -- have the fully expanded name of the unit, with lower case letters -- (except for the use of upper case letters for encoding upper half -- and wide characters, as described in Namet), and periods. Following -- this is one of the following suffixes: -- %s for package/subprogram/generic declarations (specs) -- %b for package/subprogram/generic bodies and subunits -- Unit names are stored in the names table, and referred to by the -- corresponding Name_Id values. The subtype Unit_Name, which is a -- synonym for Name_Id, is used to indicate that a Name_Id value that -- holds a unit name (as defined above) is expected. -- Note: as far as possible the conventions for unit names are encapsulated -- in this package. The one exception is that package Fname, which provides -- conversion routines from unit names to file names must be aware of the -- precise conventions that are used. ------------------- -- Display Names -- ------------------- -- For display purposes, unit names are printed out with the suffix -- " (body)" for a body and " (spec)" for a spec. These formats are -- used for the Write_Unit_Name and Get_Unit_Name_String subprograms. ----------------- -- Subprograms -- ----------------- function Get_Body_Name (N : Unit_Name_Type) return Unit_Name_Type; -- Given the name of a spec, this function returns the name of the -- corresponding body, i.e. characters %s replaced by %b function Get_Parent_Body_Name (N : Unit_Name_Type) return Unit_Name_Type; -- Given the name of a subunit, returns the name of the parent body function Get_Parent_Spec_Name (N : Unit_Name_Type) return Unit_Name_Type; -- Given the name of a child unit spec or body, returns the unit name -- of the parent spec. Returns No_Name if the given name is not the name -- of a child unit. procedure Get_External_Unit_Name_String (N : Unit_Name_Type); -- Given the name of a body or spec unit, this procedure places in -- Name_Buffer the name of the unit with periods replaced by double -- underscores. The spec/body indication is eliminated. The length -- of the stored name is placed in Name_Len. All letters are lower -- case, corresponding to the string used in external names. function Get_Spec_Name (N : Unit_Name_Type) return Unit_Name_Type; -- Given the name of a body, this function returns the name of the -- corresponding spec, i.e. characters %b replaced by %s function Get_Unit_Name (N : Node_Id) return Unit_Name_Type; -- This procedure returns the unit name that corresponds to the given node, -- which is one of the following: -- -- N_Subprogram_Declaration (spec) cases -- N_Package_Declaration -- N_Generic_Declaration -- N_With_Clause -- N_Function_Instantiation -- N_Package_Instantiation -- N_Procedure_Instantiation -- N_Pragma (Elaborate case) -- -- N_Package_Body (body) cases -- N_Subprogram_Body -- N_Identifier -- N_Selected_Component -- -- N_Subprogram_Body_Stub (subunit) cases -- N_Package_Body_Stub -- N_Task_Body_Stub -- N_Protected_Body_Stub -- N_Subunit procedure Get_Unit_Name_String (N : Unit_Name_Type); -- Places the display name of the unit in Name_Buffer and sets Name_Len -- to the length of the stored name, i.e. it uses the same interface as -- the Get_Name_String routine in the Namet package. The name contains -- an indication of spec or body, and is decoded. function Is_Body_Name (N : Unit_Name_Type) return Boolean; -- Returns True iff the given name is the unit name of a body (i.e. if -- it ends with the characters %b). function Is_Child_Name (N : Unit_Name_Type) return Boolean; -- Returns True iff the given name is a child unit name (of either a -- body or a spec). function Is_Spec_Name (N : Unit_Name_Type) return Boolean; -- Returns True iff the given name is the unit name of a specification -- (i.e. if it ends with the characters %s). function Name_To_Unit_Name (N : Name_Id) return Unit_Name_Type; -- Given the Id of the Ada name of a unit, this function returns the -- corresponding unit name of the spec (by appending %s to the name). function New_Child (Old : Unit_Name_Type; Newp : Unit_Name_Type) return Unit_Name_Type; -- Old is a child unit name (for either a body or spec). Newp is the -- unit name of the actual parent (this may be different from the -- parent in old). The returned unit name is formed by taking the -- parent name from Newp and the child unit name from Old, with the -- result being a body or spec depending on Old. For example: -- -- Old = A.B.C (body) -- Newp = A.R (spec) -- result = A.R.C (body) -- -- See spec of Load_Unit for extensive discussion of why this routine -- needs to be used (the call in the body of Load_Unit is the only one). function Uname_Ge (Left, Right : Unit_Name_Type) return Boolean; function Uname_Gt (Left, Right : Unit_Name_Type) return Boolean; function Uname_Le (Left, Right : Unit_Name_Type) return Boolean; function Uname_Lt (Left, Right : Unit_Name_Type) return Boolean; -- These functions perform lexicographic ordering of unit names. The -- ordering is suitable for printing, and is not quite a straightforward -- comparison of the names, since the convention is that specs appear -- before bodies. Note that the standard = and /= operators work fine -- because all unit names are hashed into the name table, so if two names -- are the same, they always have the same Name_Id value. procedure Write_Unit_Name (N : Unit_Name_Type); -- Given a unit name, this procedure writes the display name to the -- standard output file. Name_Buffer and Name_Len are set as described -- above for the Get_Unit_Name_String call on return. end Uname;
------------------------------------------------------------------------------ -- -- -- Ada User Repository Annex (AURA) -- -- ANNEXI-STRAYLINE Reference Implementation -- -- -- -- Command Line Interface -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai (ANNEXI-STRAYLINE) -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- -- -- * Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -- -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Ada.Unchecked_Deallocation; with Stream_Hashing; with Registrar.Registration; separate (Build) package body Recompilation_Check_Orders is package Reg_Qs renames Registrar.Queries; use type Stream_Hashing.Hash_Type; use all type Registrar.Library_Units.Library_Unit_Kind; ------------------- -- Test_Isolated -- ------------------- procedure Test_Isolated (Unit : in out Registrar.Library_Units.Library_Unit; Isolated: out Boolean) with Pre => Unit.Kind in Package_Unit | Subprogram_Unit; -- Scans the specification of Unit for any generic declarations or Inline -- subprograms. If any are found, Isolated is set to False, otherwise -- Isolated is set to True. -- -- Note that this scan is somepessemistic. There may be some cases which can -- cause it to "wrongly" classify a unit as being NOT isolated when -- it really is (false negative). It shouldn't have false positives, -- however. -- -- One interesting case is where a generic unit is declared in the private -- part of a package. In this case only some of the dependent units would -- need to be recompiled. Test_Isolated will not bother trying to sort that -- out. procedure Test_Isolated (Unit : in out Registrar.Library_Units.Library_Unit; Isolated: out Boolean) is separate; ----------------------- -- Recompilation_Set -- ----------------------- protected body Recompilation_Set is ------------------ -- Enter_Subset -- ------------------ procedure Enter_Subset (Entry_Subset: in out Unit_Names.Sets.Set) is begin Entry_Subset.Difference (Master); Master.Union (Entry_Subset); end Enter_Subset; function Retrieve return Unit_Names.Sets.Set is (Master); end Recompilation_Set; ----------- -- Image -- ----------- function Image (Order: Recompilation_Check_Order) return String is ( "[Recompilation_Check_Order] (Build)" & New_Line & " Target: " & Order.Target.To_UTF8_String & New_Line & " Mode : " & Processing_Mode'Image (Order.Mode) & New_Line); ------------- -- Execute -- ------------- procedure Execute (Order: in out Recompilation_Check_Order) is use Registrar.Library_Units; package Last_Run renames Registrar.Last_Run; function Seek_Parent (Subunit_Name: Unit_Names.Unit_Name) return Unit_Names.Unit_Name is (Reg_Qs.Trace_Subunit_Parent(Reg_Qs.Lookup_Unit (Subunit_Name)).Name); procedure Recompile_All is -- Recompile_All recursively triggers the recompilation of the -- Target unit, as well as all reverse dependencies of that unit Recurse_Order: Recompilation_Check_Order := (Tracker => Order.Tracker, Mode => Set, Recomp_Set => Order.Recomp_Set, others => <>); -- A delta aggregate would be nice here.. Rev_Deps: Unit_Names.Sets.Set := Registrar.Queries.Dependent_Units (Order.Target); begin pragma Assert (for all Unit of Rev_Deps => Reg_Qs.Lookup_Unit(Unit).Kind /= Subunit); -- This should be managed in the Registrar.Dependency_Processing. -- Consolidate_Dependencies operation. -- For Test modes, add Target directly to the Recomp_Set since Test -- mode indicates that Target is the root of a dependency tree, and so -- unlike Set orders, has not already been added by an earlier -- recursive order if Order.Mode = Test then declare Just_Me: Unit_Names.Sets.Set := Unit_Names.Sets.To_Set (Order.Target); -- Needs to be a variable for Enter_Subset begin Order.Recomp_Set.Enter_Subset (Just_Me); end; end if; Order.Recomp_Set.Enter_Subset (Rev_Deps); -- Now Rev_Deps only has the unit names that have not already -- been marked as needing recompilation (the units that have -- just been added to the Recomp_Set. So we need to dispatch -- recursive orders for them, so that they will have their -- dependencies added aswell Recurse_Order.Tracker.Increase_Total_Items_By (Natural (Rev_Deps.Length)); for Name of Rev_Deps loop Recurse_Order.Target := Name; Workers.Enqueue_Order (Recurse_Order); end loop; end Recompile_All; This, Last: Library_Unit; Isolated : Boolean; begin case Order.Mode is when Test => pragma Assert (not Last_Run.All_Library_Units.Is_Empty); -- Build.Compute_Recompilations is not supposed to submit any work -- orders at all if there is no Last_Run registry This := Reg_Qs.Lookup_Unit (Order.Target); pragma Assert (This.State = Compiled); -- We should only ever be "testing" units that are compiled. Last := Last_Run.All_Library_Units (Last_Run.All_Library_Units.Find (This)); -- Note the lookup of Last should not fail because we'd only get -- here if This had a state of "Compiled", and therefore it -- must be in Last. If this fails, good, something is very wrong. if Last.State /= Compiled or else This.Kind /= Last.Kind or else (if This.Spec_File = null then This.Implementation_Hash /= Last.Implementation_Hash else This.Specification_Hash /= Last.Specification_Hash) -- Remember that subprogram units do not need a separate spec, -- so if the body changes for such a subprogram, we cannot assume -- that it doesn't effect it's reverse dependencies or else This.Compilation_Hash /= Last.Compilation_Hash then -- Definately needs recompilation Recompile_All; elsif This.Implementation_Hash /= Last.Implementation_Hash then pragma Assert (This.Body_File /= null); if This.Kind not in Package_Unit | Subprogram_Unit | Subunit then -- All non-Ada units are assumed to not be isolated. -- Also, Test_Isolated is expecting an Ada source Isolated := False; else Test_Isolated (Unit => This, Isolated => Isolated); end if; if Isolated then -- This unit can apparently be recompiled on its own declare Just_Me: Unit_Names.Sets.Set := Unit_Names.Sets.To_Set (Order.Target); begin Order.Recomp_Set.Enter_Subset (Just_Me); end; else -- No luck Recompile_All; end if; end if; when Set => Recompile_All; end case; end Execute; ------------------- -- Phase_Trigger -- ------------------- procedure Phase_Trigger (Order: in out Recompilation_Check_Order) is use Registrar.Library_Units; -- Now the Recomp_Set should be complete. We'll use it to pull a -- subset of All_Library_Units, and set all of the states to -- "Available" procedure Free is new Ada.Unchecked_Deallocation (Object => Recompilation_Set, Name => Recompilation_Set_Access); Selected_Units: Library_Unit_Sets.Set := Reg_Qs.Entered_Library_Units; Recomp_Units : Library_Unit_Sets.Set; begin for Name of Order.Recomp_Set.Retrieve loop Recomp_Units.Include (Library_Unit'(Name => Name, others => <>)); end loop; Free (Order.Recomp_Set); Selected_Units.Intersection (Recomp_Units); declare procedure Set_Available (Unit: in out Library_Unit) is begin Unit.State := Available; end Set_Available; begin for C in Selected_Units.Iterate loop Library_Unit_Sets_Keyed_Operations.Update_Element_Preserving_Key (Container => Selected_Units, Position => C, Process => Set_Available'Access); end loop; end; Registrar.Registration.Update_Library_Unit_Subset (Selected_Units); Compute_Recompilations_Completion.Leave; exception when others => Free (Order.Recomp_Set); if Compute_Recompilations_Completion.Active then Compute_Recompilations_Completion.Leave; end if; raise; end Phase_Trigger; end Recompilation_Check_Orders;