repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
Rodeo-McCabe/orka | Ada | 1,613 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <[email protected]>
--
-- 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 Orka.SIMD.SSE2.Doubles.Arithmetic is
pragma Pure;
function "*" (Left, Right : m128d) return m128d
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_mulpd";
function "/" (Left, Right : m128d) return m128d
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_divpd";
function Divide_Or_Zero (Left, Right : m128d) return m128d;
function "+" (Left, Right : m128d) return m128d
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_addpd";
function "-" (Left, Right : m128d) return m128d
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_subpd";
function "-" (Elements : m128d) return m128d is
((0.0, 0.0) - Elements)
with Inline;
function "abs" (Elements : m128d) return m128d
with Inline;
function Sum (Elements : m128d) return GL.Types.Double
with Inline;
end Orka.SIMD.SSE2.Doubles.Arithmetic;
|
BrickBot/Bound-T-H8-300 | Ada | 9,399 | ads | -- Flow.Indexed (decl)
--
-- Dynamic flow edges where the target is defined by an arithmetic expression.
-- For example, jumps via an indexed table of target addresses in constant
-- memory.
--
-- The possible targets are found by an interval analysis followed by a
-- congruence (alignment) filter. This method is less precise than the
-- method used in the sibling package Flow.Computed, which see.
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form 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.
--
-- 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.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.6 $
-- $Date: 2015/10/24 19:36:49 $
--
-- $Log: flow-indexed.ads,v $
-- Revision 1.6 2015/10/24 19:36:49 niklas
-- Moved to free licence.
--
-- Revision 1.5 2009-11-27 11:28:07 niklas
-- BT-CH-0184: Bit-widths, Word_T, failed modular analysis.
--
-- Revision 1.4 2008/04/22 13:27:52 niklas
-- Added Edge_T.Allowed, to bound the Index values a priori.
--
-- Revision 1.3 2007/07/21 18:18:42 niklas
-- BT-CH-0064. Support for AVR/IAR switch-handler analysis.
--
-- Revision 1.2 2006/02/27 09:20:31 niklas
-- Added Report_Bounds, typically used for warnings about
-- address tables that are assumed to be constant.
--
-- Revision 1.1 2005/02/16 21:11:44 niklas
-- BT-CH-0002.
--
package Flow.Indexed is
type Edge_T is abstract new Boundable_Edge_T
with record
Index : Arithmetic.Expr_Ref;
Aligned : Storage.Bounds.Positive_Value_T;
Allowed : Storage.Bounds.Interval_T := Storage.Bounds.Universal_Interval;
Traced : Storage.Bounds.Interval_T := Storage.Bounds.Void_Interval;
end record;
--
-- A dynamic transfer of control to an address that is defined by
-- an Index expression (and usually other stuff, such as an address
-- table, not given here).
--
-- Index
-- The expression that defines the target address in some way
-- not further specified here (for example, by acting as the
-- index into an address table).
-- Aligned
-- Only Index values that are multiples of Aligned are good
-- and meaningful. This can be useful when instructions or
-- address-table elements are larger that the least addressable
-- memory element and must be aligned accordingly.
-- Allowed
-- Only Index values in this interval are good and meaningful.
-- Traced
-- The Index values in the Traced range have already been processed
-- and possibly resolved into static edges in the flow-graph.
-- Only new Index values outside the Traced range can give rise
-- to new static edges in the flow-graph.
--
-- To resolve an Edge_T we compute the interval of Index values,
-- intersect it with the Allowed interval, and within the intersection
-- find the values that are multiples of Aligned and have not yet
-- been Traced. If there are other constraints on the Index this
-- method may include some infeasible values.
type Edge_Ref is access all Edge_T'Class;
--
-- A reference to a heap-allocated indexed edge object.
function Basis (Item : Edge_T) return Storage.Cell_List_T;
--
-- The basis of an Indexed Edge_T consists of the cells used in
-- the index expression, Item.Index.
--
-- Overrides (implements) Storage.Bounds.Basis.
procedure Add_Basis_Cells (
From : in Edge_T;
To : in out Storage.Cell_Set_T);
--
-- Adds all the cells From the boundable item's Basis set To the
-- given set of cells.
--
-- Overrides Storage.Bounds.Add_Basis_Cells by scanning the Index
-- expression and adding cells directly To the desired set, without
-- using the Basis function.
procedure Add_Basis_Cells (
From : in Edge_T;
To : in out Storage.Cell_Set_T;
Added : in out Boolean);
--
-- Adds all the cells From the boundable item's Basis set To the
-- given set of cells. If some of the added cells were not already
-- in the set, Added is set to True, otherwise (no change in the
-- set) Added is not changed.
--
-- Overrides Storage.Bounds.Add_Basis_Cells by scanning the index
-- expression and adding cells directly To the desired set, without
-- using the Basis function.
function Is_Used (Cell : Storage.Cell_T; By : Edge_T)
return Boolean;
--
-- Whether the given Cell is used By the indexed edge, in other words
-- whether the Cell belongs to the Basis of the edge.
--
-- Overrides Storage.Bounds.Is_Used by scanning the index
-- expression directly, without using the Basis function.
function Image (Item : Edge_T) return String;
--
-- Displays the Item's tag, Index expression and Traced range.
--
-- Overrides Storage.Bounds.Image.
procedure Apply (
Bounds : in Storage.Bounds.Bounds_T'Class;
Upon : in out Edge_T;
Graph : in Graph_T);
--
-- Applies the Bounds Upon the boundable edge as explained for the
-- abstract declaration Flow.Apply (Upon : Boundable_Edge_T).
--
-- The default implementation works as follows:
--
-- > If Bounds is in Arithmetic.Bounds_T'Class, uses the Apply
-- operation for such bounds, declared below, with redispatch on Upon.
--
-- > Otherwise does nothing (leaving the edge Unresolved). This
-- case is ripe for overriding in derived types.
--
-- Overrides (implements) Flow.Apply (Upon : Boundable_Edge_T).
procedure Apply_Arithmetic (
Bounds : in Arithmetic.Bounds_T'Class;
Upon : in out Edge_T;
Graph : in Graph_T);
--
-- A special version of the Apply operation, above, for the case where
-- the Bounds can bound arithmetic expressions.
--
-- The default implementation computes the interval of values possible
-- for the Upon.Index expression under the given Bounds, lists the new
-- Index values allowed by this interval and Upon.Aligned but not
-- covered by Upon.Traced, and calls the Index operation (see below)
-- for each such Value. Finally Upon.Traced is updated to be the new
-- internal allowed by the Bounds.
--
-- There are two special cases:
--
-- > If the Bounds are so loose that there would be too many new
-- Index values, the operation does nothing (and leaves Upon in
-- the Unresolved state).
--
-- > If the Bounds are so tight that there are no new Index values,
-- the operation calls Mark_Stable (Upon) to indicate that this
-- dynamic edge is fully resolved (within the present computation
-- model).
--
-- I would like to name the procedure Apply, but Gnat 3.15p
-- considers this ambiguous in a call, although it accepts it here.
-- So the name Apply_Arithmetic is a work-around.
procedure Report_Bounds (
Edge : in out Edge_T;
Interval : in Storage.Bounds.Interval_T;
Values : in Storage.Bounds.Value_List_T);
--
-- Reports the bounds computed for the Index of the Edge.
-- Interval is the newest computed Index interval and Values
-- lists the new values (if any) allowed by this Interval
-- relative to the bounds computed in earlier iterations.
-- The default implementation is null.
procedure Index (
Edge : in out Edge_T;
Value : in Arithmetic.Value_T;
Graph : in Graph_T)
is abstract;
--
-- Applies a new Value as an index to the indexable Edge, possibly
-- giving new static edges in the Graph (usually only one new edge).
--
-- This operation is usually called from the Apply operation for
-- arithmetic bounds, above. The index Value is a value allowed
-- by Apply.Bounds for Edge.Index and is a multiple of Edge.Align
-- but is not in Edge.Traced.
end Flow.Indexed;
|
optikos/oasis | Ada | 1,184 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Expressions;
with Program.Lexical_Elements;
package Program.Elements.Character_Literals is
pragma Pure (Program.Elements.Character_Literals);
type Character_Literal is
limited interface and Program.Elements.Expressions.Expression;
type Character_Literal_Access is access all Character_Literal'Class
with Storage_Size => 0;
not overriding function Image (Self : Character_Literal) return Text
is abstract;
type Character_Literal_Text is limited interface;
type Character_Literal_Text_Access is
access all Character_Literal_Text'Class with Storage_Size => 0;
not overriding function To_Character_Literal_Text
(Self : aliased in out Character_Literal)
return Character_Literal_Text_Access is abstract;
not overriding function Character_Literal_Token
(Self : Character_Literal_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Character_Literals;
|
charlie5/lace | Ada | 3,838 | ads | with
physics.Joint,
lace.Any;
limited
with
gel.Sprite;
package gel.Joint
--
-- Allows sprites to be connected via a joint.
-- A joint constrains the motion of the sprites which it connects.
--
is
type Item is abstract new lace.Any.limited_item with private;
type View is access all Item'Class;
type Views is array (math.Index range <>) of View;
null_Joints : constant Joint.views;
function to_GEL (the_Joint : in physics.Joint.view) return gel.Joint.view;
subtype Degree_of_freedom is physics.Joint.Degree_of_freedom;
use Math;
---------
--- Forge
--
procedure define (Self : access Item; Sprite_A, Sprite_B : access gel.Sprite.item'Class);
procedure destroy (Self : in out Item) is abstract;
procedure free (Self : in out View);
--------------
--- Attributes
--
function Sprite_A (Self : in Item'Class) return access gel.Sprite.item'Class;
function Sprite_B (Self : in Item'Class) return access gel.Sprite.item'Class;
function Frame_A (Self : in Item) return Matrix_4x4 is abstract;
function Frame_B (Self : in Item) return Matrix_4x4 is abstract;
procedure Frame_A_is (Self : in out Item; Now : in Matrix_4x4) is abstract;
procedure Frame_B_is (Self : in out Item; Now : in Matrix_4x4) is abstract;
function Degrees_of_freedom (Self : in Item) return degree_of_Freedom is abstract;
--
-- Returns the number of possible DoF's for this joint.
type Physics_view is access all physics.Joint.item'Class;
function Physics (Self : in Item) return Physics_view is abstract;
-- Bounds - limits the range of motion for a Degree of freedom.
--
function low_Bound (Self : access Item; for_Degree : in Degree_of_freedom) return Real is abstract;
procedure low_Bound_is (Self : access Item; for_Degree : in Degree_of_freedom;
Now : in Real) is abstract;
function high_Bound (Self : access Item; for_Degree : in Degree_of_freedom) return Real is abstract;
procedure high_Bound_is (Self : access Item; for_Degree : in Degree_of_freedom;
Now : in Real) is abstract;
function is_Bound (Self : in Item; for_Degree : in Degree_of_freedom) return Boolean is abstract;
--
-- Returns true if an upper or lower bound has been set for the given Degree of freedom.
function Extent (Self : in Item; for_Degree : in Degree_of_freedom) return Real is abstract;
--
-- Angle about axis for rotational joints or spatial distance along an axis, in the case of sliders, etc.
procedure Velocity_is (Self : in Item; for_Degree : in Degree_of_freedom;
Now : in Real) is abstract;
function reaction_Force (Self : in Item'Class) return Vector_3;
function reaction_Torque (Self : in Item'Class) return Real;
--------------
--- Operations
--
-- Nil.
----------
--- Hinges
--
function local_Anchor_on_A (Self : in Item) return Vector_3;
function local_Anchor_on_B (Self : in Item) return Vector_3;
procedure local_Anchor_on_A_is (Self : out Item; Now : in Vector_3);
procedure local_Anchor_on_B_is (Self : out Item; Now : in Vector_3);
private
type Item is abstract new lace.Any.limited_item with
record
Sprite_A : access gel.Sprite.item'Class;
Sprite_B : access gel.Sprite.item'Class;
local_Anchor_on_A : Vector_3;
local_Anchor_on_B : Vector_3;
end record;
null_Joints : constant Joint.views (1 .. 0) := [others => null];
end gel.Joint;
|
reznikmm/matreshka | Ada | 4,899 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- 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.Generic_Collections;
package AMF.Utp.Test_Logs.Collections is
pragma Preelaborate;
package Utp_Test_Log_Collections is
new AMF.Generic_Collections
(Utp_Test_Log,
Utp_Test_Log_Access);
type Set_Of_Utp_Test_Log is
new Utp_Test_Log_Collections.Set with null record;
Empty_Set_Of_Utp_Test_Log : constant Set_Of_Utp_Test_Log;
type Ordered_Set_Of_Utp_Test_Log is
new Utp_Test_Log_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_Utp_Test_Log : constant Ordered_Set_Of_Utp_Test_Log;
type Bag_Of_Utp_Test_Log is
new Utp_Test_Log_Collections.Bag with null record;
Empty_Bag_Of_Utp_Test_Log : constant Bag_Of_Utp_Test_Log;
type Sequence_Of_Utp_Test_Log is
new Utp_Test_Log_Collections.Sequence with null record;
Empty_Sequence_Of_Utp_Test_Log : constant Sequence_Of_Utp_Test_Log;
private
Empty_Set_Of_Utp_Test_Log : constant Set_Of_Utp_Test_Log
:= (Utp_Test_Log_Collections.Set with null record);
Empty_Ordered_Set_Of_Utp_Test_Log : constant Ordered_Set_Of_Utp_Test_Log
:= (Utp_Test_Log_Collections.Ordered_Set with null record);
Empty_Bag_Of_Utp_Test_Log : constant Bag_Of_Utp_Test_Log
:= (Utp_Test_Log_Collections.Bag with null record);
Empty_Sequence_Of_Utp_Test_Log : constant Sequence_Of_Utp_Test_Log
:= (Utp_Test_Log_Collections.Sequence with null record);
end AMF.Utp.Test_Logs.Collections;
|
AdaCore/libadalang | Ada | 1,142 | adb | procedure Test is
package Strings is
type Vector is tagged null record;
function Append (Self : Vector; Str : String) return Vector is (Self);
function New_Line (Self : Vector) return Vector is (Self);
Empty_Vector : constant Vector := (null record);
end Strings;
function Descr return Strings.Vector
is (Strings.Empty_Vector
.Append ("a")
.New_Line
.Append ("b")
.Append ("c"
& "d"
& "e")
.New_Line
.Append ("f")
.Append ("g"
& "h"
& "i")
.New_Line
.Append ("j")
.Append ("k"
& "l"
& "m"
& "n"
& "o"
& "p"
& "q"
& "r")
.New_Line
.Append ("r")
.Append ("s"
& "t"
& "u"
& "v"
& "w"
& "x")
.New_Line
.Append ("y")
.New_Line
.Append ("z")
.New_Line
.Append ("0"));
pragma Test_Statement;
begin
null;
end Test;
|
godunko/adawebpack | Ada | 15,687 | adb | ------------------------------------------------------------------------------
-- --
-- AdaWebPack --
-- --
------------------------------------------------------------------------------
-- Copyright © 2021-2022, Vadim Godunko --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
------------------------------------------------------------------------------
with System;
with Web.Strings.WASM_Helpers;
package body WASM.Objects.Methods is
-------------------------
-- Call_Boolean_String --
-------------------------
function Call_Boolean_String
(Self : Object_Reference'Class;
Name : WASM.Methods.Method_Index;
Parameter : Web.Strings.Web_String) return Boolean
is
use type Interfaces.Unsigned_32;
function Imported
(Object : WASM.Objects.Object_Identifier;
Method : WASM.Methods.Method_Index;
Parameter_Address : System.Address;
Parameter_Size : Interfaces.Unsigned_32)
return Interfaces.Unsigned_32
with Import => True,
Convention => C,
Link_Name => "__adawebpack___boolean_string_invoker";
Parameter_Address : System.Address;
Parameter_Size : Interfaces.Unsigned_32;
begin
Web.Strings.WASM_Helpers.To_JS
(Parameter, Parameter_Address, Parameter_Size);
return
Imported (Self.Identifier, Name, Parameter_Address, Parameter_Size)
/= 0;
end Call_Boolean_String;
------------------------
-- Call_Object_Object --
------------------------
function Call_Object_Object
(Self : Object_Reference'Class;
Name : WASM.Methods.Method_Index)
return WASM.Objects.Object_Identifier
is
function Imported
(Object : WASM.Objects.Object_Identifier;
Method : WASM.Methods.Method_Index)
return WASM.Objects.Object_Identifier
with Import => True,
Convention => C,
Link_Name => "__adawebpack___object_invoker";
begin
return Imported (Self.Identifier, Name);
end Call_Object_Object;
-------------------------
-- Call_Object_Boolean --
-------------------------
function Call_Object_Boolean
(Self : Object_Reference'Class;
Name : WASM.Methods.Method_Index;
Parameter_1 : Boolean)
return WASM.Objects.Object_Identifier
is
function Imported
(Object : WASM.Objects.Object_Identifier;
Method : WASM.Methods.Method_Index;
Parameter_1 : Interfaces.Unsigned_32)
return WASM.Objects.Object_Identifier
with Import => True,
Convention => C,
Link_Name => "__adawebpack___object_boolean_invoker";
begin
return Imported (Self.Identifier, Name, Boolean'Pos (Parameter_1));
end Call_Object_Boolean;
------------------------
-- Call_Object_String --
------------------------
function Call_Object_String
(Self : Object_Reference'Class;
Name : WASM.Methods.Method_Index;
Parameter_1 : Web.Strings.Web_String)
return WASM.Objects.Object_Identifier
is
function Imported
(Object : WASM.Objects.Object_Identifier;
Method : WASM.Methods.Method_Index;
Parameter_1_Address : System.Address;
Parameter_1_Size : Interfaces.Unsigned_32)
return WASM.Objects.Object_Identifier
with Import => True,
Convention => C,
Link_Name => "__adawebpack___object_string_invoker";
Parameter_1_Address : System.Address;
Parameter_1_Size : Interfaces.Unsigned_32;
begin
Web.Strings.WASM_Helpers.To_JS
(Parameter_1, Parameter_1_Address, Parameter_1_Size);
return Imported (Self.Identifier, Name, Parameter_1_Address, Parameter_1_Size);
end Call_Object_String;
-----------------
-- Call_String --
-----------------
function Call_String
(Self : Object_Reference'Class;
Name : WASM.Methods.Method_Index)
return Web.Strings.Web_String
is
function Imported
(Object : WASM.Objects.Object_Identifier;
Attribute : WASM.Methods.Method_Index)
return System.Address
with Import => True,
Convention => C,
Link_Name => "__adawebpack___string_invoker";
begin
return
Web.Strings.WASM_Helpers.To_Ada (Imported (Self.Identifier, Name));
end Call_String;
------------------------
-- Call_String_String --
------------------------
function Call_String_String
(Self : Object_Reference'Class;
Name : WASM.Methods.Method_Index;
Parameter : Web.Strings.Web_String)
return Web.Strings.Web_String
is
function Imported
(Object : WASM.Objects.Object_Identifier;
Attribute : WASM.Methods.Method_Index;
Address : System.Address;
Size : Interfaces.Unsigned_32)
return System.Address
with Import => True,
Convention => C,
Link_Name => "__adawebpack___string_string_invoker";
Address : System.Address;
Size : Interfaces.Unsigned_32;
begin
Web.Strings.WASM_Helpers.To_JS (Parameter, Address, Size);
return
Web.Strings.WASM_Helpers.To_Ada
(Imported (Self.Identifier, Name, Address, Size));
end Call_String_String;
----------------------
-- Call_Void_String --
----------------------
procedure Call_Void_String
(Self : Object_Reference'Class;
Name : WASM.Methods.Method_Index;
Parameter : Web.Strings.Web_String)
is
procedure Imported
(Object : WASM.Objects.Object_Identifier;
Method : WASM.Methods.Method_Index;
Address : System.Address;
Size : Interfaces.Unsigned_32)
with Import => True,
Convention => C,
Link_Name => "__adawebpack___void_string_invoker";
Address : System.Address;
Size : Interfaces.Unsigned_32;
begin
Web.Strings.WASM_Helpers.To_JS (Parameter, Address, Size);
Imported (Self.Identifier, Name, Address, Size);
end Call_Void_String;
-----------------------------
-- Call_Void_String_String --
-----------------------------
procedure Call_Void_String_String
(Self : Object_Reference'Class;
Name : WASM.Methods.Method_Index;
Parameter_1 : Web.Strings.Web_String;
Parameter_2 : Web.Strings.Web_String)
is
procedure Imported
(Object : WASM.Objects.Object_Identifier;
Method : WASM.Methods.Method_Index;
Parameter_1_Address : System.Address;
Parameter_1_Size : Interfaces.Unsigned_32;
Parameter_2_Address : System.Address;
Parameter_2_Size : Interfaces.Unsigned_32)
with Import => True,
Convention => C,
Link_Name => "__adawebpack___void_string_string_invoker";
Address_1 : System.Address;
Size_1 : Interfaces.Unsigned_32;
Address_2 : System.Address;
Size_2 : Interfaces.Unsigned_32;
begin
Web.Strings.WASM_Helpers.To_JS (Parameter_1, Address_1, Size_1);
Web.Strings.WASM_Helpers.To_JS (Parameter_2, Address_2, Size_2);
Imported (Self.Identifier, Name, Address_1, Size_1, Address_2, Size_2);
end Call_Void_String_String;
----------------------
-- Call_Void_Object --
----------------------
procedure Call_Void_Object
(Self : Object_Reference'Class;
Name : WASM.Methods.Method_Index;
Parameter : Object_Reference'Class)
is
procedure Imported
(Object : WASM.Objects.Object_Identifier;
Method : WASM.Methods.Method_Index;
Parameter : WASM.Objects.Object_Identifier)
with Import => True,
Convention => C,
Link_Name => "__adawebpack___void_object_invoker";
begin
Imported (Self.Identifier, Name, Parameter.Identifier);
end Call_Void_Object;
--------------------------
-- Call_Void_U32_Object --
--------------------------
procedure Call_Void_U32_Object
(Self : Object_Reference'Class;
Name : WASM.Methods.Method_Index;
Parameter_1 : Interfaces.Unsigned_32;
Parameter_2 : Object_Reference'Class)
is
procedure Imported
(Object : WASM.Objects.Object_Identifier;
Method : WASM.Methods.Method_Index;
Parameter_1 : Interfaces.Unsigned_32;
Parameter_2 : WASM.Objects.Object_Identifier)
with Import => True,
Convention => C,
Link_Name => "__adawebpack___void_i32_object_invoker";
begin
Imported (Self.Identifier, Name, Parameter_1, Parameter_2.Identifier);
end Call_Void_U32_Object;
---------------------------
-- Call_Void_U32_U32_I32 --
---------------------------
procedure Call_Void_U32_U32_I32
(Self : Object_Reference'Class;
Name : WASM.Methods.Method_Index;
Parameter_1 : Interfaces.Unsigned_32;
Parameter_2 : Interfaces.Unsigned_32;
Parameter_3 : Interfaces.Integer_32)
is
procedure Imported
(Object : WASM.Objects.Object_Identifier;
Method : WASM.Methods.Method_Index;
Parameter_1 : Interfaces.Unsigned_32;
Parameter_2 : Interfaces.Unsigned_32;
Parameter_3 : Interfaces.Integer_32)
with Import => True,
Convention => C,
Link_Name => "__adawebpack___void_i32_i32_i32_invoker";
begin
Imported (Self.Identifier, Name, Parameter_1, Parameter_2, Parameter_3);
end Call_Void_U32_U32_I32;
-------------------------------
-- Call_Void_U32_U32_I32_I32 --
-------------------------------
procedure Call_Void_U32_U32_I32_I32
(Self : Object_Reference'Class;
Name : WASM.Methods.Method_Index;
Parameter_1 : Interfaces.Unsigned_32;
Parameter_2 : Interfaces.Unsigned_32;
Parameter_3 : Interfaces.Integer_32;
Parameter_4 : Interfaces.Integer_32)
is
procedure Imported
(Object : WASM.Objects.Object_Identifier;
Method : WASM.Methods.Method_Index;
Parameter_1 : Interfaces.Unsigned_32;
Parameter_2 : Interfaces.Unsigned_32;
Parameter_3 : Interfaces.Integer_32;
Parameter_4 : Interfaces.Integer_32)
with Import => True,
Convention => C,
Link_Name => "__adawebpack___void_i32_i32_i32_i32_invoker";
begin
Imported
(Self.Identifier,
Name,
Parameter_1,
Parameter_2,
Parameter_3,
Parameter_4);
end Call_Void_U32_U32_I32_I32;
----------------------------------
-- Call_Void_U32_U32_U32_Object --
----------------------------------
procedure Call_Void_U32_U32_U32_Object
(Self : Object_Reference'Class;
Name : WASM.Methods.Method_Index;
Parameter_1 : Interfaces.Unsigned_32;
Parameter_2 : Interfaces.Unsigned_32;
Parameter_3 : Interfaces.Unsigned_32;
Parameter_4 : Object_Reference'Class)
is
procedure Imported
(Object : WASM.Objects.Object_Identifier;
Method : WASM.Methods.Method_Index;
Parameter_1 : Interfaces.Unsigned_32;
Parameter_2 : Interfaces.Unsigned_32;
Parameter_3 : Interfaces.Unsigned_32;
Parameter_4 : WASM.Objects.Object_Identifier)
with Import => True,
Convention => C,
Link_Name => "__adawebpack___void_i32_i32_i32_object_invoker";
begin
Imported
(Self.Identifier,
Name,
Parameter_1,
Parameter_2,
Parameter_3,
Parameter_4.Identifier);
end Call_Void_U32_U32_U32_Object;
--------------------------------------
-- Call_Void_U32_U32_U32_Object_I32 --
--------------------------------------
procedure Call_Void_U32_U32_U32_Object_I32
(Self : Object_Reference'Class;
Name : WASM.Methods.Method_Index;
Parameter_1 : Interfaces.Unsigned_32;
Parameter_2 : Interfaces.Unsigned_32;
Parameter_3 : Interfaces.Unsigned_32;
Parameter_4 : Object_Reference'Class;
Parameter_5 : Interfaces.Integer_32)
is
procedure Imported
(Object : WASM.Objects.Object_Identifier;
Method : WASM.Methods.Method_Index;
Parameter_1 : Interfaces.Unsigned_32;
Parameter_2 : Interfaces.Unsigned_32;
Parameter_3 : Interfaces.Unsigned_32;
Parameter_4 : WASM.Objects.Object_Identifier;
Parameter_5 : Interfaces.Integer_32)
with Import => True,
Convention => C,
Link_Name => "__adawebpack___void_i32_i32_i32_object_i32_invoker";
begin
Imported
(Self.Identifier,
Name,
Parameter_1,
Parameter_2,
Parameter_3,
Parameter_4.Identifier,
Parameter_5);
end Call_Void_U32_U32_U32_Object_I32;
end WASM.Objects.Methods;
|
guillaume-lin/tsc | Ada | 4,052 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Menus.Item_User_Data --
-- --
-- S P E C --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 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: Juergen Pfeifer, 1996
-- Version Control:
-- $Revision: 1.14 $
-- Binding Version 01.00
------------------------------------------------------------------------------
generic
type User is limited private;
type User_Access is access User;
package Terminal_Interface.Curses.Menus.Item_User_Data is
pragma Preelaborate (Terminal_Interface.Curses.Menus.Item_User_Data);
-- The binding uses the same user pointer for menu items
-- as the low level C implementation. So you can safely
-- read or write the user pointer also with the C routines
--
-- |=====================================================================
-- | Man page mitem_userptr.3x
-- |=====================================================================
-- |
procedure Set_User_Data (Itm : in Item;
Data : in User_Access);
-- AKA: set_item_userptr
pragma Inline (Set_User_Data);
-- |
procedure Get_User_Data (Itm : in Item;
Data : out User_Access);
-- AKA: item_userptr
-- |
function Get_User_Data (Itm : in Item) return User_Access;
-- AKA: item_userptr
-- Same as function
pragma Inline (Get_User_Data);
end Terminal_Interface.Curses.Menus.Item_User_Data;
|
reznikmm/matreshka | Ada | 4,154 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2017, Vadim Godunko <[email protected]> --
-- 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.Strings;
package WUI.Widgets.Labels is
type Label is new WUI.Widgets.Abstract_Widget with private;
type Label_Access is access all Label'Class
with Storage_Size => 0;
procedure Set_Text
(Self : in out Label'Class;
To : League.Strings.Universal_String);
package Constructors is
function Create
(Element : not null WebAPI.HTML.Elements.HTML_Element_Access)
return not null Label_Access;
function Create
(Id : League.Strings.Universal_String) return not null Label_Access;
procedure Initialize
(Self : in out Label'Class;
Element : not null WebAPI.HTML.Elements.HTML_Element_Access);
end Constructors;
private
type Label is new WUI.Widgets.Abstract_Widget with null record;
end WUI.Widgets.Labels;
|
reznikmm/matreshka | Ada | 3,679 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 XML.DOM.Elements;
package ODF.DOM.Db_Character_Set_Elements is
pragma Preelaborate;
type ODF_Db_Character_Set is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Db_Character_Set_Access is
access all ODF_Db_Character_Set'Class
with Storage_Size => 0;
end ODF.DOM.Db_Character_Set_Elements;
|
AdaCore/libadalang | Ada | 138 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Main_Package; use Main_Package;
procedure Main is
begin
Bar;
Baz (1);
Foo (1);
end Main;
|
burratoo/Acton | Ada | 12,820 | adb | ------------------------------------------------------------------------------
-- --
-- OAK COMPONENTS --
-- --
-- OAK.AGENT.KERNEL --
-- --
-- --
-- Copyright (C) 2014-2014, Patrick Bernardi --
------------------------------------------------------------------------------
with Oak.Agent.Interrupts; use Oak.Agent.Interrupts;
with Oak.Agent.Oak_Agent; use Oak.Agent.Oak_Agent;
with Oak.Agent.Schedulers; use Oak.Agent.Schedulers;
with Oak.Brokers.Protected_Objects; use Oak.Brokers.Protected_Objects;
with Oak.States; use Oak.States;
with Oak.Core_Support_Package.Call_Stack;
use Oak.Core_Support_Package.Call_Stack;
package body Oak.Agent.Kernel is
------------------------------
-- Activate_Interrupt_Agent --
------------------------------
procedure Activate_Interrupt_Agent
(Oak_Kernel : in Kernel_Id;
Interrupt : in Interrupt_Id)
is
begin
Agent_Pool (Oak_Kernel).Interrupt_States
(Normal_Priority (Interrupt)) := Handling;
end Activate_Interrupt_Agent;
------------------------------
-- Add_Agent_To_Charge_List --
------------------------------
procedure Add_Agent_To_Charge_List
(Oak_Kernel : in Kernel_Id;
Agent : in Oak_Agent_Id)
is
K : Oak_Kernel_Record renames Agent_Pool (Oak_Kernel);
begin
Set_Next_Charge_Agent
(For_Agent => Agent, Next_Agent => K.Budgets_To_Charge);
K.Budgets_To_Charge := Agent;
end Add_Agent_To_Charge_List;
--------------------------------------
-- Add_Scheduler_To_Scheduler_Table --
--------------------------------------
procedure Add_Scheduler_To_Scheduler_Table
(Oak_Kernel : in Kernel_Id;
Scheduler : in Scheduler_Id)
is
K : Oak_Kernel_Record renames Agent_Pool (Oak_Kernel);
begin
-- Find spot to put Agent in table.
if K.Schedulers = No_Agent then
-- No entry in the table.
K.Schedulers := Scheduler;
Set_Next_Agent (Scheduler, No_Agent);
elsif Lowest_Resposible_Priority (Scheduler) >
Highest_Resposible_Priority (K.Schedulers)
then
-- This scheduler should be placed at the haed of the table.
Set_Next_Agent (For_Agent => Scheduler, Next_Agent => K.Schedulers);
K.Schedulers := Scheduler;
else
-- Search for spot to insert scheduler.
Search_For_Spot : declare
Agent : Scheduler_Id_With_No := K.Schedulers;
Prev_Agent : Scheduler_Id := K.Schedulers;
begin
while Agent /= No_Agent
and then Lowest_Resposible_Priority (Agent) >
Highest_Resposible_Priority (Scheduler)
loop
Prev_Agent := Agent;
Agent := Next_Agent (Agent);
end loop;
Set_Next_Agent (For_Agent => Prev_Agent, Next_Agent => Scheduler);
Set_Next_Agent (For_Agent => Scheduler, Next_Agent => Agent);
end Search_For_Spot;
end if;
-- Initialise the scheduler agent if needed
if State (Scheduler) = Not_Initialised then
Push_Scheduler_Op
(Oak_Kernel => Oak_Kernel,
Scheduler => Scheduler,
Operation => (Message_Type => No_Message));
end if;
Set_State (Scheduler, Runnable);
end Add_Scheduler_To_Scheduler_Table;
------------------------------
-- Deactivate_Interrupt_Agent --
------------------------------
procedure Deactivate_Interrupt_Agent
(Oak_Kernel : in Kernel_Id;
Interrupt : in Interrupt_Id)
is
begin
Agent_Pool (Oak_Kernel).Interrupt_States
(Normal_Priority (Interrupt)) := Inactive;
end Deactivate_Interrupt_Agent;
-------------------------------
-- Find_Top_Active_Interrupt --
-------------------------------
function Find_Top_Active_Interrupt
(Oak_Kernel : in Kernel_Id)
return Interrupt_Id_With_No
is
K : Oak_Kernel_Record renames Agent_Pool (Oak_Kernel);
begin
-- Scan interrupt state vector to find top active agent.
for P in reverse K.Interrupt_States'Range loop
if K.Interrupt_States (P) = Handling then
return K.Interrupt_Agents (P);
end if;
end loop;
-- If we go here it means no interrupt agents are active.
return No_Agent;
end Find_Top_Active_Interrupt;
-------------------------------
-- Flush_Scheduler_Ops_Stack --
-------------------------------
procedure Flush_Scheduler_Ops_Stack (Oak_Kernel : in Kernel_Id)
is
K : Oak_Kernel_Record renames Agent_Pool (Oak_Kernel);
begin
for E of K.Scheduler_Ops loop
E.Scheduler_Agent := No_Agent;
end loop;
end Flush_Scheduler_Ops_Stack;
----------------------
-- New_Kernel_Agent --
----------------------
procedure New_Kernel_Agent
(Agent : out Kernel_Id)
is
begin
Allocate_An_Agent (Agent);
New_Agent
(Agent => Agent,
Name => "Kernel",
Call_Stack_Address => Null_Address,
Call_Stack_Size => Oak_Call_Stack_Size,
Run_Loop => Null_Address,
Run_Loop_Parameter => Null_Address,
Normal_Priority => Any_Priority'Last,
Initial_State => Running);
Setup_Kernel_Agent : declare
K : Oak_Kernel_Record renames Agent_Pool (Agent);
begin
K.Schedulers := No_Agent;
K.Current_Agent := No_Agent;
K.Entry_Exit_Stamp := Clock;
K.Active_Protected_Brokers := No_Protected_Object;
K.Interrupt_States := (others => Inactive);
K.Budgets_To_Charge := No_Agent;
for P in K.Interrupt_Agents'Range loop
New_Interrupt_Agent
(Agent => K.Interrupt_Agents (P),
Priority => P);
end loop;
end Setup_Kernel_Agent;
end New_Kernel_Agent;
----------------------
-- Pop_Scheduler_Op --
----------------------
procedure Pop_Scheduler_Op
(Oak_Kernel : in Kernel_Id;
Scheduler : out Scheduler_Id;
Operation : out Oak_Message)
is
K : Oak_Kernel_Record renames Agent_Pool (Oak_Kernel);
Slot_Number : Scheduler_Op_Id;
begin
-- Note that we optimise Push_ and Pop_Scheduler_Op since there are only
-- two slots in the stack.
if K.Scheduler_Ops (Scheduler_Op_Id'Last).Scheduler_Agent /=
No_Agent
then
Slot_Number := Scheduler_Op_Id'Last;
else
Slot_Number := Scheduler_Op_Id'First;
pragma Assert
(K.Scheduler_Ops (Slot_Number).Scheduler_Agent /= No_Agent);
end if;
Scheduler := K.Scheduler_Ops (Slot_Number).Scheduler_Agent;
Operation := K.Scheduler_Ops (Slot_Number).Operation;
K.Scheduler_Ops (Slot_Number).Scheduler_Agent := No_Agent;
end Pop_Scheduler_Op;
-----------------------
-- Push_Scheduler_Op --
-----------------------
procedure Push_Scheduler_Op
(Oak_Kernel : in Kernel_Id;
Scheduler : in Scheduler_Id;
Operation : in Oak_Message)
is
K : Oak_Kernel_Record renames Agent_Pool (Oak_Kernel);
Slot_Number : Scheduler_Op_Id;
begin
-- Note that we optimise Push_ and Pop_Scheduler_Op since there are only
-- two slots in the stack.
if K.Scheduler_Ops (Scheduler_Op_Id'First).Scheduler_Agent =
No_Agent
then
Slot_Number := Scheduler_Op_Id'First;
else
Slot_Number := Scheduler_Op_Id'Last;
pragma Assert
(K.Scheduler_Ops (Slot_Number).Scheduler_Agent = No_Agent);
end if;
K.Scheduler_Ops (Slot_Number).Scheduler_Agent := Scheduler;
K.Scheduler_Ops (Slot_Number).Operation := Operation;
end Push_Scheduler_Op;
-----------------------------------
-- Remove_Agent_From_Charge_List --
-----------------------------------
procedure Remove_Agent_From_Charge_List
(Oak_Kernel : in Kernel_Id;
Agent : in Oak_Agent_Id)
is
K : Oak_Kernel_Record renames Agent_Pool (Oak_Kernel);
begin
if K.Budgets_To_Charge = Agent then
-- The agent is at the head of the charge list.
K.Budgets_To_Charge := Next_Charge_Agent (Agent);
else
-- The agent is further down the charge list.
Find_And_Remove_Agent : declare
Prev_A : Oak_Agent_Id := K.Budgets_To_Charge;
A : Oak_Agent_Id := Next_Charge_Agent (K.Budgets_To_Charge);
begin
while A /= Agent and then A /= No_Agent loop
Prev_A := A;
A := Next_Charge_Agent (A);
end loop;
if A /= No_Agent then
-- We have found the agent
Set_Next_Charge_Agent (Prev_A, Next_Charge_Agent (A));
end if;
end Find_And_Remove_Agent;
end if;
-- Clear the next agent link for the removed agent.
Set_Next_Charge_Agent (For_Agent => Agent, Next_Agent => No_Agent);
end Remove_Agent_From_Charge_List;
-----------------------
-- Set_Current_Agent --
-----------------------
procedure Set_Current_Agent
(Oak_Kernel : in Kernel_Id;
Agent : in Oak_Agent_Id)
is
begin
Agent_Pool (Oak_Kernel).Current_Agent := Agent;
end Set_Current_Agent;
procedure Set_Current_Priority
(Oak_Kernel : in Kernel_Id;
Priority : in Any_Priority) is
begin
Agent_Pool (Oak_Kernel).Current_Priority := Priority;
end Set_Current_Priority;
-----------------------
-- Set_Current_Timer --
-----------------------
procedure Set_Current_Timer
(Oak_Kernel : in Kernel_Id;
Timer : in Oak_Timer_Id)
is
begin
Agent_Pool (Oak_Kernel).Current_Timer := Timer;
end Set_Current_Timer;
--------------------------
-- Set_Entry_Exit_Stamp --
--------------------------
procedure Set_Entry_Exit_Stamp
(Oak_Kernel : in Kernel_Id;
Time : in Oak_Time.Time) is
begin
Agent_Pool (Oak_Kernel).Entry_Exit_Stamp := Time;
end Set_Entry_Exit_Stamp;
------------------------------------
-- Add_Protected_Broker_To_Kernel --
------------------------------------
procedure Add_Protected_Broker_To_Kernel
(Oak_Kernel : in Kernel_Id;
Broker : in Protected_Id)
is
Prev_B : Protected_Id_With_No := No_Protected_Object;
B : Protected_Id_With_No :=
Agent_Pool (Oak_Kernel).Active_Protected_Brokers;
begin
if B = No_Protected_Object then
Agent_Pool (Oak_Kernel).Active_Protected_Brokers := Broker;
Set_Next_Broker (Broker, No_Protected_Object);
else
while Ceiling_Priority (Broker) < Ceiling_Priority (B) loop
Prev_B := B;
B := Next_Broker (B);
end loop;
if Prev_B = No_Protected_Object then
Agent_Pool (Oak_Kernel).Active_Protected_Brokers := Broker;
else
Set_Next_Broker (Prev_B, Broker);
end if;
Set_Next_Broker (Broker, B);
end if;
end Add_Protected_Broker_To_Kernel;
-----------------------------------------
-- Remove_Protected_Broker_From_Kernel --
-----------------------------------------
procedure Remove_Protected_Broker_From_Kernel
(Oak_Kernel : in Kernel_Id;
Broker : in Protected_Id)
is
Prev_B : Protected_Id_With_No := No_Protected_Object;
B : Protected_Id_With_No :=
Agent_Pool (Oak_Kernel).Active_Protected_Brokers;
begin
if B = Broker then
Agent_Pool (Oak_Kernel).Active_Protected_Brokers :=
Next_Broker (Broker);
else
loop
Prev_B := B;
B := Next_Broker (B);
exit when B = Broker or else B = No_Protected_Object;
end loop;
if B /= No_Protected_Object then
Set_Next_Broker (Prev_B, Next_Broker (B));
end if;
end if;
end Remove_Protected_Broker_From_Kernel;
function Next_Protected_Agent_To_Run
(Oak_Kernel : in Kernel_Id) return Protected_Id_With_No is
begin
return Agent_Pool (Oak_Kernel).Active_Protected_Brokers;
end Next_Protected_Agent_To_Run;
end Oak.Agent.Kernel;
|
stcarrez/ada-util | Ada | 2,348 | ads | -----------------------------------------------------------------------
-- util-strings-tests -- Unit tests for Strings
-- Copyright (C) 2009, 2010, 2011, 2012, 2015, 2018, 2020, 2021, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- 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.Tests;
package Util.Strings.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
procedure Test_Escape_Javascript (T : in out Test);
procedure Test_Escape_Xml (T : in out Test);
procedure Test_Escape_Java (T : in out Test);
procedure Test_Unescape_Xml (T : in out Test);
procedure Test_Capitalize (T : in out Test);
procedure Test_To_Upper_Case (T : in out Test);
procedure Test_To_Lower_Case (T : in out Test);
procedure Test_To_Hex (T : in out Test);
procedure Test_Measure_Copy (T : in out Test);
procedure Test_Index (T : in out Test);
procedure Test_Rindex (T : in out Test);
procedure Test_Starts_With (T : in out Test);
procedure Test_Ends_With (T : in out Test);
procedure Test_Replace (T : in out Test);
-- Do some benchmark on String -> X hash mapped.
procedure Test_Measure_Hash (T : in out Test);
-- Test String_Ref creation
procedure Test_String_Ref (T : in out Test);
-- Benchmark comparison between the use of Iterate vs Query_Element.
procedure Test_Perf_Vector (T : in out Test);
-- Test perfect hash (samples/gperfhash)
procedure Test_Perfect_Hash (T : in out Test);
-- Test the token iteration.
procedure Test_Iterate_Token (T : in out Test);
-- Test formatting strings.
procedure Test_Format (T : in out Test);
end Util.Strings.Tests;
|
1Crazymoney/LearnAda | Ada | 7,462 | adb | pragma Ada_95;
pragma Source_File_Name (ada_main, Spec_File_Name => "b__tokeletes.ads");
pragma Source_File_Name (ada_main, Body_File_Name => "b__tokeletes.adb");
pragma Suppress (Overflow_Check);
with Ada.Exceptions;
package body ada_main is
pragma Warnings (Off);
E74 : Short_Integer; pragma Import (Ada, E74, "system__os_lib_E");
E13 : Short_Integer; pragma Import (Ada, E13, "system__soft_links_E");
E23 : Short_Integer; pragma Import (Ada, E23, "system__exception_table_E");
E48 : Short_Integer; pragma Import (Ada, E48, "ada__io_exceptions_E");
E50 : Short_Integer; pragma Import (Ada, E50, "ada__tags_E");
E47 : Short_Integer; pragma Import (Ada, E47, "ada__streams_E");
E72 : Short_Integer; pragma Import (Ada, E72, "interfaces__c_E");
E25 : Short_Integer; pragma Import (Ada, E25, "system__exceptions_E");
E77 : Short_Integer; pragma Import (Ada, E77, "system__file_control_block_E");
E66 : Short_Integer; pragma Import (Ada, E66, "system__file_io_E");
E70 : Short_Integer; pragma Import (Ada, E70, "system__finalization_root_E");
E68 : Short_Integer; pragma Import (Ada, E68, "ada__finalization_E");
E17 : Short_Integer; pragma Import (Ada, E17, "system__secondary_stack_E");
E45 : Short_Integer; pragma Import (Ada, E45, "ada__text_io_E");
Local_Priority_Specific_Dispatching : constant String := "";
Local_Interrupt_States : constant String := "";
Is_Elaborated : Boolean := False;
procedure finalize_library is
begin
E45 := E45 - 1;
declare
procedure F1;
pragma Import (Ada, F1, "ada__text_io__finalize_spec");
begin
F1;
end;
declare
procedure F2;
pragma Import (Ada, F2, "system__file_io__finalize_body");
begin
E66 := E66 - 1;
F2;
end;
declare
procedure Reraise_Library_Exception_If_Any;
pragma Import (Ada, Reraise_Library_Exception_If_Any, "__gnat_reraise_library_exception_if_any");
begin
Reraise_Library_Exception_If_Any;
end;
end finalize_library;
procedure adafinal is
procedure s_stalib_adafinal;
pragma Import (C, s_stalib_adafinal, "system__standard_library__adafinal");
procedure Runtime_Finalize;
pragma Import (C, Runtime_Finalize, "__gnat_runtime_finalize");
begin
if not Is_Elaborated then
return;
end if;
Is_Elaborated := False;
Runtime_Finalize;
s_stalib_adafinal;
end adafinal;
type No_Param_Proc is access procedure;
procedure adainit is
Main_Priority : Integer;
pragma Import (C, Main_Priority, "__gl_main_priority");
Time_Slice_Value : Integer;
pragma Import (C, Time_Slice_Value, "__gl_time_slice_val");
WC_Encoding : Character;
pragma Import (C, WC_Encoding, "__gl_wc_encoding");
Locking_Policy : Character;
pragma Import (C, Locking_Policy, "__gl_locking_policy");
Queuing_Policy : Character;
pragma Import (C, Queuing_Policy, "__gl_queuing_policy");
Task_Dispatching_Policy : Character;
pragma Import (C, Task_Dispatching_Policy, "__gl_task_dispatching_policy");
Priority_Specific_Dispatching : System.Address;
pragma Import (C, Priority_Specific_Dispatching, "__gl_priority_specific_dispatching");
Num_Specific_Dispatching : Integer;
pragma Import (C, Num_Specific_Dispatching, "__gl_num_specific_dispatching");
Main_CPU : Integer;
pragma Import (C, Main_CPU, "__gl_main_cpu");
Interrupt_States : System.Address;
pragma Import (C, Interrupt_States, "__gl_interrupt_states");
Num_Interrupt_States : Integer;
pragma Import (C, Num_Interrupt_States, "__gl_num_interrupt_states");
Unreserve_All_Interrupts : Integer;
pragma Import (C, Unreserve_All_Interrupts, "__gl_unreserve_all_interrupts");
Detect_Blocking : Integer;
pragma Import (C, Detect_Blocking, "__gl_detect_blocking");
Default_Stack_Size : Integer;
pragma Import (C, Default_Stack_Size, "__gl_default_stack_size");
Leap_Seconds_Support : Integer;
pragma Import (C, Leap_Seconds_Support, "__gl_leap_seconds_support");
procedure Runtime_Initialize (Install_Handler : Integer);
pragma Import (C, Runtime_Initialize, "__gnat_runtime_initialize");
Finalize_Library_Objects : No_Param_Proc;
pragma Import (C, Finalize_Library_Objects, "__gnat_finalize_library_objects");
begin
if Is_Elaborated then
return;
end if;
Is_Elaborated := True;
Main_Priority := -1;
Time_Slice_Value := -1;
WC_Encoding := 'b';
Locking_Policy := ' ';
Queuing_Policy := ' ';
Task_Dispatching_Policy := ' ';
Priority_Specific_Dispatching :=
Local_Priority_Specific_Dispatching'Address;
Num_Specific_Dispatching := 0;
Main_CPU := -1;
Interrupt_States := Local_Interrupt_States'Address;
Num_Interrupt_States := 0;
Unreserve_All_Interrupts := 0;
Detect_Blocking := 0;
Default_Stack_Size := -1;
Leap_Seconds_Support := 0;
Runtime_Initialize (1);
Finalize_Library_Objects := finalize_library'access;
System.Soft_Links'Elab_Spec;
System.Exception_Table'Elab_Body;
E23 := E23 + 1;
Ada.Io_Exceptions'Elab_Spec;
E48 := E48 + 1;
Ada.Tags'Elab_Spec;
Ada.Streams'Elab_Spec;
E47 := E47 + 1;
Interfaces.C'Elab_Spec;
System.Exceptions'Elab_Spec;
E25 := E25 + 1;
System.File_Control_Block'Elab_Spec;
E77 := E77 + 1;
System.Finalization_Root'Elab_Spec;
E70 := E70 + 1;
Ada.Finalization'Elab_Spec;
E68 := E68 + 1;
System.File_Io'Elab_Body;
E66 := E66 + 1;
E72 := E72 + 1;
Ada.Tags'Elab_Body;
E50 := E50 + 1;
System.Soft_Links'Elab_Body;
E13 := E13 + 1;
System.Os_Lib'Elab_Body;
E74 := E74 + 1;
System.Secondary_Stack'Elab_Body;
E17 := E17 + 1;
Ada.Text_Io'Elab_Spec;
Ada.Text_Io'Elab_Body;
E45 := E45 + 1;
end adainit;
procedure Ada_Main_Program;
pragma Import (Ada, Ada_Main_Program, "_ada_tokeletes");
function main
(argc : Integer;
argv : System.Address;
envp : System.Address)
return Integer
is
procedure Initialize (Addr : System.Address);
pragma Import (C, Initialize, "__gnat_initialize");
procedure Finalize;
pragma Import (C, Finalize, "__gnat_finalize");
SEH : aliased array (1 .. 2) of Integer;
Ensure_Reference : aliased System.Address := Ada_Main_Program_Name'Address;
pragma Volatile (Ensure_Reference);
begin
gnat_argc := argc;
gnat_argv := argv;
gnat_envp := envp;
Initialize (SEH'Address);
adainit;
Ada_Main_Program;
adafinal;
Finalize;
return (gnat_exit_status);
end;
-- BEGIN Object file/option list
-- C:\Users\Soba95\Desktop\ada\tokeletes.o
-- -LC:\Users\Soba95\Desktop\ada\
-- -LC:\Users\Soba95\Desktop\ada\
-- -LC:/gnat/2015/lib/gcc/i686-pc-mingw32/4.9.3/adalib/
-- -static
-- -lgnat
-- -Wl,--stack=0x2000000
-- END Object file/option list
end ada_main;
|
reznikmm/matreshka | Ada | 5,963 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This is implementation of package for POSIX systems.
------------------------------------------------------------------------------
with Ada.Directories;
with League.Characters;
with League.Text_Codecs;
separate (XML.SAX.Input_Sources.Streams.Files)
package body Naming_Utilities is
use type League.Characters.Universal_Character;
use type League.Strings.Universal_String;
File_Protocol_Prefix : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("file://");
-------------------
-- Absolute_Name --
-------------------
function Absolute_Name
(Name : League.Strings.Universal_String)
return League.Strings.Universal_String
is
function Current_Directory return League.Strings.Universal_String;
-----------------------
-- Current_Directory --
-----------------------
function Current_Directory return League.Strings.Universal_String is
Aux : constant String := Ada.Directories.Current_Directory;
Xua : Ada.Streams.Stream_Element_Array (1 .. Aux'Length);
for Xua'Address use Aux'Address;
begin
return
League.Text_Codecs.Codec_For_Application_Locale.Decode (Xua);
end Current_Directory;
begin
if Name.Element (1) = '/' then
return Name;
else
return Current_Directory & '/' & Name;
end if;
end Absolute_Name;
----------------------
-- File_Name_To_URI --
----------------------
function File_Name_To_URI
(File_Name : League.Strings.Universal_String)
return League.Strings.Universal_String is
begin
return File_Protocol_Prefix & File_Name;
end File_Name_To_URI;
--------------------------
-- To_Ada_RTL_File_Name --
--------------------------
function To_Ada_RTL_File_Name
(Name : League.Strings.Universal_String) return String
is
Aux : constant Ada.Streams.Stream_Element_Array
:= League.Text_Codecs.Codec_For_Application_Locale.Encode
(Name).To_Stream_Element_Array;
Result : String (1 .. Aux'Length);
for Result'Address use Aux'Address;
begin
return Result;
end To_Ada_RTL_File_Name;
----------------------
-- URI_To_File_Name --
----------------------
function URI_To_File_Name
(URI : League.Strings.Universal_String)
return League.Strings.Universal_String is
begin
if URI.Starts_With (File_Protocol_Prefix) then
return URI.Slice (8, URI.Length);
else
raise Constraint_Error;
end if;
end URI_To_File_Name;
end Naming_Utilities;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 14,486 | ads | -- This spec has been automatically generated from STM32F030.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.GPIO is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- MODER array element
subtype MODER_Element is STM32_SVD.UInt2;
-- MODER array
type MODER_Field_Array is array (0 .. 15) of MODER_Element
with Component_Size => 2, Size => 32;
-- GPIO port mode register
type MODER_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- MODER as a value
Val : STM32_SVD.UInt32;
when True =>
-- MODER as an array
Arr : MODER_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for MODER_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- OTYPER_OT array element
subtype OTYPER_OT_Element is STM32_SVD.Bit;
-- OTYPER_OT array
type OTYPER_OT_Field_Array is array (0 .. 15) of OTYPER_OT_Element
with Component_Size => 1, Size => 16;
-- Type definition for OTYPER_OT
type OTYPER_OT_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- OT as a value
Val : STM32_SVD.UInt16;
when True =>
-- OT as an array
Arr : OTYPER_OT_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for OTYPER_OT_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- GPIO port output type register
type OTYPER_Register is record
-- Port x configuration bits (y = 0..15)
OT : OTYPER_OT_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OTYPER_Register use record
OT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- OSPEEDR array element
subtype OSPEEDR_Element is STM32_SVD.UInt2;
-- OSPEEDR array
type OSPEEDR_Field_Array is array (0 .. 15) of OSPEEDR_Element
with Component_Size => 2, Size => 32;
-- GPIO port output speed register
type OSPEEDR_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- OSPEEDR as a value
Val : STM32_SVD.UInt32;
when True =>
-- OSPEEDR as an array
Arr : OSPEEDR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for OSPEEDR_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- PUPDR array element
subtype PUPDR_Element is STM32_SVD.UInt2;
-- PUPDR array
type PUPDR_Field_Array is array (0 .. 15) of PUPDR_Element
with Component_Size => 2, Size => 32;
-- GPIO port pull-up/pull-down register
type PUPDR_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PUPDR as a value
Val : STM32_SVD.UInt32;
when True =>
-- PUPDR as an array
Arr : PUPDR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for PUPDR_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- IDR array element
subtype IDR_Element is STM32_SVD.Bit;
-- IDR array
type IDR_Field_Array is array (0 .. 15) of IDR_Element
with Component_Size => 1, Size => 16;
-- Type definition for IDR
type IDR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- IDR as a value
Val : STM32_SVD.UInt16;
when True =>
-- IDR as an array
Arr : IDR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for IDR_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- GPIO port input data register
type IDR_Register is record
-- Read-only. Port input data (y = 0..15)
IDR : IDR_Field;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IDR_Register use record
IDR at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- ODR array element
subtype ODR_Element is STM32_SVD.Bit;
-- ODR array
type ODR_Field_Array is array (0 .. 15) of ODR_Element
with Component_Size => 1, Size => 16;
-- Type definition for ODR
type ODR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- ODR as a value
Val : STM32_SVD.UInt16;
when True =>
-- ODR as an array
Arr : ODR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for ODR_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- GPIO port output data register
type ODR_Register is record
-- Port output data (y = 0..15)
ODR : ODR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ODR_Register use record
ODR at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- BSRR_BS array element
subtype BSRR_BS_Element is STM32_SVD.Bit;
-- BSRR_BS array
type BSRR_BS_Field_Array is array (0 .. 15) of BSRR_BS_Element
with Component_Size => 1, Size => 16;
-- Type definition for BSRR_BS
type BSRR_BS_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- BS as a value
Val : STM32_SVD.UInt16;
when True =>
-- BS as an array
Arr : BSRR_BS_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for BSRR_BS_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- BSRR_BR array element
subtype BSRR_BR_Element is STM32_SVD.Bit;
-- BSRR_BR array
type BSRR_BR_Field_Array is array (0 .. 15) of BSRR_BR_Element
with Component_Size => 1, Size => 16;
-- Type definition for BSRR_BR
type BSRR_BR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- BR as a value
Val : STM32_SVD.UInt16;
when True =>
-- BR as an array
Arr : BSRR_BR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for BSRR_BR_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- GPIO port bit set/reset register
type BSRR_Register is record
-- Write-only. Port x set bit y (y= 0..15)
BS : BSRR_BS_Field := (As_Array => False, Val => 16#0#);
-- Write-only. Port x set bit y (y= 0..15)
BR : BSRR_BR_Field := (As_Array => False, Val => 16#0#);
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BSRR_Register use record
BS at 0 range 0 .. 15;
BR at 0 range 16 .. 31;
end record;
-- LCKR_LCK array element
subtype LCKR_LCK_Element is STM32_SVD.Bit;
-- LCKR_LCK array
type LCKR_LCK_Field_Array is array (0 .. 15) of LCKR_LCK_Element
with Component_Size => 1, Size => 16;
-- Type definition for LCKR_LCK
type LCKR_LCK_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- LCK as a value
Val : STM32_SVD.UInt16;
when True =>
-- LCK as an array
Arr : LCKR_LCK_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for LCKR_LCK_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
subtype LCKR_LCKK_Field is STM32_SVD.Bit;
-- GPIO port configuration lock register
type LCKR_Register is record
-- Port x lock bit y (y= 0..15)
LCK : LCKR_LCK_Field := (As_Array => False, Val => 16#0#);
-- Port x lock bit y (y= 0..15)
LCKK : LCKR_LCKK_Field := 16#0#;
-- unspecified
Reserved_17_31 : STM32_SVD.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for LCKR_Register use record
LCK at 0 range 0 .. 15;
LCKK at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
-- AFRL array element
subtype AFRL_Element is STM32_SVD.UInt4;
-- AFRL array
type AFRL_Field_Array is array (0 .. 7) of AFRL_Element
with Component_Size => 4, Size => 32;
-- GPIO alternate function low register
type AFRL_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- AFRL as a value
Val : STM32_SVD.UInt32;
when True =>
-- AFRL as an array
Arr : AFRL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for AFRL_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- AFRH array element
subtype AFRH_Element is STM32_SVD.UInt4;
-- AFRH array
type AFRH_Field_Array is array (8 .. 15) of AFRH_Element
with Component_Size => 4, Size => 32;
-- GPIO alternate function high register
type AFRH_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- AFRH as a value
Val : STM32_SVD.UInt32;
when True =>
-- AFRH as an array
Arr : AFRH_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for AFRH_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- BRR_BR array element
subtype BRR_BR_Element is STM32_SVD.Bit;
-- BRR_BR array
type BRR_BR_Field_Array is array (0 .. 15) of BRR_BR_Element
with Component_Size => 1, Size => 16;
-- Type definition for BRR_BR
type BRR_BR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- BR as a value
Val : STM32_SVD.UInt16;
when True =>
-- BR as an array
Arr : BRR_BR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for BRR_BR_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- Port bit reset register
type BRR_Register is record
-- Write-only. Port x Reset bit y
BR : BRR_BR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BRR_Register use record
BR at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- General-purpose I/Os
type GPIO_Peripheral is record
-- GPIO port mode register
MODER : aliased MODER_Register;
-- GPIO port output type register
OTYPER : aliased OTYPER_Register;
-- GPIO port output speed register
OSPEEDR : aliased OSPEEDR_Register;
-- GPIO port pull-up/pull-down register
PUPDR : aliased PUPDR_Register;
-- GPIO port input data register
IDR : aliased IDR_Register;
-- GPIO port output data register
ODR : aliased ODR_Register;
-- GPIO port bit set/reset register
BSRR : aliased BSRR_Register;
-- GPIO port configuration lock register
LCKR : aliased LCKR_Register;
-- GPIO alternate function low register
AFRL : aliased AFRL_Register;
-- GPIO alternate function high register
AFRH : aliased AFRH_Register;
-- Port bit reset register
BRR : aliased BRR_Register;
end record
with Volatile;
for GPIO_Peripheral use record
MODER at 16#0# range 0 .. 31;
OTYPER at 16#4# range 0 .. 31;
OSPEEDR at 16#8# range 0 .. 31;
PUPDR at 16#C# range 0 .. 31;
IDR at 16#10# range 0 .. 31;
ODR at 16#14# range 0 .. 31;
BSRR at 16#18# range 0 .. 31;
LCKR at 16#1C# range 0 .. 31;
AFRL at 16#20# range 0 .. 31;
AFRH at 16#24# range 0 .. 31;
BRR at 16#28# range 0 .. 31;
end record;
-- General-purpose I/Os
GPIOA_Periph : aliased GPIO_Peripheral
with Import, Address => System'To_Address (16#48000000#);
-- General-purpose I/Os
GPIOB_Periph : aliased GPIO_Peripheral
with Import, Address => System'To_Address (16#48000400#);
-- General-purpose I/Os
GPIOC_Periph : aliased GPIO_Peripheral
with Import, Address => System'To_Address (16#48000800#);
-- General-purpose I/Os
GPIOD_Periph : aliased GPIO_Peripheral
with Import, Address => System'To_Address (16#48000C00#);
-- General-purpose I/Os
GPIOF_Periph : aliased GPIO_Peripheral
with Import, Address => System'To_Address (16#48001400#);
function Port_Index (Port : GPIO_Peripheral) return Natural is
(if Port = GPIOA_Periph then 0
elsif Port = GPIOB_Periph then 1
elsif Port = GPIOC_Periph then 2
elsif Port = GPIOD_Periph then 3
else 5);
end STM32_SVD.GPIO;
|
AdaDoom3/wayland_ada_binding | Ada | 5,325 | ads | ------------------------------------------------------------------------------
-- Copyright (C) 2016-2016, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 3, or (at your option) any later --
-- version. This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- 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/>. --
-- --
------------------------------------------------------------------------------
-- This package provides wrappers around SPARK compatible algorithms of
-- Conts.Algorithms providing postconditions.
-- They should be instanciated with appropriate models
-- of the container. More precisely, for every container Self, the
-- result of Content.Model (Self) must be such that Content.Get (Content.Model
-- (Self), Content.First + I) is always the element returned by
-- Getters.Get (Self, C) on the cursor C obtained by applying Cursors.Next
-- I times on Cursors.First (Self).
-- These algorithms have a body with SPARK_Mode => Off so they must be
-- instantiated at library level inside SPARK code.
pragma Ada_2012;
with Conts.Cursors;
with Conts.Properties;
with Conts.Properties.SPARK;
package Conts.Algorithms.SPARK is
----------
-- Find --
----------
generic
with package Cursors is new Conts.Cursors.Forward_Cursors (<>);
with package Getters is new Conts.Properties.Read_Only_Maps
(Map_Type => Cursors.Container,
Key_Type => Cursors.Cursor,
others => <>);
with function "=" (K1, K2 : Getters.Element) return Boolean is <>;
with package Content is new Conts.Properties.SPARK.Content_Models
(Map_Type => Getters.Map,
Element_Type => Getters.Element_Type,
others => <>);
function Find
(Self : Cursors.Container;
E : Getters.Element)
return Cursors.Cursor
with SPARK_Mode,
Global => null,
Contract_Cases =>
((for all I in Content.First .. Content.Last (Content.Model (Self)) =>
Content.Get (Content.Model (Self), I) /= E) =>
Cursors."=" (Find'Result, Cursors.No_Element),
others => Cursors.Has_Element (Self, Find'Result)
and then Getters.Get (Self, Find'Result) = E);
--------------
-- Contains --
--------------
generic
with package Cursors is new Conts.Cursors.Forward_Cursors (<>);
with package Getters is new Conts.Properties.Read_Only_Maps
(Map_Type => Cursors.Container,
Key_Type => Cursors.Cursor,
others => <>);
with function "=" (K1, K2 : Getters.Element) return Boolean is <>;
with package Content is new Conts.Properties.SPARK.Content_Models
(Map_Type => Getters.Map,
Element_Type => Getters.Element_Type,
others => <>);
function Contains
(Self : Cursors.Container;
E : Getters.Element)
return Boolean
with SPARK_Mode,
Global => null,
Post => Contains'Result =
(for some I in Content.First .. Content.Last (Content.Model (Self)) =>
Content.Get (Content.Model (Self), I) = E);
------------
-- Equals --
------------
generic
with package Cursors is new Conts.Cursors.Random_Access_Cursors (<>);
with package Getters is new Conts.Properties.Read_Only_Maps
(Map_Type => Cursors.Container,
Key_Type => Cursors.Index_Type,
others => <>);
with function "=" (K1, K2 : Getters.Element) return Boolean is <>;
with package Content is new Conts.Properties.SPARK.Content_Models
(Map_Type => Getters.Map,
Element_Type => Getters.Element_Type,
others => <>);
function Equals (Left, Right : Cursors.Container) return Boolean
with SPARK_Mode,
Global => null,
Post => Equals'Result =
(Content."=" (Content.Last (Content.Model (Left)),
Content.Last (Content.Model (Right)))
and then
(for all I in Content.First .. Content.Last (Content.Model (Left)) =>
Content.Get (Content.Model (Left), I) =
Content.Get (Content.Model (Right), I)));
end Conts.Algorithms.SPARK;
|
sungyeon/drake | Ada | 288 | adb | with Ada.Strings.Wide_Wide_Hash;
function Ada.Strings.Wide_Wide_Bounded.Wide_Wide_Hash (
Key : Bounded.Bounded_Wide_Wide_String)
return Containers.Hash_Type is
begin
return Strings.Wide_Wide_Hash (Key.Element (1 .. Key.Length));
end Ada.Strings.Wide_Wide_Bounded.Wide_Wide_Hash;
|
aeszter/lox-spark | Ada | 426 | adb | separate (Exprs)
procedure Store (The_Expr : Expr'Class;
Result : out Expr_Handle;
Success : out Boolean) is
use Ada.Containers;
use Storage;
begin
if Length (Container) >= Container.Capacity then
Success := False;
Result := 1;
return;
end if;
Append (Container, The_Expr);
Result := Last_Index (Container);
Success := Is_Valid (Result);
end Store;
|
zhmu/ananas | Ada | 9,051 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 1 4 --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.Storage_Elements;
with System.Unsigned_Types;
package body System.Pack_14 is
subtype Bit_Order is System.Bit_Order;
Reverse_Bit_Order : constant Bit_Order :=
Bit_Order'Val (1 - Bit_Order'Pos (System.Default_Bit_Order));
subtype Ofs is System.Storage_Elements.Storage_Offset;
subtype Uns is System.Unsigned_Types.Unsigned;
subtype N07 is System.Unsigned_Types.Unsigned range 0 .. 7;
use type System.Storage_Elements.Storage_Offset;
use type System.Unsigned_Types.Unsigned;
type Cluster is record
E0, E1, E2, E3, E4, E5, E6, E7 : Bits_14;
end record;
for Cluster use record
E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1;
E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1;
E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1;
E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1;
E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1;
E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1;
E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1;
E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1;
end record;
for Cluster'Size use Bits * 8;
for Cluster'Alignment use Integer'Min (Standard'Maximum_Alignment,
1 +
1 * Boolean'Pos (Bits mod 2 = 0) +
2 * Boolean'Pos (Bits mod 4 = 0));
-- Use maximum possible alignment, given the bit field size, since this
-- will result in the most efficient code possible for the field.
type Cluster_Ref is access Cluster;
type Rev_Cluster is new Cluster
with Bit_Order => Reverse_Bit_Order,
Scalar_Storage_Order => Reverse_Bit_Order;
type Rev_Cluster_Ref is access Rev_Cluster;
-- The following declarations are for the case where the address
-- passed to GetU_14 or SetU_14 is not guaranteed to be aligned.
-- These routines are used when the packed array is itself a
-- component of a packed record, and therefore may not be aligned.
type ClusterU is new Cluster;
for ClusterU'Alignment use 1;
type ClusterU_Ref is access ClusterU;
type Rev_ClusterU is new ClusterU
with Bit_Order => Reverse_Bit_Order,
Scalar_Storage_Order => Reverse_Bit_Order;
type Rev_ClusterU_Ref is access Rev_ClusterU;
------------
-- Get_14 --
------------
function Get_14
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_14
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : Cluster_Ref with Address => A'Address, Import;
RC : Rev_Cluster_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => return RC.E0;
when 1 => return RC.E1;
when 2 => return RC.E2;
when 3 => return RC.E3;
when 4 => return RC.E4;
when 5 => return RC.E5;
when 6 => return RC.E6;
when 7 => return RC.E7;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => return C.E0;
when 1 => return C.E1;
when 2 => return C.E2;
when 3 => return C.E3;
when 4 => return C.E4;
when 5 => return C.E5;
when 6 => return C.E6;
when 7 => return C.E7;
end case;
end if;
end Get_14;
-------------
-- GetU_14 --
-------------
function GetU_14
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_14
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : ClusterU_Ref with Address => A'Address, Import;
RC : Rev_ClusterU_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => return RC.E0;
when 1 => return RC.E1;
when 2 => return RC.E2;
when 3 => return RC.E3;
when 4 => return RC.E4;
when 5 => return RC.E5;
when 6 => return RC.E6;
when 7 => return RC.E7;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => return C.E0;
when 1 => return C.E1;
when 2 => return C.E2;
when 3 => return C.E3;
when 4 => return C.E4;
when 5 => return C.E5;
when 6 => return C.E6;
when 7 => return C.E7;
end case;
end if;
end GetU_14;
------------
-- Set_14 --
------------
procedure Set_14
(Arr : System.Address;
N : Natural;
E : Bits_14;
Rev_SSO : Boolean)
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : Cluster_Ref with Address => A'Address, Import;
RC : Rev_Cluster_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => RC.E0 := E;
when 1 => RC.E1 := E;
when 2 => RC.E2 := E;
when 3 => RC.E3 := E;
when 4 => RC.E4 := E;
when 5 => RC.E5 := E;
when 6 => RC.E6 := E;
when 7 => RC.E7 := E;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => C.E0 := E;
when 1 => C.E1 := E;
when 2 => C.E2 := E;
when 3 => C.E3 := E;
when 4 => C.E4 := E;
when 5 => C.E5 := E;
when 6 => C.E6 := E;
when 7 => C.E7 := E;
end case;
end if;
end Set_14;
-------------
-- SetU_14 --
-------------
procedure SetU_14
(Arr : System.Address;
N : Natural;
E : Bits_14;
Rev_SSO : Boolean)
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : ClusterU_Ref with Address => A'Address, Import;
RC : Rev_ClusterU_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => RC.E0 := E;
when 1 => RC.E1 := E;
when 2 => RC.E2 := E;
when 3 => RC.E3 := E;
when 4 => RC.E4 := E;
when 5 => RC.E5 := E;
when 6 => RC.E6 := E;
when 7 => RC.E7 := E;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => C.E0 := E;
when 1 => C.E1 := E;
when 2 => C.E2 := E;
when 3 => C.E3 := E;
when 4 => C.E4 := E;
when 5 => C.E5 := E;
when 6 => C.E6 := E;
when 7 => C.E7 := E;
end case;
end if;
end SetU_14;
end System.Pack_14;
|
phendriksnl/goertzel | Ada | 2,370 | ads | -- @summary
-- Goertzel filter in pure Ada/Spark
--
-- @description
-- An implementation of the Goertzel filter.
-- It is designed with speed and portability in mind.
package Goertzel with
SPARK_Mode => On
is
-- The type for (most of the) values used. That is, samples, values
-- derived from samples, frequencies and the like.
type Value is digits 8;
-- Maximum number of samples handled
Max_Samples : constant := 1000;
-- The type for the range of possible number of samples
type Sample_Count is new Integer range 1..Max_Samples;
-- Helper for remembering the last two filter "running values" for
-- the Geortzel filter implemented as an IIR filter.
type Vn2 is
record
-- The previous filter value
M1: Value;
-- The value before that
M2: Value;
end record;
-- Holds data for a Goertzel filter
type Filter is
record
-- The frequency of the filter
F: Value;
-- The sampling frequency
Fs: Value;
-- The Goertzel coefficient, calulcated
-- from the above mentioned frequencies
Koef: Value;
-- The running values of the Goertzel filter calculation.
Vn: Vn2;
end record;
-- An array of samples to process
type Samples is array (Positive range <>) of Value;
-- Makes a Goertzel filter for the given parameters
-- @param F The frequency of the filter
-- @param Fs The sampling frequency of the samples to process
-- @return the filter made
function Make(F, Fs: Value) return Filter
with
Pre => (Fs < 100_000.0) and (F < Fs / 2.0) and (Fs > 0.0);
-- Resets the filter so that we can start it over again.
-- @param Flt The filter to reset
procedure Reset(Flt: in out Filter);
-- Process the samples using the given filter
-- @param Flt The filter to use
-- @param Sample The Samples to process
-- @param Rslt The resulting power of the signal at the filter frequency
procedure Process(Flt: in out Filter; Sample: Samples; Rslt: out Value)
with
Pre => (Sample'Length in Sample_Count'Range);
-- Returns the dBm of the given power of a signal
-- @param Power The power to convert to dBm
-- @result The calculated dBm
function DBm(Power: Value) return Value
with
Pre => Power > 0.0;
end Goertzel;
|
reznikmm/matreshka | Ada | 14,187 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
-- GNAT: enforce generation of preinitialized data section instead of
-- generation of elaboration code.
package Matreshka.Internals.Unicode.Ucd.Core_01D4 is
pragma Preelaborate;
Group_01D4 : aliased constant Core_Second_Stage
:= (16#1A# .. 16#21# => -- 01D41A .. 01D421
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#22# .. 16#23# => -- 01D422 .. 01D423
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Soft_Dotted
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#24# .. 16#33# => -- 01D424 .. 01D433
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#4E# .. 16#54# => -- 01D44E .. 01D454
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#55# => -- 01D455
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#56# .. 16#57# => -- 01D456 .. 01D457
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Soft_Dotted
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#58# .. 16#67# => -- 01D458 .. 01D467
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#82# .. 16#89# => -- 01D482 .. 01D489
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8A# .. 16#8B# => -- 01D48A .. 01D48B
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Soft_Dotted
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8C# .. 16#9B# => -- 01D48C .. 01D49B
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#9D# => -- 01D49D
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#A0# .. 16#A1# => -- 01D4A0 .. 01D4A1
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#A3# .. 16#A4# => -- 01D4A3 .. 01D4A4
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#A7# .. 16#A8# => -- 01D4A7 .. 01D4A8
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#AD# => -- 01D4AD
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#B6# .. 16#B9# => -- 01D4B6 .. 01D4B9
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#BA# => -- 01D4BA
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#BB# => -- 01D4BB
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#BC# => -- 01D4BC
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#BD# => -- 01D4BD
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#BE# .. 16#BF# => -- 01D4BE .. 01D4BF
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Soft_Dotted
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#C0# .. 16#C3# => -- 01D4C0 .. 01D4C3
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#C4# => -- 01D4C4
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#C5# .. 16#CF# => -- 01D4C5 .. 01D4CF
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#EA# .. 16#F1# => -- 01D4EA .. 01D4F1
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#F2# .. 16#F3# => -- 01D4F2 .. 01D4F3
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Soft_Dotted
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#F4# .. 16#FF# => -- 01D4F4 .. 01D4FF
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
others =>
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Math
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_01D4;
|
reznikmm/matreshka | Ada | 4,679 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Citation_Style_Name_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Citation_Style_Name_Attribute_Node is
begin
return Self : Text_Citation_Style_Name_Attribute_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Citation_Style_Name_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Citation_Style_Name_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Citation_Style_Name_Attribute,
Text_Citation_Style_Name_Attribute_Node'Tag);
end Matreshka.ODF_Text.Citation_Style_Name_Attributes;
|
Tim-Tom/project-euler | Ada | 174 | adb | with Ada.Text_IO;
package body Problem_66 is
package IO renames Ada.Text_IO;
procedure Solve is
begin
IO.Put_Line("The Answer");
end Solve;
end Problem_66;
|
pat-rogers/LmcpGen | Ada | 17,121 | adb | with Conversion_Equality_Lemmas; use Conversion_Equality_Lemmas;
with AVTAS.LMCP.ByteBuffers.Copying; use AVTAS.LMCP.ByteBuffers.Copying;
package body AVTAS.LMCP.ByteBuffers with
SPARK_Mode
is
pragma Unevaluated_Use_Of_Old (Allow);
---------------
-- Raw_Bytes --
---------------
function Raw_Bytes (This : ByteBuffer'Class) return String is
Length : constant Natural := Natural (Index'Min (Max_String_Length, This.Highest_Write_Pos));
Result : String (1 .. Length);
begin
for K in Result'Range loop
Result (K) := Character'Val (This.Content (Index (K - 1)));
end loop;
return Result;
end Raw_Bytes;
------------
-- Rewind --
------------
procedure Rewind (This : in out ByteBuffer'Class) is
begin
This.Position := 0;
end Rewind;
-----------
-- Reset --
-----------
procedure Reset (This : in out ByteBuffer'Class) is
begin
Rewind (This);
This.Highest_Write_Pos := 0;
end Reset;
--------------
-- Checksum --
--------------
function Checksum (This : ByteBuffer'Class; Last : Index) return UInt32 is
Result : UInt32 := 0;
begin
for K in Index range This.Content'First .. Last loop
Result := Result + UInt32 (This.Content (K));
pragma Annotate (GNATProve,
Intentional,
"overflow check might fail",
"Wrap-around semantics are required in this function.");
end loop;
return Result;
end Checksum;
--------------
-- Get_Byte --
--------------
procedure Get_Byte (This : in out ByteBuffer'Class; Value : out Byte) is
begin
Value := This.Content (This.Position);
This.Position := This.Position + 1;
end Get_Byte;
-----------------
-- Get_Boolean --
-----------------
procedure Get_Boolean (This : in out ByteBuffer'Class; Value : out Boolean) is
begin
Value := This.Content (This.Position) /= 0;
This.Position := This.Position + 1;
end Get_Boolean;
---------------
-- Get_Int16 --
---------------
procedure Get_Int16 (This : in out ByteBuffer'Class; Value : out Int16) is
procedure Lemma_Two_Bytes_Equal_Int16 is new Lemma_Conversion_Equality
(Numeric => Int16,
Byte => Byte,
Index => Index,
Bytes => Byte_Array,
To_Numeric => As_Int16,
To_Bytes => As_Two_Bytes);
begin
Value := As_Int16 (This.Content (This.Position .. This.Position + 1));
Lemma_Two_Bytes_Equal_Int16
(This_Numeric => Value,
These_Bytes => This.Content (This.Position .. This.Position + 1));
This.Position := This.Position + 2;
end Get_Int16;
----------------
-- Get_UInt16 --
----------------
procedure Get_UInt16 (This : in out ByteBuffer'Class; Value : out UInt16) is
procedure Lemma_Two_Bytes_Equal_UInt16 is new Lemma_Conversion_Equality
(Numeric => UInt16,
Byte => Byte,
Index => Index,
Bytes => Byte_Array,
To_Numeric => As_UInt16,
To_Bytes => As_Two_Bytes);
begin
Value := As_UInt16 (This.Content (This.Position .. This.Position + 1));
Lemma_Two_Bytes_Equal_UInt16
(This_Numeric => Value,
These_Bytes => This.Content (This.Position .. This.Position + 1));
This.Position := This.Position + 2;
end Get_UInt16;
---------------
-- Get_Int32 --
---------------
procedure Get_Int32 (This : in out ByteBuffer'Class; Value : out Int32) is
procedure Lemma_Four_Bytes_Equal_Int32 is new Lemma_Conversion_Equality
(Numeric => Int32,
Byte => Byte,
Index => Index,
Bytes => Byte_Array,
To_Numeric => As_Int32,
To_Bytes => As_Four_Bytes);
begin
Value := As_Int32 (This.Content (This.Position .. This.Position + 3));
Lemma_Four_Bytes_Equal_Int32
(This_Numeric => Value,
These_Bytes => This.Content (This.Position .. This.Position + 3));
This.Position := This.Position + 4;
end Get_Int32;
----------------
-- Get_UInt32 --
----------------
procedure Get_UInt32 (This : in out ByteBuffer'Class; Value : out UInt32) is
procedure Lemma_Four_Bytes_Equal_UInt32 is new Lemma_Conversion_Equality
(Numeric => UInt32,
Byte => Byte,
Index => Index,
Bytes => Byte_Array,
To_Numeric => As_UInt32,
To_Bytes => As_Four_Bytes);
begin
Value := As_UInt32 (This.Content (This.Position .. This.Position + 3));
Lemma_Four_Bytes_Equal_UInt32
(This_Numeric => Value,
These_Bytes => This.Content (This.Position .. This.Position + 3));
This.Position := This.Position + 4;
end Get_UInt32;
----------------
-- Get_UInt32 --
----------------
procedure Get_UInt32
(This : ByteBuffer'Class;
Value : out UInt32;
First : Index)
is
procedure Lemma_Four_Bytes_Equal_UInt32 is new Lemma_Conversion_Equality
(Numeric => UInt32,
Byte => Byte,
Index => Index,
Bytes => Byte_Array,
To_Numeric => As_UInt32,
To_Bytes => As_Four_Bytes);
begin
Value := As_UInt32 (This.Content (First .. First + 3));
Lemma_Four_Bytes_Equal_UInt32
(This_Numeric => Value,
These_Bytes => This.Content (First .. First + 3));
end Get_UInt32;
---------------
-- Get_Int64 --
---------------
procedure Get_Int64 (This : in out ByteBuffer'Class; Value : out Int64) is
procedure Lemma_Eight_Bytes_Equal_Int64 is new Lemma_Conversion_Equality
(Numeric => Int64,
Byte => Byte,
Index => Index,
Bytes => Byte_Array,
To_Numeric => As_Int64,
To_Bytes => As_Eight_Bytes);
begin
Value := As_Int64 (This.Content (This.Position .. This.Position + 7));
Lemma_Eight_Bytes_Equal_Int64
(This_Numeric => Value,
These_Bytes => This.Content (This.Position .. This.Position + 7));
This.Position := This.Position + 8;
end Get_Int64;
----------------
-- Get_UInt64 --
----------------
procedure Get_UInt64 (This : in out ByteBuffer'Class; Value : out UInt64) is
procedure Lemma_Eight_Bytes_Equal_UInt64 is new Lemma_Conversion_Equality
(Numeric => UInt64,
Byte => Byte,
Index => Index,
Bytes => Byte_Array,
To_Numeric => As_UInt64,
To_Bytes => As_Eight_Bytes);
begin
Value := As_UInt64 (This.Content (This.Position .. This.Position + 7));
Lemma_Eight_Bytes_Equal_UInt64
(This_Numeric => Value,
These_Bytes => This.Content (This.Position .. This.Position + 7));
This.Position := This.Position + 8;
end Get_UInt64;
---------------
-- Get_Real32 --
---------------
procedure Get_Real32 (This : in out ByteBuffer'Class; Value : out Real32) is
function To_Real32 is new Ada.Unchecked_Conversion (Source => UInt32, Target => Real32);
pragma Annotate
(GNATProve,
Intentional,
"type is unsuitable as a target for unchecked conversion",
"Per the C++ implementation, we assume the same or compatible floating-point" &
" format on each participating machine");
-- SPARK does not assume that the UC will produce valid bit
-- representations for floating-point values.
function As_Real32 (Value : Four_Bytes) return Real32 is
(To_Real32 (As_UInt32 (Value)));
procedure Lemma_Four_Bytes_Equal_Real32 is new Lemma_Conversion_Equality
(Numeric => Real32,
Byte => Byte,
Index => Index,
Bytes => Byte_Array,
To_Numeric => As_Real32,
To_Bytes => As_Four_Bytes);
begin
-- We get a suitably-sized integer value and then convert to the required
-- floating-point type, to ensure the compiler does not see the byte
-- swapping (in the As_UInt32 instance) as producing an invalid
-- floating-point value.
Value := As_Real32 (This.Content (This.Position .. This.Position + 3));
Lemma_Four_Bytes_Equal_Real32
(This_Numeric => Value,
These_Bytes => This.Content (This.Position .. This.Position + 3));
This.Position := This.Position + 4;
end Get_Real32;
----------------
-- Get_Real64 --
----------------
procedure Get_Real64 (This : in out ByteBuffer'Class; Value : out Real64) is
function To_Real64 is new Ada.Unchecked_Conversion (Source => UInt64, Target => Real64);
pragma Annotate
(GNATProve,
Intentional,
"type is unsuitable as a target for unchecked conversion",
"Per the C++ implementation, we assume the same or compatible floating-point" &
" format on each participating machine");
-- SPARK does not assume that the UC will produce valid bit
-- representations for floating-point values.
function As_Real64 (Value : Eight_Bytes) return Real64 is
(To_Real64 (As_UInt64 (Value)));
procedure Lemma_Eight_Bytes_Equal_Real64 is new Lemma_Conversion_Equality
(Numeric => Real64,
Byte => Byte,
Index => Index,
Bytes => Byte_Array,
To_Numeric => As_Real64,
To_Bytes => As_Eight_Bytes);
begin
-- We get a suitably-sized integer value and then convert to the required
-- floating-point type, to ensure the compiler does not see the byte
-- swapping (in the As_UInt64 instance) as producing an invalid
-- floating-point value.
Value := As_Real64 (This.Content (This.Position .. This.Position + 7));
Lemma_Eight_Bytes_Equal_Real64
(This_Numeric => Value,
These_Bytes => This.Content (This.Position .. This.Position + 7));
This.Position := This.Position + 8;
end Get_Real64;
----------------
-- Get_String --
----------------
procedure Get_String
(This : in out ByteBuffer'Class;
Value : in out String;
Last : out Integer;
Stored_Length : out UInt32)
is
Result : System.Address with Unreferenced;
begin
This.Get_UInt16 (UInt16 (Stored_Length));
if Index (Stored_Length) > Remaining (This) then
-- We don't have that many bytes logically remaining in the buffer
-- to be consumed. Some corruption of the message has occurred.
Last := -1;
elsif Stored_Length > Value'Length then
-- The buffer has more string bytes than the arg Value can hold.
-- Silly client. Nothing wrong with the buffer though.
Last := -1;
elsif This.Highest_Write_Pos + Index (Stored_Length) > This.Capacity or else
This.Position + Index (Stored_Length) > This.Highest_Write_Pos
then
Last := -1;
elsif Stored_Length = 0 then
-- This is a normal case of an empty string in the buffer.
Last := Value'First - 1;
else
-- The normal, non-zero length case, and the client has passed a
-- sufficiently large string arg.
Copy_Buffer_To_String (This, Index (Stored_Length), Value);
Last := Value'First + (Positive (Stored_Length) - 1);
end if;
end Get_String;
--------------------------
-- Get_Unbounded_String --
--------------------------
procedure Get_Unbounded_String
(This : in out ByteBuffer'Class;
Value : out Unbounded_String;
Stored_Length : out UInt32)
is
begin
This.Get_UInt16 (UInt16 (Stored_Length));
if Stored_Length > Max_String_Length or else
Index (Stored_Length) > Remaining (This) or else
This.Position + Index (Stored_length) > This.Highest_Write_Pos
then
Value := To_Unbounded_String ("Corrupted buffer");
elsif Stored_Length = 0 then
Value := Null_Unbounded_String;
else
Copy_Buffer_To_Unbounded_String (This, Index (Stored_Length), Value);
end if;
end Get_Unbounded_String;
--------------
-- Put_Byte --
--------------
procedure Put_Byte (This : in out ByteBuffer'Class; Value : Byte) is
begin
This.Content (This.Position) := Value;
This.Highest_Write_Pos := This.Highest_Write_Pos + 1;
This.Position := This.Position + 1;
end Put_Byte;
-----------------
-- Put_Boolean --
-----------------
procedure Put_Boolean (This : in out ByteBuffer'Class; Value : Boolean) is
begin
This.Content (This.Position) := Boolean'Pos (Value);
This.Highest_Write_Pos := This.Highest_Write_Pos + 1;
This.Position := This.Position + 1;
end Put_Boolean;
---------------
-- Put_Int16 --
---------------
procedure Put_Int16 (This : in out ByteBuffer'Class; Value : Int16) is
begin
This.Content (This.Position .. This.Position + 1) := As_Two_Bytes (Value);
This.Highest_Write_Pos := This.Highest_Write_Pos + 2;
This.Position := This.Position + 2;
end Put_Int16;
----------------
-- Put_UInt16 --
----------------
procedure Put_UInt16 (This : in out ByteBuffer'Class; Value : UInt16) is
begin
This.Content (This.Position .. This.Position + 1) := As_Two_Bytes (Value);
This.Highest_Write_Pos := This.Highest_Write_Pos + 2;
This.Position := This.Position + 2;
end Put_UInt16;
---------------
-- Put_Int32 --
---------------
procedure Put_Int32 (This : in out ByteBuffer'Class; Value : Int32) is
begin
This.Content (This.Position .. This.Position + 3) := As_Four_Bytes (Value);
This.Highest_Write_Pos := This.Highest_Write_Pos + 4;
This.Position := This.Position + 4;
end Put_Int32;
----------------
-- Put_UInt32 --
----------------
procedure Put_UInt32 (This : in out ByteBuffer'Class; Value : UInt32) is
begin
This.Content (This.Position .. This.Position + 3) := As_Four_Bytes (Value);
This.Highest_Write_Pos := This.Highest_Write_Pos + 4;
This.Position := This.Position + 4;
end Put_UInt32;
---------------
-- Put_Int64 --
---------------
procedure Put_Int64 (This : in out ByteBuffer'Class; Value : Int64) is
begin
This.Content (This.Position .. This.Position + 7) := As_Eight_Bytes (Value);
This.Highest_Write_Pos := This.Highest_Write_Pos + 8;
This.Position := This.Position + 8;
end Put_Int64;
----------------
-- Put_UInt64 --
----------------
procedure Put_UInt64 (This : in out ByteBuffer'Class; Value : UInt64) is
begin
This.Content (This.Position .. This.Position + 7) := As_Eight_Bytes (Value);
This.Highest_Write_Pos := This.Highest_Write_Pos + 8;
This.Position := This.Position + 8;
end Put_UInt64;
----------------
-- Put_Real32 --
----------------
procedure Put_Real32 (This : in out ByteBuffer'Class; Value : Real32) is
begin
This.Content (This.Position .. This.Position + 3) := As_Four_Bytes (Value);
This.Highest_Write_Pos := This.Highest_Write_Pos + 4;
This.Position := This.Position + 4;
end Put_Real32;
----------------
-- Put_Real64 --
----------------
procedure Put_Real64 (This : in out ByteBuffer'Class; Value : Real64) is
begin
This.Content (This.Position .. This.Position + 7) := As_Eight_Bytes (Value);
This.Highest_Write_Pos := This.Highest_Write_Pos + 8;
This.Position := This.Position + 8;
end Put_Real64;
----------------
-- Put_String --
----------------
procedure Put_String (This : in out ByteBuffer'Class; Value : String) is
begin
-- We need to insert the length in any case, including when zero, so that
-- the deserialization routine will have a length to read. That routine
-- will then read that many bytes, so a zero length will work on that
-- side.
This.Put_UInt16 (Value'Length);
if Value'Length > 0 then
This.Put_Raw_Bytes (Value);
end if;
end Put_String;
-------------------
-- Put_Raw_Bytes --
-------------------
procedure Put_Raw_Bytes (This : in out ByteBuffer'Class; Value : String) is
begin
if Value'Length > 0 then
Copy_String_To_Buffer (This, From => Value);
end if;
end Put_Raw_Bytes;
-------------------
-- Put_Raw_Bytes --
-------------------
procedure Put_Raw_Bytes (This : in out ByteBuffer'Class; Value : Byte_Array) is
begin
if Value'Length > 0 then
Copy_Bytes_To_Buffer (This, From => Value);
end if;
end Put_Raw_Bytes;
--------------------------
-- Put_Unbounded_String --
--------------------------
procedure Put_Unbounded_String (This : in out ByteBuffer'Class; Value : Unbounded_String) is
begin
This.Put_String (To_String (Value));
end Put_Unbounded_String;
end AVTAS.LMCP.ByteBuffers;
|
zhmu/ananas | Ada | 3,530 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . T E X T _ I O . C O M P L E X _ A U X --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, 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 contains the routines for Ada.Text_IO.Complex_IO that are
-- shared among separate instantiations of this package. The routines in this
-- package are identical semantically to those in Complex_IO, except that the
-- generic parameter Complex has been replaced by separate real and imaginary
-- parameters, and default parameters have been removed because they are
-- supplied explicitly by the calls from within the generic template.
with Ada.Text_IO.Float_Aux;
private generic
type Num is digits <>;
with package Aux is new Ada.Text_IO.Float_Aux (Num, <>, <>);
package Ada.Text_IO.Complex_Aux is
procedure Get
(File : File_Type;
ItemR : out Num;
ItemI : out Num;
Width : Field);
procedure Put
(File : File_Type;
ItemR : Num;
ItemI : Num;
Fore : Field;
Aft : Field;
Exp : Field);
procedure Gets
(From : String;
ItemR : out Num;
ItemI : out Num;
Last : out Positive);
procedure Puts
(To : out String;
ItemR : Num;
ItemI : Num;
Aft : Field;
Exp : Field);
end Ada.Text_IO.Complex_Aux;
|
zhmu/ananas | Ada | 99 | adb | -- { dg-do compile }
package body Generic_Inst9 is
procedure Dummy is null;
end Generic_Inst9;
|
reznikmm/matreshka | Ada | 3,961 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 ODF.DOM.Draw_Green_Attributes;
package Matreshka.ODF_Draw.Green_Attributes is
type Draw_Green_Attribute_Node is
new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node
and ODF.DOM.Draw_Green_Attributes.ODF_Draw_Green_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Green_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Draw_Green_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Draw.Green_Attributes;
|
reznikmm/matreshka | Ada | 4,558 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Svg.Stemv_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Svg_Stemv_Attribute_Node is
begin
return Self : Svg_Stemv_Attribute_Node do
Matreshka.ODF_Svg.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Svg_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Svg_Stemv_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Stemv_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Svg_URI,
Matreshka.ODF_String_Constants.Stemv_Attribute,
Svg_Stemv_Attribute_Node'Tag);
end Matreshka.ODF_Svg.Stemv_Attributes;
|
zhmu/ananas | Ada | 165 | ads | package Tagged2 is
type Device;
procedure Get_Parent
(DeviceX : Device;
Parent : out Device);
type Device is tagged null record;
end Tagged2;
|
tum-ei-rcs/StratoX | Ada | 29,064 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . L I B M --
-- --
-- B o d y --
-- --
-- Copyright (C) 2014-2015, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is the Ada Cert Math specific version of s-libm.adb
-- When Cody and Waite implementation is cited, it refers to the
-- Software Manual for the Elementary Functions by William J. Cody, Jr.
-- and William Waite, published by Prentice-Hall Series in Computational
-- Mathematics. Copyright 1980. ISBN 0-13-822064-6.
-- When Hart implementation is cited, it refers to
-- "Computer Approximations" by John F. Hart, published by Krieger.
-- Copyright 1968, Reprinted 1978 w/ corrections. ISBN 0-88275-642-7.
with Ada.Numerics; use Ada.Numerics;
package body System.Libm is
type Unsigned_64 is mod 2**64;
generic
type T is private;
with function Multiply_Add (X, Y, Z : T) return T is <>;
-- The Multiply_Add function returns the value of X * Y + Z, ideally
-- (but not necessarily) using a wider intermediate type, or a fused
-- multiply-add operation with only a single rounding. They are used
-- for evaluating polynomials.
package Generic_Polynomials is
type Polynomial is array (Natural range <>) of T;
-- A value P of type PolynomialRepresents the polynomial
-- P (X) = P_0 + P_1 * X + ... + P_(n-1) * X**(n-1) + P_n * X**n,
--
-- where n = P'Length - 1, P_0 is P (P'First) and P_n is P (P'Last)
-- P (X) = P_0 + X * (P_1 + X * (P_2 + X * (... + X * P_n)))
function Compute_Horner (P : Polynomial; X : T) return T with Inline;
-- Computes the polynomial P using the Horner scheme:
-- P (X) = P_0 + X * (P_1 + X * (P_2 + X * (... + X * P_n)))
end Generic_Polynomials;
------------------------
-- Generic_Polynomial --
------------------------
package body Generic_Polynomials is
--------------------
-- Compute_Horner --
---------------------
function Compute_Horner (P : Polynomial; X : T) return T is
Result : T := P (P'Last);
begin
for P_j of reverse P (P'First .. P'Last - 1) loop
Result := Multiply_Add (Result, X, P_j);
end loop;
return Result;
end Compute_Horner;
end Generic_Polynomials;
----------------------------------
-- Generic_Float_Approximations --
----------------------------------
package body Generic_Approximations is
function Multiply_Add (X, Y, Z : T) return T is (X * Y + Z);
package Float_Polynomials is new Generic_Polynomials (T);
use Float_Polynomials;
-----------------
-- Approx_Asin --
-----------------
function Approx_Asin (X : T) return T is
P : T;
Q : T;
begin
if Mantissa <= 24 then
declare
-- Approximation MRE = 6.0128E-9
P1 : constant T := Exact (0.93393_5835);
P2 : constant T := Exact (-0.50440_0557);
Q0 : constant T := Exact (5.6036_3004);
Q1 : constant T := Exact (-5.5484_6723);
begin
P := Compute_Horner ((P1, P2), X);
Q := Compute_Horner ((Q0, Q1 + X), X);
end;
else
declare
-- Approximation MRE = 2.0975E-18
P1 : constant T := Exact (-0.27368_49452_41642_55994E+2);
P2 : constant T := Exact (+0.57208_22787_78917_31407E+2);
P3 : constant T := Exact (-0.39688_86299_75048_77339E+2);
P4 : constant T := Exact (+0.10152_52223_38064_63645E+2);
P5 : constant T := Exact (-0.69674_57344_73506_46411);
Q0 : constant T := Exact (-0.16421_09671_44985_60795E+3);
Q1 : constant T := Exact (+0.41714_43024_82604_12556E+3);
Q2 : constant T := Exact (-0.38186_30336_17501_49284E+3);
Q3 : constant T := Exact (+0.15095_27084_10306_04719E+3);
Q4 : constant T := Exact (-0.23823_85915_36702_38830E+2);
begin
P := Compute_Horner ((P1, P2, P3, P4, P5), X);
Q := Compute_Horner ((Q0, Q1, Q2, Q3, Q4 + X), X);
end;
end if;
return X * P / Q;
end Approx_Asin;
-----------------
-- Approx_Atan --
-----------------
function Approx_Atan (X : T) return T is
G : constant T := X * X;
P, Q : T;
begin
if Mantissa <= 24 then
declare
-- Approximation MRE = 3.2002E-9
P0 : constant T := Exact (-0.47083_25141);
P1 : constant T := Exact (-0.50909_58253E-1);
Q0 : constant T := Exact (0.14125_00740E1);
begin
P := Compute_Horner ((P0, P1), G);
Q := Q0 + G;
end;
else
declare
-- Approximation MRE = 1.8154E-18
P0 : constant T := Exact (-0.13688_76889_41919_26929E2);
P1 : constant T := Exact (-0.20505_85519_58616_51981E2);
P2 : constant T := Exact (-0.84946_24035_13206_83534E1);
P3 : constant T := Exact (-0.83758_29936_81500_59274);
Q0 : constant T := Exact (0.41066_30668_25757_81263E2);
Q1 : constant T := Exact (0.86157_34959_71302_42515E2);
Q2 : constant T := Exact (0.59578_43614_25973_44465E2);
Q3 : constant T := Exact (0.15024_00116_00285_76121E2);
begin
P := Compute_Horner ((P0, P1, P2, P3), G);
Q := Compute_Horner ((Q0, Q1, Q2, Q3 + G), G);
end;
end if;
return Multiply_Add (X, (G * P / Q), X);
end Approx_Atan;
function Approx_Cos (X : T) return T is
-- Note: The reference tables named below for cosine lists
-- constants for cos((pi/4) * x) ~= P (x^2), in order to get
-- cos (x), the constants have been adjusted by division of
-- appropriate powers of (pi/4) ^ n, for n 0,2,4,6 etc.
Cos_P : constant Polynomial :=
(if Mantissa <= 24
then
-- Hart's constants : #COS 3821# (p. 209)
-- Approximation MRE = 8.1948E-9 ???
(0 => Exact (0.99999_99999),
1 => Exact (-0.49999_99957),
2 => Exact (0.41666_61323E-1),
3 => Exact (-0.13888_52915E-2),
4 => Exact (0.24372_67909E-4))
elsif Mantissa <= 53
then
-- Hart's constants : #COS 3824# (p. 209)
-- Approximation MRE = 1.2548E-18
(0 => Exact (0.99999_99999_99999_99995),
1 => Exact (-0.49999_99999_99999_99279),
2 => Exact (+0.04166_66666_66666_430254),
3 => Exact (-0.13888_88888_88589_60433E-2),
4 => Exact (+0.24801_58728_28994_63022E-4),
5 => Exact (-0.27557_31286_56960_82219E-6),
6 => Exact (+0.20875_55514_56778_82872E-8),
7 => Exact (-0.11352_12320_57839_39582E-10))
else
-- Hart's constants : #COS 3825# (p. 209-210)
-- Approximation MRE = ???
(0 => Exact (+1.0),
1 => Exact (-0.49999_99999_99999_99994_57899),
2 => Exact (+0.41666_66666_66666_66467_89627E-1),
3 => Exact (-0.13888_88888_88888_57508_03579E-2),
4 => Exact (+0.24801_58730_15616_31808_80662E-4),
5 => Exact (-0.27557_31921_21557_14660_22522E-6),
6 => Exact (+0.20876_75377_75228_35357_18906E-8),
7 => Exact (-0.11470_23678_56189_18819_10735E-10),
8 => Exact (+0.47358_93914_72413_21156_01793E-13)));
begin
return Compute_Horner (Cos_P, X * X);
end Approx_Cos;
----------------
-- Approx_Exp --
----------------
function Approx_Exp (X : T) return T is
-- Cody and Waite implementation (page 69)
Exp_P : constant Polynomial :=
(if Mantissa <= 24
then -- Approximation MRE = 8.1529E-10
(0 => Exact (0.24999_99995_0),
1 => Exact (0.41602_88626_0E-2))
elsif Mantissa <= 53
then -- Approximation MRE = 1.0259E-17
(0 => Exact (0.24999_99999_99999_993),
1 => Exact (0.69436_00015_11792_852E-2),
2 => Exact (0.16520_33002_68279_130E-4))
else
(0 => Exact (0.25),
1 => Exact (0.75753_18015_94227_76666E-2),
2 => Exact (0.31555_19276_56846_46356E-4)));
Exp_Q : constant Polynomial :=
(if Mantissa <= 24
then
(0 => Exact (0.5),
1 => Exact (0.49987_17877_8E-1))
elsif Mantissa <= 53
then
(0 => Exact (0.5),
1 => Exact (0.55553_86669_69001_188E-1),
2 => Exact (0.49586_28849_05441_294E-3))
else
(0 => Exact (0.5),
1 => Exact (0.56817_30269_85512_21787E-1),
2 => Exact (0.63121_89437_43985_03557E-3),
3 => Exact (0.75104_02839_98700_46114E-6)));
G : constant T := X * X;
P : T;
Q : T;
begin
P := Compute_Horner (Exp_P, G);
Q := Compute_Horner (Exp_Q, G);
return Exact (2.0) * Multiply_Add (X, P / (Multiply_Add (-X, P, Q)),
Exact (0.5));
end Approx_Exp;
----------------
-- Approx_Log --
----------------
function Approx_Log (X : T) return T is
Log_P : constant Polynomial :=
(if Mantissa <= 24
then -- Approximation MRE = 1.0368E-10
(0 => Exact (-0.46490_62303_464),
1 => Exact (0.013600_95468_621))
else -- Approximation MRE = 4.7849E-19
(0 => Exact (-0.64124_94342_37455_81147E+2),
1 => Exact (0.16383_94356_30215_34222E+2),
2 => Exact (-0.78956_11288_74912_57267)));
Log_Q : constant Polynomial :=
(if Mantissa <= 24
then
(0 => Exact (-5.5788_73750_242),
1 => Exact (1.0))
else
(0 => Exact (-0.76949_93210_84948_79777E+3),
1 => Exact (0.31203_22209_19245_32844E+3),
2 => Exact (-0.35667_97773_90346_46171E+2),
3 => Exact (1.0)));
G : T;
P : T;
Q : T;
ZNum, ZDen, Z : T;
begin
ZNum := (X + Exact (-0.5)) + Exact (-0.5);
ZDen := X * Exact (0.5) + Exact (0.5);
Z := ZNum / ZDen;
G := Z * Z;
P := Compute_Horner (Log_P, G);
Q := Compute_Horner (Log_Q, G);
return Multiply_Add (Z, G * (P / Q), Z);
end Approx_Log;
----------------------
-- Approx_Power Log --
----------------------
function Approx_Power_Log (X : T) return T is
Power_Log_P : constant Polynomial :=
(if Mantissa <= 24
then -- Approximation MRE = 7.9529E-4
(1 => Exact (0.83357_541E-1))
else -- Approximation MRE = 8.7973E-8
(1 => Exact (0.83333_33333_33332_11405E-1),
2 => Exact (0.12500_00000_05037_99174E-1),
3 => Exact (0.22321_42128_59242_58967E-2),
4 => Exact (0.43445_77567_21631_19635E-3)));
K : constant T := Exact (0.44269_50408_88963_40736);
G : constant T := X * X;
P : T;
begin
P := Compute_Horner (Power_Log_P, G);
P := (P * G) * X;
P := Multiply_Add (P, K, P);
return Multiply_Add (X, K, P) + X;
end Approx_Power_Log;
-----------------
-- Approx_Exp2 --
-----------------
function Approx_Exp2 (X : T) return T is
Exp2_P : constant Polynomial :=
(if Mantissa > 24
then -- Approximation MRE = 1.7418E-17
(1 => Exact (0.69314_71805_59945_29629),
2 => Exact (0.24022_65069_59095_37056),
3 => Exact (0.55504_10866_40855_95326E-1),
4 => Exact (0.96181_29059_51724_16964E-2),
5 => Exact (0.13333_54131_35857_84703E-2),
6 => Exact (0.15400_29044_09897_64601E-3),
7 => Exact (0.14928_85268_05956_08186E-4))
else -- Approximation MRE = 3.3642E-9
(1 => Exact (0.69314_675),
2 => Exact (0.24018_510),
3 => Exact (0.54360_383E-1)));
begin
return Exact (1.0) + Compute_Horner (Exp2_P, X) * X;
end Approx_Exp2;
----------------
-- Approx_Sin --
----------------
function Approx_Sin (X : T) return T is
-- Note: The reference tables named below for sine lists constants
-- for sin((pi/4) * x) ~= x * P (x^2), in order to get sin (x),
-- the constants have been adjusted by division of appropriate
-- powers of (pi/4) ^ n, for n 1,3,5, etc.
Sin_P : constant Polynomial :=
(if Mantissa <= 24
then
-- Hart's constants: #SIN 3040# (p. 199)
(1 => Exact (-0.16666_65022),
2 => Exact (0.83320_16396E-2),
3 => Exact (-0.19501_81843E-3))
else
-- Hart's constants: #SIN 3044# (p. 199)
-- Approximation MRE = 2.4262E-18 ???
(1 => Exact (-0.16666_66666_66666_66628),
2 => Exact (0.83333_33333_33332_03335E-2),
3 => Exact (-0.19841_26984_12531_05860E-3),
4 => Exact (0.27557_31921_33901_68712E-5),
5 => Exact (-0.25052_10473_82673_30950E-7),
6 => Exact (0.16058_34762_32246_06553E-9),
7 => Exact (-0.75778_67884_01271_15607E-12)));
Sqrt_Epsilon_LLF : constant Long_Long_Float :=
Sqrt_2 ** (1 - Long_Long_Float'Machine_Mantissa);
G : constant T := X * X;
begin
if abs X <= Exact (Sqrt_Epsilon_LLF) then
return X;
end if;
return Multiply_Add (X, Compute_Horner (Sin_P, G) * G, X);
end Approx_Sin;
-----------------
-- Approx_Sinh --
-----------------
function Approx_Sinh (X : T) return T is
Sinh_P : constant Polynomial :=
(if Mantissa <= 24
then -- Approximation MRE = 2.6841E-8
(0 => Exact (-0.71379_3159E1),
1 => Exact (-0.19033_3300))
else -- Approximation MRE = 4.6429E-18
(0 => Exact (-0.35181_28343_01771_17881E6),
1 => Exact (-0.11563_52119_68517_68270E5),
2 => Exact (-0.16375_79820_26307_51372E3),
3 => Exact (-0.78966_12741_73570_99479)));
Sinh_Q : constant Polynomial :=
(if Mantissa <= 24
then
(0 => Exact (-0.42827_7109E2),
1 => Exact (1.0))
else
(0 => Exact (-0.21108_77005_81062_71242E7),
1 => Exact (0.36162_72310_94218_36460E5),
2 => Exact (-0.27773_52311_96507_01667E3),
3 => Exact (1.0)));
G : constant T := X * X;
P : T;
Q : T;
begin
P := Compute_Horner (Sinh_P, G);
Q := Compute_Horner (Sinh_Q, G);
return Multiply_Add (X, (G * P / Q), X);
end Approx_Sinh;
----------------
-- Approx_Tan --
----------------
function Approx_Tan (X : T) return T is
Tan_P : constant Polynomial :=
(if Mantissa <= 24
then -- Approximation MRE = 2.7824E-8
(1 => Exact (-0.95801_7723E-1))
else -- Approximation MRE = 3.5167E-18
(1 => Exact (-0.13338_35000_64219_60681),
2 => Exact (0.34248_87823_58905_89960E-2),
3 => Exact (-0.17861_70734_22544_26711E-4)));
Tan_Q : constant Polynomial :=
(if Mantissa <= 24
then
(0 => Exact (1.0),
1 => Exact (-0.42913_5777),
2 => Exact (0.97168_5835E-2))
else
(0 => Exact (1.0),
1 => Exact (-0.46671_68333_97552_94240),
2 => Exact (0.25663_83228_94401_12864E-1),
3 => Exact (-0.31181_53190_70100_27307E-3),
4 => Exact (0.49819_43399_37865_12270E-6)));
G : constant T := X * X;
P : constant T := Multiply_Add (X, G * Compute_Horner (Tan_P, G), X);
Q : constant T := Compute_Horner (Tan_Q, G);
begin
return P / Q;
end Approx_Tan;
----------------
-- Approx_Cot --
----------------
function Approx_Cot (X : T) return T is
Tan_P : constant Polynomial :=
(if Mantissa <= 24
then -- Approxmiation MRE = 1.5113E-17
(1 => Exact (-0.95801_7723E-1))
else
(1 => Exact (-0.13338_35000_64219_60681),
2 => Exact (0.34248_87823_58905_89960E-2),
3 => Exact (-0.17861_70734_22544_26711E-4)));
Tan_Q : constant Polynomial :=
(if Mantissa <= 24
then
(0 => Exact (1.0),
1 => Exact (-0.42913_5777),
2 => Exact (0.97168_5835E-2))
else
(0 => Exact (1.0),
1 => Exact (-0.46671_68333_97552_94240),
2 => Exact (0.25663_83228_94401_12864E-1),
3 => Exact (-0.31181_53190_70100_27307E-3),
4 => Exact (0.49819_43399_37865_12270E-6)));
G : constant T := X * X;
P : constant T := Multiply_Add (X, G * Compute_Horner (Tan_P, G), X);
Q : constant T := Compute_Horner (Tan_Q, G);
begin
return -Q / P;
end Approx_Cot;
-----------------
-- Approx_Tanh --
-----------------
function Approx_Tanh (X : T) return T is
Tanh_P : constant Polynomial :=
(if Mantissa <= 24
then -- Approximation MRE = 2.7166E-9
(0 => Exact (-0.82377_28127),
1 => Exact (-0.38310_10665E-2))
else -- Approximation MRE = 3.2436E-18
(0 => Exact (-0.16134_11902_39962_28053E4),
1 => Exact (-0.99225_92967_22360_83313E2),
2 => Exact (-0.96437_49277_72254_69787)));
Tanh_Q : constant Polynomial :=
(if Mantissa <= 24
then
(0 => Exact (2.4713_19654),
1 => Exact (1.0))
else
(0 => Exact (0.48402_35707_19886_88686E4),
1 => Exact (0.22337_72071_89623_12926E4),
2 => Exact (0.11274_47438_05349_49335E3),
3 => Exact (1.0)));
G : constant T := X * X;
P, Q : T;
begin
P := Compute_Horner (Tanh_P, G);
Q := Compute_Horner (Tanh_Q, G);
return Multiply_Add (X, G * P / Q, X);
end Approx_Tanh;
----------
-- Asin --
----------
function Asin (X : T) return T is
-- Cody and Waite implementation (page 174)
Y : T := abs X;
G : T;
Result : T;
begin
if Y <= Exact (0.5) then
Result := X + X * Approx_Asin (X * X);
else
G := (Exact (1.0) + (-Y)) * Exact (0.5);
Y := Sqrt (G);
Result :=
Exact (Pi / 2.0) - Exact (2.0) * (Y + Y * Approx_Asin (G));
if not (Exact (0.0) <= X) then
Result := -Result;
end if;
end if;
return Result;
end Asin;
end Generic_Approximations;
------------------
-- Generic_Acos --
------------------
function Generic_Acos (X : T) return T is
-- Cody and Waite implementation (page 174)
Y : T := abs (X);
G : T;
Result : T;
begin
if Y <= 0.5 then
-- No reduction needed
G := Y * Y;
Result := T'Copy_Sign (Y + Y * Approx_Asin (G), X);
return 0.5 * Pi - Result;
end if;
-- In the reduction step that follows, it is not Y, but rather G that
-- is reduced. The reduced G is in 0.0 .. 0.25.
G := (1.0 - Y) / 2.0;
Y := -2.0 * Sqrt (G);
Result := Y + Y * Approx_Asin (G);
return (if X < 0.0 then Pi + Result else -Result);
end Generic_Acos;
-------------------
-- Generic_Atan2 --
-------------------
function Generic_Atan2 (Y, X : T) return T is
-- Cody and Waite implementation (page 194)
F : T;
N : Integer := -1;
-- Default value for N is -1 so that if X=0 or over/underflow
-- tests on N are all false.
Result : T;
begin
if Y = 0.0 then
if T'Copy_Sign (1.0, X) < 0.0 then
return T'Copy_Sign (Pi, Y);
else
return T'Copy_Sign (0.0, Y);
end if;
elsif X = 0.0 then
return T'Copy_Sign (Half_Pi, Y);
elsif abs (Y) > T'Last * abs (X) then -- overflow
Result := T (Half_Pi);
elsif abs (X) > T'Last * abs (Y) then -- underflow
Result := 0.0;
elsif abs (X) > T'Last and then abs (Y) > T'Last then
-- NaN
if X < 0.0 then
return T'Copy_Sign (3.0 * Pi / 4.0, Y);
else
return T'Copy_Sign (Pi / 4.0, Y);
end if;
else
F := abs (Y / X);
if F > 1.0 then
F := 1.0 / F;
N := 2;
else
N := 0;
end if;
if F > 2.0 - Sqrt_3 then
F := (((Sqrt_3 - 1.0) * F - 1.0) + F) / (Sqrt_3 + F);
N := N + 1;
end if;
Result := Approx_Atan (F);
end if;
if N > 1 then
Result := -Result;
end if;
case N is
when 1 => Result := Result + Sixth_Pi;
when 2 => Result := Result + Half_Pi;
when 3 => Result := Result + Third_Pi;
when others => null;
end case;
if T'Copy_Sign (1.0, X) < 0.0 then
Result := Pi - Result;
end if;
return T'Copy_Sign (Result, Y);
end Generic_Atan2;
procedure Generic_Pow_Special_Cases
(Left : T;
Right : T;
Is_Special : out Boolean;
Result : out T)
is
------------
-- Is_Even --
------------
function Is_Even (X : T) return Boolean is
(abs X >= 2.0**T'Machine_Mantissa
or else Unsigned_64 (abs X) mod 2 = 0);
pragma Assert (T'Machine_Mantissa <= 64);
-- If X is large enough, then X is a multiple of 2. Otherwise,
-- conversion to Unsigned_64 is safe, assuming a mantissa of at
-- most 64 bits.
begin
Is_Special := True;
Result := 0.0;
-- value 'Result' is not used if the input is
-- not a couple of special values
if Right = 0.0 or else not (Left /= 1.0) then
Result := (if Right = 0.0 then 1.0 else Left);
elsif Left = 0.0 then
if Right < 0.0 then
if Right = T'Rounding (Right) and then not Is_Even (Right) then
Result := 1.0 / Left; -- Infinity with sign of Left
else
Result := 1.0 / abs Left; -- +Infinity
end if;
else
if Right = T'Rounding (Right)
and then not Is_Even (Right)
then
Result := Left;
else
Result := +0.0;
end if;
end if;
elsif abs (Right) > T'Last and then Left = -1.0 then
Result := 1.0;
elsif Left < 0.0
and then Left >= T'First
and then abs (Right) <= T'Last
and then Right /= T'Rounding (Right)
then
Result := 0.0 / (Left - Left); -- NaN
elsif Right < T'First then
if abs (Left) < 1.0 then
Result := -Right; -- Infinity
else
Result := 0.0; -- Cases where Left=+-1 are dealt with above
end if;
elsif Right > T'Last then
if abs (Left) < 1.0 then
Result := 0.0;
else
Result := Right;
end if;
elsif Left > T'Last then
if Right < 0.0 then
Result := 0.0;
else
Result := Left;
end if;
elsif Left < T'First then
if Right > 0.0 then
if Right = T'Rounding (Right)
and then not Is_Even (Right)
then
Result := Left;
else
Result := -Left; -- -Left = +INF
end if;
else
if Right = T'Rounding (Right)
and then not Is_Even (Right)
then
Result := -0.0;
else
Result := +0.0;
end if;
end if;
else
Is_Special := False;
end if;
end Generic_Pow_Special_Cases;
end System.Libm;
|
BrickBot/Bound-T-H8-300 | Ada | 97,135 | adb | -- Flow.Const (body)
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form 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.
--
-- 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.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.38 $
-- $Date: 2015/10/24 20:05:48 $
--
-- $Log: flow-const.adb,v $
-- Revision 1.38 2015/10/24 20:05:48 niklas
-- Moved to free licence.
--
-- Revision 1.37 2013/12/20 21:11:07 niklas
-- Using Opt.Resolve_Opt (Resolve_Flow, Resolve_Stack) to control
-- the use of constant propagation for resolving dynamic flow and
-- stack usage.
--
-- Revision 1.36 2013-02-19 09:15:24 niklas
-- BT-CH-0245 clean-up. Only descriptions and tracing changed.
--
-- Revision 1.35 2013-02-12 08:47:19 niklas
-- BT-CH-0245: Global volatile cells and "volatile" assertions.
--
-- Revision 1.34 2012-02-13 17:52:20 niklas
-- BT-CH-0230: Options -max_loop and -max_stack for spurious bounds.
--
-- Revision 1.33 2009-11-27 11:28:07 niklas
-- BT-CH-0184: Bit-widths, Word_T, failed modular analysis.
--
-- Revision 1.32 2009/02/27 11:53:13 niklas
-- Suppressed the Fault messages on unprocessed feasible steps
-- when Opt.Refine_Edge_Conditions is disabled.
--
-- Revision 1.31 2009/01/18 08:06:50 niklas
-- Removed unused context clauses and locals.
--
-- Revision 1.30 2008/06/20 10:11:53 niklas
-- BT-CH-0132: Data pointers using Difference (Expr, Cell, Bounds).
--
-- Revision 1.29 2008/06/18 20:52:56 niklas
-- BT-CH-0130: Data pointers relative to initial-value cells.
--
-- Revision 1.28 2008/01/31 21:57:45 niklas
-- BT-CH-0108: Fixes to BT-CH-0098.
--
-- Revision 1.27 2007/12/17 13:54:36 niklas
-- BT-CH-0098: Assertions on stack usage and final stack height, etc.
--
-- Revision 1.26 2007/11/12 21:37:27 niklas
-- BT-CH-0097: Only arithmetic analysis marks boundable edge domain.
--
-- Revision 1.25 2007/10/26 12:44:35 niklas
-- BT-CH-0091: Reanalyse a boundable edge only if its domain grows.
--
-- Revision 1.24 2007/08/25 18:56:11 niklas
-- Added a nicer Image for Eval_Domain_T.
--
-- Revision 1.23 2007/08/17 14:44:00 niklas
-- BT-CH-0074: Stable and Unstable stacks.
--
-- Revision 1.22 2007/08/14 20:52:32 niklas
-- Changed Known_Values to give bounds only for given Cells.
-- Changed Bound_Calls to bound only the call's input cells.
--
-- Revision 1.21 2007/07/21 18:18:41 niklas
-- BT-CH-0064. Support for AVR/IAR switch-handler analysis.
--
-- Revision 1.20 2007/07/10 19:13:22 niklas
-- Improved Refine (Edge) to show Initial before Refined.
--
-- Revision 1.19 2007/04/18 18:34:38 niklas
-- BT-CH-0057.
--
-- Revision 1.18 2007/03/29 15:18:01 niklas
-- BT-CH-0056.
--
-- Revision 1.17 2007/03/18 12:50:38 niklas
-- BT-CH-0050.
--
-- Revision 1.16 2007/01/25 21:25:14 niklas
-- BT-CH-0043.
--
-- Revision 1.15 2007/01/13 13:51:04 niklas
-- BT-CH-0041.
--
-- Revision 1.14 2006/10/24 08:44:31 niklas
-- BT-CH-0028.
--
-- Revision 1.13 2006/09/05 18:40:56 niklas
-- Added Note on number of cells.
--
-- Revision 1.12 2006/05/06 06:59:20 niklas
-- BT-CH-0021.
--
-- Revision 1.11 2005/10/12 17:31:44 niklas
-- Extended Compute_And_Assign to show the locus of the
-- step that causes an assertion violation.
--
-- Revision 1.10 2005/08/24 10:01:30 niklas
-- Force display of the code address in warnings about unreachable
-- (infeasible) flow (as if the -address option were in effect).
--
-- Revision 1.9 2005/06/29 13:01:10 niklas
-- Added optional (-warn reach) warning about infeasible edges,
-- called "unreachable flow" in the warning.
--
-- Revision 1.8 2005/06/14 17:10:16 niklas
-- Added step context for Output in Resolve_Dynamic_Edges.
--
-- Revision 1.7 2005/05/10 13:46:50 niklas
-- Corrected Find_Stack_Heights to call P.E.Bound_Stack_Height.
--
-- Revision 1.6 2005/04/20 12:15:33 niklas
-- Corrected Warn_If_Node_Splits to skip the warning when the edge
-- loops back from the last to the first step of the node, because
-- this is not an internal edge. Also, added the edge and node
-- indices to the warning message when it occurs.
--
-- Revision 1.5 2005/02/23 09:05:18 niklas
-- BT-CH-0005.
--
-- Revision 1.4 2005/02/20 15:15:36 niklas
-- BT-CH-0004.
--
-- Revision 1.3 2005/02/16 21:11:43 niklas
-- BT-CH-0002.
--
-- Revision 1.2 2004/08/09 19:51:32 niklas
-- BT-CH-0001.
--
-- Revision 1.1 2004/04/28 18:54:41 niklas
-- First version.
--
--:dbpool with GNAT.Debug_Pools;
with Ada.Text_IO;
with Ada.Unchecked_Deallocation;
with Arithmetic.Evaluation;
with Bounds.Calling;
with Bounds.Stacking.Opt;
with Calling;
with Faults;
with Flow.Computation;
with Flow.Const.Opt;
with Flow.Pruning.Opt;
with Flow.Show;
with Least_Fixpoint;
with Output;
with Storage.Cell_Numbering;
package body Flow.Const is
use type Computation.Model_Ref;
package Stacking_Opt renames Bounds.Stacking.Opt;
-- Principles of Operation
--
-- The analysis consists of six phases:
--
-- (1) Propagate the constant values for all cells through the
-- flow-graph by a least-fixpoint data-flow solution over the
-- domain of mappings from cell to the domain (unknown, constant
-- value = C, variable).
--
-- (2) Construct a simplified computation model by partial
-- evaluation of the given model on the computed cell values,
-- where a cell has only a single possible value. This phase
-- also applies such single possible values as bounds to
-- resolve dynamic references to cells.
--
-- (3) Prune the simplified computation model by identifying
-- the infeasible edges, if any, and propagating infeasibility
-- over the flow-graph.
--
-- (4) Bound the protocols and inputs for the (remaining) feasible
-- calls by applying the propagated constant values as bounds.
--
-- (5) Again prune the computation model in case some more calls
-- were found to be infeasible in phase 4.
--
-- If phase 2 or 4 resolves dynamic cell references to static cell
-- names, we can optionally repeat phases 1 .. 4 to include
-- these (perhaps new) cells in the results and to improve the
-- precision of the results. Otherwise, we go on to phase 6:
--
-- (6) Extract the maximum local stack height and the take-off
-- heights for the calls from the computed stack-height
-- values (if constant), for all stacks.
--
-- (7) Apply the propagated constant cell values as bounds to
-- resolve dynamic control-flow edges.
--
-- If phase 7 actually resolves some dynamic flow and extends the
-- flow-graph, the results of phases 1 .. 6 are out of date and
-- can be discarded (but they are still computed).
--
-- The basic domain of abstracted values:
--
subtype Level_T is Arithmetic.Evaluation.Level_T;
--
-- The three levels in the value domain, expressing the
-- level of knowledge we have about the possible values that
-- a cell can take at a given point in the flow-graph.
--
-- The levels correspond to the evaluation levels from the
-- Arithmetic.Evaluation package, but note carefully that their
-- lattice order here, for constant propagation purposes, is
-- different from their order in Arithmetic.Evaluation.
--
-- The meaning of the three levels here is:
--
-- Unknown
-- We know nothing yet. Bottom element of value domain.
-- Known
-- We have seen a single value so far.
-- Middle level of value domain (domain elements at this
-- level are distinguished by the values, see Value_T).
-- Relative
-- We have so far seen only a value of the form Base + Offset,
-- where Base is a known initial-value cell (evaluated on
-- entry to the subprogram under analysis, and constant
-- thereafter) and Offset is a known constant.
-- Middle level of value domain (domain elements at this
-- level are distinguished by the Base and Offset).
-- Variable
-- We have seen at least two different values, so
-- we consider the cell to be variable (not constant)
-- at this point. Top element of domain.
use type Level_T;
Unknown : constant Level_T := Arithmetic.Evaluation.Unknown;
Known : constant Level_T := Arithmetic.Evaluation.Known;
Relative : constant Level_T := Arithmetic.Evaluation.Relative;
Variable : constant Level_T := Arithmetic.Evaluation.Variable;
subtype Value_T is Arithmetic.Evaluation.Cell_Value_T;
--
-- The possible values of a cell at some point in the
-- flow-graph, from the point of view of constant propagation.
-- The type has a discriminant, Level, that shows the level
-- of knowledge about the cell's value. If Level = Known,
-- the type has a component Value : Processor.Value_T that
-- is the known unique value of the cell.
Unknown_Value : constant Value_T := (Level => Unknown);
--
-- Represents a lack of knowledge about the value of a
-- cell at some point.
-- The single element in the domain at the Unknown level; the
-- bottom element in the domain.
Variable_Value : constant Value_T := (Level => Variable);
--
-- Represents a cell that is not known to have a constant
-- value (appears to have many possible values).
-- The single element in the domain at the Variable level;
-- the top element in the domain.
function Image (Item : Value_T) return String
renames Arithmetic.Evaluation.Image;
subtype Target_Level_T is Arithmetic.Evaluation.Target_Level_T;
--
-- Just an abbreviation.
use type Target_Level_T;
Dynamic_Ref : constant Target_Level_T := Arithmetic.Evaluation.Dynamic_Ref;
--
-- Just an abbreviation.
procedure Merge (
More : in Value_T;
Into : in out Value_T;
Grew : in out Boolean)
--
-- Updates the Into value to define the union set of the
-- Into value and the More value. Since we only record one
-- possible constant value for each cell, or one possible
-- Base cell and constant Offset, if More and Into provide
-- different values Into becomes Variable_Value.
--
-- Returns Grew as True if Into was changed, otherwise
-- does not change Grew.
--
is
use type Value_T;
use type Arithmetic.Word_T;
use type Arithmetic.Width_T;
begin
if More.Level /= Unknown then
-- We may learn something.
case Into.Level is
when Unknown =>
-- We now know a little bit, whereas we
-- knew nothing before.
Into := More;
Grew := True;
when Relative =>
if More /= Into then
-- We knew something, but we are now told
-- something different, so who knows...
Into := Variable_Value;
Grew := True;
end if;
when Known =>
if More.Level = Known
and then (More.Value = Into.Value
and More.Width = Into.Width)
then
-- More and Into are the same value and width, so
-- there is no change in those aspects of the value.
if More.Signed and not Into.Signed then
-- More brings a hint that this value should
-- be considered signed. This hint is merged Into
-- the united value.
Into.Signed := True;
Grew := True;
end if;
else
-- We knew something, but we are now told
-- something different, so who knows...
Into := Variable_Value;
Grew := True;
end if;
when Variable =>
-- We have already lost whatever illusions
-- we may have had.
null;
end case;
end if;
end Merge;
procedure Set_Single_Value (
Bound : in Storage.Bounds.Interval_T;
Width : in Arithmetic.Width_T;
Value : in out Value_T)
--
-- Sets the Value to the single constant value that may be
-- implied by the given Bound, otherwise leaves the Value
-- unchanged.
--
is
use type Arithmetic.Value_T;
Single_Value : Arithmetic.Value_T;
-- The single value in the Bound, if Bound is singular.
begin
if Storage.Bounds.Singular (Bound) then
-- Unique value.
Single_Value := Storage.Bounds.Single_Value (Bound);
Value := (
Level => Known,
Value => Arithmetic.Unsigned_Word (
Value => Single_Value,
Width => Width),
Width => Width,
Signed => Single_Value < 0);
end if;
end Set_Single_Value;
--
-- Assigning an abstract value to each cell:
--
type Numbered_Cell_Values_T is
array (Storage.Cell_Numbering.Number_T range <>)
of Value_T;
--
-- The possible constant value for each cell used in the
-- flow-graph under analysis.
-- This is the domain for phase 1, constant propagation,
-- when constrained to the cell-numbers in use.
--
-- If the flow-graph contains dynamic data (cell) references,
-- the possible referent cells are not included in the cell
-- numbering. If constant propagation manages to resolve such
-- a reference resolves to a unique cell, that cell is considered
-- to have an undefined (Variable) value in this round of constant
-- propagation. However, this will trigger a new round of constant
-- propagation in which this referent cell is included in the same
-- way as statically addressed cells.
type Numbered_Cell_Values_Ref is access Numbered_Cell_Values_T;
--
-- The vectors of cell values are stored in the heap for
-- two reasons: firstly, to make it easier to refer to the
-- correct vector when using Arithmetic.Evaluation to evalute
-- the expressions in a step, and secondly because such a
-- vector is needed for each step in the flow-graph and the
-- whole set of vectors would use a lot of stack space, which
-- is limited on some platforms.
--:dbpool Numbered_Cell_Values_Pool : GNAT.Debug_Pools.Debug_Pool;
--:dbpool for Numbered_Cell_Values_Ref'Storage_Pool use Numbered_Cell_Values_Pool;
function Image (Item : Numbered_Cell_Values_T) return String
--
-- Describes the cell values.
--
is
use type Storage.Cell_Numbering.Number_T;
begin
if Item'Length = 0 then
return "";
else
return
Storage.Cell_Numbering.Number_T'Image (Item'First)
& " =>"
& Image (Item(Item'First))
& ','
& Image (Item(Item'First + 1 .. Item'Last));
end if;
end Image;
procedure Unchecked_Discard
is new Ada.Unchecked_Deallocation (
Name => Numbered_Cell_Values_Ref,
Object => Numbered_Cell_Values_T);
procedure Discard (Item : in out Numbered_Cell_Values_Ref)
--
-- Unchecked deallocation depending on Opt.Deallocate.
--
is
begin
if Opt.Deallocate then
Unchecked_Discard (Item);
end if;
exception when others => Faults.Deallocation;
end Discard;
--
-- Evaluation domain for constant propagation:
--
type Eval_Domain_T is new Arithmetic.Evaluation.Domain_T
with record
Numbers : Storage.Cell_Numbering.Map_T;
Values : Numbered_Cell_Values_Ref;
end record;
--
-- The domain, defining some cell values, within which
-- the expressions in a step are evaluated to propagate
-- constant cell values to constant (or partially evaluated)
-- expression results.
-- overriding
function Image (Item : Eval_Domain_T) return String;
-- overriding
function Basis (Item : Eval_Domain_T) return Storage.Cell_List_T;
--
-- The basis of an Eval Domain is the set of cells that are
-- involved, ie. the cells with Numbers and Values.
-- overriding
function Value_Of (Cell : Storage.Cell_T; Within : Eval_Domain_T)
return Value_T;
--
-- The value that this domain defines for the cell.
-- Eval_Domain_T operation bodies
function Image (Item : Eval_Domain_T) return String
is
begin
pragma Warnings (Off, Item);
-- Yes, GNAT, we know that Item is not referenced here.
return "constant propagation";
end Image;
function Basis (Item : Eval_Domain_T) return Storage.Cell_List_T
is
use Storage;
begin
return Cell_List_T (Cell_Numbering.Inverse (Item.Numbers));
end Basis;
function Value_Of (Cell : Storage.Cell_T; Within : Eval_Domain_T)
return Value_T
is
use Storage.Cell_Numbering;
begin
if Numbered (Cell, Within.Numbers) then
-- This Cell's value is included in this round of constant
-- propagation.
return Within.Values(Number (Cell, Within.Numbers));
else
-- This Cell is a new one for this round, discovered as the
-- unique referent of a dynamic pointer. Its value is not
-- considered in this round of constant propagation but is
-- taken as variable (in effect "not known").
return (Level => Variable);
end if;
end Value_Of;
function Numbered_Cell (
Target : Arithmetic.Variable_T;
Within : Eval_Domain_T)
return Boolean
--
-- Whether the Target is a basis cell Within the domain.
--
is
use type Arithmetic.Expr_Kind_T;
begin
return Target.Kind = Arithmetic.Cell
and then Storage.Cell_Numbering.Numbered (Target.Cell, Within.Numbers);
end Numbered_Cell;
function Known_Values (
Cells : Storage.Cell_List_T;
Domain : Eval_Domain_T)
return Storage.Bounds.Bounds_Ref
--
-- The Domain bounds on the given Cells, converted to Singular_Bounds_T
-- and stored on the heap. If the Domain contains no Known values for
-- these Cells the result is Storage.Bounds.No_Bounds and nothing new
-- is stored on the heap. It may be that some Cells are not in the
-- Domain numbering; for such cells no bounds apply.
--
is
Values : Storage.Cell_Value_List_T (1 .. Cells'Length);
Last : Natural := 0;
-- The cells and their values will be in Values(1 .. Last).
Cell_Value : Value_T;
-- The Domain value for one of the Cells.
begin
for C in Cells'Range loop
Cell_Value := Value_Of (Cell => Cells(C), Within => Domain);
if Cell_Value.Level = Known then
Last := Last + 1;
Values(Last) := (
Cell => Cells(C),
Value => Cell_Value.Value);
end if;
end loop;
if Last > 0 then
-- We have some known cell values.
return new Storage.Bounds.Singular_Bounds_T'(
Length => Last,
List => Values(1 .. Last));
else
-- No known cell values.
return Storage.Bounds.No_Bounds;
end if;
end Known_Values;
--
-- Creating a new computation model:
--
procedure Refine (
Assignment : in Arithmetic.Assignment_T;
Within : in Eval_Domain_T;
Into : in out Arithmetic.Assignment_Set_T;
Refined : in out Boolean;
Bounded : in out Boolean;
Values : in out Numbered_Cell_Values_T)
--
-- Refines a Defining Assignment, Within the domain of cell-values
-- that flow into the assignment, to make a new assignment in which
-- the expressions (including the condition if any) are refined by
-- partial evaluation on the domain, as is also the target variable
-- if it is a dynamic memory reference. The new assignment is added
-- Into a set of (refined) assignments, unless it has become just
-- an identity assignment that can be dropped.
--
-- If the assignment was changed or dropped, Refined is returned
-- as True, otherwise Refined is returned unchanged.
--
-- If a dynamic data pointer was resolved or bounded, Bounded is returned
-- as True, otherwise Bounded is returned unchanged.
--
-- If the evaluated Target variable is one of the cells currently under
-- analysis, the value of the assigned expression is also stored in
-- Values under the index number that Within assigns to this cell.
--
-- If Opt.Refine_Effects is False, we just evaluate and store the
-- value in Values and do not try to refine the expressions.
--
is
use Arithmetic.Evaluation;
Target_Result : constant Target_Result_T :=
Eval (
Target => Assignment.Target,
Within => Within,
Partly => Opt.Refine_Effects);
--
-- The result of evaluating the target.
Target : constant Arithmetic.Variable_T := Residual (Target_Result);
--
-- The partially evaluated (dereferenced) target variable.
Result : constant Assignment_Result_T :=
Eval (
Assignment => Assignment,
Within => Within,
Target => Target_Result,
Partly => Opt.Refine_Effects);
--
-- The partially evaluated assignment.
Target_Number : Storage.Cell_Numbering.Number_T;
--
-- The (number of) the target cell of an assignment where the
-- target is a statically named or resolved cell and this cell
-- belongs to the nomenclatura (range of Within).
begin
-- Perhaps add the assignment Into the new effect:
if Identity (Result) then
-- This assignment can be ignored.
Refined := True;
else
-- The assignment must be kept.
if not Same (Result, Assignment) then
-- Some real refinement.
Refined := True;
end if;
Arithmetic.Add (To => Into, More => Residual (Result));
end if;
-- Note bounded pointers:
if Result.Ref_Bounded then
Output.Note ("Refine (Assignment) bounded a pointer.");
Bounded := True;
end if;
-- Perhaps store the assigned value in Values(Target):
if Numbered_Cell (Target, Within) then
-- The (possibly resolved) target is a cell, and moreover one
-- of the cells involved in the constant propagation, so we
-- will return the assigned value in Values.
Target_Number := Storage.Cell_Numbering.Number (
Target.Cell, Within.Numbers);
Values(Target_Number) := Value_Of (Result.Value);
end if;
end Refine;
procedure Warn_If_Node_Splits (
Edge : in Step_Edge_T;
Graph : in Graph_T;
Program : in Programs.Program_T)
--
-- Warns if the infeasible Edge splits a node in the Graph.
-- Such a split is unexpected and suspicious, because edges within
-- a node should usually have a True precondition.
--
is
Source_Node : constant Node_T := Node_Containing (Source (Edge), Graph);
Target_Node : constant Node_T := Node_Containing (Target (Edge), Graph);
-- The source and target nodes of the Edge.
begin
if Source_Node = Target_Node
and then Target (Edge) /= First_Step (Target_Node)
then
-- The Edge is internal to a node.
Output.Warning (
Locus => Flow.Show.Locus (
Node => Source_Node,
Source => Programs.Symbol_Table (Program)),
Text =>
"Infeasible edge"
& Step_Edge_Index_T'Image (Index (Edge))
& " splits node"
& Node_Index_T'Image (Index (Source_Node)));
-- else
-- If Source_Node /= Target_Node there is no problem.
-- Otherwise, the Edge goes from the last step of the node back
-- to the first step of the node, so the node is the body of a
-- loop. The infeasibility of the edge simply means that the loop
-- is unrepeatable. No problem, in fact rather nice.
--
end if;
end Warn_If_Node_Splits;
procedure Refine (
Edge : in Step_Edge_T;
Within : in Eval_Domain_T;
Program : in Programs.Program_T;
Model : in out Computation.Model_Ref;
Bounded : in out Boolean)
--
-- Refines the precondition of an edge, under a given computation
-- Model and Within the domain of cell-values that flow out from the
-- source step, to make a new precondition expression that is refined
-- by partial evaluation on the domain.
--
-- The new precondition is stored in the refined computation Model.
--
-- If a dynamic data pointer is resolved or bounded, Bounded is returned
-- as True, otherwise Bounded is returned unchanged.
--
-- A warning is issued if the Edge is internal to a node and becomes
-- infeasible.
--
-- The Program parameter is only for showing loci.
--
is
use Arithmetic.Evaluation;
use type Arithmetic.Expr_Ref;
Old_Cond : constant Arithmetic.Condition_T :=
Computation.Condition (Edge => Edge, Under => Model);
-- The old precondition.
Result : Result_T;
-- The (partially) evaluated old precondition.
New_Cond : Arithmetic.Condition_T;
-- The new condition, if refined.
begin
if Old_Cond /= Arithmetic.Always
and Old_Cond /= Arithmetic.Never
and Old_Cond /= Arithmetic.Unknown
then
-- Partial evaluation may help.
Result := Eval (
Expr => Old_Cond,
Within => Within,
Partly => True);
if Result.Ref_Bounded then
Output.Note ("Refine (Edge) bounded a pointer.");
Bounded := True;
end if;
if not Same (Result, Old_Cond) then
-- The condition changed.
New_Cond := To_Condition (Result);
if Opt.Trace_Refinements then
Output.Trace (
"Initial condition"
& Output.Field_Separator
& "Edge"
& Step_Edge_Index_T'Image (Index (Edge))
& Output.Field_Separator
& Arithmetic.Image (Old_Cond));
Output.Trace (
"Refined condition"
& Output.Field_Separator
& "Edge"
& Step_Edge_Index_T'Image (Index (Edge))
& Output.Field_Separator
& Arithmetic.Image (New_Cond));
end if;
Computation.Set_Condition (
On => Edge,
To => New_Cond,
Under => Model);
if New_Cond = Arithmetic.Never then
-- The edge became infeasible. Hmm.
Output.Note (
"Infeasible flow to "
& Output.Image (Flow.Show.All_Statements (
Step => Target (Edge),
Source => Programs.Symbol_Table (Program)),
Address => True));
if Pruning.Opt.Warn_Unreachable then
Output.Warning (
"Unreachable flow to instruction at "
& Output.Image (
Item => Flow.Show.All_Statements (
Step => Target (Edge),
Source => Programs.Symbol_Table (Program)),
Address => True));
end if;
Warn_If_Node_Splits (
Edge => Edge,
Graph => Computation.Graph (Model),
Program => Program);
end if;
end if;
end if;
end Refine;
procedure Trace_Refined_Effect (
Step : in Step_T;
Locus : in Output.Locus_T;
Initial : in Arithmetic.Effect_T;
Refined : in Arithmetic.Effect_T)
--
-- Traces the refinement of the effect of the Step.
--
is
begin
Output.Trace (
Locus => Locus,
Text =>
"Initial effect"
& Output.Field_Separator
& "Step"
& Step_Index_T'Image (Index (Step))
& Output.Field_Separator
& Arithmetic.Image (Initial));
Output.Trace (
Locus => Locus,
Text =>
"Refined effect"
& Output.Field_Separator
& "Step"
& Step_Index_T'Image (Index (Step))
& Output.Field_Separator
& Arithmetic.Image (Refined));
end Trace_Refined_Effect;
procedure Refine (
Step : in Step_T;
Domain : in out Eval_Domain_T;
Post : in Numbered_Cell_Values_Ref;
Program : in Programs.Program_T;
Model : in out Computation.Model_Ref;
Bounded : in out Boolean)
--
-- Refines (simplifies, partially evaluates) the effect of a Step,
-- including dynamic data accesses, and the preconditions on the
-- edges that leave the Step, under a given computation Model and
-- a given Domain of cell-values that flow into the step.
--
-- All the refinements are optional depending on Opt.Refine_Effects
-- and Opt.Refine_Edge_Conditions.
--
-- The Post parameter is a working area with the same Range
-- as Domain.Values. Its contents on entry are irrelevant,
-- and it will be returned as the Post values holding after
-- the Step. For reasons of convenience, Domain.Values will
-- be set to Post on return; this is why Domain is "in out".
--
-- The new effect etc. are stored in the refined computation Model.
--
-- If some dynamic data access pointer is resolved to a unique cell,
-- or is bounded to a narrower range, the Bounded parameter is set
-- True, otherwise it is returned unchanged.
--
is
use Arithmetic;
Old_Effect : constant Effect_Ref :=
Computation.Effect (Step => Step, Under => Model);
-- The old effect of the step.
New_Effect : Assignment_Set_T (Positive_Length (Old_Effect));
-- The new, refined effect of the step.
Effect_Refined : Boolean := False;
-- Whether the effect was really changed.
Edges : constant Step_Edge_List_T :=
Computation.Edges_From (Step => Step, Under => Model);
-- The edges leaving the Step, feasible under the Model.
-- We will refine the preconditions on these edges.
Step_Mark : Output.Nest_Mark_T;
-- Marks the default Output locus for the step.
begin
Step_Mark := Output.Nest (
Flow.Show.Locus (
Step => Step,
Source => Programs.Symbol_Table (Program)));
-- Refine the effect and compute the Post values:
Post.all := Domain.Values.all;
if Opt.Refine_Effects or Opt.Refine_Edge_Conditions
then
-- If the edge conditions will be refined, we must
-- compute the Post values even if the effect is not
-- to be refined.
for E in Old_Effect'Range loop
if Old_Effect(E).Kind in Defining_Kind_T then
-- Currently we refine only Defining assignments.
Refine (
Assignment => Old_Effect(E),
Within => Domain,
Into => New_Effect,
Refined => Effect_Refined,
Bounded => Bounded,
Values => Post.all);
else
-- Range constraint assignments are currently kept
-- in their original form.
-- TBA refine the Min and Max expressions in
-- the range constraint Old_Effect(E).
-- TBA refine (resolve) the Target of Old_Effect(E).
Add (New_Effect, Old_Effect(E));
end if;
end loop;
if Effect_Refined and Opt.Refine_Effects then
-- The effect was refined and refinement is enabled.
-- Therefore we shall record the new, refined effect
-- for later use.
if Opt.Trace_Refinements then
Trace_Refined_Effect (
Step => Step,
Locus => Flow.Show.Locus (
Step => Step,
Source => Programs.Symbol_Table (Program)),
Initial => Old_Effect.all,
Refined => To_Effect (New_Effect));
end if;
Computation.Set_Effect (
Step => Step,
To => To_Effect_Ref (New_Effect),
Under => Model);
end if;
end if;
-- Refine the edge preconditions:
Domain.Values := Post;
if Opt.Refine_Edge_Conditions then
for E in Edges'Range loop
Refine (
Edge => Edges(E),
Within => Domain,
Program => Program,
Model => Model,
Bounded => Bounded);
end loop;
end if;
Output.Unnest (Step_Mark);
exception
when others =>
-- Clean up the output locus and punt:
Output.Unnest (Step_Mark);
raise;
end Refine;
--
-- Components for Least_Fixpoint for constant propagation:
--
procedure Trace (
Action : in String;
Step : in Step_T;
Source : in Step_T;
Input : in Numbered_Cell_Values_T;
Output : in Numbered_Cell_Values_T;
Grew : in Boolean)
--
-- Report an "initialisation", "transform", or "merging" action.
--
is
use Ada.Text_IO;
begin
Put (
"Constant Propagation:"
& Action
& ":Step:" & Step_Index_T'Image (Index (Step)));
if Source /= null then
Put (":Source_Step:" & Step_Index_T'Image (Index (Source)));
end if;
New_Line;
Put_Line ("- Input : " & Image (Input));
Put_Line ("- Output : " & Image (Output));
Put_Line ("- Grew : " & Boolean'Image (Grew));
end Trace;
subtype Step_Number_T is Positive;
--
-- The number of a step in the flow-graph, as required for
-- Least_Fixpoint. The value is the same as the Step_Index,
-- only the type is different.
function Number (Step : Step_T) return Step_Number_T
--
-- The index of a step, as a Step_Number_T for Least_Fixpoint.
--
is
begin
return Step_Number_T (Index (Step));
end Number;
procedure Propagate_Constants (
Subprogram : in Programs.Subprogram_T;
Asserted : in Storage.Bounds.Var_Interval_List_T;
Initial : in Storage.Bounds.Cell_Interval_List_T;
Round : in Positive;
Last_Round : in Boolean;
Bounded : out Boolean;
Bounds : in Programs.Execution.Bounds_Ref)
--
-- Implements the provided operation Propagate, when
-- Opt.Propagate is True. However, this operation executes phases 1
-- to 4 once; the iteration over these phases is implemented in the
-- caller, because the types and local variables defined here are
-- sized for a certain set of cells and must be elaborated anew if
-- new (resolved) cells are added.
--
-- Asserted
-- Bounds on variable (cell) values, throughout the subprogram.
--
-- Initial
-- The bounds on the initial values of cells, on entry to the
-- Subprogram. We assume that the Asserted bounds are included
-- (conjoined) with the specific entry-point bounds, and both
-- are represented here.
--
-- Round
-- The number of the iteration round.
--
-- Last_Round
-- Whether this is the last round of iteration of phases 1 .. 4.
-- In other words, even if Bounded is returned as True, the caller
-- will not repeat this Propagate_Constants operation because of
-- Bounded. Consequently, when Last_Round is True this operation
-- will perform phases 5 and 6 even if Bounded is returned as True.
--
-- Bounded
-- Whether some data pointers (dynamic data references) were
-- resolved to unique cell referents, or bounded (constrained)
-- to narrower pointers, in the refined model. Also true if some
-- calling protocol was refined and thus the effect of a call was
-- updated.
--
-- If Bounded is True it means, first, that the refined model is
-- different from the input model, and second, that a new round of
-- Propagate_Constants may be useful because there are new cells that
-- may have constant values, or new assignments or uses of existing
-- cells, or because reduced aliasing may give a better result.
--
is
-- Constant propagation is implemented by least-fixpoint
-- iteration of data-flow equations along the flow (forward
-- direction). Thus, the results are the constant cell values
-- (if any) before each step.
use type Storage.Cell_T;
use type Storage.Bounds.Cell_Interval_List_T;
use type Storage.Bounds.Var_Interval_List_T;
Program : constant Programs.Program_T :=
Programs.Execution.Program (Bounds);
--
-- The target program under analysis, for show.
Model : Flow.Computation.Model_Ref renames
Programs.Execution.Computation (Bounds).all;
--
-- The computation model to be used and updated.
Graph : constant Graph_T := Computation.Graph (Model);
--
-- The flow-graph underlying the computation model.
-- Only the step-level graph will be used.
Steps : constant Step_List_T := All_Steps (Graph);
--
-- All the steps of the graph (including infeasible steps).
-- Note that the indices in this vector are equal to the
-- Step_Index_T values of the steps, although of Positive type.
-- In other words, this array can be indexed by Step_Number_T.
-- Infeasible steps are not processed, but they are included in
-- the list to have this indexing property.
Code_Range : constant Storage.Code_Address_Range_T :=
Flow.Code_Range (Graph);
--
-- A code-address interval that covers the Graph.
-- For checking which bounded variables are located in the same
-- cells throughout the subprogram. This is a weak way of using
-- the Asserted variable bounds; TBM to a localized one.
Named_Cells : Storage.Cell_Set_T := Computation.Cells_In (
Model => Model,
Calls => True);
--
-- All the cells (statically) named in the given computation model,
-- including the output cells of calls as far as they are encoded
-- in the effects of the call steps.
--
-- The input cells of calls are not included, but if such a cell
-- is not named in the computation model itself then we have no
-- reason to propagate values for it.
--
-- TBA: include those input cells for calls that are bounded in
-- the initial bounds or asserted for this subprogram.
Domain : Eval_Domain_T := (
Numbers => Storage.Cell_Numbering.Map (Named_Cells),
Values => null);
--
-- The Numbers component defines a (fixed) consecutive numbering
-- of all the cells (statically) named in the computation. This
-- provides each such cell with an index position in the vectors
-- of abstract cell values.
--
-- This Domain variable is used as a global work-space in most
-- of the least-fixpoint iteration operations. The Numbers
-- component is held fixed; the Values component is set as
-- needed.
--
-- The Values component will be set to the Cell_Values flowing
-- into a step, when we propagate these values through the
-- assignments in the step.
--
-- The Values component will be set to the Cell_Values flowing
-- from a step, when we compute the preconditions on edges
-- that leave this step.
Cell_Num : constant Storage.Cell_Numbering.List_T :=
Storage.Cell_Numbering.Inverse (Domain.Numbers);
--
-- The cell for each cell-number.
subtype Cell_Number_T is
Storage.Cell_Numbering.Number_T range Cell_Num'Range;
--
-- The number of a cell in the consecutive numbering of
-- of all the (statically) named cells in the flow-graph.
subtype Cell_Values_T is Numbered_Cell_Values_T (Cell_Number_T);
--
-- The abstract value for each cell, indexed by the consecutive
-- numbers assigned to cells (statically) named in the computation.
subtype Cell_Values_Ref is Numbered_Cell_Values_Ref;
--
-- The accessed object will always be of subtype Cell_Values_T.
type Cell_Values_List_T is
array (Step_Number_T range <>) of Cell_Values_Ref;
--
-- Abstract cell values for each step in the flow-graph.
-- This is the result of the least-fixpoint iteration.
Values : Cell_Values_List_T (Steps'Range);
--
-- For each step, the propagated abstract cell values
-- on reaching the step through any kind of edge. For
-- the entry step, the values hold on entering the
-- subprogram.
Work_Post : Cell_Values_Ref := new Cell_Values_T;
--
-- A working array of cell values, to be used in phase 2
-- where the new computation model is constructed.
subtype Default_T is Level_T range Unknown .. Relative;
--
-- Specifies a default level of knowledge for a cell.
function Default_Value (
Cell : Storage.Cell_T;
Default : Default_T)
return Value_T
--
-- The Default value for the given Cell.
--
is
use type Storage.Cell_T;
Init : constant Storage.Cell_T := Storage.Initial_Cell (Cell);
-- The initial-value cell for the given Cell, or No_Cell
-- if there is none.
begin
case Default is
when Unknown =>
return Unknown_Value;
when Variable =>
return Variable_Value;
when Relative =>
if Opt.Relative_Values and Init /= Storage.No_Cell then
-- Use the Relative model.
return (
Level => Relative,
Base => Init,
Offset => 0);
else
-- Relative values are denied, or the Cell has no
-- initial-value cell, so we use a Variable model
-- instead.
return Variable_Value;
end if;
end case;
end Default_Value;
function To_Values (
Given : Storage.Bounds.Cell_Interval_List_T;
Default : Default_T)
return Cell_Values_T
--
-- Returns a set of abstract cell values that contains those
-- single values that are defined by the Given bounds and
-- marks the other cells with a given default value.
--
-- If the same cell is listed twice in the Given list,
-- the last occurrence applies.
--
is
use Arithmetic;
Num : Cell_Number_T;
-- The number of a cell that is listed in the Given
-- bounds and is also named in the computation.
Values : Cell_Values_T;
-- The result.
begin
-- First make everything default:
for B in Values'Range loop
Values(B) := Default_Value (Cell_Num(B), Default);
end loop;
-- Then add the given bounds:
for G in Given'Range loop
if Storage.Is_Member (Given(G).Cell, Named_Cells) then
-- This cell is named in the computation.
Num := Storage.Cell_Numbering.Number (
Cell => Given(G).Cell,
Under => Domain.Numbers);
Set_Single_Value (
Bound => Given(G).Interval,
Width => Storage.Width_Of (Given(G).Cell),
Value => Values(Num));
end if;
end loop;
return Values;
end To_Values;
function To_Values (
Given : Storage.Bounds.Var_Interval_List_T;
Default : Value_T)
return Cell_Values_T
--
-- Returns a set of abstract cell values that contains those
-- single values that are defined by the Given variable bounds
-- for the _whole_ subprogram (fixed-location variables) and
-- marks the other cells with a given default value.
--
-- This is a weak way of using the Asserted variable bounds; TBM
-- to a localized one.
--
-- If the same cell is listed twice in the Given list,
-- the last occurrence applies.
--
is
use Arithmetic;
use type Storage.Code_Address_Range_T;
Loc : Storage.Location_Ref;
-- The location of one of the bounded variables.
Num : Cell_Number_T;
-- The number of a cell that is listed in the Given
-- bounds and is also named in the computation.
Values : Cell_Values_T;
-- The result.
begin
-- First make everything default:
for B in Values'Range loop
Values(B) := Default;
end loop;
-- Then add the given bounds:
for G in Given'Range loop
Loc := Given(G).Location;
for L in Loc'Range loop
if Code_Range <= Loc(L).Address
and then Storage.Is_Member (Loc(L).Cell, Named_Cells)
then
-- The bounded variable is located in Loc(L).Cell through
-- the whole subprogram, and this cell is named in the
-- computation.
Num := Storage.Cell_Numbering.Number (
Cell => Loc(L).Cell,
Under => Domain.Numbers);
Set_Single_Value (
Bound => Given(G).Interval,
Width => Storage.Width_Of (Loc(L).Cell),
Value => Values(Num));
end if;
end loop;
end loop;
return Values;
end To_Values;
Invariant_Values : constant Cell_Values_T :=
To_Values (
Given => Asserted,
Default => Unknown_Value);
--
-- The cell values that are asserted to hold at all points
-- in the subprogram. For other cells, we know nothing but
-- are prepared to know more.
--
-- This is the actual "bottom" element in the least-fixpoint
-- domain, representing our least possible knowledge of the
-- values of the relevant cells.
Pass_Cell : array (Cell_Number_T) of Boolean := (others => True);
--
-- Workspace for marking the cells that are to be passed through
-- a step, from Pre to Post.
-- Used in Compute_And_Assign, but kept in a global variable to
-- retain the initial value (all True) which is also restored on
-- exit from Compute_And_Assign.
function Feasible_Successors (
After : Step_T;
Post : Cell_Values_Ref;
Within : Computation.Model_Ref)
return Step_List_T
--
-- The "successors" operation for Least_Fixpoint used for constant
-- value propagation.
--
-- Returns the successor steps After the given step, omitting those
-- successors for which the edge precondition evaluates to False
-- under the currently known cell values (Post) flowing from the
-- After step. Only the successors that are feasible Within the
-- given computation model are considered.
--
is
use Arithmetic.Evaluation;
use type Arithmetic.Expr_Ref;
Edges : constant Step_Edge_List_T :=
Computation.Edges_From (After, Within);
-- The edges leaving the step and feasible Within this model.
Targets : Step_List_T (1 .. Edges'Length);
Last : Natural := 0;
-- The accepted successor steps are Targets(1 .. Last).
Cond : Arithmetic.Condition_T;
-- The precondition of the edge under consideration.
Result : Result_T;
-- The result of evaluating Cond under the Post values.
Feasible : Boolean;
-- Whether the edge is feasible under the Post values.
begin
Domain.Values := Post;
for E in Edges'Range loop
Cond := Computation.Condition (
Edge => Edges(E),
Under => Model);
if Cond = Arithmetic.Always then
-- The most common and also easy case.
Feasible := True;
else
Result := Eval (
Expr => Cond,
Within => Domain,
Partly => False);
Feasible := To_Condition (Result) /= Arithmetic.Never;
end if;
if Feasible then
-- Accept this edge as leading to a successor.
Last := Last + 1;
Targets(Last) := Target (Edges(E));
elsif Opt.Trace_Iteration then
Output.Trace (
"Constant propgation ignores infeasible edge"
& Step_Edge_Index_T'Image (Index (Edges(E))));
end if;
end loop;
return Targets(1 .. Last);
end Feasible_Successors;
procedure Compute_And_Assign (
Pre : in Cell_Values_Ref;
Via : in Step_T;
Post : in out Cell_Values_T;
Grew : out Boolean)
--
-- The "transform" operation for Least_Fixpoint used for constant
-- value propagation.
--
-- Interprets the arithmetic expressions and Defining assignments
-- in the step, as constrained by the values (Pre) flowing into
-- the step, and updates the values (Post) flowing out from the
-- step to include the possible assigned values and the flow-
-- through values of the other cells.
--
-- Ignores assignments to volatile cells and instead lets the Pre
-- value flow through to the Post value.
--
-- Uses the (global) array Pass_Cell as workspace, with the
-- pre- and postcondition that it is filled with True values.
--
is
use type Arithmetic.Word_T;
use type Arithmetic.Expr_Kind_T;
Effect : constant Arithmetic.Effect_Ref :=
Computation.Effect (Step => Via, Under => Model);
-- The effect of the step under the given computation model.
Target_Result : Arithmetic.Evaluation.Target_Result_T;
-- The result of evaluating the target of an assignment.
Target : Cell_Number_T;
-- The (number of) the target cell of an assignment,
-- assuming that the target variable is a unique cell.
Result : Arithmetic.Evaluation.Assignment_Result_T;
-- The result of evaluating an assignment.
Value : Value_T;
-- The value of the result, as constrained by the
-- invariant assertions.
Invariant : Value_T;
-- The invariant value (if any) asserted for the target.
begin
-- Evaluate each assignment expression in the step within
-- the domain of cell values defined by Pre, and propagate
-- the assigned abstract value to Post.
Domain.Values := Pre;
Grew := False;
-- Apply the effect:
for E in Effect'Range loop
if Effect(E).Kind in Arithmetic.Defining_Kind_T then
-- A defining assignment.
Target_Result := Arithmetic.Evaluation.Eval (
Target => Effect(E).Target,
Within => Domain,
Partly => False);
if Target_Result.Level = Dynamic_Ref then
-- The target is a dynamic reference and not resolved.
if Opt.Trace_Iteration then
Output.Trace (
"Constant propagation ignores assignment "
& "to dynamic target"
& Output.Field_Separator
& Arithmetic.Image (Effect(E)));
end if;
null; -- TBA aliasing effects.
elsif not Storage.Is_Member (Target_Result.Cell, Named_Cells)
then
-- Target pointer resolved to a new cell, not in Named_Cells.
if Opt.Trace_Iteration then
Output.Trace (
"Constant propagation ignores assignment "
& "to novel cell"
& Output.Field_Separator
& Arithmetic.Image (Effect(E)));
end if;
null; -- TBA something?
elsif Storage.Is_Volatile (Target_Result.Cell) then
-- An assignment to a volatile cell, to be ignored.
-- The value of the cell (if known, i.e. if asserted) is
-- passed through to the Post values.
if Opt.Trace_Iteration then
Output.Trace (
"Constant propagation ignores assignment "
& "to volatile cell"
& Output.Field_Separator
& Arithmetic.Image (Effect(E)));
end if;
else
-- The target is a known non-volatile cell and one of
-- the cells for which we propagate values.
Target :=
Storage.Cell_Numbering.Number (
Cell => Target_Result.Cell,
Under => Domain.Numbers);
if Post(Target).Level /= Variable then
-- We can perhaps add information to Post(Target).
Result := Arithmetic.Evaluation.Eval (
Assignment => Effect(E),
Within => Domain,
Target => Target_Result,
Partly => False);
Value := Arithmetic.Evaluation.Value_Of (Result.Value);
-- Constrain the result with the asserted invariant:
Invariant := Invariant_Values(Target);
if Invariant.Level = Known then
-- This cell has an asserted invariant value.
if Value.Level = Variable then
-- Appears variable, but really invariant.
-- TBD if Value.Level = Relative.
Value := Invariant;
elsif Value.Level = Known
and then Value.Value /= Invariant.Value
then
-- Invariant violation!
Output.Warning (
Locus => Show.Locus (
Step => Via,
Source => Programs.Symbol_Table (Subprogram)),
Text =>
"Assertion violated in step"
& Step_Index_T'Image (Index (Via))
& Output.Field_Separator
& Arithmetic.Image (Effect(E).Target)
& " := "
& Arithmetic.Image (Value.Value)
& " /= "
& Arithmetic.Image (Invariant.Value));
Value := Variable_Value;
end if;
end if;
-- Merge the result into the Post values:
Merge (
More => Value,
Into => Post(Target),
Grew => Grew);
end if;
Pass_Cell(Target) := False;
--
-- Whether or not this defining assignment is evaluated,
-- the cell value is not to be passed from Pre to Post,
-- because either it was assigned by Evaluate to Post, or
-- Post is already Variable.
end if;
else
-- A range constraint assignment.
null; -- TBA evaluate and use Range_Kind assignments.
end if;
end loop;
-- Pass the cells that are not assigned by Effect, unless
-- the cell may be aliased by an assigned cell in which case
-- pass a Variable value:
for C in Cell_Number_T loop
if not Pass_Cell(C) then
-- The cell was assigned in this step, and the assigned
-- value was merged into Post(C).
-- Restore Pass_Cell to all True:
Pass_Cell(C) := True;
elsif Invariant_Values(C).Level = Known
or else Storage.Is_Volatile (Cell_Num(C))
then
-- The cell has an asserted invariant value, or is
-- volatile. For a volatile cell, we want to propagate
-- a possible asserted initial value to all program
-- points. Thus, in both cases, the value of the cell
-- passes from Pre to Post:
if Opt.Trace_Iteration then
Output.Trace (
"Constant propagation merging invariant or "
& "volatile cell "
& Storage.Image (Cell_Num(C)));
end if;
Merge (
More => Pre(C),
Into => Post(C),
Grew => Grew);
elsif Arithmetic.May_Alias (
Cell => Cell_Num (C),
Effect => Effect.all)
-- TBA alias-range for calls if not in Effect call-step.
then
-- The cell is not assigned in this step, and does not
-- have an invariant asserted value, and is at risk from
-- aliasing with the assignment targets. This means that
-- its value becomes unknown (variable) in this step.
if Opt.Trace_Iteration then
Output.Trace (
"In constant propagation, aliasing in step"
& Step_Index_T'Image (Index (Via))
& " hides cell"
& Output.Field_Separator
& Storage.Image (Cell_Num (C)));
end if;
Merge (
More => Variable_Value,
Into => Post(C),
Grew => Grew);
else
-- The cell is not assigned in this step, does not have
-- an invariant asserted value, and is neither volatile
-- nor at risk from aliasing with the assignment targets.
-- This means that its value passes through, unchanged,
-- from Pre to Post.
Merge (
More => Pre(C),
Into => Post(C),
Grew => Grew);
end if;
end loop;
end Compute_And_Assign;
procedure Compute_And_Assign_Ref (
Pre : in Cell_Values_Ref;
Via : in Step_T;
Post : in out Cell_Values_Ref;
Grew : out Boolean)
--
-- The "transform" operation for Least_Fixpoint used for constant
-- value propagation. Same as Compute_And_Assign but the Post
-- parameter is a reference (access) as Least_Fixpoint requires
-- in our instance.
--
is
begin
Compute_And_Assign (
Pre => Pre,
Via => Via,
Post => Post.all,
Grew => Grew);
if Opt.Trace_Iteration then
Trace (
Action => "Trans",
Step => Via,
Source => null,
Input => Pre.all,
Output => Post.all,
Grew => Grew);
end if;
end Compute_And_Assign_Ref;
procedure Initialize_Values (
Via : in Step_T;
Pre : out Cell_Values_Ref;
Post : out Cell_Values_Ref;
Grew : out Boolean)
--
-- The "initialize" operation for Least_Fixpoint for constant
-- value propagation.
--
-- Initializes the cell values that flow into the step (Pre) to
-- be bounded only by the global assertions, and the cell
-- values after the step (Post) by interpreting the assignments
-- in the step on the initialized values that flow into the
-- step.
--
-- As a special case, for the entry step the Initial bounds
-- (entry to subprogram) and also taken into account in the
-- flow into the step.
--
is
begin
-- Initialize the values flowing into the step:
if Via = Entry_Step (Graph) then
-- The initial bounds apply (only) to the entry step.
-- The globally asserted bounds also apply.
Pre := new Cell_Values_T'(
To_Values (
Given => Initial,
Default => Relative));
--
-- For those cells that are not hereby constrained to
-- single values, a variable or relative value is fed
-- into the flow-graph from the caller.
else
-- General case: not entry step.
-- Only the globally asserted bounds apply.
Pre := new Cell_Values_T'(Invariant_Values);
end if;
-- TBA/TBC other assertions: calls, loops.
-- Effect of step on values after the step:
Post := new Cell_Values_T'(Invariant_Values);
Compute_And_Assign (
Pre => Pre,
Via => Via,
Post => Post.all,
Grew => Grew);
--
-- TBC if Grew is correct if Via is the entry step
-- and there is an edge from Via to itself, meeting
-- the Pre value taken from Initial and Asserted and
-- not just Invariant_Values which is the reference
-- value of Post visavi Grew.
if Opt.Trace_Iteration then
Trace (
Action => "Init",
Step => Via,
Source => null,
Input => Pre.all,
Output => Post.all,
Grew => Grew);
end if;
end Initialize_Values;
-- TBA verification of computed constant values against
-- Asserted bounds (not just against Invariant_Values).
procedure Merge_Values (
Source : in Step_T;
Post : in Cell_Values_Ref;
Target : in Step_T;
Pre : in out Cell_Values_Ref;
Grew : out Boolean)
--
-- The "merge" operation for Least_Fixpoint for constant
-- propagation.
--
-- Updates the cell values that flow into the Target step (Pre),
-- using a new set of cell values (Post) generated from the
-- Source step, which is a predecessor of Target.
--
is
begin
Grew := False;
-- Default value unless changes noted below.
for N in Cell_Number_T loop
Merge (
More => Post(N),
Into => Pre (N),
Grew => Grew);
end loop;
if Opt.Trace_Iteration then
Trace (
Action => "Merge",
Step => Target,
Source => Source,
Input => Post.all,
Output => Pre.all,
Grew => Grew);
end if;
end Merge_Values;
procedure Finalize (Item : in out Cell_Values_Ref)
--
-- The "Finalize" operation for Least_Fixpoint.
--
is
begin
Discard (Item);
-- Deallocate the vector of cell values.
end Finalize;
function Constant_Cell_Values
is new Least_Fixpoint (
Graph => Computation.Model_Ref,
Node => Step_T,
Node_List => Step_List_T,
Index_Of => Number,
Successors => Feasible_Successors,
Value => Cell_Values_Ref,
Value_List => Cell_Values_List_T,
Initialize => Initialize_Values,
Transform => Compute_And_Assign_Ref,
Merge => Merge_Values,
Finalize => Finalize);
--
-- Instance of Least_Fixpoint for constant propagation.
procedure Show_Cell_Values
--
-- Displays the computed value information.
--
is
use Ada.Text_IO;
Cell_Value_Col : constant := 10;
-- Column for the first cell value, in the cell value table.
Cell_Value_Width : constant := 8;
-- The width of each column in the cell value table.
Value_Col : Positive_Count;
-- Current column in cell value table.
begin
New_Line;
Put_Line (
"Constant propagation results for "
& Programs.Name (Subprogram));
New_Line;
Put_Line (
Arithmetic.Evaluation.Unknown_Image
& " means unknown (not reached)");
Put_Line (
Arithmetic.Evaluation.Variable_Image
& " means variable (not constant)");
New_Line;
Set_Col (Cell_Value_Col);
Put_Line ("Cell values flowing into the step, by Cell #");
Put ("Step#");
Value_Col := Cell_Value_Col;
for C in Cell_Number_T loop
Set_Col (Value_Col - 1);
Put (Cell_Number_T'Image (C));
Value_Col := Value_Col + Cell_Value_Width;
end loop;
New_Line;
for S in Steps'Range loop
Put (Step_Index_T'Image (Index(Steps(S))));
Value_Col := Cell_Value_Col;
for C in Cell_Number_T loop
Set_Col (Value_Col - 1); Put (' ');
Put (Image (Values(S)(C)));
Value_Col := Value_Col + Cell_Value_Width;
end loop;
New_Line;
end loop;
New_Line;
Put_Line (
"End of constant propagation results for "
& Programs.Name (Subprogram));
New_Line (2);
end Show_Cell_Values;
procedure Bound_Calls
--
-- Bounds the dynamic calling protocols for all (feasible) calls
-- from the Subprogram using the computed Values. Sets Bounded to
-- True if some dynamic protocol(s)are successfully bounded, and
-- for such calls also updates the effect of the call-step to use
-- the new protocol.
--
-- If this is the final round of Propagate_Constants (that is, if
-- Last_Round or not Bounded) this operation also extracts input
-- bounds from Values for all feasible calls and stores them in
-- Bounds.
--
is
use type Calling.Protocol_Ref;
Calls : constant Programs.Execution.Call_Bounds_List_T :=
Programs.Execution.Call_Bounds (Bounds);
-- The calls from the Subprogram that are (still) feasible
-- under the present computation model, together with execution
-- bounds on the callees (from earlier analyses of the callees).
Call : Programs.Call_T;
-- One of the Calls.
Call_Mark : Output.Nest_Mark_T;
-- For the locus of the Call.
Protocol_Bounded : Boolean;
-- Whether the calling protocol for the Call was bounded or
-- constrained to a tighter protocol.
begin
-- Bound the dynamic protocols if any:
for C in Calls'Range loop
Call := Calls(C).Call;
if not Computation.Calling_Protocol_Is_Static (Call, Model)
then
-- The protocol is dynamic and can perhaps be bounded.
Call_Mark := Output.Nest (Programs.Locus (Call));
begin
Domain.Values := Values(Number (Programs.Step (Call)));
-- The cell-bounds on entry to the Call, as computed
-- by constant propagation.
-- TBM to include the Asserted bounds.
-- TBM? to include (existing) input bounds from Bounds.
Standard.Bounds.Calling.Bound_Protocol (
Call => Call,
Data => Domain,
Model => Model,
Bounded => Protocol_Bounded);
if Protocol_Bounded then
Bounded := True;
-- A new computation model is formed, so a new
-- round of Propagate_Constants is desirable.
end if;
exception
when Flow.False_Path =>
-- This call seems to be infeasible.
Computation.Mark_Infeasible (Call, Model);
end;
Output.Unnest (Call_Mark);
end if;
end loop;
-- Bound the inputs for the calls:
if Last_Round or not Bounded then
-- The Values and Model are as good as it gets, so now it makes
-- sense to compute and store the input bounds for the calls.
for C in Calls'Range loop
Call := Calls(C).Call;
Call_Mark := Output.Nest (Programs.Locus (Call));
Domain.Values := Values(Number (Programs.Step (Call)));
Programs.Execution.Bound_Call_Input (
Call => Call,
Bounds => Known_Values (
Cells =>
Programs.Execution.Input_Cells (Calls(C).Bounds),
Domain => Domain),
Within => Bounds);
Output.Unnest (Call_Mark);
end loop;
end if;
exception
when others =>
-- Clean up the output locus and punt:
Output.Unnest (Call_Mark);
raise;
end Bound_Calls;
procedure Find_Final_Stack_Height (
Stack : in Programs.Stack_T;
Returns : in Step_List_T;
SH : in Cell_Number_T;
Giving : out Programs.Execution.Final_Stack_Height_T)
--
-- Finds the final local stack height in the given Stack for the
-- Return steps. Assumes that the stack-height cell for the given
-- Stack is a member of Named_Cells with number SH.
--
-- This procedure is called only for an Unstable Stack because the
-- final local stack height for Stable stacks is known (assumed).
--
-- Enters the result in the Bounds and also returns it in Giving.
--
is
Step : Step_T;
-- The return step under inspection.
Post : Cell_Values_T;
-- The cell values after the Step.
Grew : Boolean;
-- Unused output from Compute_And_Assign.
Height : Value_T;
-- The stack-height after the Step, from Post.
Known_Returns : Natural := 0;
-- The number of Return steps for which a constant final
-- stack-height was found.
Autograph : constant String :=
"Flow.Const.Propagate_Constants.Find_Final_Stack_Height";
-- For Fault messages.
Final : Storage.Bounds.Interval_T := Storage.Bounds.Void_Interval;
-- Collecting the final stack-height values.
begin
-- Find the bounds on the stack height after all Return steps:
for R in Returns'Range loop
Step := Returns(R);
if Computation.Is_Feasible (Step, Model) then
-- Compute the state after the return:
Post := Invariant_Values;
Compute_And_Assign (
Pre => Values(Number (Step)),
Via => Step,
Post => Post,
Grew => Grew);
Height := Post(SH);
case Height.Level is
when Unknown =>
if Opt.Refine_Edge_Conditions then
-- This should not happen.
Output.Fault (
Location => Autograph,
Text =>
"Feasible return step"
& Positive'Image (Number (Step))
& " has unknown final stack-height for stack "
& Programs.Name (Stack));
-- else
-- This step was omitted from the analysis because it
-- is infeasible, but it was not marked as infeasible
-- because edge-conditions are not refined.
end if;
when Known =>
Storage.Bounds.Widen (
Interval => Final,
To_Contain => Arithmetic.Signed_Value (
Word => Height.Value,
Width => Programs.Width_Of (Stack)));
Known_Returns := Known_Returns + 1;
when Variable | Relative =>
Final := Storage.Bounds.Universal_Interval;
end case;
end if;
end loop;
if Returns'Length > 0 then
Output.Note (
"Final stack-height in stack "
& Programs.Name (Stack)
& " is constant for"
& Natural'Image (Known_Returns)
& " of"
& Natural'Image (Returns'Length)
& " return points.");
else
-- No return points? Never returns?
Output.Note (
"No return steps for final stack-height in stack "
& Programs.Name (Stack));
Final := Storage.Bounds.Singleton (0);
-- Just to bound it, although the bound should never
-- be relevant.
end if;
Giving := Programs.Execution.To_Stack_Limit (Final);
Output.Note (
"Final stack-height from constant propagation for "
& Programs.Name (Stack)
& Output.Field_Separator
& Programs.Execution.Image (
Item => Giving,
Name => Storage.Image (Cell_Num (SH))));
Stacking_Opt.Ignore_Huge_Bounds (Giving);
Programs.Execution.Bound_Final_Stack_Height (
Stack => Stack,
To => Giving,
Within => Bounds);
end Find_Final_Stack_Height;
procedure Find_Stack_Heights (
Stack : in Programs.Stack_T;
Calls : in Programs.Call_List_T;
SH : in Cell_Number_T;
Final : in Programs.Execution.Final_Stack_Height_T)
--
-- Finds the maximum local stack height and the take-off heights
-- in the given Stack for the given Calls, when these heights have
-- been found to be constant. Assumes that the stack-height cell
-- for the given Stack is a member of Named_Cells with number SH.
-- The (bounds on the) Final local stack height have already been
-- computed and take part in the maximum.
--
is
Max_Stack : Programs.Execution.Stack_Limit_T :=
Programs.Execution.To_Stack_Limit (
Storage.Bounds.Singleton (0));
-- Collects the maximum stack height over all steps.
Step : Step_T;
-- The step under inspection.
Height : Value_T;
-- The stack-height at Step.
Known_Calls : Natural := 0;
-- The number of Calls for which a constant take-off
-- stack-height was found.
Autograph : constant String :=
"Flow.Const.Propagate_Constants.Find_Stack_Heights";
-- For Fault messages.
Take_Off : Programs.Execution.Stack_Limit_T;
-- The take-off height for a call.
begin
-- Consider the final stack height:
Max_Stack := Programs.Execution.Max (Max_Stack, Final);
-- Find the maximum stack height over all steps, using the
-- stack height on entry to the step:
for S in Steps'Range loop
Step := Steps(S);
if Computation.Is_Feasible (Step, Model) then
Height := Values(S)(SH);
case Height.Level is
when Unknown =>
if Opt.Refine_Edge_Conditions then
-- This should not happen.
Output.Fault (
Location => Autograph,
Text =>
"Feasible step"
& Positive'Image (S)
& " has unknown stack-height for stack "
& Programs.Name (Stack));
-- else
-- This step was omitted from the analysis because it
-- is infeasible, but it was not marked as infeasible
-- because edge-conditions are not refined.
end if;
when Known =>
Max_Stack := Programs.Execution.Max (
Max_Stack,
Arithmetic.Signed_Value (
Word => Height.Value,
Width => Programs.Width_Of (Stack)));
when Variable | Relative =>
Max_Stack := Programs.Execution.Unbounded;
end case;
end if;
end loop;
Output.Note (
"Maximum stack-height from constant propagation for "
& Programs.Name (Stack)
& Output.Field_Separator
& Programs.Execution.Max_Image (Max_Stack));
Stacking_Opt.Ignore_Huge_Bounds (Max_Stack);
Programs.Execution.Bound_Stack_Height (
Stack => Stack,
To => Max_Stack,
Within => Bounds);
-- Take-off height for all calls:
for C in Calls'Range loop
Step := Programs.Step (Calls(C));
if Computation.Is_Feasible (Step, Model) then
Height := Values(Number(Step))(SH);
case Height.Level is
when Unknown =>
if Opt.Refine_Edge_Conditions then
-- This should not happen.
Output.Fault (
Location => Autograph,
Text =>
"Feasible call-step"
& Positive'Image (Number (Step))
& " has unknown stack-height for stack "
& Programs.Name (Stack));
-- else
-- This step was omitted from the analysis because it
-- is infeasible, but it was not marked as infeasible
-- because edge-conditions are not refined.
end if;
Take_Off := Programs.Execution.Unbounded;
when Known =>
Take_Off := Programs.Execution.To_Stack_Limit (
Storage.Bounds.Singleton (
Arithmetic.Signed_Value (
Word => Height.Value,
Width => Programs.Width_Of (Stack))));
Known_Calls := Known_Calls + 1;
when Variable | Relative =>
Take_Off := Programs.Execution.Unbounded;
end case;
Stacking_Opt.Ignore_Huge_Bounds (Take_Off);
Programs.Execution.Bound_Take_Off_Height (
Stack => Stack,
Before => Calls(C),
To => Take_Off,
Within => Bounds);
end if;
end loop;
Output.Note (
"Take-off stack-height in stack "
& Programs.Name (Stack)
& " is constant for"
& Natural'Image (Known_Calls)
& " of"
& Natural'Image (Calls'Length)
& " calls.");
end Find_Stack_Heights;
function Height_For_Unused (Stack : Programs.Stack_T)
return Programs.Execution.Stack_Limit_T
--
-- The height (limit) to be used for a Stack when the
-- subprogram does not change the stack-height cell.
--
is
Height : constant Storage.Cell_T := Programs.Height (Stack);
-- The stack-height cell.
begin
-- Use the bounds on the stack-height from the Initial bounds:
return Programs.Execution.To_Stack_Limit (
Storage.Bounds.Interval (
Cell => Height,
From => Initial));
end Height_For_Unused;
procedure Bound_Stack_Heights
--
-- Bounds the local stack-height and the take-off height for
-- all (feasible) calls from the Subprogram and all stacks.
--
is
Stacks : constant Programs.Stacks_T := Programs.Stacks (Program);
-- All the stacks in the program.
Calls : constant Programs.Call_List_T :=
Computation.Calls_From (Model);
-- The calls from the Subprogram that are (still) feasible
-- under the present Model.
Stack_Height : Storage.Cell_T;
-- The stack-height cell for the current stack.
SH : Cell_Number_T;
-- The number of the Stack_Height cell, in our numbering.
Unused_Height : Programs.Execution.Stack_Limit_T;
-- The height limit for a stack where the subprogram
-- does not access the stack-height cell.
Net_Change : Storage.Bounds.Limit_T;
-- The possibly known net change in stack height = final stack
-- height at return.
Final_Height : Programs.Execution.Final_Stack_Height_T;
-- The final (local) stack height for the stack.
begin
for S in Stacks'Range loop
Stack_Height := Programs.Height (Stacks(S));
if not Storage.Is_Member (Stack_Height, Named_Cells) then
-- This stack-height cell is not accessed in this flow-graph.
-- Use the initial stack-height limit for this stack and
-- subprogram.
Unused_Height := Height_For_Unused (Stack => Stacks(S));
Output.Note (
"No change in initial stack-height for stack "
& Programs.Name (Stacks(S))
& Output.Field_Separator
& Programs.Execution.Max_Image (Unused_Height));
Programs.Execution.Bound_Stack_Height (
Stack => Stacks(S),
To => Unused_Height,
Within => Bounds);
for C in Calls'Range loop
Programs.Execution.Bound_Take_Off_Height (
Stack => Stacks(S),
Before => Calls(C),
To => Unused_Height,
Within => Bounds);
end loop;
-- The final stack height is zero. For a Stable stack
-- this is the defined (but irrelevant) value; for an
-- Unstable stack this is the result of making no changes
-- to an initial zero stack height.
Programs.Execution.Bound_Final_Stack_Height (
Stack => Stacks(S),
To => Programs.Execution.To_Stack_Limit (
Storage.Bounds.Exactly_Zero),
Within => Bounds);
else
-- This stack-height cell is used or manipulated in the
-- subprogram, and we have tried to compute constant values
-- for it at each step. We scan these values to find the
-- maximum local stack height and the take-off heights.
SH := Storage.Cell_Numbering.Number (
Cell => Stack_Height,
Under => Domain.Numbers);
-- First we find the final stack height, because it too is
-- a contributor to the upper bound on the local stack height
-- when a return step can increase the height:
Net_Change := Programs.Net_Change (Stacks(S));
Final_Height := Programs.Execution.Final_Stack_Height (
Stack => Stacks(S),
Within => Bounds);
if Programs.Execution.Singular (Final_Height) then
-- The final height is already known precisely.
null;
elsif Storage.Bounds.Known (Net_Change) then
-- The net change = final height of this stack is known to
-- be the same for all calls of all subprograms. No need to
-- do any work to find it.
Output.Note (
"Fixed final height of stack "
& Programs.Name (Stacks(S))
& Output.Field_Separator
& Storage.Bounds.Image (Net_Change));
Final_Height := Programs.Execution.One_Or_All (Net_Change);
Programs.Execution.Bound_Final_Stack_Height (
Stack => Stacks(S),
To => Final_Height,
Within => Bounds);
else
-- The net change = final height of this stack may vary
-- from subprogram to subprogram. Working, working...
Find_Final_Stack_Height (
Stack => Stacks(S),
Returns => Computation.Final_Steps (Model),
SH => SH,
Giving => Final_Height);
end if;
Find_Stack_Heights (
Stack => Stacks(S),
Calls => Calls,
SH => SH,
Final => Final_Height);
end if;
end loop;
end Bound_Stack_Heights;
procedure Resolve_Dynamic_Edges
--
-- Applies the computed Values as bounds on the (remaining
-- feasible and Unresolved) dynamic edges in the Graph, trying
-- to resolve them into statically known edges.
--
is
Dyn_Edges : constant Dynamic_Edge_List_T :=
Computation.Unstable_Dynamic_Edges (Model);
-- The dynamic (boundable) edges in the Graph that are
-- still feasible under the (refined) Model and are
-- still not stably resolved (or stably unresolved).
Edge : Dynamic_Edge_T;
-- One of the dynamic edges.
Step : Step_T;
-- The source of the Edge.
Step_Mark : Output.Nest_Mark_T;
-- The locus of the Step.
begin
for D in Dyn_Edges'Range loop
Edge := Dyn_Edges(D);
Step := Source (Edge.all);
Step_Mark := Output.Nest (Show.Locus (
Step => Step,
Source => Programs.Symbol_Table (Program)));
Domain.Values := Values(Number (Step));
Apply (
Bounds => Domain,
Upon => Edge.all,
Graph => Graph);
Output.Unnest (Step_Mark);
end loop;
end Resolve_Dynamic_Edges;
begin -- Propagate_Constants
if Opt.Trace_Iteration
or Opt.Show_Results
then
Output.Trace (
"Constant propagation round"
& Positive'Image (Round)
& " starts for"
& Natural'Image (Cell_Num'Length)
& " cells.");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line ("Cell numbering for constant propagation:");
Storage.Cell_Numbering.Show (Domain.Numbers);
end if;
Bounded := False;
-- Initially. Will be changed to True if some dynamic reference
-- or calling protocol is bounded.
-- Compute cell values by constant propagation (phase 1):
Values := Constant_Cell_Values (
Nodes => Steps,
Edges => Natural (Max_Step_Edge (Graph)),
Within => Model);
if Opt.Show_Results then
Show_Cell_Values;
end if;
-- Create the new computation model (phase 2):
for S in Steps'Range loop
if Computation.Is_Feasible (Steps(S), Model) then
Domain.Values := Values(S);
Refine (
Step => Steps(S),
Domain => Domain,
Post => Work_Post,
Program => Program,
Model => Model,
Bounded => Bounded);
end if;
end loop;
-- Prune the graph (phase 3):
Computation.Prune (Model);
-- Bound calling protocols and inputs for calls (phase 4):
Bound_Calls;
-- And again prune the graph (phase 5):
Computation.Prune (Model);
-- Are we done?
if Last_Round
or not Programs.Execution.Computation_Changed (Bounds)
then
-- The computation model is stable, or we will not iterate
-- further on it.
-- Determine local stack heights and take-off heights (phase 6):
if Programs.Number_Of_Stacks (Program) > 0
and Opt.Resolve_Stack
then
-- There are some stack-heights that we can bound.
Bound_Stack_Heights;
end if;
-- Apply the constant values to bound dynamic flow (phase 7):
if Opt.Resolve_Flow then
Resolve_Dynamic_Edges;
end if;
end if;
-- Some working data are no longer needed:
Storage.Discard (Named_Cells);
Storage.Cell_Numbering.Discard (Domain.Numbers);
for V in Values'Range loop
Discard (Values(V));
end loop;
Discard (Work_Post);
end Propagate_Constants;
--
-- Provided operations:
--
procedure Propagate (
Subprogram : in Programs.Subprogram_T;
Asserted : in Storage.Bounds.Var_Interval_List_T;
Bounds : in Programs.Execution.Bounds_Ref)
is
use type Storage.Bounds.Cell_Interval_List_T;
Initial : constant Storage.Bounds.Cell_Interval_List_T :=
Programs.Execution.Initial (Bounds)
and Storage.Bounds.Cell_Intervals (
From => Asserted,
Point => Programs.Entry_Address (Subprogram));
--
-- The "and" conjunction of the Initial and Asserted bound lists
-- computes the intersection of the bounds, if the same cell appears
-- in both lists. For those cells that are not hereby constrained to
-- single values, a variable or relative value is fed into the
-- flow-graph from the caller.
--
-- The Asserted bounds are probably already included in the Initial
-- bounds (vide package Bounds) but including them again does no
-- harm and makes this package more general.
Pointers_Bounded : Boolean;
-- Whether Propagate_Constants was able to resolve or bound some
-- pointers for dynamically addressed data.
Rounds : Natural := 0;
-- Counts the number of iterations of Propagate_Constants to make
-- use of resolved or bounded data pointers.
begin
if Opt.Propagate then
-- Constant propagation is enabled.
-- We repeat it until the computation model is stable, or
-- the flow-graph grows through resolved dynamic edges, or
-- the iteration limit is reached.
-- Optionally show the initial and invariant bounds:
if Opt.Show_Results
or Opt.Trace_Iteration
then
Output.Trace (
"Constant propagation initial bounds"
& Output.Field_Separator
& Storage.Bounds.Image (Initial));
if Asserted'Length > 0 then
Output.Trace (
"Constant propagation invariant bounds:");
for A in Asserted'Range loop
Output.Trace (
"Location"
& Output.Field_Separator
& Storage.Image (Asserted(A).Location.all));
Output.Trace (
"Interval"
& Output.Field_Separator
& Storage.Bounds.Image (Asserted(A).Interval));
end loop;
end if;
end if;
-- Propagate constants, repeatedly:
loop
Rounds := Rounds + 1;
Propagate_Constants (
Subprogram => Subprogram,
Asserted => Asserted,
Initial => Initial,
Round => Rounds,
Last_Round => Rounds >= Opt.Max_Pointer_Iterations,
Bounded => Pointers_Bounded,
Bounds => Bounds);
if not Programs.Execution.Computation_Changed (Bounds) then
-- Constant propagation did not change the computation
-- model in any way. We have nothing more to do here.
Output.Note ("Constant propagation changed nothing.");
exit;
end if;
if Programs.Execution.Dynamic_Flow (Bounds) = Growing then
-- Constant propagation resolved some dynamic edges and
-- the flow-graph is thus growing. Even if the computation
-- model changed we have no reason to do any more work on
-- this model, because we will anyway build a new model
-- for the extended flow-graph.
if Opt.Show_Results then
Output.Trace (
"Constant propagation resolved dynamic edges.");
end if;
exit;
end if;
-- Constant propagation changed the computation model in
-- some ways, by simplifying the effects or conditions or
-- by resolving dynamic memory references or calling
-- protocols, but the flow-graph is not (yet) growing, so
-- we will continue with this computation model.
if Opt.Show_Results then
Output.Trace (
"Constant propagation refined the computation.");
end if;
Programs.Execution.Note_Updated_Computation (Bounds);
Programs.Execution.Mark_Computation_Clean (Bounds);
if Rounds >= Opt.Max_Pointer_Iterations then
Output.Warning (
"Constant propagation stops at iteration limit.");
exit;
end if;
Output.Note ("Repeating constant propagation.");
end loop;
end if;
end Propagate;
end Flow.Const;
|
stcarrez/ada-keystore | Ada | 9,842 | adb | -----------------------------------------------------------------------
-- keystore-verifier -- Toolbox to explore raw content of keystore
-- Copyright (C) 2019, 2021, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Interfaces.C.Strings;
with Ada.IO_Exceptions;
with Ada.Text_IO;
with Util.Strings;
with Util.Systems.Os;
with Util.Systems.Types;
with Util.Systems.Constants;
with Util.Streams.Raw;
with Util.Log.Loggers;
with Util.Encoders;
with Keystore.Buffers;
with Keystore.Marshallers;
with Keystore.IO.Headers;
with Keystore.Passwords.GPG;
with Intl;
package body Keystore.Verifier is
use type Interfaces.Unsigned_16;
use type Interfaces.Unsigned_32;
use type Interfaces.C.int;
use type Ada.Text_IO.Count;
use Ada.Streams;
use Util.Systems.Constants;
use Util.Systems.Types;
use type Keystore.Buffers.Block_Count;
use type Keystore.IO.Storage_Identifier;
function "-" (Message : in String) return String is (Intl."-" (Message));
function Sys_Error return String;
function Get_Storage_Id (Path : in String) return IO.Storage_Identifier;
procedure Open (Path : in String;
File : in out Util.Streams.Raw.Raw_Stream;
Sign : in Secret_Key;
Header : in out Keystore.IO.Headers.Wallet_Header;
Is_Keystore : out Boolean);
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Keystore.Verifier");
function Sys_Error return String is
Msg : constant Interfaces.C.Strings.chars_ptr
:= Util.Systems.Os.Strerror (Util.Systems.Os.Errno);
begin
return Interfaces.C.Strings.Value (Msg);
end Sys_Error;
function Get_Storage_Id (Path : in String) return IO.Storage_Identifier is
Pos : Natural;
begin
if Util.Strings.Ends_With (Path, ".dkt") then
Pos := Util.Strings.Rindex (Path, '-');
if Pos = 0 then
return IO.DEFAULT_STORAGE_ID;
end if;
return IO.Storage_Identifier'Value (Path (Pos + 1 .. Path'Last - 4));
else
return IO.DEFAULT_STORAGE_ID;
end if;
exception
when Constraint_Error =>
return IO.DEFAULT_STORAGE_ID;
end Get_Storage_Id;
procedure Open (Path : in String;
File : in out Util.Streams.Raw.Raw_Stream;
Sign : in Secret_Key;
Header : in out Keystore.IO.Headers.Wallet_Header;
Is_Keystore : out Boolean) is
-- Compilation on Windows requires this type visibility but GNAT 2019 complains.
pragma Warnings (Off);
use type Util.Systems.Types.File_Type;
pragma Warnings (On);
Storage_Id : constant IO.Storage_Identifier := Get_Storage_Id (Path);
Fd : Util.Systems.Types.File_Type := Util.Systems.Os.NO_FILE;
P : Interfaces.C.Strings.chars_ptr;
Flags : Interfaces.C.int;
Stat : aliased Util.Systems.Types.Stat_Type;
Result : Integer;
begin
Flags := O_CLOEXEC + O_RDONLY;
P := Interfaces.C.Strings.New_String (Path);
Fd := Util.Systems.Os.Sys_Open (P, Flags, 8#600#);
Interfaces.C.Strings.Free (P);
if Fd = Util.Systems.Os.NO_FILE then
Log.Error (-("cannot open keystore '{0}': {1}"), Path, Sys_Error);
raise Ada.IO_Exceptions.Name_Error with Path;
end if;
Result := Util.Systems.Os.Sys_Fstat (Fd, Stat'Access);
if Result /= 0 then
Result := Util.Systems.Os.Sys_Close (Fd);
Log.Error (-("invalid keystore file '{0}': {1}"), Path, Sys_Error);
raise Ada.IO_Exceptions.Name_Error with Path;
end if;
Ada.Text_IO.Put ("Path");
Ada.Text_IO.Set_Col (30);
Ada.Text_IO.Put_Line (Path);
Ada.Text_IO.Put ("File size");
Ada.Text_IO.Set_Col (30 - 1);
Ada.Text_IO.Put_Line (off_t'Image (Stat.st_size));
if Stat.st_size mod IO.Block_Size /= 0 then
Result := Util.Systems.Os.Sys_Close (Fd);
Log.Error (-("invalid or truncated keystore file '{0}': size is incorrect"), Path);
raise Ada.IO_Exceptions.Name_Error with Path;
end if;
File.Initialize (Fd);
Header.Buffer := Buffers.Allocate ((Storage_Id, IO.HEADER_BLOCK_NUM));
declare
Buf : constant Buffers.Buffer_Accessor := Header.Buffer.Data.Value;
Last : Ada.Streams.Stream_Element_Offset;
Data : Keystore.IO.IO_Block_Type;
begin
File.Read (Data, Last);
if Last /= Data'Last then
Log.Warn ("Header block is too short");
raise Invalid_Keystore;
end if;
Buf.Data := Data (Buf.Data'Range);
Keystore.IO.Headers.Sign_Header (Header, Sign);
if Header.HMAC /= Data (Keystore.IO.BT_HMAC_HEADER_POS .. Data'Last) then
Log.Warn ("Header block HMAC signature is invalid");
-- raise Invalid_Block;
end if;
Keystore.IO.Headers.Read_Header (Header);
Is_Keystore := Storage_Id = IO.DEFAULT_STORAGE_ID;
Ada.Text_IO.Put ("Type");
Ada.Text_IO.Set_Col (30);
if not Is_Keystore then
Ada.Text_IO.Put ("storage");
Ada.Text_IO.Put_Line (IO.Storage_Identifier'Image (Storage_Id));
else
Ada.Text_IO.Put_Line ("keystore");
end if;
end;
end Open;
procedure Print_Information (Path : in String;
Is_Keystore : out Boolean) is
Header : Keystore.IO.Headers.Wallet_Header;
File : Util.Streams.Raw.Raw_Stream;
Sign : Secret_Key (Length => 32);
Data : Ada.Streams.Stream_Element_Array (1 .. 1024);
Last : Ada.Streams.Stream_Element_Offset;
Kind : Header_Slot_Type;
Encode : constant Util.Encoders.Encoder := Util.Encoders.Create ("hex");
begin
Open (Path => Path,
File => File,
Sign => Sign,
Header => Header,
Is_Keystore => Is_Keystore);
Ada.Text_IO.Put ("UUID");
Ada.Text_IO.Set_Col (30);
Ada.Text_IO.Put_Line (To_String (Header.UUID));
Ada.Text_IO.Put ("HMAC");
Ada.Text_IO.Set_Col (30);
Ada.Text_IO.Put_Line (Encode.Encode_Binary (Header.HMAC));
Ada.Text_IO.Put ("Header data");
Ada.Text_IO.Set_Col (29);
Ada.Text_IO.Put_Line (Header_Slot_Count_Type'Image (Header.Data_Count));
for I in 1 .. Header.Data_Count loop
IO.Headers.Get_Header_Data (Header, I, Kind, Data, Last);
Ada.Text_IO.Put (Header_Slot_Count_Type'Image (I));
Ada.Text_IO.Put (" Kind");
Ada.Text_IO.Set_Col (29);
Ada.Text_IO.Put (Header_Slot_Type'Image (Kind));
Ada.Text_IO.Set_Col (39);
Ada.Text_IO.Put (Stream_Element_Offset'Image (Last));
Ada.Text_IO.Put (" bytes ");
Ada.Text_IO.Put_Line (Keystore.Passwords.GPG.Extract_Key_Id (Data));
end loop;
declare
procedure Report;
Buf : constant Buffers.Buffer_Accessor := Header.Buffer.Data.Value;
Last : Ada.Streams.Stream_Element_Offset;
Data : Keystore.IO.IO_Block_Type;
Block : IO.Block_Number := 1;
Buffer : Keystore.Marshallers.Marshaller;
Btype : Interfaces.Unsigned_16;
Esize : Interfaces.Unsigned_16 with Unreferenced;
Id : Interfaces.Unsigned_32;
Current_Id : Interfaces.Unsigned_32 := 0;
Current_Type : Interfaces.Unsigned_16 := 0;
First_Block : IO.Block_Number := 1;
procedure Report is
begin
Ada.Text_IO.Put (IO.Block_Number'Image (First_Block));
if First_Block + 1 < Block then
Ada.Text_IO.Put ("..");
Ada.Text_IO.Put (IO.Block_Number'Image (Block - 1));
end if;
Ada.Text_IO.Put (" Wallet");
Ada.Text_IO.Put (Interfaces.Unsigned_32'Image (Current_Id));
if Current_Type = IO.BT_WALLET_DIRECTORY then
Ada.Text_IO.Put (" Directory");
elsif Current_Type = IO.BT_WALLET_HEADER then
Ada.Text_IO.Put (" Header");
elsif Current_Type = IO.BT_WALLET_DATA then
Ada.Text_IO.Put (" Data");
else
Ada.Text_IO.Put (" Unkown");
end if;
Ada.Text_IO.New_Line;
end Report;
begin
loop
File.Read (Data, Last);
exit when Last /= Data'Last;
Buffer.Buffer := Header.Buffer;
Buf.Data := Data (Buf.Data'Range);
Btype := Marshallers.Get_Header_16 (Buffer);
Esize := Marshallers.Get_Unsigned_16 (Buffer);
Id := Marshallers.Get_Unsigned_32 (Buffer);
if Btype /= Current_Type or else Id /= Current_Id then
if Current_Id > 0 then
Report;
end if;
Current_Id := Id;
Current_Type := Btype;
First_Block := Block;
end if;
Block := Block + 1;
end loop;
Report;
end;
end Print_Information;
end Keystore.Verifier;
|
MatrixMike/AdaDemo1 | Ada | 3,299 | adb | ------------------------------------------------------------------------------
-- Copyright (C) 2018, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with this software; see file --
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
-- of the license. --
------------------------------------------------------------------------------
-- This simple example shows a scrolling text on the micro:bit LED matrix.
--
-- It is intended as first project to get familiar with Ada and GNAT
-- Programing Studio on the micro:bit.
--
-- For more advanced micro:bit features please have a look at the
-- Ada_Drivers_Library project: https://github.com/AdaCore/Ada_Drivers_Library
--
-- The micro:bit has a 5 x 5 multiplexed LED matrix, this means only one LED
-- can be lit at a time. To overcome this limitation, the LEDs are lit one
-- after the other very quickly. This process, called scanning, happens so fast
-- that the human eyes sees all the LED lit together (persistence of vision).
-- In this example, the scan is done with a periodic Timing_Event. Timing_Event
-- is an Ada standard feature that allows you to have a callback executed at a
-- give point in time and can be used to create periodic timers. The periodic
-- timers are implemented in the Generic_Timer package.
--
-- The LED matrix initialization and text scrolling are implemented in the
-- Display package.
--
-- The hardware maping for the GPIOs has been generated from a SVD description
-- file using SVD2Ada: https://github.com/AdaCore/svd2ada
with Display;
with Ada.Text_Io; use Ada.Text_Io;
--with Ada.Text_Io.Editing; use Ada.Text_Io.Editing;
--with Ada.Numerics.Elementary_Functions;
--with Ada.Float_Text_IO;
procedure Main is
subtype Name_String is String (1..10);
Name1 : Name_String;
fl1 : float;
type Cog is new Integer;
type rearGears is array(Cog) of Cog ;
Name2 : String := Integer'Image(42); -- string padded with spaces
Name3 : Name_String ; --:= Float'Image(3.4);
Name4 : Name_String; --:= Float'Image(fl1);
type T is array (Integer range <>) of Integer;
A2 : T (1..10);
begin
fl1 := 2.0; -- testing floating point on BBC
fl1 := fl1 * 2.0;
-- Name4 := Float'Image(fl1);
A2(3) := 8;
-- Name3 := Float'Image(fl1);
Name1:="Mildred ";
loop
Display.Scroll_Text (" Made with Ada! by Mike " & Name1 & Name2);
-- Display.Scroll_Text (Name_String);
fl1 := 2.0; -- testing floating point on BBC
fl1 := fl1 * 2.0;
end loop;
end Main;
|
reznikmm/matreshka | Ada | 3,724 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 XML.DOM.Attributes;
package ODF.DOM.Meta_Object_Count_Attributes is
pragma Preelaborate;
type ODF_Meta_Object_Count_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Meta_Object_Count_Attribute_Access is
access all ODF_Meta_Object_Count_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Meta_Object_Count_Attributes;
|
reznikmm/matreshka | Ada | 3,581 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- 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$
------------------------------------------------------------------------------
function League.Stream_Element_Vectors.Hash
(Item : League.Stream_Element_Vectors.Stream_Element_Vector)
return Ada.Containers.Hash_Type is
begin
return Ada.Containers.Hash_Type (Item.Hash);
end League.Stream_Element_Vectors.Hash;
|
tum-ei-rcs/StratoX | Ada | 42 | ads | ../../../hal/boards/common/tools/units.ads |
stcarrez/ada-ado | Ada | 6,307 | adb | -----------------------------------------------------------------------
-- pschema - Print the database schema
-- Copyright (C) 2009, 2010, 2011, 2012, 2015, 2021 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with ADO;
with ADO.Drivers;
with ADO.Configs;
with ADO.Sessions;
with ADO.Sessions.Factory;
with ADO.Schemas;
with Ada.Text_IO;
with Ada.Exceptions;
with Ada.Command_Line;
with Util.Strings.Transforms;
with Util.Log.Loggers;
procedure Pschema is
use ADO;
use Ada;
use ADO.Schemas;
use Util.Strings.Transforms;
function To_Model_Type (Kind : in ADO.Schemas.Column_Type) return String;
function To_Model_Type (Kind : in ADO.Schemas.Column_Type) return String is
begin
case Kind is
when T_BOOLEAN =>
return "boolean";
when T_TINYINT | T_SMALLINT | T_INTEGER =>
return "integer";
when T_LONG_INTEGER =>
return "long";
when T_TIME | T_DATE_TIME | T_TIMESTAMP =>
return "datetime";
when T_DATE =>
return "date";
when T_BLOB =>
return "blob";
when T_VARCHAR =>
return "string";
when others =>
return "?";
end case;
end To_Model_Type;
Factory : ADO.Sessions.Factory.Session_Factory;
begin
Util.Log.Loggers.Initialize ("samples.properties");
-- Initialize the database drivers.
ADO.Drivers.Initialize ("samples.properties");
-- Initialize the session factory to connect to the
-- database defined by 'ado.database' property.
if Ada.Command_Line.Argument_Count < 1 then
Ada.Text_IO.Put_Line ("Usage: pschema connection");
Ada.Text_IO.Put_Line ("Example: pschema mysql://localhost:3306/test");
Ada.Command_Line.Set_Exit_Status (2);
return;
end if;
Factory.Create (Ada.Command_Line.Argument (1));
declare
DB : constant ADO.Sessions.Master_Session := Factory.Get_Master_Session;
Schema : ADO.Schemas.Schema_Definition;
Iter : Table_Cursor;
begin
DB.Load_Schema (Schema);
-- Dump the database schema using SQL create table forms.
Iter := Get_Tables (Schema);
while Has_Element (Iter) loop
declare
Table : constant Table_Definition := Element (Iter);
Table_Iter : Column_Cursor := Get_Columns (Table);
begin
-- Ada.Text_IO.Put_Line ("create table " & Get_Name (Table) & " (");
Ada.Text_IO.Put_Line (Get_Name (Table) & ":");
Ada.Text_IO.Put_Line (" type: entity");
Ada.Text_IO.Put (" table: ");
Ada.Text_IO.Put_Line (Get_Name (Table));
Ada.Text_IO.Put_Line (" id:");
while Has_Element (Table_Iter) loop
declare
Col : constant Column_Definition := Element (Table_Iter);
begin
if Is_Primary (Col) then
Ada.Text_IO.Put (" ");
Ada.Text_IO.Put (To_Lower_Case (Get_Name (Col)));
Ada.Text_IO.Put_Line (":");
Ada.Text_IO.Put (" type: ");
if Get_Type (Col) in T_INTEGER | T_LONG_INTEGER then
Ada.Text_IO.Put_Line ("identifier");
else
Ada.Text_IO.Put_Line (To_Model_Type (Get_Type (Col)));
Ada.Text_IO.Put (" length:");
Ada.Text_IO.Put_Line (Natural'Image (Get_Size (Col)));
end if;
Ada.Text_IO.Put (" column: ");
Ada.Text_IO.Put_Line (Get_Name (Col));
Ada.Text_IO.Put (" not-null: ");
Ada.Text_IO.Put_Line ((if Is_Null (Col) then "true" else "false"));
end if;
end;
Next (Table_Iter);
end loop;
Ada.Text_IO.Put_Line (" fields:");
Table_Iter := Get_Columns (Table);
while Has_Element (Table_Iter) loop
declare
Col : constant Column_Definition := Element (Table_Iter);
begin
if not Is_Primary (Col) then
Ada.Text_IO.Put (" ");
Ada.Text_IO.Put (To_Lower_Case (Get_Name (Col)));
Ada.Text_IO.Put_Line (":");
Ada.Text_IO.Put (" type: ");
Ada.Text_IO.Put_Line (To_Model_Type (Get_Type (Col)));
if Get_Size (Col) > 0 then
Ada.Text_IO.Put (" length:");
Ada.Text_IO.Put_Line (Natural'Image (Get_Size (Col)));
end if;
Ada.Text_IO.Put (" column: ");
Ada.Text_IO.Put_Line (Get_Name (Col));
Ada.Text_IO.Put (" not-null: ");
Ada.Text_IO.Put_Line ((if Is_Null (Col) then "true" else "false"));
if Get_Default (Col)'Length > 0 then
Ada.Text_Io.Put (" default: ");
Ada.Text_Io.Put_Line (Get_Default (Col));
end if;
end if;
end;
Next (Table_Iter);
end loop;
-- Ada.Text_IO.Put_Line (");");
end;
Next (Iter);
end loop;
end;
exception
when E : ADO.Sessions.Connection_Error =>
Ada.Text_IO.Put_Line ("Cannot connect to database: "
& Ada.Exceptions.Exception_Message (E));
end Pschema;
|
gitter-badger/libAnne | Ada | 2,213 | adb | with Ada.Wide_Wide_Text_IO;
use Ada.Wide_Wide_Text_IO;
package body Generics.Testing.Discrete_Assertions is
function Assert(Statement : Wide_Wide_String; Object : Discrete_Type) return Asserter is
begin
return Asserter'(Statement_Length => Statement'Length, Statement => Statement, Object => Object);
end Assert;
function Equal(Self : Asserter; Value : Discrete_Type) return Asserter is
Result : Asserter := Self;
begin
if Result.Object /= Value then
Put_Line(" ❌ " & Self.Statement & " → " & Discrete_Type'Wide_Wide_Image(Self.Object) & " = " & Discrete_Type'Wide_Wide_Image(Value));
end if;
return Result;
end Equal;
procedure Equal(Self : Asserter; Value : Discrete_Type) is
Result : Asserter := Self.Equal(Value);
begin
null;
end Equal;
function Not_Equal(Self : Asserter; Value : Discrete_Type) return Asserter is
Result : Asserter := Self;
begin
if Result.Object = Value then
Put_Line(" ❌ " & Self.Statement & " → " & Discrete_Type'Wide_Wide_Image(Self.Object) & " ≠ " & Discrete_Type'Wide_Wide_Image(Value));
end if;
return Result;
end;
procedure Not_Equal(Self : Asserter; Value : Discrete_Type) is
Result : Asserter := Self.Not_Equal(Value);
begin
null;
end Not_Equal;
function Greater(Self : Asserter; Value : Discrete_Type) return Asserter is
Result : Asserter := Self;
begin
if Result.Object <= Value then
Put_Line(" ❌ " & Self.Statement & " → " & Discrete_Type'Wide_Wide_Image(Self.Object) & " > " & Discrete_Type'Wide_Wide_Image(Value));
end if;
return Result;
end Greater;
procedure Greater(Self : Asserter; Value : Discrete_Type) is
Result : Asserter := Self.Greater(Value);
begin
null;
end Greater;
function Lesser(Self : Asserter; Value : Discrete_Type) return Asserter is
Result : Asserter := Self;
begin
if Result.Object >= Value then
Put_Line(" ❌ " & Self.Statement & " → " & Discrete_Type'Wide_Wide_Image(Self.Object) & " < " & Discrete_Type'Wide_Wide_Image(Value));
end if;
return Result;
end Lesser;
procedure Lesser(Self : Asserter; Value : Discrete_Type) is
Result : Asserter := Self.Lesser(Value);
begin
null;
end Lesser;
end Generics.Testing.Discrete_Assertions; |
sungyeon/drake | Ada | 89 | ads | pragma License (Unrestricted);
with Ada.Calendar;
package Calendar renames Ada.Calendar;
|
sungyeon/drake | Ada | 1,047 | ads | pragma License (Unrestricted);
-- implementation unit
package System.Exponentiations is
pragma Pure;
generic
type Integer_Type is range <>;
function Generic_Exp_Integer (Left : Integer_Type; Right : Natural)
return Integer_Type;
generic
type Integer_Type is range <>;
function Generic_Exp_Integer_No_Check (Left : Integer_Type; Right : Natural)
return Integer_Type;
-- Modulus = 2 ** N
generic
type Unsigned_Type is mod <>;
with function Shift_Left (Value : Unsigned_Type; Amount : Natural)
return Unsigned_Type is <>;
function Generic_Exp_Unsigned (Left : Unsigned_Type; Right : Natural)
return Unsigned_Type;
-- Modulus /= 2 ** N
generic
type Unsigned_Type is mod <>;
with function Shift_Left (Value : Unsigned_Type; Amount : Natural)
return Unsigned_Type is <>;
function Generic_Exp_Modular (
Left : Unsigned_Type;
Modulus : Unsigned_Type;
Right : Natural)
return Unsigned_Type;
end System.Exponentiations;
|
sungyeon/drake | Ada | 1,028 | ads | pragma License (Unrestricted);
-- implementation unit required by compiler
package System.Bit_Ops is
pragma Preelaborate;
-- It can not be Pure, subprograms would become __attribute__((const)).
-- required for "=" packed boolean array by compiler (s-bitop.ads)
function Bit_Eq (
Left : Address;
Llen : Natural;
Right : Address;
Rlen : Natural)
return Boolean;
pragma Machine_Attribute (Bit_Eq, "pure");
-- required by compiler ??? (s-bitop.ads)
-- procedure Bit_Not (
-- Opnd : Address;
-- Len : Natural;
-- Result : Address);
-- procedure Bit_And (
-- Left : Address;
-- Llen : Natural;
-- Right : Address;
-- Rlen : Natural;
-- Result : Address);
-- procedure Bit_Or (
-- Left : Address;
-- Llen : Natural;
-- Right : Address;
-- Rlen : Natural;
-- Result : Address);
-- procedure Bit_Xor (
-- Left : Address;
-- Llen : Natural;
-- Right : Address;
-- Rlen : Natural;
-- Result : Address);
end System.Bit_Ops;
|
reznikmm/matreshka | Ada | 4,027 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 ODF.DOM.Style_Vertical_Pos_Attributes;
package Matreshka.ODF_Style.Vertical_Pos_Attributes is
type Style_Vertical_Pos_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Vertical_Pos_Attributes.ODF_Style_Vertical_Pos_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Vertical_Pos_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Vertical_Pos_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Vertical_Pos_Attributes;
|
sungyeon/drake | Ada | 15,534 | ads | pragma License (Unrestricted);
with Ada.Strings.Maps;
with Ada.Strings.Unbounded_Strings.Functions.Maps;
package Ada.Strings.Unbounded is
pragma Preelaborate;
-- type Unbounded_String is private;
-- pragma Preelaborable_Initialization (Unbounded_String);
subtype Unbounded_String is Unbounded_Strings.Unbounded_String;
-- modified
-- Null_Unbounded_String : constant Unbounded_String;
function Null_Unbounded_String return Unbounded_String
renames Unbounded_Strings.Null_Unbounded_String;
function Length (Source : Unbounded_String) return Natural
renames Unbounded_Strings.Length;
-- type String_Access is access all String;
subtype String_Access is Unbounded_Strings.String_Access;
procedure Free (X : in out String_Access)
renames Unbounded_Strings.Free;
-- Conversion, Concatenation, and Selection functions
function To_Unbounded_String (Source : String)
return Unbounded_String
renames Unbounded_Strings.To_Unbounded_String;
function To_Unbounded_String (Length : Natural)
return Unbounded_String
renames Unbounded_Strings.To_Unbounded_String;
function To_String (Source : Unbounded_String) return String
renames Unbounded_Strings.To_String;
procedure Set_Unbounded_String (
Target : out Unbounded_String;
Source : String)
renames Unbounded_Strings.Set_Unbounded_String;
procedure Append (
Source : in out Unbounded_String;
New_Item : Unbounded_String)
renames Unbounded_Strings.Append;
procedure Append (
Source : in out Unbounded_String;
New_Item : String)
renames Unbounded_Strings.Append;
procedure Append (
Source : in out Unbounded_String;
New_Item : Character)
renames Unbounded_Strings.Append_Element;
function "&" (Left, Right : Unbounded_String) return Unbounded_String
renames Unbounded_Strings."&";
function "&" (Left : Unbounded_String; Right : String)
return Unbounded_String
renames Unbounded_Strings."&";
function "&" (Left : String; Right : Unbounded_String)
return Unbounded_String
renames Unbounded_Strings."&";
function "&" (Left : Unbounded_String; Right : Character)
return Unbounded_String
renames Unbounded_Strings."&";
function "&" (Left : Character; Right : Unbounded_String)
return Unbounded_String
renames Unbounded_Strings."&";
function Element (Source : Unbounded_String; Index : Positive)
return Character
renames Unbounded_Strings.Element;
procedure Replace_Element (
Source : in out Unbounded_String;
Index : Positive;
By : Character)
renames Unbounded_Strings.Replace_Element;
function Slice (
Source : Unbounded_String;
Low : Positive;
High : Natural)
return String
renames Unbounded_Strings.Slice;
function Unbounded_Slice (
Source : Unbounded_String;
Low : Positive;
High : Natural)
return Unbounded_String
renames Unbounded_Strings.Unbounded_Slice;
procedure Unbounded_Slice (
Source : Unbounded_String;
Target : out Unbounded_String;
Low : Positive;
High : Natural)
renames Unbounded_Strings.Unbounded_Slice;
function "=" (Left, Right : Unbounded_String) return Boolean
renames Unbounded_Strings."=";
function "=" (Left : Unbounded_String; Right : String) return Boolean
renames Unbounded_Strings."=";
function "=" (Left : String; Right : Unbounded_String) return Boolean
renames Unbounded_Strings."=";
function "<" (Left, Right : Unbounded_String) return Boolean
renames Unbounded_Strings."<";
function "<" (Left : Unbounded_String; Right : String) return Boolean
renames Unbounded_Strings."<";
function "<" (Left : String; Right : Unbounded_String) return Boolean
renames Unbounded_Strings."<";
function "<=" (Left, Right : Unbounded_String) return Boolean
renames Unbounded_Strings."<=";
function "<=" (Left : Unbounded_String; Right : String) return Boolean
renames Unbounded_Strings."<=";
function "<=" (Left : String; Right : Unbounded_String) return Boolean
renames Unbounded_Strings."<=";
function ">" (Left, Right : Unbounded_String) return Boolean
renames Unbounded_Strings.">";
function ">" (Left : Unbounded_String; Right : String) return Boolean
renames Unbounded_Strings.">";
function ">" (Left : String; Right : Unbounded_String) return Boolean
renames Unbounded_Strings.">";
function ">=" (Left, Right : Unbounded_String) return Boolean
renames Unbounded_Strings.">=";
function ">=" (Left : Unbounded_String; Right : String) return Boolean
renames Unbounded_Strings.">=";
function ">=" (Left : String; Right : Unbounded_String) return Boolean
renames Unbounded_Strings.">=";
-- Search subprograms
-- modified
-- function Index (
-- Source : Unbounded_String;
-- Pattern : String;
-- From : Positive;
-- Going : Direction := Forward;
-- Mapping : Maps.Character_Mapping := Maps.Identity)
-- return Natural;
function Index (
Source : Unbounded_String;
Pattern : String;
From : Positive;
Going : Direction := Forward)
return Natural
renames Unbounded_Strings.Functions.Index;
function Index (
Source : Unbounded_String;
Pattern : String;
From : Positive;
Going : Direction := Forward;
Mapping : Maps.Character_Mapping)
return Natural
renames Unbounded_Strings.Functions.Maps.Index;
-- modified
-- function Index (
-- Source : Unbounded_String;
-- Pattern : String;
-- From : Positive;
-- Going : Direction := Forward;
-- Mapping : Maps.Character_Mapping_Function)
-- return Natural;
function Index (
Source : Unbounded_String;
Pattern : String;
From : Positive;
Going : Direction := Forward;
Mapping : not null access function (From : Character) return Character)
return Natural
renames Unbounded_Strings.Functions.Maps.Index_Element;
function Index (
Source : Unbounded_String;
Pattern : String;
From : Positive;
Going : Direction := Forward;
Mapping : not null access function (From : Wide_Wide_Character)
return Wide_Wide_Character)
return Natural
renames Unbounded_Strings.Functions.Maps.Index;
-- modified
-- function Index (
-- Source : Unbounded_String;
-- Pattern : String;
-- Going : Direction := Forward;
-- Mapping : Maps.Character_Mapping := Maps.Identity)
-- return Natural;
function Index (
Source : Unbounded_String;
Pattern : String;
Going : Direction := Forward)
return Natural
renames Unbounded_Strings.Functions.Index;
function Index (
Source : Unbounded_String;
Pattern : String;
Going : Direction := Forward;
Mapping : Maps.Character_Mapping)
return Natural
renames Unbounded_Strings.Functions.Maps.Index;
-- modified
-- function Index (
-- Source : Unbounded_String;
-- Pattern : String;
-- Going : Direction := Forward;
-- Mapping : Maps.Character_Mapping_Function)
-- return Natural;
function Index (
Source : Unbounded_String;
Pattern : String;
Going : Direction := Forward;
Mapping : not null access function (From : Character) return Character)
return Natural
renames Unbounded_Strings.Functions.Maps.Index_Element;
function Index (
Source : Unbounded_String;
Pattern : String;
Going : Direction := Forward;
Mapping : not null access function (From : Wide_Wide_Character)
return Wide_Wide_Character)
return Natural
renames Unbounded_Strings.Functions.Maps.Index;
function Index (
Source : Unbounded_String;
Set : Maps.Character_Set;
From : Positive;
Test : Membership := Inside;
Going : Direction := Forward)
return Natural
renames Unbounded_Strings.Functions.Maps.Index;
function Index (
Source : Unbounded_String;
Set : Maps.Character_Set;
Test : Membership := Inside;
Going : Direction := Forward)
return Natural
renames Unbounded_Strings.Functions.Maps.Index;
function Index_Non_Blank (
Source : Unbounded_String;
From : Positive;
Going : Direction := Forward)
return Natural
renames Unbounded_Strings.Functions.Index_Non_Blank;
function Index_Non_Blank (
Source : Unbounded_String;
Going : Direction := Forward)
return Natural
renames Unbounded_Strings.Functions.Index_Non_Blank;
-- modified
-- function Count (
-- Source : Unbounded_String;
-- Pattern : String;
-- Mapping : Maps.Character_Mapping := Maps.Identity)
-- return Natural;
function Count (
Source : Unbounded_String;
Pattern : String)
return Natural
renames Unbounded_Strings.Functions.Count;
function Count (
Source : Unbounded_String;
Pattern : String;
Mapping : Maps.Character_Mapping)
return Natural
renames Unbounded_Strings.Functions.Maps.Count;
-- modified
-- function Count (
-- Source : Unbounded_String;
-- Pattern : String;
-- Mapping : Maps.Character_Mapping_Function)
-- return Natural;
function Count (
Source : Unbounded_String;
Pattern : String;
Mapping : not null access function (From : Character) return Character)
return Natural
renames Unbounded_Strings.Functions.Maps.Count_Element;
function Count (
Source : Unbounded_String;
Pattern : String;
Mapping : not null access function (From : Wide_Wide_Character)
return Wide_Wide_Character)
return Natural
renames Unbounded_Strings.Functions.Maps.Count;
function Count (
Source : Unbounded_String;
Set : Maps.Character_Set)
return Natural
renames Unbounded_Strings.Functions.Maps.Count;
procedure Find_Token (
Source : Unbounded_String;
Set : Maps.Character_Set;
From : Positive;
Test : Membership;
First : out Positive;
Last : out Natural)
renames Unbounded_Strings.Functions.Maps.Find_Token;
procedure Find_Token (
Source : Unbounded_String;
Set : Maps.Character_Set;
Test : Membership;
First : out Positive;
Last : out Natural)
renames Unbounded_Strings.Functions.Maps.Find_Token;
-- String translation subprograms
function Translate (
Source : Unbounded_String;
Mapping : Maps.Character_Mapping)
return Unbounded_String
renames Unbounded_Strings.Functions.Maps.Translate;
procedure Translate (
Source : in out Unbounded_String;
Mapping : Maps.Character_Mapping)
renames Unbounded_Strings.Functions.Maps.Translate;
-- modified
-- function Translate (
-- Source : Unbounded_String;
-- Mapping : Maps.Character_Mapping_Function)
-- return Unbounded_String;
function Translate (
Source : Unbounded_String;
Mapping : not null access function (From : Character) return Character)
return Unbounded_String
renames Unbounded_Strings.Functions.Maps.Translate_Element;
function Translate (
Source : Unbounded_String;
Mapping : not null access function (From : Wide_Wide_Character)
return Wide_Wide_Character)
return Unbounded_String
renames Unbounded_Strings.Functions.Maps.Translate;
-- modified
-- procedure Translate (
-- Source : in out Unbounded_String;
-- Mapping : Maps.Character_Mapping_Function);
procedure Translate (
Source : in out Unbounded_String;
Mapping : not null access function (From : Character) return Character)
renames Unbounded_Strings.Functions.Maps.Translate_Element;
procedure Translate (
Source : in out Unbounded_String;
Mapping : not null access function (From : Wide_Wide_Character)
return Wide_Wide_Character)
renames Unbounded_Strings.Functions.Maps.Translate;
-- String transformation subprograms
function Replace_Slice (
Source : Unbounded_String;
Low : Positive;
High : Natural;
By : String)
return Unbounded_String
renames Unbounded_Strings.Functions.Replace_Slice;
procedure Replace_Slice (
Source : in out Unbounded_String;
Low : Positive;
High : Natural;
By : String)
renames Unbounded_Strings.Functions.Replace_Slice;
function Insert (
Source : Unbounded_String;
Before : Positive;
New_Item : String)
return Unbounded_String
renames Unbounded_Strings.Functions.Insert;
procedure Insert (
Source : in out Unbounded_String;
Before : Positive;
New_Item : String)
renames Unbounded_Strings.Functions.Insert;
function Overwrite (
Source : Unbounded_String;
Position : Positive;
New_Item : String)
return Unbounded_String
renames Unbounded_Strings.Functions.Overwrite;
procedure Overwrite (
Source : in out Unbounded_String;
Position : Positive;
New_Item : String)
renames Unbounded_Strings.Functions.Overwrite;
function Delete (
Source : Unbounded_String;
From : Positive;
Through : Natural)
return Unbounded_String
renames Unbounded_Strings.Functions.Delete;
procedure Delete (
Source : in out Unbounded_String;
From : Positive;
Through : Natural)
renames Unbounded_Strings.Functions.Delete;
-- modified
function Trim (
Source : Unbounded_String;
Side : Trim_End;
Blank : Character := Space) -- additional
return Unbounded_String
renames Unbounded_Strings.Functions.Trim;
-- modified
procedure Trim (
Source : in out Unbounded_String;
Side : Trim_End;
Blank : Character := Space) -- additional
renames Unbounded_Strings.Functions.Trim;
function Trim (
Source : Unbounded_String;
Left : Maps.Character_Set;
Right : Maps.Character_Set)
return Unbounded_String
renames Unbounded_Strings.Functions.Maps.Trim;
procedure Trim (
Source : in out Unbounded_String;
Left : Maps.Character_Set;
Right : Maps.Character_Set)
renames Unbounded_Strings.Functions.Maps.Trim;
function Head (
Source : Unbounded_String;
Count : Natural;
Pad : Character := Space)
return Unbounded_String
renames Unbounded_Strings.Functions.Head;
procedure Head (
Source : in out Unbounded_String;
Count : Natural;
Pad : Character := Space)
renames Unbounded_Strings.Functions.Head;
function Tail (
Source : Unbounded_String;
Count : Natural;
Pad : Character := Space)
return Unbounded_String
renames Unbounded_Strings.Functions.Tail;
procedure Tail (
Source : in out Unbounded_String;
Count : Natural;
Pad : Character := Space)
renames Unbounded_Strings.Functions.Tail;
function "*" (Left : Natural; Right : Character) return Unbounded_String
renames Unbounded_Strings.Functions."*";
function "*" (Left : Natural; Right : String) return Unbounded_String
renames Unbounded_Strings.Functions."*";
function "*" (Left : Natural; Right : Unbounded_String)
return Unbounded_String
renames Unbounded_Strings.Functions."*";
end Ada.Strings.Unbounded;
|
thierr26/ada-keystore | Ada | 5,282 | ads | -----------------------------------------------------------------------
-- akt-commands -- Ada Keystore Tool commands
-- Copyright (C) 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- 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 Keystore.Passwords;
with Keystore.Passwords.GPG;
with Util.Commands;
with Keystore;
private with Util.Log.Loggers;
private with Keystore.Files;
private with Keystore.Passwords.Keys;
private with Ada.Finalization;
private with GNAT.Command_Line;
private with GNAT.Strings;
package AKT.Commands is
Error : exception;
subtype Argument_List is Util.Commands.Argument_List;
type Context_Type is limited private;
-- Print the command usage.
procedure Usage (Args : in Argument_List'Class;
Context : in out Context_Type;
Name : in String := "");
-- Open the keystore file using the password password.
-- When `Use_Worker` is set, a workers of N tasks is created and assigned to the keystore
-- for the decryption and encryption process.
procedure Open_Keystore (Context : in out Context_Type;
Args : in Argument_List'Class;
Use_Worker : in Boolean := False);
-- Open the keystore file and change the password.
procedure Change_Password (Context : in out Context_Type;
Args : in Argument_List'Class;
New_Password : in out Keystore.Passwords.Provider'Class;
Config : in Keystore.Wallet_Config;
Mode : in Keystore.Mode_Type);
-- Execute the command with its arguments.
procedure Execute (Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type);
procedure Parse (Context : in out Context_Type;
Arguments : out Util.Commands.Dynamic_Argument_List);
procedure Parse_Range (Value : in String;
Config : in out Keystore.Wallet_Config);
-- Get the keystore file path.
function Get_Keystore_Path (Context : in out Context_Type;
Args : in Argument_List'Class) return String;
private
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AKT.Commands");
package GC renames GNAT.Command_Line;
procedure Initialize (Context : in out Keystore.Passwords.GPG.Context_Type);
type Context_Type is limited new Ada.Finalization.Limited_Controlled with record
Wallet : Keystore.Files.Wallet_File;
Info : Keystore.Wallet_Info;
Config : Keystore.Wallet_Config := Keystore.Secure_Config;
Workers : Keystore.Task_Manager_Access;
Provider : Keystore.Passwords.Provider_Access;
Key_Provider : Keystore.Passwords.Keys.Key_Provider_Access;
Slot : Keystore.Key_Slot;
Worker_Count : aliased Integer := 1;
Version : aliased Boolean := False;
Verbose : aliased Boolean := False;
Debug : aliased Boolean := False;
Dump : aliased Boolean := False;
Zero : aliased Boolean := False;
Config_File : aliased GNAT.Strings.String_Access;
Wallet_File : aliased GNAT.Strings.String_Access;
Data_Path : aliased GNAT.Strings.String_Access;
Wallet_Key_File : aliased GNAT.Strings.String_Access;
Password_File : aliased GNAT.Strings.String_Access;
Password_Env : aliased GNAT.Strings.String_Access;
Unsafe_Password : aliased GNAT.Strings.String_Access;
Password_Socket : aliased GNAT.Strings.String_Access;
Password_Command : aliased GNAT.Strings.String_Access;
Password_Askpass : aliased Boolean := False;
No_Password_Opt : Boolean := False;
Command_Config : GC.Command_Line_Configuration;
First_Arg : Positive := 1;
GPG : Keystore.Passwords.GPG.Context_Type;
end record;
-- Initialize the commands.
overriding
procedure Initialize (Context : in out Context_Type);
overriding
procedure Finalize (Context : in out Context_Type);
procedure Setup_Password_Provider (Context : in out Context_Type);
procedure Setup_Key_Provider (Context : in out Context_Type);
-- Setup the command before parsing the arguments and executing it.
procedure Setup (Config : in out GC.Command_Line_Configuration;
Context : in out Context_Type);
end AKT.Commands;
|
reznikmm/matreshka | Ada | 4,703 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Draw.Measure_Vertical_Align_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Measure_Vertical_Align_Attribute_Node is
begin
return Self : Draw_Measure_Vertical_Align_Attribute_Node do
Matreshka.ODF_Draw.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Draw_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Draw_Measure_Vertical_Align_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Measure_Vertical_Align_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Measure_Vertical_Align_Attribute,
Draw_Measure_Vertical_Align_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Measure_Vertical_Align_Attributes;
|
AdaCore/training_material | Ada | 1,925 | adb | with Ada.Directories;
with Ada.Text_IO;
with Movie_Servers;
with Drawable_Chars;
with Drawable_Chars.Latin_1;
with Drawable_Chars.Circles;
procedure Mini_Cinema is
type Charsets_List_T is
array (Positive range <>) of Drawable_Chars.Sorted_Charset_T;
Charsets : constant Charsets_List_T :=
(Drawable_Chars.Circles.By_White, Drawable_Chars.Circles.By_Black,
Drawable_Chars.Latin_1.By_White, Drawable_Chars.Latin_1.By_Black);
Charset_Chosen : Positive := Positive'First;
Play_Settings : constant Movie_Servers.Play_Settings_Access_T :=
new Movie_Servers.Play_Settings_T;
Display_Server : Movie_Servers.Movie_Server_Task_T (Play_Settings);
begin
Play_Settings.Set_FPS (4);
Play_Settings.Set_Charset (Charsets (Charsets'First));
Display_Server.Play_Loop (Dir => "resources/movies/rotating_triangle");
loop
declare
Input : constant String := Ada.Text_IO.Get_Line;
begin
if Input = "pause" then
Display_Server.Pause;
elsif Input = "resume" then
Display_Server.Resume;
elsif Input = "exit" then
exit;
elsif Input = "stop" then
Display_Server.Stop;
elsif Input = "char" then
if Charset_Chosen = Charsets'Last then
Charset_Chosen := Charsets'First;
else
Charset_Chosen := Charset_Chosen + 1;
end if;
Play_Settings.Set_Charset (Charsets (Charset_Chosen));
elsif Input = "fast" then
Play_Settings.Set_FPS (Play_Settings.FPS * 2);
elsif Input = "slow" then
if Play_Settings.FPS > 1 then
Play_Settings.Set_FPS (Play_Settings.FPS / 2);
end if;
elsif Ada.Directories.Exists (Input) then
Display_Server.Play_Loop (Input);
end if;
end;
end loop;
Display_Server.Finish;
end Mini_Cinema;
|
io7m/coreland-postgres-ada | Ada | 7,984 | ads | ------------------------------------------------------------------------------
-- --
-- P G A D A . T H I N --
-- --
-- S p e c --
-- --
-- Copyright (c) coreland 2009 --
-- Copyright (c) Samuel Tardieu 2000 --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form 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 Samuel Tardieu 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 SAMUEL TARDIEU 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 SAMUEL --
-- TARDIEU 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 Interfaces.C.Strings;
with Interfaces.C;
package PGAda.Thin is
pragma Preelaborate;
package C renames Interfaces.C;
package CS renames Interfaces.C.Strings;
type Conn_Status_t is (CONNECTION_OK, CONNECTION_BAD);
for Conn_Status_t'Size use C.int'Size;
pragma Convention (C, Conn_Status_t);
type Exec_Status_t is
(PGRES_EMPTY_QUERY,
PGRES_COMMAND_OK,
PGRES_TUPLES_OK,
PGRES_COPY_OUT,
PGRES_COPY_IN,
PGRES_BAD_RESPONSE,
PGRES_NONFATAL_ERROR,
PGRES_FATAL_ERROR);
for Exec_Status_t'Size use C.int'Size;
pragma Convention (C, Exec_Status_t);
type PG_Conn is null record;
type PG_Conn_Access_t is access PG_Conn;
pragma Convention (C, PG_Conn_Access_t);
type PG_Result is null record;
type PG_Result_Access_t is access PG_Result;
pragma Convention (C, PG_Result_Access_t);
type Oid is new C.unsigned;
type Error_Field is
(PG_DIAG_SQLSTATE,
PG_DIAG_MESSAGE_DETAIL,
PG_DIAG_SOURCE_FILE,
PG_DIAG_MESSAGE_HINT,
PG_DIAG_SOURCE_LINE,
PG_DIAG_MESSAGE_PRIMARY,
PG_DIAG_STATEMENT_POSITION,
PG_DIAG_SOURCE_FUNCTION,
PG_DIAG_SEVERITY,
PG_DIAG_CONTEXT,
PG_DIAG_INTERNAL_POSITION,
PG_DIAG_INTERNAL_QUERY);
for Error_Field use
(PG_DIAG_SQLSTATE => 67,
PG_DIAG_MESSAGE_DETAIL => 68,
PG_DIAG_SOURCE_FILE => 70,
PG_DIAG_MESSAGE_HINT => 72,
PG_DIAG_SOURCE_LINE => 76,
PG_DIAG_MESSAGE_PRIMARY => 77,
PG_DIAG_STATEMENT_POSITION => 80,
PG_DIAG_SOURCE_FUNCTION => 82,
PG_DIAG_SEVERITY => 83,
PG_DIAG_CONTEXT => 87,
PG_DIAG_INTERNAL_POSITION => 112,
PG_DIAG_INTERNAL_QUERY => 113);
for Error_Field'Size use C.int'Size;
function PQ_Set_Db_Login
(PG_Host : CS.chars_ptr;
PG_Port : CS.chars_ptr;
PG_Options : CS.chars_ptr;
PG_TTY : CS.chars_ptr;
Db_Name : CS.chars_ptr;
Login : CS.chars_ptr;
Password : CS.chars_ptr) return PG_Conn_Access_t;
pragma Import (C, PQ_Set_Db_Login, "PQsetdbLogin");
function PQ_Db (Conn : PG_Conn_Access_t) return CS.chars_ptr;
pragma Import (C, PQ_Db, "PQdb");
function PQ_Host (Conn : PG_Conn_Access_t) return CS.chars_ptr;
pragma Import (C, PQ_Host, "PQhost");
function PQ_Port (Conn : PG_Conn_Access_t) return CS.chars_ptr;
pragma Import (C, PQ_Port, "PQport");
function PQ_Options (Conn : PG_Conn_Access_t) return CS.chars_ptr;
pragma Import (C, PQ_Options, "PQoptions");
function PQ_Status (Conn : PG_Conn_Access_t) return Conn_Status_t;
pragma Import (C, PQ_Status, "PQstatus");
function PQ_Error_Message (Conn : PG_Conn_Access_t) return CS.chars_ptr;
pragma Import (C, PQ_Error_Message, "PQerrorMessage");
procedure PQ_Finish (Conn : in PG_Conn_Access_t);
pragma Import (C, PQ_Finish, "PQfinish");
procedure PQ_Reset (Conn : in PG_Conn_Access_t);
pragma Import (C, PQ_Reset, "PQreset");
function PQ_Exec
(Conn : PG_Conn_Access_t;
Query : CS.chars_ptr) return PG_Result_Access_t;
pragma Import (C, PQ_Exec, "PQexec");
function PQ_Result_Status (Res : PG_Result_Access_t) return Exec_Status_t;
pragma Import (C, PQ_Result_Status, "PQresultStatus");
function PQ_N_Tuples (Res : PG_Result_Access_t) return C.int;
pragma Import (C, PQ_N_Tuples, "PQntuples");
function PQ_N_Fields (Res : PG_Result_Access_t) return C.int;
pragma Import (C, PQ_N_Fields, "PQnfields");
function PQ_F_Name
(Res : PG_Result_Access_t;
Field_Index : C.int) return CS.chars_ptr;
pragma Import (C, PQ_F_Name, "PQfname");
function PQ_F_Number
(Res : PG_Result_Access_t;
Field_Index : CS.chars_ptr) return C.int;
pragma Import (C, PQ_F_Number, "PQfnumber");
function PQ_F_Type
(Res : PG_Result_Access_t;
Field_Index : C.int) return Oid;
pragma Import (C, PQ_F_Type, "PQftype");
function PQ_Get_Value
(Res : PG_Result_Access_t;
Tup_Num : C.int;
Field_Num : C.int) return CS.chars_ptr;
pragma Import (C, PQ_Get_Value, "PQgetvalue");
function PQ_Get_Length
(Res : PG_Result_Access_t;
Tup_Num : C.int;
Field_Num : C.int) return C.int;
pragma Import (C, PQ_Get_Length, "PQgetlength");
function PQ_Get_Is_Null
(Res : PG_Result_Access_t;
Tup_Num : C.int;
Field_Num : C.int) return C.int;
pragma Import (C, PQ_Get_Is_Null, "PQgetisnull");
function PQ_Cmd_Tuples (Res : PG_Result_Access_t) return CS.chars_ptr;
pragma Import (C, PQ_Cmd_Tuples, "PQcmdTuples");
function PQ_Cmd_Status (Res : PG_Result_Access_t) return CS.chars_ptr;
pragma Import (C, PQ_Cmd_Status, "PQcmdStatus");
function PQ_Oid_Status (Res : PG_Result_Access_t) return CS.chars_ptr;
pragma Import (C, PQ_Oid_Status, "PQoidStatus");
procedure PQ_Clear (Res : in PG_Result_Access_t);
pragma Import (C, PQ_Clear, "PQclear");
function PQ_Result_Error_Field
(Res : PG_Result_Access_t;
Field : Error_Field) return CS.chars_ptr;
pragma Import (C, PQ_Result_Error_Field, "PQresultErrorField");
end PGAda.Thin;
|
zhmu/ananas | Ada | 4,930 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- T E M P D I R --
-- --
-- B o d y --
-- --
-- Copyright (C) 2003-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
with Opt; use Opt;
with Output; use Output;
package body Tempdir is
Tmpdir_Needs_To_Be_Displayed : Boolean := True;
Tmpdir : constant String := "TMPDIR";
Temp_Dir : String_Access := new String'("");
----------------------
-- Create_Temp_File --
----------------------
procedure Create_Temp_File
(FD : out File_Descriptor;
Name : out Path_Name_Type)
is
File_Name : String_Access;
Current_Dir : constant String := Get_Current_Dir;
function Directory return String;
-- Returns Temp_Dir.all if not empty, else return current directory
---------------
-- Directory --
---------------
function Directory return String is
begin
if Temp_Dir'Length /= 0 then
return Temp_Dir.all;
else
return Current_Dir;
end if;
end Directory;
-- Start of processing for Create_Temp_File
begin
if Temp_Dir'Length /= 0 then
-- In verbose mode, display once the value of TMPDIR, so that
-- if temp files cannot be created, it is easier to understand
-- where temp files are supposed to be created.
if Verbose_Mode and then Tmpdir_Needs_To_Be_Displayed then
Write_Str ("TMPDIR = """);
Write_Str (Temp_Dir.all);
Write_Line ("""");
Tmpdir_Needs_To_Be_Displayed := False;
end if;
-- Change directory to TMPDIR before creating the temp file,
-- then change back immediately to the previous directory.
Change_Dir (Temp_Dir.all);
Create_Temp_File (FD, File_Name);
Change_Dir (Current_Dir);
else
Create_Temp_File (FD, File_Name);
end if;
if FD = Invalid_FD then
Write_Line ("could not create temporary file in " & Directory);
Name := No_Path;
else
declare
Path_Name : constant String :=
Normalize_Pathname
(Directory & Directory_Separator & File_Name.all);
begin
Name_Len := Path_Name'Length;
Name_Buffer (1 .. Name_Len) := Path_Name;
Name := Name_Find;
Free (File_Name);
end;
end if;
end Create_Temp_File;
------------------
-- Use_Temp_Dir --
------------------
procedure Use_Temp_Dir (Status : Boolean) is
Dir : String_Access;
begin
if Status then
Dir := Getenv (Tmpdir);
end if;
Free (Temp_Dir);
if Dir /= null
and then Dir'Length > 0
and then Is_Absolute_Path (Dir.all)
and then Is_Directory (Dir.all)
then
Temp_Dir := new String'(Normalize_Pathname (Dir.all));
else
Temp_Dir := new String'("");
end if;
Free (Dir);
end Use_Temp_Dir;
-- Start of elaboration for package Tempdir
begin
Use_Temp_Dir (Status => True);
end Tempdir;
|
reznikmm/matreshka | Ada | 5,394 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- 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.Generic_Collections;
package AMF.UML.Encapsulated_Classifiers.Collections is
pragma Preelaborate;
package UML_Encapsulated_Classifier_Collections is
new AMF.Generic_Collections
(UML_Encapsulated_Classifier,
UML_Encapsulated_Classifier_Access);
type Set_Of_UML_Encapsulated_Classifier is
new UML_Encapsulated_Classifier_Collections.Set with null record;
Empty_Set_Of_UML_Encapsulated_Classifier : constant Set_Of_UML_Encapsulated_Classifier;
type Ordered_Set_Of_UML_Encapsulated_Classifier is
new UML_Encapsulated_Classifier_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_Encapsulated_Classifier : constant Ordered_Set_Of_UML_Encapsulated_Classifier;
type Bag_Of_UML_Encapsulated_Classifier is
new UML_Encapsulated_Classifier_Collections.Bag with null record;
Empty_Bag_Of_UML_Encapsulated_Classifier : constant Bag_Of_UML_Encapsulated_Classifier;
type Sequence_Of_UML_Encapsulated_Classifier is
new UML_Encapsulated_Classifier_Collections.Sequence with null record;
Empty_Sequence_Of_UML_Encapsulated_Classifier : constant Sequence_Of_UML_Encapsulated_Classifier;
private
Empty_Set_Of_UML_Encapsulated_Classifier : constant Set_Of_UML_Encapsulated_Classifier
:= (UML_Encapsulated_Classifier_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_Encapsulated_Classifier : constant Ordered_Set_Of_UML_Encapsulated_Classifier
:= (UML_Encapsulated_Classifier_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_Encapsulated_Classifier : constant Bag_Of_UML_Encapsulated_Classifier
:= (UML_Encapsulated_Classifier_Collections.Bag with null record);
Empty_Sequence_Of_UML_Encapsulated_Classifier : constant Sequence_Of_UML_Encapsulated_Classifier
:= (UML_Encapsulated_Classifier_Collections.Sequence with null record);
end AMF.UML.Encapsulated_Classifiers.Collections;
|
reznikmm/matreshka | Ada | 4,083 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 ODF.DOM.Style_Snap_To_Layout_Grid_Attributes;
package Matreshka.ODF_Style.Snap_To_Layout_Grid_Attributes is
type Style_Snap_To_Layout_Grid_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Snap_To_Layout_Grid_Attributes.ODF_Style_Snap_To_Layout_Grid_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Snap_To_Layout_Grid_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Snap_To_Layout_Grid_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Snap_To_Layout_Grid_Attributes;
|
AaronC98/PlaneSystem | Ada | 2,358 | ads | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2000-2012, AdaCore --
-- --
-- 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. --
-- --
-- --
-- --
-- --
-- --
-- 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/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
with Ada.Containers.Indefinite_Ordered_Maps;
package AWS.Containers.Key_Value is
new Ada.Containers.Indefinite_Ordered_Maps (String, String);
|
AaronC98/PlaneSystem | Ada | 2,636 | ads | ------------------------------------------------------------------------------
-- Templates Parser --
-- --
-- Copyright (C) 2005-2012, AdaCore --
-- --
-- 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. --
-- --
-- --
-- --
-- --
-- --
-- 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/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
package Templates_Parser_Tasking is
-- Implements a simple semaphore. There is two implementations for this
-- unit, one that is based on a protected object that is required for
-- tasking applications and one that does nothing (the tasking runtime is
-- not dragged in this configuration).
procedure Lock;
-- Lock all tasks
procedure Unlock;
-- Unlock tasks
end Templates_Parser_Tasking;
|
charlie5/lace | Ada | 706 | ads | package openGL.Geometry.lit_colored
--
-- Supports per-vertex color and lighting.
--
is
type Item is new openGL.Geometry.item with private;
type View is access all Item'Class;
function new_Geometry return View;
----------
-- Vertex
--
type Vertex is
record
Site : Vector_3;
Normal : Vector_3;
Color : rgba_Color;
Shine : Real;
end record;
type Vertex_array is array (Index_t range <>) of aliased Vertex;
--------------
-- Attributes
--
procedure Vertices_are (Self : in out Item; Now : in Vertex_array);
private
type Item is new Geometry.item with null record;
end openGL.Geometry.lit_colored;
|
vasil-sd/ada-tlsf | Ada | 53,034 | adb | package body TLSF.Proof.Model.Block with SPARK_Mode is
function Initial_Block (Space : Address_Space)
return Block is
pragma Assert (Space.Last > Space.First);
Size : BT.Aligned_Size := Space.Last - Space.First;
B : Block := (Space.First, BT.Address_Null, Size);
begin
pragma Assert (Valid_Block (Space, B));
pragma Assert (Next_Block_Address(B) = Space.Last);
return B;
end Initial_Block;
function Init_Model(Space : Address_Space)
return Formal_Model
is
B : Block := Initial_Block (Space);
Model : Formal_Model;
begin
Model.Mem_Region := Space;
Model.Blocks := Add(Model.Blocks, B);
return Model;
end Init_Model;
procedure Addresses_Equality_Implies_Blocks_Equality
(M : Formal_Model)
is
begin
pragma Assert (All_Block_Are_Uniq (M.Mem_Region, M.Blocks, 1, Last (M.Blocks)));
pragma Assert (if (for some I in 1 .. Last (M.Blocks) =>
(for Some J in 1 .. Last (M.Blocks) =>
I /= J and Get (M.Blocks, I).Address = Get (M.Blocks, J).Address))
then
not All_Block_Are_Uniq (M.Mem_Region, M.Blocks, 1, Last (M.Blocks)));
pragma Assert (for all I in 1 .. Last (M.Blocks) =>
(for all J in 1 .. Last (M.Blocks) =>
(if Get (M.Blocks, I).Address = Get (M.Blocks, J).Address
then I = J and then
Get (M.Blocks, I) = Get (M.Blocks, J))));
end Addresses_Equality_Implies_Blocks_Equality;
procedure Addresses_Equality_Implies_Blocks_Equality
(M : Formal_Model;
Left, Right : Block)
is
begin
Addresses_Equality_Implies_Blocks_Equality (M);
pragma Assert (if Left.Address = Right.Address then Left = Right);
end Addresses_Equality_Implies_Blocks_Equality;
function Is_First_Block(M: Formal_Model; B: Block) return Boolean is
begin
if B.Address = M.Mem_Region.First then
pragma Assert (Blocks_Addresses_Are_In_Ascending_Order (M.Blocks, 1, Last (M.Blocks)));
pragma Assert (All_Block_Are_Uniq (M.Mem_Region, M.Blocks, 1, Last (M.Blocks)));
pragma Assert (for some Blk of M.Blocks => Blk = B);
pragma Assert (Get (M.Blocks, 1).Address = B.Address);
pragma Assert (if Get (M.Blocks, 1) /= B then not Valid (M));
return True;
end if;
return False;
end Is_First_Block;
function Is_Last_Block(M: Formal_Model; B: Block) return Boolean is
begin
if Next_Block_Address(B) = M.Mem_Region.Last then
pragma Assert (Blocks_Addresses_Are_In_Ascending_Order (M.Blocks, 1, Last (M.Blocks)));
pragma Assert (All_Block_Are_Uniq (M.Mem_Region, M.Blocks, 1, Last (M.Blocks)));
pragma Assert (for some Blk of M.Blocks => Blk = B);
pragma Assert (Get (M.Blocks, Last(M.Blocks)) = B);
pragma Assert (if Get (M.Blocks, Last (M.Blocks)) /= B then not Valid (M));
return True;
end if;
return False;
end Is_Last_Block;
function Is_Adjacent_In_Array (BS : FV_Pkg.Sequence;
Idx : Index_Type;
Left, Right : Block)
return Boolean
is (Get (BS, Idx) = Left and Get (BS, Idx + 1) = Right)
with Global => null,
Pre => Idx < Last (BS);
procedure Neighbor_Valid_Blocks_Are_Adjacent_In_Array
(M : Formal_Model; Left, Right : Block)
with Global => null,
Pre => Valid (M) and then
In_Model (M, Left) and then
In_Model (M, Right) and then
Neighbor_Blocks (Left, Right),
Post => (for some Idx in 1 .. Last (M.Blocks) - 1 =>
Is_Adjacent_In_Array (M.Blocks, Idx, Left, Right))
and then (for all I in 1 .. Last (M.Blocks) - 1 =>
(for all J in 1 .. Last (M.Blocks) - 1 =>
(if Is_Adjacent_In_Array (M.Blocks, I, Left, Right)
and then Is_Adjacent_In_Array (M.Blocks, J, Left, Right)
then I = J)))
is
Found_Idx : Extended_Index := Extended_Index'First;
begin
pragma Assert (Contains (M.Blocks, 1, Last (M.Blocks), Left));
pragma Assert (Contains (M.Blocks, 1, Last (M.Blocks), Right));
pragma Assert (Left /= Right);
pragma Assert (Length (M.Blocks) >= 2);
pragma Assert (Last (M.Blocks) >= 2);
pragma Assert (Left.Address < Right.Address);
pragma Assert (Blocks_Addresses_Are_In_Ascending_Order (M.Blocks, 1, Last (M.Blocks)));
pragma Assert (All_Block_Addresses_Are_Uniq(M.Mem_Region, M.Blocks, 1, Last (M.Blocks)));
pragma Assert (if Get (M.Blocks, Last (M.Blocks)) = Left then
Right.Address < Left.Address);
pragma Assert (Get (M.Blocks, Last (M.Blocks)) /= Left);
for Idx in 1 .. Last (M.Blocks) - 1 loop
if Get (M.Blocks, Idx ) = Left then
Found_Idx := Idx;
pragma Assert (Found_Idx /= Extended_Index'First);
pragma Assert (Neighbor_Blocks (Left, Get (M.Blocks, Found_Idx + 1)));
pragma Assert (Get (M.Blocks, Found_Idx + 1) = Right);
pragma Assert (Is_Adjacent_In_Array (M.Blocks, Found_Idx, Left, Right));
exit;
end if;
pragma Loop_Invariant (not Contains (M.Blocks, 1, Idx, Left));
pragma Loop_Invariant (Found_Idx = Extended_Index'First);
end loop;
pragma Assert (Found_Idx /= Extended_Index'First);
pragma Assert (if Found_Idx = Extended_Index'First
then not Contains (M.Blocks, 1, Last (M.Blocks), Left));
pragma Assert (Contains (M.Blocks, 1, Last (M.Blocks), Left));
pragma Assert (Found_Idx >= 1);
pragma Assert (Is_Adjacent_In_Array (M.Blocks, Found_Idx, Left, Right));
pragma Assert (for some Idx in 1 .. Last (M.Blocks) - 1 =>
Is_Adjacent_In_Array (M.Blocks, Idx, Left, Right));
pragma Assert (All_Block_Are_Uniq (M.Mem_Region, M.Blocks, 1, Last (M.Blocks)));
pragma Assert (if not
(for all I in 1 .. Last (M.Blocks) - 1 =>
(for all J in 1 .. Last (M.Blocks) - 1 =>
(if Is_Adjacent_In_Array (M.Blocks, I, Left, Right)
and then Is_Adjacent_In_Array (M.Blocks, J, Left, Right)
then I = J)))
then (for some I in 1 .. Last (M.Blocks) =>
(for some J in 1 .. Last (M.Blocks) =>
I /= J
and then Is_Adjacent_In_Array (M.Blocks, I, Left, Right)
and then Is_Adjacent_In_Array (M.Blocks, J, Left, Right)
and then not
(All_Block_Are_Uniq (M.Mem_Region, M.Blocks, 1, Last (M.Blocks))))));
end Neighbor_Valid_Blocks_Are_Adjacent_In_Array;
function Get_Prev(M: Formal_Model; B: Block) return Block
is
Prev : Block := Get(M.Blocks, 1);
begin
pragma Assert (if Length(M.Blocks) > 0
and not Is_First_Block (M, B)
and In_Model(M, B)
then Last(M.Blocks) >= 2);
pragma Assert (Last(M.Blocks) >= 2);
pragma Assert (Valid_Block(M.Mem_Region, Prev));
pragma Assert (Contains(M.Blocks, 2, Last(M.Blocks), B));
pragma Assert (for all From in 1..Last(M.Blocks) =>
(for all To in 1..From =>
(if Partial_Valid(M.Mem_Region, M.Blocks, 1, Last(M.Blocks))
then Partial_Valid(M.Mem_Region, M.Blocks, From, To))));
pragma Assert (for all From in 1..Last(M.Blocks) =>
(for all To in 1..From =>
(if Partial_Valid(M.Mem_Region, M.Blocks, From, To)
then Coverage_Is_Continuous(M.Mem_Region, M.Blocks, From, To))));
pragma Assert (for all From in 1..Last(M.Blocks)-1 =>
(if not Neighbor_Blocks(Get(M.Blocks, From), Get(M.Blocks, From+1))
then not Coverage_Is_Continuous(M.Mem_Region, M.Blocks, From, From+1)));
for Idx in 2..Last(M.Blocks) loop
pragma Loop_Invariant (Prev = Get(M.Blocks, Idx-1));
pragma Loop_Invariant (All_Blocks_Are_Valid(M.Mem_Region, M.Blocks, Idx-1, Idx));
pragma Loop_Invariant (Coverage_Is_Continuous(M.Mem_Region, M.Blocks, Idx-1, Idx));
pragma Loop_Invariant (Neighbor_Blocks(Get(M.Blocks, Idx-1), Get(M.Blocks, Idx)));
pragma Loop_Invariant (Neighbor_Blocks(Prev, Get(M.Blocks, Idx)));
pragma Loop_Invariant (if Get(M.Blocks, Idx) = B
then Neighbor_Blocks(Prev, B));
pragma Loop_Invariant (not Contains(M.Blocks, 2, Idx-1, B));
pragma Loop_Invariant (In_Model(M, Prev));
exit when Get(M.Blocks, Idx) = B;
Prev := Get(M.Blocks, Idx);
pragma Assert (In_Model(M, Prev));
end loop;
pragma Assert (if Get(M.Blocks, Last(M.Blocks)) = Prev
then not Contains(M.Blocks, 2, Last(M.Blocks), B));
pragma Assert (Neighbor_Blocks(Prev, B));
return Prev;
end Get_Prev;
function Get_Next(M: Formal_Model; B: Block) return Block
is
pragma Assert (if Length(M.Blocks) > 0
and not Is_First_Block(M, B)
and In_Model(M, B)
then Last(M.Blocks) >= 2);
pragma Assert (Last(M.Blocks) >= 2);
Next : Block := Get(M.Blocks, 1);
begin
pragma Assert (Contains(M.Blocks, 1, Last(M.Blocks)-1, B));
pragma Assert (for all From in 1..Last(M.Blocks) =>
(for all To in 1..From =>
(if Partial_Valid(M.Mem_Region, M.Blocks, 1, Last(M.Blocks))
then Partial_Valid(M.Mem_Region, M.Blocks, From, To))));
pragma Assert (for all From in 1..Last(M.Blocks) =>
(for all To in 1..From =>
(if Partial_Valid(M.Mem_Region, M.Blocks, From, To)
then Coverage_Is_Continuous(M.Mem_Region, M.Blocks, From, To))));
pragma Assert (for all From in 1..Last(M.Blocks)-1 =>
(if not Neighbor_Blocks(Get(M.Blocks, From), Get(M.Blocks, From+1))
then not Coverage_Is_Continuous(M.Mem_Region, M.Blocks, From, From+1)));
for Idx in 1..Last(M.Blocks)-1 loop
Next := Get(M.Blocks, Idx+1);
pragma Loop_Invariant (Valid_Block(M.Mem_Region, Next));
pragma Loop_Invariant (All_Blocks_Are_Valid(M.Mem_Region, M.Blocks, Idx, Idx+1));
pragma Loop_Invariant (Neighbor_Blocks(Get(M.Blocks, Idx), Next));
pragma Loop_Invariant (if Get(M.Blocks, Idx) = B
then Neighbor_Blocks(B, Next));
pragma Loop_Invariant (In_Model(M, Next));
pragma Loop_Invariant (not Contains (M.Blocks, 1, Idx - 1, B));
exit when Get(M.Blocks, Idx) = B;
end loop;
pragma Assert (if Next = Get(M.Blocks, 1)
then not Contains(M.Blocks, 1, Last(M.Blocks)-1, B));
pragma Assert (Neighbor_Blocks (B, Next));
return Next;
end Get_Next;
function Shift_Index (Idx : Index_Type;
Offset : Count_Type'Base)
return Index_Type
is (Index_Type'Val (Index_Type'Pos (Idx) + Offset))
with
Global => null,
Pre => (if Offset < 0 then
Index_Type'Pos (Index_Type'Base'First) - Offset <=
Index_Type'Pos (Index_Type'First))
and then (Offset in
Index_Type'Pos (Index_Type'First) - Index_Type'Pos (Idx) ..
Index_Type'Pos (Index_Type'Last) - Index_Type'Pos (Idx));
pragma Annotate (GNATprove, Inline_For_Proof, Shift_Index);
procedure Range_Shifted_Preserves_Partial_Validity
(Old_Space, New_Space : Address_Space;
Old_Blocks, New_Blocks : FV_Pkg.Sequence;
From : Index_Type;
To : Extended_Index;
Offset : Count_Type'Base)
with
Global => null,
Pre =>
Old_Space = New_Space
and then
To <= Last (Old_Blocks)
and then
(if Offset < 0 then
Index_Type'Pos (Index_Type'Base'First) - Offset <=
Index_Type'Pos (Index_Type'First))
and then
(if From <= To then
Offset in
Index_Type'Pos (Index_Type'First) - Index_Type'Pos (From) ..
(Index_Type'Pos (Index_Type'First) - 1) + Length (New_Blocks) -
Index_Type'Pos (To))
and then Range_Shifted (Old_Blocks, New_Blocks, From, To, Offset)
and then Partial_Valid (Old_Space, Old_Blocks, From, To),
Post =>
(if From <= To then
Partial_Valid (New_Space,
New_Blocks,
Shift_Index (From, Offset),
Shift_Index (To, Offset)))
is
begin
for Idx in From..To loop
pragma Loop_Invariant
(Partial_Valid(Old_Space, Old_Blocks, From, Idx));
pragma Loop_Invariant
(for all I in From..Idx =>
Get(Old_Blocks, I) = Get(New_Blocks, Shift_Index(I, Offset)));
pragma Loop_Invariant (if Idx >= 1 then Shift_Index(Idx, Offset) >= 1);
pragma Loop_Invariant (if Shift_Index(Idx, Offset) >= 1 then Idx >= 1);
pragma Loop_Invariant
(if Idx >= 1 Then
(for all I in From..Idx-1 =>
Get (Old_Blocks, I).Address < Get (Old_Blocks, I + 1).Address
and then Get (Old_Blocks, I) = Get (New_Blocks, Shift_Index (I, Offset))
and then Get (Old_Blocks, I + 1) = Get (New_Blocks, Shift_Index (I, Offset + 1))
and then Get(New_Blocks, Shift_Index(I,Offset)).Address < Get(New_Blocks, Shift_Index(I, Offset+1)).Address));
pragma Loop_Invariant
(if Shift_Index (Idx, Offset) >= 1 then
(for all I in Shift_Index (From, Offset) .. Shift_Index (Idx, Offset)-1 =>
Get (New_Blocks, I).Address < Get (New_Blocks, I + 1).Address));
pragma Assert (All_Blocks_Are_Valid (New_Space, New_Blocks, Shift_Index (From, Offset), Shift_Index (Idx, Offset)));
pragma Assert (Blocks_Addresses_Are_In_Ascending_Order (New_Blocks, Shift_Index (From, Offset), Shift_Index (Idx, Offset)));
pragma Assert (Coverage_Is_Continuous (New_Space, New_Blocks, Shift_Index (From, Offset), Shift_Index (Idx, Offset)));
pragma Assert (Blocks_Do_Not_Overlap (New_Space, New_Blocks, Shift_Index (From, Offset), Shift_Index (Idx, Offset)));
pragma Assert (All_Block_Are_Uniq (New_Space, New_Blocks, Shift_Index (From, Offset), Shift_Index (Idx, Offset)));
pragma Assert (All_Block_Addresses_Are_Uniq (New_Space, New_Blocks, Shift_Index (From, Offset), Shift_Index (Idx, Offset)));
pragma Assert (Partial_Valid(New_Space, New_Blocks,Shift_Index(From, Offset), Shift_Index(Idx, Offset)));
null;
end loop;
end Range_Shifted_Preserves_Partial_Validity;
procedure Range_Equal_Preserves_Partial_Validity
(Old_Space, New_Space : Address_Space;
Old_Blocks, New_Blocks : FV_Pkg.Sequence;
From : Index_Type;
To : Extended_Index)
with Global => null,
Pre => To <= Last (Old_Blocks) and then To <= Last (New_Blocks)
and then Old_Space = New_Space and then
Range_Equal (Old_Blocks, New_Blocks, From, To) and then
Partial_Valid (Old_Space, Old_Blocks, From, To),
Post => Partial_Valid (New_Space, New_Blocks, From, To)
is
begin
pragma Assert (for all Idx in From .. To =>
Get (Old_Blocks, Idx) = Get (New_Blocks, Idx));
pragma Assert (Partial_Valid (New_Space, New_Blocks, From, To));
null;
end Range_Equal_Preserves_Partial_Validity;
procedure Continuous_Coverage_Implies_Non_Overlapping
(Space : Address_Space;
Blocks : FV_Pkg.Sequence;
From : Index_Type;
To : Extended_Index)
with
Global => null,
Pre =>
To <= Last (Blocks) and then
All_Blocks_Are_Valid (Space, Blocks, From, To) and then
Coverage_Is_Continuous (Space, Blocks, From, To) and then
Blocks_Addresses_Are_In_Ascending_Order (Blocks, From, To),
Post =>
Blocks_Do_Not_Overlap (Space, Blocks, From, To)
is
begin
for T in From .. To loop
pragma Loop_Invariant
(for all I in From .. T =>
(for all J in From .. T =>
(if I < J then Get (Blocks, I).Address < Get (Blocks, J).Address)));
pragma Loop_Invariant
(for all I in From .. T =>
(for all J in From .. T =>
(if I < J then Get (Blocks, I).Address + Get (Blocks, I).Size <= Get (Blocks, J).Address)));
end loop;
pragma Assert
(for all I in From .. To =>
(for all J in From .. To =>
(if I < J then Get (Blocks, I).Address < Get (Blocks, J).Address)));
pragma Assert
(for all I in From .. To =>
(for all J in From .. To =>
(if I < J then Get (Blocks, I).Address + Get (Blocks, I).Size <= Get (Blocks, J).Address)));
pragma Assert
(if not Blocks_Do_Not_Overlap (Space, Blocks, From, To)
then
(for some I in From .. To =>
(for some J in From .. To =>
(I < J and then
Blocks_Overlap (Space,
Get (Blocks, I),
Get (Blocks, J))
and then
Get (Blocks, I).Address + Get (Blocks, I).Size > Get (Blocks, J).Address))));
end Continuous_Coverage_Implies_Non_Overlapping;
procedure Continuous_Coverage_Implies_Uniqueness
(Space : Address_Space;
Blocks : FV_Pkg.Sequence;
From : Index_Type;
To : Extended_Index)
with
Global => null,
Pre =>
To <= Last (Blocks) and then
All_Blocks_Are_Valid (Space, Blocks, From, To) and then
Coverage_Is_Continuous (Space, Blocks, From, To) and then
Blocks_Addresses_Are_In_Ascending_Order (Blocks, From, To),
Post =>
All_Block_Are_Uniq (Space, Blocks, From, To) and then
All_Block_Addresses_Are_Uniq (Space, Blocks, From, To)
is
begin
for T in From .. To loop
pragma Loop_Invariant
(for all I in From .. T =>
(for all J in From .. T =>
(if I < J then Get (Blocks, I).Address < Get (Blocks, J).Address)));
pragma Loop_Invariant
(for all I in From .. T =>
(for all J in From .. T =>
(if I > J then Get (Blocks, I).Address > Get (Blocks, J).Address)));
pragma Loop_Invariant
(for all I in From .. T =>
(for all J in From .. T =>
(if I = J then Get (Blocks, I).Address = Get (Blocks, J).Address)));
end loop;
pragma Assert
(for all I in From .. To =>
(for all J in From .. To =>
(if I < J then Get (Blocks, I).Address < Get (Blocks, J).Address)));
pragma Assert
(for all I in From .. To =>
(for all J in From .. To =>
(if I > J then Get (Blocks, I).Address > Get (Blocks, J).Address)));
pragma Assert
(for all I in From .. To =>
(for all J in From .. To =>
(if I = J then Get (Blocks, I).Address = Get (Blocks, J).Address)));
pragma Assert
(if not All_Block_Are_Uniq (Space, Blocks, From, To)
then
(for some I in From .. To =>
(for some J in From .. To =>
(I < J and then
(Get (Blocks, I).Address =
Get (Blocks, J).Address)))));
pragma Assert
(if not All_Block_Addresses_Are_Uniq (Space, Blocks, From, To)
then
(for some I in From .. To =>
(for some J in From .. To =>
(I < J and then
(Get (Blocks, I).Address =
Get (Blocks, J).Address)))));
end Continuous_Coverage_Implies_Uniqueness;
procedure Partial_Validity_Is_Additive
( Space : Address_Space;
Blocks : FV_Pkg.Sequence;
Left_From : Index_Type;
Left_To : Extended_Index;
Right_From : Index_Type;
Right_To : Extended_Index)
with
Global => null,
Pre =>
Left_To <= Last (Blocks) and then
Right_To <= Last (Blocks) and then
Left_To <= Right_To and then
Left_From <= Right_From and then
Partial_Valid (Space, Blocks, Left_From, Left_To) and then
Partial_Valid (Space, Blocks, Right_From, Right_To) and then
Right_From <= Left_To,
Post => Partial_Valid (Space, Blocks, Left_From, Right_To)
is
begin
for Idx in Left_From..Right_To loop
pragma Loop_Invariant
(if Idx >= 1 Then
(for all I in Left_From..Idx-1 =>
Get (Blocks, I).Address < Get (Blocks, I + 1).Address));
pragma Assert (All_Blocks_Are_Valid (Space, Blocks, Left_From, Idx));
pragma Assert (Blocks_Addresses_Are_In_Ascending_Order (Blocks, Left_From, Idx));
pragma Assert (Coverage_Is_Continuous (Space, Blocks, Left_From, Idx));
Continuous_Coverage_Implies_Non_Overlapping (Space, Blocks, Left_From, Idx);
pragma Assert (Blocks_Do_Not_Overlap (Space, Blocks, Left_From, Idx));
pragma Assert (All_Block_Are_Uniq (Space, Blocks, Left_From, Idx));
pragma Assert (Partial_Valid (Space, Blocks, Left_From, Idx));
null;
end loop;
end Partial_Validity_Is_Additive;
procedure Every_Subseq_Of_Partial_Valid_Seq_Is_Partial_Valid
(Space : Address_Space;
Blocks : FV_Pkg.Sequence;
From : Index_Type;
To : Extended_Index)
with Global => null,
Pre => To <= Last (Blocks)
and then Partial_Valid (Space, Blocks, From, To),
Post => (for all I in From .. To =>
(for all J in From .. I =>
Partial_Valid (Space, Blocks, J, I)))
is
begin
for I in From .. To loop
for J in From .. I loop
pragma Loop_Invariant (Partial_Valid (Space, Blocks, J, I));
end loop;
end loop;
null;
end Every_Subseq_Of_Partial_Valid_Seq_Is_Partial_Valid;
procedure Increment_Partial_Validity
(Space : Address_Space;
Blocks : FV_Pkg.Sequence;
From : Index_Type;
To : Index_Type)
with Global => null,
Pre => To < Last (Blocks)
and then Partial_Valid (Space, Blocks, From, To)
and then Valid_Block (Space, Get (Blocks, To + 1))
and then Valid_Block (Space, Get (Blocks, To))
and then Neighbor_Blocks (Get (Blocks, To), Get (Blocks, To + 1)),
Post => Partial_Valid (Space, Blocks, From, To + 1)
is
begin
for Idx in From .. To loop
pragma Assert (Get (Blocks, Idx).Address < Get (Blocks, Idx + 1).Address);
pragma Assert (Neighbor_Blocks (Get (Blocks, Idx), Get (Blocks, Idx + 1)));
pragma Assert (Blocks_Addresses_Are_In_Ascending_Order (Blocks, From, Idx + 1));
pragma Assert (Coverage_Is_Continuous (Space, Blocks, From, Idx + 1));
Continuous_Coverage_Implies_Non_Overlapping
(Space, Blocks, From, Idx + 1);
pragma Assert (Blocks_Do_Not_Overlap (Space, Blocks, From, Idx + 1));
Continuous_Coverage_Implies_Uniqueness
(Space, Blocks, From, Idx + 1);
pragma Assert (All_Block_Are_Uniq (Space, Blocks, From, Idx + 1));
pragma Loop_Invariant (Get (Blocks, Idx).Address < Get (Blocks, Idx + 1).Address);
pragma Loop_Invariant (Neighbor_Blocks (Get (Blocks, Idx), Get (Blocks, Idx + 1)));
pragma Loop_Invariant (Blocks_Addresses_Are_In_Ascending_Order (Blocks, From, Idx + 1));
pragma Loop_Invariant (Coverage_Is_Continuous (Space, Blocks, From, Idx + 1));
pragma Loop_Invariant (Blocks_Do_Not_Overlap (Space, Blocks, From, Idx + 1));
pragma Loop_Invariant (All_Block_Are_Uniq (Space, Blocks, From, Idx + 1));
pragma Loop_Invariant (All_Block_Addresses_Are_Uniq (Space, Blocks, From, Idx + 1));
end loop;
end Increment_Partial_Validity;
procedure Equality_Preserves_Validity (Old_M, New_M : Formal_Model)
is
begin
pragma Assert (Valid (Old_M));
pragma Assert (Old_M = New_M);
pragma Assert (for all Idx in 1 .. Last (Old_M.Blocks) =>
Get (Old_M.Blocks, Idx) = Get (New_M.Blocks, Idx));
pragma Assert (Blocks_Addresses_Are_In_Ascending_Order (New_M.Blocks, 1, Last (New_M.Blocks)));
pragma Assert (Coverage_Is_Continuous (New_M.Mem_Region, New_M.Blocks, 1, Last (New_M.Blocks)));
pragma Assert (Blocks_Do_Not_Overlap (New_M.Mem_Region, New_M.Blocks, 1, Last (New_M.Blocks)));
pragma Assert (All_Block_Are_Uniq (New_M.Mem_Region, New_M.Blocks, 1, Last (New_M.Blocks)));
pragma Assert (Valid (New_M));
null;
end Equality_Preserves_Validity;
procedure Equality_Preserves_Block_Relations
(Left_M, Right_M : Formal_Model;
B : Block)
is
begin
Equality_Preserves_Validity (Left_M, Right_M);
pragma Assert (Valid (Right_M));
pragma Assert (In_Model (Right_M, B));
pragma Assert (for all Idx in 1 .. Last (Right_M.Blocks) =>
Get (Left_M.Blocks, Idx) = Get (Right_M.Blocks, Idx));
pragma Assert (Is_Last_Block (Left_M, B) = Is_Last_Block (Right_M, B));
pragma Assert (Is_First_Block (Left_M, B) = Is_First_Block (Right_M, B));
pragma Assert (if not Is_Last_Block (Left_M, B) then
Get_Next (Left_M, B) = Get_Next (Right_M, B));
pragma Assert (if not Is_First_Block (Left_M, B) then
Get_Prev (Left_M, B) = Get_Prev (Right_M, B));
end Equality_Preserves_Block_Relations;
procedure All_Blocks_In_Model_Are_Valid (M : Formal_Model)
with Global => null,
Pre => Valid (M),
Post => (for all Idx in 1 .. Last (M.Blocks) =>
Valid_Block (M.Mem_Region, Get (M.Blocks, Idx)))
is
begin
for Idx in 1 .. Last (M.Blocks) loop
pragma Assert (if not Valid_Block (M.Mem_Region, Get (M.Blocks, Idx))
and then Valid (M)
then not In_Model (M, Get (M.Blocks, Idx)));
pragma Loop_Invariant
(for all I in 1 .. Idx =>
Valid_Block (M.Mem_Region, Get (M.Blocks, I)));
end loop;
end All_Blocks_In_Model_Are_Valid;
procedure Continuous_Coverage_Implies_Block_Addresses_In_Ascending_Order
(AS : Address_Space;
BS : FV_Pkg.Sequence;
From : Index_Type;
To : Extended_Index)
with Global => null,
Pre => To <= Last (BS) and then
All_Blocks_Are_Valid (AS, BS, From, To) and then
Coverage_Is_Continuous (AS, BS, From, To),
Post => Blocks_Addresses_Are_In_Ascending_Order (BS, From, To)
is
begin
pragma Assert
(if not Blocks_Addresses_Are_In_Ascending_Order (BS, From, To)
then
To < 1 or else
(for some Idx in From .. To - 1 =>
Get (Bs, Idx).Address >= Get (Bs, Idx + 1).Address
and then
not Neighbor_Blocks (Get (Bs, Idx), Get (Bs, Idx + 1))
and then
not Coverage_Is_Continuous (AS, BS, From, To)));
end Continuous_Coverage_Implies_Block_Addresses_In_Ascending_Order;
procedure Blocks_Validity_And_Continuous_Coverage_Implies_Partial_Validity
(AS : Address_Space;
BS : FV_Pkg.Sequence;
From : Index_Type;
To : Extended_Index)
with Global => null,
Pre => To <= Last (BS) and then
All_Blocks_Are_Valid (AS, BS, From, To) and then
Coverage_Is_Continuous (AS, BS, From, To),
Post => Partial_Valid (AS, BS, From, To)
is
begin
Continuous_Coverage_Implies_Block_Addresses_In_Ascending_Order (AS, BS, From, To);
Continuous_Coverage_Implies_Non_Overlapping (AS, BS, From, To);
Continuous_Coverage_Implies_Uniqueness (AS, BS, From, To);
end Blocks_Validity_And_Continuous_Coverage_Implies_Partial_Validity;
function Is_Sub_Block (M : Formal_Model;
Sub, Orig : Block)
return Boolean
is (Sub.Size < Orig.Size and then
Sub.Address in Orig.Address .. Orig.Address + Orig.Size - 1 and then
Integer (Sub.Address) + Integer (Sub.Size) in 0 .. Integer (BT.Address'Last) and then
Sub.Address + Sub.Size in Orig.Address .. Orig.Address + Orig.Size and then
(if Orig.Prev_Block_Address /= BT.Address_Null then
Sub.Prev_Block_Address in Orig.Prev_Block_Address .. Sub.Address - 1
or else Sub.Prev_Block_Address = BT.Address_Null
else Sub.Prev_Block_Address in Orig.Address .. Sub.Address - 1
or else Sub.Prev_Block_Address = BT.Address_Null))
with Global => null,
Pre => Valid_Block (M.Mem_Region, Orig);
procedure Sub_Block_Of_Valid_Block_Is_Valid
(M : Formal_Model;
Sub, Orig : Block)
with Global => null,
Pre => Valid_Block (M.Mem_Region, Orig) and then
Is_Sub_Block (M, Sub, Orig),
Post => Valid_Block (M.Mem_Region, Sub)
is
begin
pragma Assert (Orig.Address in M.Mem_Region.First .. M.Mem_Region.Last);
pragma Assert (Orig.Address + Orig.Size in M.Mem_Region.First .. M.Mem_Region.Last);
pragma Assert (Sub.Address in Orig.Address .. Orig.Address + Orig.Size - 1);
pragma Assert (Sub.Address in M.Mem_Region.First .. M.Mem_Region.Last);
pragma Assert (Sub.Address + Sub.Size in Orig.Address .. Orig.Address + Orig.Size);
pragma Assert (Sub.Address + Sub.Size in M.Mem_Region.First .. M.Mem_Region.Last);
pragma Assert (if Sub.Prev_Block_Address /= BT.Address_Null
then Sub.Prev_Block_Address in M.Mem_Region.First .. M.Mem_Region.Last);
pragma Assert (Sub.Prev_Block_Address in M.Mem_Region.First .. M.Mem_Region.Last
or else Sub.Prev_Block_Address = BT.Address_Null);
pragma Assert (Valid_Block(M.Mem_Region, Sub));
end Sub_Block_Of_Valid_Block_Is_Valid;
procedure Split_Block (M : Formal_Model;
B : Block;
L_Size, R_Size : BT.Aligned_Size;
B_Left, B_Right : out Block;
New_M : out Formal_Model)
is
Next : Block := B;
Old_Blocks : FV_Pkg.Sequence;
begin
New_M := M;
All_Blocks_In_Model_Are_Valid (M);
pragma Assert (Valid_Block (M.Mem_Region, B));
B_Left := Block'(B.Address, B.Prev_Block_Address, L_Size);
pragma Assert (Is_Sub_Block (New_M, B_Left, B));
Sub_Block_Of_Valid_Block_Is_Valid (New_M, B_Left, B);
B_Right := Block'(Next_Block_Address (B_Left), B_Left.Address, R_Size);
pragma Assert (Is_Sub_Block (New_M, B_Right, B));
Sub_Block_Of_Valid_Block_Is_Valid (New_M, B_Right, B);
pragma Assert (Next_Block_Address (B_Right) = Next_Block_Address (B));
pragma Assert (Neighbor_Blocks (B_Left, B_Right));
pragma Assert (B_Left /= B and then B_Left.Address = B.Address);
pragma Assert (In_Model (M, B));
pragma Assert (if In_Model (M, B_Left) then
not Blocks_Addresses_Are_In_Ascending_Order
(M.Blocks, 1, Last (M.Blocks)));
pragma Assert (not In_Model (M, B_Left));
pragma Assert (Blocks_Overlap (M.Mem_Region, B, B_Right));
pragma Assert (if In_Model (M, B_Right) then
not Blocks_Do_Not_Overlap
(M.Mem_Region, M.Blocks, 1, Last (M.Blocks)));
pragma Assert (not In_Model (M, B_Right));
pragma Assert (In_Model (New_M, B));
pragma Assert (Valid (New_M));
Equality_Preserves_Block_Relations(M, New_M, B);
pragma Assert (if not Is_First_Block (M, B) then
Get_Prev (M, B) = Get_Prev (New_M, B));
pragma Assert (Partial_Valid (New_M.Mem_Region, New_M.Blocks, 1, Last (New_M.Blocks)));
if not Is_Last_Block (M, B) then
Next := Get_Next(M, B);
pragma Assert (Neighbor_Blocks (B, Next));
end if;
Every_Subseq_Of_Partial_Valid_Seq_Is_Partial_Valid (New_M.Mem_Region, New_M.Blocks, 1, Last (New_M.Blocks));
Every_Subseq_Of_Partial_Valid_Seq_Is_Partial_Valid (M.Mem_Region, M.Blocks, 1, Last (M.Blocks));
for Idx in 1 .. Last (New_M.Blocks) loop
if B = Get (New_M.Blocks, Idx) then
Equality_Preserves_Block_Relations (M, New_M, B);
pragma Assert (if not Is_Last_Block (M, B) then Idx < Last (New_M.Blocks));
pragma Assert (if Idx < Last (New_M.Blocks) then not Is_Last_Block(New_M, B));
if Idx < Last (New_M.Blocks) then
pragma Assert (not Is_Last_Block(New_M, B));
pragma Assert (B = Get (New_M.Blocks, Idx));
pragma Assert (Neighbor_Blocks (B, Next));
pragma Assert (Neighbor_Blocks (Get (New_M.Blocks, Idx), Next));
Neighbor_Valid_Blocks_Are_Adjacent_In_Array (New_M, Get (New_M.Blocks, Idx), Next);
pragma Assert (Is_Adjacent_In_Array (New_M.Blocks, Idx, Get (New_M.Blocks, Idx), Next));
pragma Assert (B = Get (New_M.Blocks, Idx));
pragma Assert (Is_Adjacent_In_Array (M.Blocks, Idx, B, Next));
pragma Assert (Next = Get (New_M.Blocks, Idx + 1));
end if;
pragma Assert (if Idx < Last (New_M.Blocks) then Next = Get (New_M.Blocks, Idx + 1));
pragma Assert (not Contains (New_M.Blocks, 1, Idx - 1, B));
pragma Assert (Partial_Valid (New_M.Mem_Region, New_M.Blocks, 1, Idx));
pragma Assert (All_Block_Are_Uniq (New_M.Mem_Region, New_M.Blocks, 1, Last (New_M.Blocks)));
pragma Assert (for all I in 1 .. Last (New_M.Blocks) =>
(if I /= Idx then
Get (New_M.Blocks, I) /= B));
pragma Assert (if Idx > 1 then
Neighbor_Blocks
( Get (New_M.Blocks, Idx - 1), B));
pragma Assert (if Idx < Last (New_M.Blocks)
then Next_Block_Address (B) = Get (New_M.Blocks, Idx + 1).Address);
New_M.Blocks := Set (New_M.Blocks, Idx, B_Left);
pragma Assert (if Idx < Last (New_M.Blocks) then
Next = Get (New_M.Blocks, Idx + 1));
pragma Assert (B_Left /= B);
pragma Assert (Get (New_M.Blocks, Idx) /= B);
pragma Assert (for all I in 1 .. Last (New_M.Blocks) =>
Get (New_M.Blocks, I) /= B);
pragma Assert (not Contains (New_M.Blocks, 1, Last (New_M.Blocks), B));
pragma Assert (Range_Equal (M.Blocks, New_M.Blocks, 1, Idx - 1));
pragma Assert (if Idx < Last (New_M.Blocks) then
Get (New_M.Blocks, Last (New_M.Blocks)) =
Get (M.Blocks, Last (M.Blocks)));
pragma Assert (if Idx > 1 then Get (New_M.Blocks, 1) = Get (M.Blocks, 1));
Range_Equal_Preserves_Partial_Validity
(M.Mem_Region, New_M.Mem_Region,
M.Blocks, New_M.Blocks,
1, Idx - 1);
pragma Assert (Partial_Valid (New_M.Mem_Region, New_M.Blocks, 1, Idx - 1));
pragma Assert (if Idx > 1 then
Neighbor_Blocks
(Get (New_M.Blocks, Idx - 1), B));
pragma Assert (if Idx > 1 then
Neighbor_Blocks
( Get (New_M.Blocks, Idx - 1), B_Left));
pragma Assert (B.Address = B_Left.Address);
pragma Assert (All_Blocks_Are_Valid (New_M.Mem_Region, New_M.Blocks, 1, Idx));
pragma Assert (Coverage_Is_Continuous (New_M.Mem_Region, New_M.Blocks, 1, Idx));
Blocks_Validity_And_Continuous_Coverage_Implies_Partial_Validity (New_M.Mem_Region, New_M.Blocks, 1, Idx);
pragma Assume (Idx <= Index_Type'Last - 2);
pragma Assert (Range_Equal (M.Blocks, New_M.Blocks, Idx + 1, Last (New_M.Blocks)));
Range_Equal_Preserves_Partial_Validity
(M.Mem_Region, New_M.Mem_Region,
M.Blocks, New_M.Blocks,
Idx + 1, Last (New_M.Blocks));
pragma Assert (Partial_Valid (New_M.Mem_Region, New_M.Blocks, Idx + 1, Last (New_M.Blocks)));
pragma Assume (Length (New_M.Blocks) < Count_Type'Last);
Old_Blocks := New_M.Blocks;
pragma Assert (Get (New_M.Blocks, Idx) = B_Left);
pragma Assert (Last (Old_Blocks) = Last (New_M.Blocks));
pragma Assert (Length (Old_Blocks) = Length (New_M.Blocks));
pragma Assert (Idx in 1 .. Last (New_M.Blocks));
pragma Assert (Idx in 1 .. Last (Old_Blocks));
pragma Assert (if Idx < Last (New_M.Blocks)
then Next_Block_Address (B) = Get (New_M.Blocks, Idx + 1).Address);
pragma Assert (if Idx < Last (New_M.Blocks)
then Next_Block_Address (B_Right) = Get (New_M.Blocks, Idx + 1).Address);
pragma Assert (Partial_Valid (New_M.Mem_Region, New_M.Blocks, Idx + 1, Last (New_M.Blocks)));
New_M.Blocks := Add (New_M.Blocks, Idx + 1, B_Right);
pragma Assert (if Idx < Last (Old_Blocks) then
Next = Get (New_M.Blocks, Idx + 2));
pragma Assert (Partial_Valid (New_M.Mem_Region, Old_Blocks, Idx + 1, Last (Old_Blocks)));
pragma Assert (if Idx < Last (Old_Blocks)
then Next_Block_Address (B_Right) = Get (New_M.Blocks, Idx + 2).Address);
pragma Assert (Last (Old_Blocks) + 1 = Last (New_M.Blocks));
pragma Assert (Get (New_M.Blocks, Idx) = B_Left);
pragma Assert (if Idx < Last (Old_Blocks) then
Get (New_M.Blocks, Last (New_M.Blocks)) =
Get (M.Blocks, Last (M.Blocks)));
pragma Assert (Range_Equal (Old_Blocks, New_M.Blocks, 1, Idx));
pragma Assert (Range_Shifted (Old_Blocks, New_M.Blocks, Idx + 1, Last (Old_Blocks), 1));
Range_Equal_Preserves_Partial_Validity
(New_M.Mem_Region, New_M.Mem_Region,
Old_Blocks, New_M.Blocks,
1, Idx);
Range_Shifted_Preserves_Partial_Validity
(New_M.Mem_Region, New_M.Mem_Region,
Old_Blocks, New_M.Blocks,
Idx + 1, Last (Old_Blocks), 1);
pragma Assert (Partial_Valid (New_M.Mem_Region, New_M.Blocks, 1, Idx));
pragma Assert (Last (New_M.Blocks) = Last (Old_Blocks) + 1);
pragma Assert (All_Blocks_Are_Valid (New_M.Mem_Region, New_M.Blocks, Idx + 2, Last (New_M.Blocks)));
pragma Assert (Coverage_Is_Continuous (New_M.Mem_Region, New_M.Blocks, Idx + 2, Last (New_M.Blocks)));
Blocks_Validity_And_Continuous_Coverage_Implies_Partial_Validity
(New_M.Mem_Region, New_M.Blocks, Idx + 2, Last (New_M.Blocks));
pragma Assert (Partial_Valid (New_M.Mem_Region, New_M.Blocks, Idx + 2, Last (New_M.Blocks)));
pragma Assert (Get (New_M.Blocks, Idx + 1) = B_Right);
pragma Assert (Get (New_M.Blocks, Idx) = B_Left);
pragma Assert (Neighbor_Blocks (Get (New_M.Blocks, Idx), Get (New_M.Blocks, Idx + 1)));
Increment_Partial_Validity (New_M.Mem_Region, New_M.Blocks, 1, Idx);
pragma Assert (Partial_Valid (New_M.Mem_Region, New_M.Blocks, 1, Idx + 1));
if Idx = Last (Old_Blocks) then
pragma Assert (Partial_Valid (New_M.Mem_Region, New_M.Blocks, 1, Last (New_M.Blocks)));
pragma Assert (B_Right.Address + B_Right.Size = B.Address + B.Size);
pragma Assert (Boundary_Blocks_Coverage_Is_Correct (M.Mem_Region, M.Blocks));
pragma Assert (Get (M.Blocks, Last (M.Blocks)) = B);
pragma Assert (B.Address + B.Size = New_M.Mem_Region.Last);
pragma Assert (Get (New_M.Blocks, 1).Address = Get (M.Blocks, 1).Address);
pragma Assert (Boundary_Blocks_Coverage_Is_Correct (New_M.Mem_Region, New_M.Blocks));
pragma Assert (Valid (New_M));
pragma Assert (In_Model (New_M, B_Right));
pragma Assert (In_Model (New_M, B_Left));
pragma Assert (not In_Model (New_M, B));
null;
else
pragma Assert (Next = Get (New_M.Blocks, Idx + 2));
pragma Assert (Next_Block_Address (B) = Next.Address);
pragma Assert (Get (New_M.Blocks, Idx + 1) = B_Right);
pragma Assert (Next_Block_Address (B_Right) = Next.Address);
pragma Assert (Next.Address > B_Right.Address);
Next.Prev_Block_Address := B_Right.Address;
if Idx + 2 = Last (New_M.Blocks) then
pragma Assert (Next.Address =
Get (M.Blocks, Last (M.Blocks)).Address);
pragma Assert (Next.Size =
Get (M.Blocks, Last (M.Blocks)).Size);
else
pragma Assert (Next.Address =
Get (M.Blocks, Idx + 2).Address);
pragma Assert (Next.Size =
Get (M.Blocks, Idx + 2).Size);
end if;
pragma Assert (Last (Old_Blocks) + 1 = Last (New_M.Blocks));
pragma Assert (Get (New_M.Blocks, Last (New_M.Blocks)) =
Get (M.Blocks, Last (M.Blocks)));
Old_Blocks := New_M.Blocks;
pragma Assert (Get (Old_Blocks, Last (Old_Blocks)) =
Get (M.Blocks, Last (M.Blocks)));
pragma Assert (Idx + 2 <= Last (New_M.Blocks));
New_M.Blocks := Set (New_M.Blocks, Idx + 2, Next);
if Idx + 2 = Last (New_M.Blocks) then
pragma Assert (Next = Get (New_M.Blocks, Last (New_M.Blocks)));
pragma Assert (Get (New_M.Blocks, Last (New_M.Blocks)).Address =
Get (M.Blocks, Last (M.Blocks)).Address);
pragma Assert (Get (New_M.Blocks, Last (New_M.Blocks)).Size =
Get (M.Blocks, Last (M.Blocks)).Size);
else
pragma Assert (Idx + 2 < Last (New_M.Blocks));
pragma Assert (Range_Equal (Old_Blocks, New_M.Blocks, Idx + 3, Last (New_M.Blocks)));
pragma Assert (Get (Old_Blocks, Last (Old_Blocks)) =
Get (M.Blocks, Last (M.Blocks)));
pragma Assert (Get (New_M.Blocks, Last (New_M.Blocks)) =
Get (M.Blocks, Last (M.Blocks)));
pragma Assert (Get (New_M.Blocks, Last (New_M.Blocks)).Address =
Get (M.Blocks, Last (M.Blocks)).Address);
pragma Assert (Get (New_M.Blocks, Last (New_M.Blocks)).Size =
Get (M.Blocks, Last (M.Blocks)).Size);
end if;
pragma Assert (Get (New_M.Blocks, Last (New_M.Blocks)).Address =
Get (M.Blocks, Last (M.Blocks)).Address);
pragma Assert (Get (New_M.Blocks, Last (New_M.Blocks)).Size =
Get (M.Blocks, Last (M.Blocks)).Size);
pragma Assert (Range_Equal (Old_Blocks, New_M.Blocks, 1, Idx + 1));
Range_Equal_Preserves_Partial_Validity
(M.Mem_Region, New_M.Mem_Region,
Old_Blocks, New_M.Blocks,
1, Idx + 1);
if Idx + 2 < Last (New_M.Blocks) then
pragma Assert (Range_Equal (Old_Blocks, New_M.Blocks, Idx + 3, Last (New_M.Blocks)));
pragma Assert (Partial_Valid (New_M.Mem_Region, Old_Blocks, Idx + 3, Last (New_M.Blocks)));
Range_Equal_Preserves_Partial_Validity
(M.Mem_Region, New_M.Mem_Region,
Old_Blocks, New_M.Blocks,
Idx + 3, Last (New_M.Blocks));
pragma Assert (Partial_Valid (New_M.Mem_Region, New_M.Blocks, Idx + 3, Last (New_M.Blocks)));
end if;
pragma Assert (Partial_Valid (New_M.Mem_Region, New_M.Blocks, 1, Idx + 1));
pragma Assert (Neighbor_Blocks (B_Right, Get (New_M.Blocks, Idx + 2)));
Increment_Partial_Validity (New_M.Mem_Region, New_M.Blocks, 1, Idx + 1);
pragma Assert (Partial_Valid (New_M.Mem_Region, New_M.Blocks, 1, Idx + 2));
if Idx + 2 < Last (New_M.Blocks) then
pragma Assert (Neighbor_Blocks (Get (New_M.Blocks, Idx + 2), Get (New_M.Blocks, Idx + 3)));
Increment_Partial_Validity (New_M.Mem_Region, New_M.Blocks, 1, Idx + 2);
pragma Assert (Partial_Valid (New_M.Mem_Region, New_M.Blocks, 1, Idx + 3));
pragma Assert (Partial_Valid (New_M.Mem_Region, New_M.Blocks, Idx + 3, Last (New_M.Blocks)));
Partial_Validity_Is_Additive (New_M.Mem_Region, New_M.Blocks, 1, Idx + 3, Idx + 3, Last (New_M.Blocks));
pragma Assert (Partial_Valid (New_M.Mem_Region, New_M.Blocks, 1, Last (New_M.Blocks)));
else
pragma Assert (Idx + 2 = Last (New_M.Blocks));
pragma Assert (Partial_Valid (New_M.Mem_Region, New_M.Blocks, 1, Last (New_M.Blocks)));
end if;
pragma Assert (Partial_Valid (New_M.Mem_Region, New_M.Blocks, 1, Last (New_M.Blocks)));
if Idx = 1 then
pragma Assert (B_Left.Address = B.Address);
pragma Assert (B_Left.Prev_Block_Address = B.Prev_Block_Address);
pragma Assert (B_Left.Prev_Block_Address = BT.Address_Null);
pragma Assert (Get (New_M.Blocks, 1) = B_Left);
pragma Assert (Get (New_M.Blocks, Last (New_M.Blocks)).Address =
Get (M.Blocks, Last (M.Blocks)).Address);
pragma Assert (Get (New_M.Blocks, Last (New_M.Blocks)).Size =
Get (M.Blocks, Last (M.Blocks)).Size);
pragma Assert (Get (New_M.Blocks, 1).Address = New_M.Mem_Region.First);
pragma Assert (Next_Block_Address (Get (New_M.Blocks, Last (New_M.Blocks))) =
New_M.Mem_Region.Last);
pragma Assert (Boundary_Blocks_Coverage_Is_Correct (New_M.Mem_Region, New_M.Blocks));
pragma Assert (Valid (New_M));
pragma Assert (In_Model (New_M, B_Right));
pragma Assert (In_Model (New_M, B_Left));
pragma Assert (not In_Model (New_M, B));
null;
else
pragma Assert (Get (New_M.Blocks, 1) = Get (M.Blocks, 1));
pragma Assert (Get (New_M.Blocks, Last (New_M.Blocks)).Address =
Get (M.Blocks, Last (M.Blocks)).Address);
pragma Assert (Get (New_M.Blocks, Last (New_M.Blocks)).Size =
Get (M.Blocks, Last (M.Blocks)).Size);
pragma Assert (Get (New_M.Blocks, 1).Address = New_M.Mem_Region.First);
pragma Assert (Get (New_M.Blocks, 1).Prev_Block_Address = BT.Address_Null);
pragma Assert (Next_Block_Address (Get (New_M.Blocks, Last (New_M.Blocks))) =
New_M.Mem_Region.Last);
pragma Assert (Boundary_Blocks_Coverage_Is_Correct (New_M.Mem_Region, New_M.Blocks));
pragma Assert (Valid (New_M));
pragma Assert (In_Model (New_M, B_Right));
pragma Assert (In_Model (New_M, B_Left));
pragma Assert (not In_Model (New_M, B));
null;
end if;
null;
end if;
pragma Assert (Valid (New_M));
pragma Assert (In_Model (New_M, B_Left));
pragma Assert (In_Model (New_M, B_Right));
exit;
end if;
pragma Loop_Invariant (if not Is_Last_Block (M, B) then
Next = Get_Next (M, B));
pragma Loop_Invariant (Idx in 1 .. Last (New_M.Blocks));
pragma Loop_Invariant (not Contains (New_M.Blocks, 1, Idx, B));
pragma Loop_Invariant (for all I in 1 .. Last (New_M.Blocks) =>
(Get (New_M.Blocks, I) = Get (M.Blocks, I)));
pragma Loop_Invariant (if not Is_Last_Block (M, B) then
Next = Get_Next (New_M, B));
pragma Loop_Invariant (Partial_Valid (New_M.Mem_Region, New_M.Blocks, 1, Last (New_M.Blocks)));
pragma Loop_Invariant (Range_Equal (M.Blocks, New_M.Blocks, 1, Idx));
pragma Loop_Invariant (Partial_Valid (New_M.Mem_Region, New_M.Blocks, 1, Idx));
end loop;
pragma Assert (not In_Model (New_M, B));
pragma Assert (Valid (New_M));
end Split_Block;
function Find_Block (M : Formal_Model; B : Block)
return Index_Type
with Global => null,
Depends => (Find_Block'Result => (M, B)),
Pre => Valid (M) and then In_Model (M, B),
Post =>
Find_Block'Result in Index_Type'First .. Last (M.Blocks) and then
Get (M.Blocks, Find_Block'Result) = B
is
Result : Index_Type := 1;
begin
pragma Assert (Contains (M.Blocks, 1, Last (M.Blocks), B));
for Idx in 1 .. Last (M.Blocks) loop
Result := Idx;
exit when Get (M.Blocks, Result) = B;
pragma Loop_Invariant (not Contains (M.Blocks, 1, Idx, B));
end loop;
pragma Assert (if Get (M.Blocks, Result) /= B
then not (Contains (M.Blocks, 1, Last (M.Blocks), B)));
return Result;
end Find_Block;
procedure Join (M : Formal_Model;
Left, Right : Block;
B : out Block;
New_M : out Formal_Model)
is
Idx : Index_Type := 1;
begin
New_M := M;
Equality_Preserves_Validity (M, New_M);
Equality_Preserves_Block_Relations(M, New_M, Left);
Equality_Preserves_Block_Relations(M, New_M, Right);
B := Block'(Address => Left.Address,
Prev_Block_Address => Left.Prev_Block_Address,
Size => Left.Size + Right.Size);
pragma Assert (Valid_Block (M.Mem_Region, Left));
pragma Assert (Valid_Block (M.Mem_Region, Right));
pragma Assert (Next_Block_Address (Right) = Next_Block_Address (B));
pragma Assert (Valid_Block (New_M.Mem_Region, B));
Idx := Find_Block (M, Left);
pragma Assert (Get (M.Blocks, Idx) = Left);
Neighbor_Valid_Blocks_Are_Adjacent_In_Array (M, Left, Right);
pragma Assert (Is_Adjacent_In_Array(M.Blocks, Idx, Left, Right));
pragma Assert (Get (M.Blocks, Idx + 1) = Right);
end Join;
end TLSF.Proof.Model.Block;
|
jhumphry/PRNG_Zoo | Ada | 1,792 | ads | --
-- PRNG Zoo
-- Copyright (c) 2014 - 2015, James Humphry
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
with AUnit; use AUnit;
with AUnit.Test_Cases; use AUnit.Test_Cases;
with PRNG_Zoo.Linear_Congruential.Examples;
with PRNGTests_Suite.Sanity_Checks32;
package PRNGTests_Suite.Lin_Con_Tests is
type Lin_Con_Test is new Test_Cases.Test_Case with null record;
procedure Register_Tests (T: in out Lin_Con_Test);
function Name (T : Lin_Con_Test) return Test_String;
procedure Set_Up (T : in out Lin_Con_Test);
-- Test Routines:
procedure Sanity_Check_MINSTD is
new PRNGTests_Suite.Sanity_Checks32(P => PRNG_Zoo.Linear_Congruential.Examples.MINSTD);
procedure Sanity_Check_MINSTD0 is
new PRNGTests_Suite.Sanity_Checks32(P => PRNG_Zoo.Linear_Congruential.Examples.MINSTD0);
procedure Sanity_Check_RANDU is
new PRNGTests_Suite.Sanity_Checks32(P => PRNG_Zoo.Linear_Congruential.Examples.RANDU);
procedure Test_RANDU (T : in out Test_Cases.Test_Case'Class);
procedure Test_MINSTD (T : in out Test_Cases.Test_Case'Class);
end PRNGTests_Suite.Lin_Con_Tests;
|
charlie5/lace | Ada | 2,563 | adb | with
gel.Window.sdl,
gel.Applet.gui_world,
gel.Forge,
gel.Sprite,
gel.Joint,
Physics,
openGL.Palette;
pragma unreferenced (gel.Window.sdl);
procedure launch_Chains_2d
--
-- Creates a chain of balls in a 2D space.
--
is
use gel.Forge,
gel.Applet,
gel.Math,
opengl.Palette;
the_Applet : gel.Applet.gui_World.view := new_gui_Applet ("Chains 2D",
1536, 864,
space_Kind => physics.Box2D);
the_Ground : constant gel.Sprite.view := new_rectangle_Sprite (the_Applet.gui_World,
Mass => 0.0,
Width => 100.0,
Height => 1.0,
Color => apple_Green);
begin
the_Applet.gui_World .Gravity_is ([0.0, -10.0, 0.0]);
the_Applet.gui_Camera.Site_is ([0.0, -30.0, 100.0]);
the_Applet.Renderer .Background_is (Grey);
the_Applet.enable_simple_Dolly (in_World => gui_World.gui_world_Id);
the_Ground.Site_is ([0.0, -40.0, 0.0]);
the_Applet.gui_World.add (the_Ground, and_Children => False);
-- Add joints.
--
declare
ball_Count : constant := 39;
the_root_Ball : constant gel.Sprite.view := new_circle_Sprite (the_Applet.gui_World, Mass => 0.0);
the_Balls : constant gel.Sprite.views := [1 .. ball_Count => new_circle_Sprite (the_Applet.gui_World, Mass => 1.0)];
Parent : gel.Sprite.view := the_root_Ball;
new_Joint : gel.Joint .view;
begin
for i in the_Balls'Range
loop
the_Balls (i).Site_is ([Real (-i), 0.0, 0.0]);
Parent.attach_via_Hinge (the_Child => the_Balls (i),
pivot_Axis => [0.0, 0.0, 1.0],
low_Limit => to_Radians (-180.0),
high_Limit => to_Radians ( 180.0),
new_joint => new_Joint);
Parent := the_Balls (i);
end loop;
the_Applet.gui_World.add (the_root_Ball, and_Children => True);
end;
while the_Applet.is_open
loop
the_Applet.freshen; -- Handle any new events, evolve physics and update the screen.
end loop;
gel.Applet.gui_world.free (the_Applet);
end launch_Chains_2d;
|
LiberatorUSA/GUCEF | Ada | 853 | ads | with agar.gui.types;
package agar.gui.widget.titlebar is
subtype titlebar_t is agar.gui.types.widget_titlebar_t;
subtype titlebar_access_t is agar.gui.types.widget_titlebar_access_t;
subtype flags_t is agar.gui.types.widget_titlebar_flags_t;
TITLEBAR_NO_CLOSE : constant flags_t := 16#01#;
TITLEBAR_NO_MINIMIZE : constant flags_t := 16#02#;
TITLEBAR_NO_MAXIMIZE : constant flags_t := 16#04#;
function allocate
(parent : widget_access_t;
flags : flags_t) return titlebar_access_t;
pragma import (c, allocate, "AG_TitlebarNew");
procedure set_caption
(titlebar : titlebar_access_t;
caption : string);
pragma inline (set_caption);
function widget (titlebar : titlebar_access_t)
return agar.gui.widget.widget_access_t
renames agar.gui.types.widget_titlebar_widget;
end agar.gui.widget.titlebar;
|
godunko/adawebpack | Ada | 9,465 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . W C H _ C O N --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2021, 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 defines the codes used to identify the encoding method for
-- wide characters in string and character constants. This is needed both
-- at compile time and at runtime (for the wide character runtime routines)
-- This unit may be used directly from an application program by providing
-- an appropriate WITH, and the interface can be expected to remain stable.
package System.WCh_Con is
pragma Pure;
-------------------------------------
-- Wide_Character Encoding Methods --
-------------------------------------
-- A wide character encoding method is a method for uniquely representing
-- a Wide_Character or Wide_Wide_Character value using a one or more
-- Character values. Three types of encoding method are supported by GNAT:
-- An escape encoding method uses ESC as the first character of the
-- sequence, and subsequent characters determine the wide character
-- value that is represented. Any character other than ESC stands
-- for itself as a single byte (i.e. any character in Latin-1, other
-- than ESC itself, is represented as a single character: itself).
-- An upper half encoding method uses a character in the upper half
-- range (i.e. in the range 16#80# .. 16#FF#) as the first byte of
-- a wide character encoding sequence. Subsequent characters are
-- used to determine the wide character value that is represented.
-- Any character in the lower half (16#00# .. 16#7F#) represents
-- itself as a single character.
-- The brackets notation, where a wide character is represented by the
-- sequence ["xx"] or ["xxxx"] or ["xxxxxx"] where xx are hexadecimal
-- characters. Note that currently this is the only encoding that
-- supports the full UTF-32 range.
-- Note that GNAT does not currently support escape-in, escape-out
-- encoding methods, where an escape sequence is used to set a mode
-- used to recognize subsequent characters. All encoding methods use
-- individual character-by-character encodings, so that a sequence of
-- wide characters is represented by a sequence of encodings.
-- To add new encoding methods, the following steps are required:
-- 1. Define a code for a new value of type WC_Encoding_Method
-- 2. Adjust the definition of WC_Encoding_Method accordingly
-- 3. Provide appropriate conversion routines in System.WCh_Cnv
-- 4. Adjust definition of WC_Longest_Sequence if necessary
-- 5. Add an entry in WC_Encoding_Letters for the new method
-- 6. Add proper code to s-wchstw.adb, s-wchwts.adb, s-widwch.adb
-- 7. Update documentation (remember section on form strings)
-- Note that the WC_Encoding_Method values must be kept ordered so that
-- the definitions of the subtypes WC_Upper_Half_Encoding_Method and
-- WC_ESC_Encoding_Method are still correct.
---------------------------------
-- Encoding Method Definitions --
---------------------------------
type WC_Encoding_Method is range 5 .. 6;
-- Type covering the range of values used to represent wide character
-- encoding methods. An enumeration type might be a little neater, but
-- more trouble than it's worth, given the need to pass these values
-- from the compiler to the backend, and to record them in the ALI file.
WCEM_UTF8 : constant WC_Encoding_Method := 5;
-- An ISO 10646-1 BMP/Unicode wide character is represented in UCS
-- Transformation Format 8 (UTF-8), as defined in Annex R of ISO
-- 10646-1/Am.2. Depending on the character value, a Unicode character
-- is represented as the one to six byte sequence.
--
-- 16#0000_0000#-16#0000_007f#: 2#0xxxxxxx#
-- 16#0000_0080#-16#0000_07ff#: 2#110xxxxx# 2#10xxxxxx#
-- 16#0000_0800#-16#0000_ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
-- 16#0001_0000#-16#001F_FFFF#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx#
-- 2#10xxxxxx#
-- 16#0020_0000#-16#03FF_FFFF#: 2#111110xx# 2#10xxxxxx# 2#10xxxxxx#
-- 2#10xxxxxx# 2#10xxxxxx#
-- 16#0400_0000#-16#7FFF_FFFF#: 2#1111110x# 2#10xxxxxx# 2#10xxxxxx#
-- 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
--
-- where the xxx bits correspond to the left-padded bits of the
-- 16-bit character value. Note that all lower half ASCII characters
-- are represented as ASCII bytes and all upper half characters and
-- other wide characters are represented as sequences of upper-half. This
-- encoding method can represent the entire range of Wide_Wide_Character.
WCEM_Brackets : constant WC_Encoding_Method := 6;
-- A wide character is represented using one of the following sequences:
--
-- ["xx"]
-- ["xxxx"]
-- ["xxxxxx"]
-- ["xxxxxxxx"]
--
-- where xx are hexadecimal digits representing the character code. This
-- encoding method can represent the entire range of Wide_Wide_Character
-- but in the general case results in ambiguous representations (there is
-- no ambiguity in Ada sources, since the above sequences are illegal Ada).
WC_Encoding_Letters : constant array (WC_Encoding_Method) of Character :=
[WCEM_UTF8 => '8',
WCEM_Brackets => 'b'];
-- Letters used for selection of wide character encoding method in the
-- compiler options (-gnatW? switch) and for Wide_Text_IO (WCEM parameter
-- in the form string).
subtype WC_Upper_Half_Encoding_Method is
WC_Encoding_Method range WCEM_UTF8 .. WCEM_UTF8;
-- Encoding methods using an upper half character (16#80#..16#FF) at
-- the start of the sequence.
WC_Longest_Sequence : constant := 12;
-- The longest number of characters that can be used for a wide character
-- or wide wide character sequence for any of the active encoding methods.
WC_Longest_Sequences : constant array (WC_Encoding_Method) of Natural :=
[WCEM_UTF8 => 6,
WCEM_Brackets => 12];
-- The longest number of characters that can be used for a wide character
-- or wide wide character sequence using the given encoding method.
function Get_WC_Encoding_Method (C : Character) return WC_Encoding_Method;
-- Given a character C, returns corresponding encoding method (see array
-- WC_Encoding_Letters above). Raises Constraint_Error if not in list.
function Get_WC_Encoding_Method (S : String) return WC_Encoding_Method;
-- Given a lower case string that is one of hex, upper, shift_jis, euc,
-- utf8, brackets, return the corresponding encoding method. Raises
-- Constraint_Error if not in list.
function Is_Start_Of_Encoding
(C : Character;
EM : WC_Encoding_Method) return Boolean;
pragma Inline (Is_Start_Of_Encoding);
-- Returns True if the Character C is the start of a multi-character
-- encoding sequence for the given encoding method EM. If EM is set to
-- WCEM_Brackets, this function always returns False.
end System.WCh_Con;
|
kimtg/euler-ada | Ada | 496 | adb | with ada.text_io;
use ada.text_io;
procedure euler7 is
function is_prime(n : integer) return boolean is
i : integer := 2;
begin
while i * i <= n loop
if n mod i = 0 then
return false;
end if;
i := i + 1;
end loop;
return true;
end;
count : integer := 0;
i : integer := 2;
begin
while count < 10001 loop
if is_prime(i) then
count := count + 1;
put_line(integer'image(count) & integer'image(i));
end if;
i := i + 1;
end loop;
end;
|
redparavoz/ada-wiki | Ada | 2,276 | ads | -----------------------------------------------------------------------
-- wiki-filters-toc -- Filter for the creation of Table Of Contents
-- Copyright (C) 2016 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- 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.
-----------------------------------------------------------------------
-- === TOC Filter ===
-- The <tt>TOC_Filter</tt> is a filter used to build the table of contents.
-- It collects the headers with the section level as they are added to the
-- wiki document. The TOC is built in the wiki document as a separate node
-- and it can be retrieved by using the <tt>Get_TOC</tt> function. To use
-- the filter, declare an aliased instance:
--
-- TOC : aliased Wiki.Filters.TOC.TOC_Filter;
--
-- and add the filter to the Wiki parser engine:
--
-- Engine.Add_Filter (TOC'Unchecked_Access);
--
package Wiki.Filters.TOC is
pragma Preelaborate;
-- ------------------------------
-- TOC Filter
-- ------------------------------
type TOC_Filter is new Filter_Type with null record;
-- Add a text content with the given format to the document.
overriding
procedure Add_Text (Filter : in out TOC_Filter;
Document : in out Wiki.Documents.Document;
Text : in Wiki.Strings.WString;
Format : in Wiki.Format_Map);
-- Add a section header with the given level in the document.
overriding
procedure Add_Header (Filter : in out TOC_Filter;
Document : in out Wiki.Documents.Document;
Header : in Wiki.Strings.WString;
Level : in Natural);
end Wiki.Filters.TOC;
|
charlie5/lace | Ada | 135 | ads | with
any_Math.any_Geometry;
package float_math.Geometry is new float_Math.any_Geometry;
pragma Pure (float_math.Geometry);
|
sungyeon/drake | Ada | 485 | ads | pragma License (Unrestricted);
-- extended unit
package Ada.Fixed is
-- Ada.Decimal-like utilities for ordinary fixed types.
pragma Pure;
generic
type Dividend_Type is delta <>;
type Divisor_Type is delta <>;
type Quotient_Type is delta <>;
type Remainder_Type is delta <>;
procedure Divide (
Dividend : Dividend_Type;
Divisor : Divisor_Type;
Quotient : out Quotient_Type;
Remainder : out Remainder_Type);
end Ada.Fixed;
|
stcarrez/dynamo | Ada | 4,311 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- P R J . M A K R --
-- --
-- S p e c --
-- --
-- Copyright (C) 2001-2009, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Support for procedure Gnatname
-- For arbitrary naming schemes, create or update a project file, or create a
-- configuration pragmas file.
with System.Regexp; use System.Regexp;
package Prj.Makr is
procedure Initialize
(File_Path : String;
Project_File : Boolean;
Preproc_Switches : Argument_List;
Very_Verbose : Boolean;
Flags : Processing_Flags);
-- Start the creation of a configuration pragmas file or the creation or
-- modification of a project file, for gnatname.
--
-- When Project_File is False, File_Path is the name of a configuration
-- pragmas file to create. When Project_File is True, File_Path is the name
-- of a project file to create if it does not exist or to modify if it
-- already exists.
--
-- Preproc_Switches is a list of switches to be used when invoking the
-- compiler to get the name and kind of unit of a source file.
--
-- Very_Verbose controls the verbosity of the output, in conjunction with
-- Opt.Verbose_Mode.
type Regexp_List is array (Positive range <>) of Regexp;
procedure Process
(Directories : Argument_List;
Name_Patterns : Regexp_List;
Excluded_Patterns : Regexp_List;
Foreign_Patterns : Regexp_List);
-- Look for source files in the specified directories, with the specified
-- patterns.
--
-- Directories is the list of source directories where to look for sources.
--
-- Name_Patterns is a potentially empty list of file name patterns to check
-- for Ada Sources.
--
-- Excluded_Patterns is a potentially empty list of file name patterns that
-- should not be checked for Ada or non Ada sources.
--
-- Foreign_Patterns is a potentially empty list of file name patterns to
-- check for non Ada sources.
--
-- At least one of Name_Patterns and Foreign_Patterns is not empty
--
-- Note that this procedure currently assumes that it is only used by
-- gnatname. If other processes start using it, then an additional
-- parameter would need to be added, and call to Osint.Program_Name
-- updated accordingly in the body.
procedure Finalize;
-- Write the configuration pragmas file or the project file indicated in a
-- call to procedure Initialize, after one or several calls to procedure
-- Process.
end Prj.Makr;
|
xeenta/learning-ada | Ada | 324 | adb | with A, B, Person;
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Pkg is
begin
Put_Line ("Test_Pkg: " & Integer'Image (Person.Unit_Age));
A.Print_Modify;
Put_Line ("Test_Pkg: " & Integer'Image (Person.Unit_Age));
B.Print_Modify;
Put_Line ("Test_Pkg: " & Integer'Image (Person.Unit_Age));
end Test_Pkg;
|
stcarrez/ada-awa | Ada | 7,504 | adb | -----------------------------------------------------------------------
-- awa-storages-servlets -- Serve files saved in the storage service
-- Copyright (C) 2012, 2016, 2019, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Util.Log.Loggers;
with ADO.Objects;
with Servlet.Routes;
with ASF.Streams;
with AWA.Storages.Services;
with AWA.Storages.Modules;
package body AWA.Storages.Servlets is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Storages.Servlets");
-- ------------------------------
-- Called by the servlet container to indicate to a servlet that the servlet
-- is being placed into service.
-- ------------------------------
overriding
procedure Initialize (Server : in out Storage_Servlet;
Context : in Servlet.Core.Servlet_Registry'Class) is
begin
null;
end Initialize;
-- ------------------------------
-- Called by the server (via the service method) to allow a servlet to handle
-- a GET request.
--
-- Overriding this method to support a GET request also automatically supports
-- an HTTP HEAD request. A HEAD request is a GET request that returns no body
-- in the response, only the request header fields.
--
-- When overriding this method, read the request data, write the response headers,
-- get the response's writer or output stream object, and finally, write the
-- response data. It's best to include content type and encoding.
-- When using a PrintWriter object to return the response, set the content type
-- before accessing the PrintWriter object.
--
-- The servlet container must write the headers before committing the response,
-- because in HTTP the headers must be sent before the response body.
--
-- Where possible, set the Content-Length header (with the
-- Response.Set_Content_Length method), to allow the servlet container
-- to use a persistent connection to return its response to the client,
-- improving performance. The content length is automatically set if the entire
-- response fits inside the response buffer.
--
-- When using HTTP 1.1 chunked encoding (which means that the response has a
-- Transfer-Encoding header), do not set the Content-Length header.
--
-- The GET method should be safe, that is, without any side effects for which
-- users are held responsible. For example, most form queries have no side effects.
-- If a client request is intended to change stored data, the request should use
-- some other HTTP method.
--
-- The GET method should also be idempotent, meaning that it can be safely repeated.
-- Sometimes making a method safe also makes it idempotent. For example, repeating
-- queries is both safe and idempotent, but buying a product online or modifying
-- data is neither safe nor idempotent.
--
-- If the request is incorrectly formatted, Do_Get returns an HTTP "Bad Request"
-- ------------------------------
overriding
procedure Do_Get (Server : in Storage_Servlet;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class) is
URI : constant String := Request.Get_Request_URI;
Data : ADO.Blob_Ref;
Mime : Ada.Strings.Unbounded.Unbounded_String;
Name : Ada.Strings.Unbounded.Unbounded_String;
Date : Ada.Calendar.Time;
Format : Get_Type;
begin
Format := Storage_Servlet'Class (Server).Get_Format (Request);
if Format = INVALID then
Log.Info ("GET: {0}: invalid format", URI);
Response.Send_Error (ASF.Responses.SC_NOT_FOUND);
return;
end if;
Storage_Servlet'Class (Server).Load (Request, Name, Mime, Date, Data);
if Data.Is_Null then
Log.Info ("GET: {0}: storage file not found", URI);
Response.Send_Error (ASF.Responses.SC_NOT_FOUND);
return;
end if;
Log.Info ("GET: {0}", URI);
-- Send the file.
Response.Set_Content_Type (Ada.Strings.Unbounded.To_String (Mime));
if Format = AS_CONTENT_DISPOSITION and then Ada.Strings.Unbounded.Length (Name) > 0 then
Response.Add_Header ("Content-Disposition",
"attachment; filename=" & Ada.Strings.Unbounded.To_String (Name));
end if;
declare
Output : ASF.Streams.Print_Stream := Response.Get_Output_Stream;
begin
Output.Write (Data.Value.Data);
end;
exception
when Servlet.Routes.No_Parameter =>
Log.Info ("GET: {0}: Invalid servlet-mapping, a path parameter is missing", URI);
Response.Send_Error (ASF.Responses.SC_NOT_FOUND);
return;
when ADO.Objects.NOT_FOUND | Constraint_Error =>
Log.Info ("GET: {0}: Storage file not found", URI);
Response.Send_Error (ASF.Responses.SC_NOT_FOUND);
return;
end Do_Get;
-- ------------------------------
-- Load the data content that correspond to the GET request and get the name as well
-- as mime-type and date.
-- ------------------------------
procedure Load (Server : in Storage_Servlet;
Request : in out ASF.Requests.Request'Class;
Name : out Ada.Strings.Unbounded.Unbounded_String;
Mime : out Ada.Strings.Unbounded.Unbounded_String;
Date : out Ada.Calendar.Time;
Data : out ADO.Blob_Ref) is
pragma Unreferenced (Server);
Store : constant String := Request.Get_Path_Parameter (1);
Manager : constant Services.Storage_Service_Access := Storages.Modules.Get_Storage_Manager;
Id : ADO.Identifier;
begin
if Store'Length = 0 then
Log.Info ("Invalid storage URI: {0}", Store);
return;
end if;
-- Extract the storage identifier from the URI.
Id := ADO.Identifier'Value (Store);
Log.Info ("GET storage file {0}", Store);
Manager.Load (From => Id, Name => Name, Mime => Mime, Date => Date, Into => Data);
end Load;
-- ------------------------------
-- Get the expected return mode (content disposition for download or inline).
-- ------------------------------
function Get_Format (Server : in Storage_Servlet;
Request : in ASF.Requests.Request'Class) return Get_Type is
pragma Unreferenced (Server);
Format : constant String := Request.Get_Path_Parameter (2);
begin
if Format = "view" then
return DEFAULT;
elsif Format = "download" then
return AS_CONTENT_DISPOSITION;
else
return INVALID;
end if;
end Get_Format;
end AWA.Storages.Servlets;
|
reznikmm/matreshka | Ada | 3,719 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 XML.DOM.Attributes;
package ODF.DOM.Draw_Start_Shape_Attributes is
pragma Preelaborate;
type ODF_Draw_Start_Shape_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Start_Shape_Attribute_Access is
access all ODF_Draw_Start_Shape_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Start_Shape_Attributes;
|
stcarrez/ada-wiki | Ada | 1,158 | ads | -----------------------------------------------------------------------
-- wiki-filters-html-tests -- Unit tests for wiki HTML filters
-- Copyright (C) 2015 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- 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.Tests;
package Wiki.Filters.Html.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
-- Test Find_Tag operation.
procedure Test_Find_Tag (T : in out Test);
end Wiki.Filters.Html.Tests;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 5,199 | adb | with STM32_SVD.GPIO; use STM32_SVD.GPIO;
with STM32_SVD.SCB; use STM32_SVD.SCB;
with STM32_SVD.RCC; use STM32_SVD.RCC;
with STM32_SVD.EXTI; use STM32_SVD.EXTI;
with STM32_SVD.NVIC; use STM32_SVD.NVIC;
with STM32_SVD.SYSCFG; use STM32_SVD.SYSCFG;
with STM32GD.GPIO.Port;
package body STM32GD.GPIO.Pin is
type Port_Periph_Access is access all GPIO_Peripheral;
function Index return Natural is begin return GPIO_Pin'Pos (Pin); end Index;
function Pin_Mask return UInt16 is begin return GPIO_Pin'Enum_Rep (Pin); end Pin_Mask;
function Port_Periph return Port_Periph_Access is begin
return (if Port = Port_A then STM32_SVD.GPIO.GPIOA_Periph'Access
elsif Port = Port_B then STM32_SVD.GPIO.GPIOB_Periph'Access
elsif Port = Port_C then STM32_SVD.GPIO.GPIOC_Periph'Access
elsif Port = Port_D then STM32_SVD.GPIO.GPIOD_Periph'Access
elsif Port = Port_E then STM32_SVD.GPIO.GPIOD_Periph'Access
else STM32_SVD.GPIO.GPIOH_Periph'Access); end Port_Periph;
procedure Enable is
begin
case Port is
when Port_A => RCC_Periph.IOPENR.IOPAEN := 1;
when Port_B => RCC_Periph.IOPENR.IOPBEN := 1;
when Port_C => RCC_Periph.IOPENR.IOPCEN := 1;
when Port_D => RCC_Periph.IOPENR.IOPDEN := 1;
when Port_E => RCC_Periph.IOPENR.IOPEEN := 1;
when Port_H => RCC_Periph.IOPENR.IOPHEN := 1;
end case;
end Enable;
procedure Disable is
begin
case Port is
when Port_A => RCC_Periph.IOPENR.IOPAEN := 0;
when Port_B => RCC_Periph.IOPENR.IOPBEN := 0;
when Port_C => RCC_Periph.IOPENR.IOPCEN := 0;
when Port_D => RCC_Periph.IOPENR.IOPDEN := 0;
when Port_E => RCC_Periph.IOPENR.IOPEEN := 0;
when Port_H => RCC_Periph.IOPENR.IOPHEN := 0;
end case;
end Disable;
procedure Init is
begin
if Mode /= Mode_In then
Set_Mode (Mode);
end if;
if Pull_Resistor /= Floating then
Set_Pull_Resistor (Pull_Resistor);
end if;
if Output_Type /= Push_Pull then
Set_Type (Output_Type);
end if;
if Alternate_Function /= 0 then
Configure_Alternate_Function (Alternate_Function);
end if;
end Init;
procedure Set_Mode (Mode : Pin_IO_Modes) is
begin
Port_Periph.MODER.Arr (Index) := Pin_IO_Modes'Enum_Rep (Mode);
end Set_Mode;
procedure Set_Type (Pin_Type : Pin_Output_Types) is
begin
Port_Periph.OTYPER.OT.Arr (Index) := Pin_Output_Types'Enum_Rep (Pin_Type);
end Set_Type;
function Get_Pull_Resistor return Internal_Pin_Resistors is
begin
if Port_Periph.PUPDR.Arr (Index) = 0 then
return Floating;
elsif Port_Periph.PUPDR.Arr (Index) = 1 then
return Pull_Up;
else
return Pull_Down;
end if;
end Get_Pull_Resistor;
procedure Set_Pull_Resistor (Pull : Internal_Pin_Resistors) is
begin
Port_Periph.PUPDR.Arr (Index) := Internal_Pin_Resistors'Enum_Rep (Pull);
end Set_Pull_Resistor;
function Is_Set return Boolean is
begin
return (Port_Periph.IDR.ID.Val and Pin_Mask) = Pin_Mask;
end Is_Set;
procedure Set is
begin
Port_Periph.BSRR.BS.Val := GPIO_Pin'Enum_Rep (Pin);
end Set;
procedure Clear is
begin
Port_Periph.BRR.BR.Val := GPIO_Pin'Enum_Rep (Pin);
end Clear;
procedure Toggle is
begin
Port_Periph.ODR.OD.Val := Port_Periph.ODR.OD.Val xor GPIO_Pin'Enum_Rep (Pin);
end Toggle;
procedure Configure_Alternate_Function (AF : GPIO_Alternate_Function) is
begin
if Index < 8 then
Port_Periph.AFRL.Arr (Index) := UInt4 (AF);
else
Port_Periph.AFRH.Arr (Index) := UInt4 (AF);
end if;
end Configure_Alternate_Function;
procedure Connect_External_Interrupt
is
Port_Id : constant UInt4 := GPIO_Port'Enum_Rep (Port);
begin
case Index is
when 0 .. 3 =>
SYSCFG_COMP_Periph.EXTICR1.EXTI.Arr (Index) := Port_Id;
when 4 .. 7 =>
SYSCFG_COMP_Periph.EXTICR2.EXTI.Arr (Index) := Port_Id;
when 8 .. 11 =>
SYSCFG_COMP_Periph.EXTICR3.EXTI.Arr (Index) := Port_Id;
when 12 .. 15 =>
SYSCFG_COMP_Periph.EXTICR4.EXTI.Arr (Index) := Port_Id;
when others =>
raise Program_Error;
end case;
end Connect_External_Interrupt;
procedure Wait_For_Trigger is
begin
loop
STM32GD.Wait_For_Event;
exit when Triggered;
end loop;
Clear_Trigger;
end Wait_For_Trigger;
procedure Clear_Trigger is
begin
EXTI_Periph.PR.PIF.Arr (Index) := 1;
NVIC_Periph.ICPR := 2 ** 5;
end Clear_Trigger;
function Triggered return Boolean is
begin
return EXTI_Periph.PR.PIF.Arr (Index) = 1;
end Triggered;
procedure Configure_Trigger (Rising : Boolean := False; Falling : Boolean := False) is
begin
Connect_External_Interrupt;
if Rising then
EXTI_Periph.RTSR.RT.Arr (Index) := 1;
end if;
if Falling then
EXTI_Periph.FTSR.FT.Arr (Index) := 1;
end if;
EXTI_Periph.EMR.EM.Arr (Index) := 1;
end Configure_Trigger;
end STM32GD.GPIO.Pin;
|
MinimSecure/unum-sdk | Ada | 801 | ads | -- Copyright 2008-2019 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with System;
package Pck is
procedure Do_Nothing (A : System.Address);
end Pck;
|
godunko/adawebui | Ada | 61 | adb |
with Cube_Demo;
procedure Cube is
begin
null;
end Cube;
|
AdaCore/training_material | Ada | 1,452 | ads | package Basics is
type Rec is record
A, B : Integer;
end record;
type Index is range 1 .. 10;
type Table is array (Index range <>) of Integer;
procedure Swap (X, Y : in out Integer)
with
Global => null,
Depends => (X => Y, Y => X);
The_Rec : Rec;
The_Table : Table (1 .. 10);
procedure Swap_Rec (R : in out Rec)
with
Global => null,
Depends => (R => +null);
procedure Swap_Table (T : in out Table; I, J : Index)
with
Global => null,
Depends => (T => +(I, J));
procedure Swap_The_Rec
with
Global => (In_Out => The_Rec),
Depends => (The_Rec => +null);
procedure Swap_The_Table (I, J : Index)
with
Global => (In_Out => The_Table),
Depends => (The_Table => +(I, J));
procedure Init_Rec (R : out Rec)
with
Global => null,
Depends => (R => null);
procedure Init_Table (T : out Table)
with
Global => null,
Depends => (T => +null);
procedure Init_The_Rec
with
Global => (Output => The_Rec),
Depends => (The_Rec => null);
procedure Init_The_Table
with
Global => (Output => The_Table),
Depends => (The_Table => null);
procedure Strange_Init_Rec (R : out Rec; Cond : Boolean)
with
Global => null,
Depends => (R => Cond);
procedure Strange_Init_Table (T : out Table; Val : Integer)
with
Global => null,
Depends => (T => +Val);
end Basics;
|
Fabien-Chouteau/GESTE | Ada | 5,474 | adb | with GESTE;
with GESTE.Tile_Bank;
with GESTE.Grid;
with GESTE_Config; use GESTE_Config;
with GESTE.Maths_Types; use GESTE.Maths_Types;
with GESTE.Physics;
with Game_Assets.Tileset;
with Game_Assets.character;
with Interfaces; use Interfaces;
package body Player is
Player_Sprite : aliased GESTE.Grid.Grid_Data :=
((0, 0, 0, 0),
(0, 0, 0, 0));
type Player_Type (Bank : not null GESTE.Tile_Bank.Const_Ref;
Init_Frame : GESTE_Config.Tile_Index)
is limited new GESTE.Physics.Object with record
Sprite : aliased GESTE.Grid.Instance
(Player_Sprite'Access,
Bank);
end record;
Tile_Bank : aliased GESTE.Tile_Bank.Instance
(Game_Assets.Tileset.Tiles'Access,
GESTE.No_Collisions,
Game_Assets.Palette'Access);
P : aliased Player_Type (Tile_Bank'Access, 3);
Move_Unit : constant := 1.0;
Going_Left : Boolean := False;
Going_Right : Boolean := False;
Going_Up : Boolean := False;
Going_Down : Boolean := False;
type Collision_Points is (BL, BR, TL, TR);
Collides : array (Collision_Points) of Boolean;
Offset : constant array (Collision_Points) of GESTE.Pix_Point
:= (BL => (-13, 7),
BR => (13, 7),
TL => (-13, -5),
TR => (13, -5));
procedure Update_Collisions;
-----------------------
-- Update_Collisions --
-----------------------
procedure Update_Collisions is
X : constant Integer := Integer (P.Position.X);
Y : constant Integer := Integer (P.Position.Y);
begin
for Pt in Collision_Points loop
Collides (Pt) := GESTE.Collides ((X + Offset (Pt).X,
Y + Offset (Pt).Y));
end loop;
end Update_Collisions;
----------
-- Move --
----------
procedure Move (Pt : GESTE.Pix_Point) is
begin
P.Set_Position ((Value (Pt.X), Value (Pt.Y)));
P.Sprite.Move ((Integer (P.Position.X) - 16,
Integer (P.Position.Y) - 50));
end Move;
--------------
-- Position --
--------------
function Position return GESTE.Pix_Point
is ((Integer (P.Position.X), Integer (P.Position.Y)));
------------
-- Update --
------------
procedure Update is
Old : Point := P.Position;
begin
if Going_Up then
P.Set_Position ((P.Position.X, P.Position.Y - Move_Unit));
elsif Going_Down then
P.Set_Position ((P.Position.X, P.Position.Y + Move_Unit));
end if;
Update_Collisions;
if Collides (BL)
or else
Collides (BR)
or else
Collides (TL)
or else
Collides (TR)
then
P.Set_Position (Old);
end if;
Old := P.Position;
if Going_Right then
P.Set_Position ((P.Position.X + Move_Unit, P.Position.Y));
elsif Going_Left then
P.Set_Position ((P.Position.X - Move_Unit, P.Position.Y));
end if;
Update_Collisions;
if Collides (BL)
or else
Collides (BR)
or else
Collides (TL)
or else
Collides (TR)
then
P.Set_Position (Old);
end if;
if Going_Up then
case Unsigned_32 (abs P.Position.Y) mod 16 is
when 0 .. 3 => Player_Sprite := Game_Assets.character.Up1.Data;
when 4 .. 5 | 12 .. 15 => Player_Sprite := Game_Assets.character.Up2.Data;
when others => Player_Sprite := Game_Assets.character.Up3.Data;
end case;
elsif Going_Down then
case Unsigned_32 (abs P.Position.Y) mod 16 is
when 0 .. 3 => Player_Sprite := Game_Assets.character.Down1.Data;
when 4 .. 5 | 12 .. 15 => Player_Sprite := Game_Assets.character.Down2.Data;
when others => Player_Sprite := Game_Assets.character.Down3.Data;
end case;
elsif Going_Left then
case Unsigned_32 (abs P.Position.X) mod 16 is
when 0 .. 3 => Player_Sprite := Game_Assets.character.Left1.Data;
when 4 .. 5 | 12 .. 15 => Player_Sprite := Game_Assets.character.Left2.Data;
when others => Player_Sprite := Game_Assets.character.Left3.Data;
end case;
elsif Going_Right then
case Unsigned_32 (abs P.Position.X) mod 16 is
when 0 .. 3 => Player_Sprite := Game_Assets.character.Right1.Data;
when 4 .. 5 | 12 .. 15 => Player_Sprite := Game_Assets.character.Right2.Data;
when others => Player_Sprite := Game_Assets.character.Right3.Data;
end case;
end if;
P.Sprite.Move ((Integer (P.Position.X) - 16,
Integer (P.Position.Y) - 50));
Going_Left := False;
Going_Right := False;
Going_Up := False;
Going_Down := False;
end Update;
---------------
-- Move_Left --
---------------
procedure Move_Left is
begin
Going_Left := True;
end Move_Left;
----------------
-- Move_Right --
----------------
procedure Move_Right is
begin
Going_Right := True;
end Move_Right;
-------------
-- Move_Up --
-------------
procedure Move_Up is
begin
Going_Up := True;
end Move_Up;
----------------
-- Move_Down --
----------------
procedure Move_Down is
begin
Going_Down := True;
end Move_Down;
begin
Player_Sprite := Game_Assets.character.Up1.Data;
GESTE.Add (P.Sprite'Access, 4);
end Player;
|
Heziode/lsystem-editor | Ada | 1,685 | ads | -------------------------------------------------------------------------------
-- LSE -- L-System Editor
-- Author: Heziode
--
-- License:
-- MIT License
--
-- Copyright (c) 2018 Quentin Dauprat (Heziode) <[email protected]>
--
-- Permission is hereby granted, free of charge, to any person obtaining a
-- copy of this software and associated documentation files (the "Software"),
-- to deal in the Software without restriction, including without limitation
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons to whom the
-- Software is furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-- DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
with Ada.Containers.Indefinite_Vectors;
with LSE.Utils.Coordinate_2D_Ptr;
use LSE.Utils.Coordinate_2D_Ptr;
-- @description
-- This package provide a list of 2D coordinate.
--
package LSE.Utils.Coordinate_2D_List is
new Ada.Containers.Indefinite_Vectors (Natural, Holder);
|
Martin-Molinero/coinapi-sdk | Ada | 34,512 | adb | -- OEML _ REST API
-- This section will provide necessary information about the `CoinAPI OEML REST API` protocol. This API is also available in the Postman application: <a href=\"https://postman.coinapi.io/\" target=\"_blank\">https://postman.coinapi.io/</a>
--
-- The version of the OpenAPI document: v1
-- Contact: [email protected]
--
-- NOTE: This package is auto generated by OpenAPI-Generator 5.1.1.
-- https://openapi-generator.tech
-- Do not edit the class manually.
package body .Models is
pragma Style_Checks ("-mr");
pragma Warnings (Off, "*use clause for package*");
use Swagger.Streams;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Severity_Type) is
begin
Into.Start_Entity (Name);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Severity_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Severity_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Severity_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : Severity_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Message_Type) is
begin
Into.Start_Entity (Name);
Into.Write_Entity ("type", Value.P_Type);
Serialize (Into, "severity", Value.Severity);
Into.Write_Entity ("exchange_id", Value.Exchange_Id);
Into.Write_Entity ("message", Value.Message);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Message_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Message_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "type", Value.P_Type);
Deserialize (Object, "severity", Value.Severity);
Swagger.Streams.Deserialize (Object, "exchange_id", Value.Exchange_Id);
Swagger.Streams.Deserialize (Object, "message", Value.Message);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Message_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : Message_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in ValidationError_Type) is
begin
Into.Start_Entity (Name);
Into.Write_Entity ("type", Value.P_Type);
Into.Write_Entity ("title", Value.Title);
Serialize (Into, "status", Value.Status);
Into.Write_Entity ("traceId", Value.Trace_Id);
Into.Write_Entity ("errors", Value.Errors);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in ValidationError_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out ValidationError_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "type", Value.P_Type);
Swagger.Streams.Deserialize (Object, "title", Value.Title);
Swagger.Streams.Deserialize (Object, "status", Value.Status);
Swagger.Streams.Deserialize (Object, "traceId", Value.Trace_Id);
Swagger.Streams.Deserialize (Object, "errors", Value.Errors);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out ValidationError_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : ValidationError_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrdType_Type) is
begin
Into.Start_Entity (Name);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrdType_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrdType_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrdType_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : OrdType_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrdStatus_Type) is
begin
Into.Start_Entity (Name);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrdStatus_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrdStatus_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrdStatus_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : OrdStatus_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderCancelAllRequest_Type) is
begin
Into.Start_Entity (Name);
Into.Write_Entity ("exchange_id", Value.Exchange_Id);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderCancelAllRequest_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderCancelAllRequest_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "exchange_id", Value.Exchange_Id);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderCancelAllRequest_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : OrderCancelAllRequest_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderCancelSingleRequest_Type) is
begin
Into.Start_Entity (Name);
Into.Write_Entity ("exchange_id", Value.Exchange_Id);
Into.Write_Entity ("exchange_order_id", Value.Exchange_Order_Id);
Into.Write_Entity ("client_order_id", Value.Client_Order_Id);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderCancelSingleRequest_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderCancelSingleRequest_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "exchange_id", Value.Exchange_Id);
Swagger.Streams.Deserialize (Object, "exchange_order_id", Value.Exchange_Order_Id);
Swagger.Streams.Deserialize (Object, "client_order_id", Value.Client_Order_Id);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderCancelSingleRequest_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : OrderCancelSingleRequest_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrdSide_Type) is
begin
Into.Start_Entity (Name);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrdSide_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrdSide_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrdSide_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : OrdSide_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in TimeInForce_Type) is
begin
Into.Start_Entity (Name);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in TimeInForce_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out TimeInForce_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out TimeInForce_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : TimeInForce_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderNewSingleRequest_Type) is
begin
Into.Start_Entity (Name);
Into.Write_Entity ("exchange_id", Value.Exchange_Id);
Into.Write_Entity ("client_order_id", Value.Client_Order_Id);
Into.Write_Entity ("symbol_id_exchange", Value.Symbol_Id_Exchange);
Into.Write_Entity ("symbol_id_coinapi", Value.Symbol_Id_Coinapi);
Serialize (Into, "amount_order", Value.Amount_Order);
Serialize (Into, "price", Value.Price);
Serialize (Into, "side", Value.Side);
Serialize (Into, "order_type", Value.Order_Type);
Serialize (Into, "time_in_force", Value.Time_In_Force);
Serialize (Into, "expire_time", Value.Expire_Time);
Serialize (Into, "exec_inst", Value.Exec_Inst);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderNewSingleRequest_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderNewSingleRequest_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "exchange_id", Value.Exchange_Id);
Swagger.Streams.Deserialize (Object, "client_order_id", Value.Client_Order_Id);
Swagger.Streams.Deserialize (Object, "symbol_id_exchange", Value.Symbol_Id_Exchange);
Swagger.Streams.Deserialize (Object, "symbol_id_coinapi", Value.Symbol_Id_Coinapi);
Swagger.Streams.Deserialize (Object, "amount_order", Value.Amount_Order);
Swagger.Streams.Deserialize (Object, "price", Value.Price);
Deserialize (Object, "side", Value.Side);
Deserialize (Object, "order_type", Value.Order_Type);
Deserialize (Object, "time_in_force", Value.Time_In_Force);
Swagger.Streams.Deserialize (Object, "expire_time", Value.Expire_Time);
Swagger.Streams.Deserialize (Object, "exec_inst", Value.Exec_Inst);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderNewSingleRequest_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : OrderNewSingleRequest_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Fills_Type) is
begin
Into.Start_Entity (Name);
Serialize (Into, "time", Value.Time);
Serialize (Into, "price", Value.Price);
Serialize (Into, "amount", Value.Amount);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Fills_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Fills_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "time", Value.Time);
Swagger.Streams.Deserialize (Object, "price", Value.Price);
Swagger.Streams.Deserialize (Object, "amount", Value.Amount);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Fills_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : Fills_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderExecutionReport_Type) is
begin
Into.Start_Entity (Name);
Into.Write_Entity ("exchange_id", Value.Exchange_Id);
Into.Write_Entity ("client_order_id", Value.Client_Order_Id);
Into.Write_Entity ("symbol_id_exchange", Value.Symbol_Id_Exchange);
Into.Write_Entity ("symbol_id_coinapi", Value.Symbol_Id_Coinapi);
Serialize (Into, "amount_order", Value.Amount_Order);
Serialize (Into, "price", Value.Price);
Serialize (Into, "side", Value.Side);
Serialize (Into, "order_type", Value.Order_Type);
Serialize (Into, "time_in_force", Value.Time_In_Force);
Serialize (Into, "expire_time", Value.Expire_Time);
Serialize (Into, "exec_inst", Value.Exec_Inst);
Into.Write_Entity ("client_order_id_format_exchange", Value.Client_Order_Id_Format_Exchange);
Into.Write_Entity ("exchange_order_id", Value.Exchange_Order_Id);
Serialize (Into, "amount_open", Value.Amount_Open);
Serialize (Into, "amount_filled", Value.Amount_Filled);
Serialize (Into, "avg_px", Value.Avg_Px);
Serialize (Into, "status", Value.Status);
Serialize (Into, "status_history", Value.Status_History);
Into.Write_Entity ("error_message", Value.Error_Message);
Serialize (Into, "fills", Value.Fills);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderExecutionReport_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderExecutionReport_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "exchange_id", Value.Exchange_Id);
Swagger.Streams.Deserialize (Object, "client_order_id", Value.Client_Order_Id);
Swagger.Streams.Deserialize (Object, "symbol_id_exchange", Value.Symbol_Id_Exchange);
Swagger.Streams.Deserialize (Object, "symbol_id_coinapi", Value.Symbol_Id_Coinapi);
Swagger.Streams.Deserialize (Object, "amount_order", Value.Amount_Order);
Swagger.Streams.Deserialize (Object, "price", Value.Price);
Deserialize (Object, "side", Value.Side);
Deserialize (Object, "order_type", Value.Order_Type);
Deserialize (Object, "time_in_force", Value.Time_In_Force);
Swagger.Streams.Deserialize (Object, "expire_time", Value.Expire_Time);
Swagger.Streams.Deserialize (Object, "exec_inst", Value.Exec_Inst);
Swagger.Streams.Deserialize (Object, "client_order_id_format_exchange", Value.Client_Order_Id_Format_Exchange);
Swagger.Streams.Deserialize (Object, "exchange_order_id", Value.Exchange_Order_Id);
Swagger.Streams.Deserialize (Object, "amount_open", Value.Amount_Open);
Swagger.Streams.Deserialize (Object, "amount_filled", Value.Amount_Filled);
Swagger.Streams.Deserialize (Object, "avg_px", Value.Avg_Px);
Deserialize (Object, "status", Value.Status);
Swagger.Streams.Deserialize (Object, "status_history", Value.Status_History);
Swagger.Streams.Deserialize (Object, "error_message", Value.Error_Message);
Deserialize (Object, "fills", Value.Fills);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderExecutionReport_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : OrderExecutionReport_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderExecutionReportAllOf_Type) is
begin
Into.Start_Entity (Name);
Into.Write_Entity ("client_order_id_format_exchange", Value.Client_Order_Id_Format_Exchange);
Into.Write_Entity ("exchange_order_id", Value.Exchange_Order_Id);
Serialize (Into, "amount_open", Value.Amount_Open);
Serialize (Into, "amount_filled", Value.Amount_Filled);
Serialize (Into, "avg_px", Value.Avg_Px);
Serialize (Into, "status", Value.Status);
Serialize (Into, "status_history", Value.Status_History);
Into.Write_Entity ("error_message", Value.Error_Message);
Serialize (Into, "fills", Value.Fills);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderExecutionReportAllOf_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderExecutionReportAllOf_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "client_order_id_format_exchange", Value.Client_Order_Id_Format_Exchange);
Swagger.Streams.Deserialize (Object, "exchange_order_id", Value.Exchange_Order_Id);
Swagger.Streams.Deserialize (Object, "amount_open", Value.Amount_Open);
Swagger.Streams.Deserialize (Object, "amount_filled", Value.Amount_Filled);
Swagger.Streams.Deserialize (Object, "avg_px", Value.Avg_Px);
Deserialize (Object, "status", Value.Status);
Swagger.Streams.Deserialize (Object, "status_history", Value.Status_History);
Swagger.Streams.Deserialize (Object, "error_message", Value.Error_Message);
Deserialize (Object, "fills", Value.Fills);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderExecutionReportAllOf_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : OrderExecutionReportAllOf_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in BalanceData_Type) is
begin
Into.Start_Entity (Name);
Into.Write_Entity ("asset_id_exchange", Value.Asset_Id_Exchange);
Into.Write_Entity ("asset_id_coinapi", Value.Asset_Id_Coinapi);
Serialize (Into, "balance", Value.Balance);
Serialize (Into, "available", Value.Available);
Serialize (Into, "locked", Value.Locked);
Into.Write_Entity ("last_updated_by", Value.Last_Updated_By);
Serialize (Into, "rate_usd", Value.Rate_Usd);
Serialize (Into, "traded", Value.Traded);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in BalanceData_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out BalanceData_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "asset_id_exchange", Value.Asset_Id_Exchange);
Swagger.Streams.Deserialize (Object, "asset_id_coinapi", Value.Asset_Id_Coinapi);
Swagger.Streams.Deserialize (Object, "balance", Value.Balance);
Swagger.Streams.Deserialize (Object, "available", Value.Available);
Swagger.Streams.Deserialize (Object, "locked", Value.Locked);
Swagger.Streams.Deserialize (Object, "last_updated_by", Value.Last_Updated_By);
Swagger.Streams.Deserialize (Object, "rate_usd", Value.Rate_Usd);
Swagger.Streams.Deserialize (Object, "traded", Value.Traded);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out BalanceData_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : BalanceData_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Balance_Type) is
begin
Into.Start_Entity (Name);
Into.Write_Entity ("exchange_id", Value.Exchange_Id);
Serialize (Into, "data", Value.Data);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Balance_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Balance_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "exchange_id", Value.Exchange_Id);
Deserialize (Object, "data", Value.Data);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Balance_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : Balance_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Position_Type) is
begin
Into.Start_Entity (Name);
Into.Write_Entity ("exchange_id", Value.Exchange_Id);
Serialize (Into, "data", Value.Data);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Position_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Position_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "exchange_id", Value.Exchange_Id);
Deserialize (Object, "data", Value.Data);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Position_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : Position_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in PositionData_Type) is
begin
Into.Start_Entity (Name);
Into.Write_Entity ("symbol_id_exchange", Value.Symbol_Id_Exchange);
Into.Write_Entity ("symbol_id_coinapi", Value.Symbol_Id_Coinapi);
Serialize (Into, "avg_entry_price", Value.Avg_Entry_Price);
Serialize (Into, "quantity", Value.Quantity);
Serialize (Into, "side", Value.Side);
Serialize (Into, "unrealized_pnl", Value.Unrealized_Pnl);
Serialize (Into, "leverage", Value.Leverage);
Into.Write_Entity ("cross_margin", Value.Cross_Margin);
Serialize (Into, "liquidation_price", Value.Liquidation_Price);
Into.Write_Entity ("raw_data", Value.Raw_Data);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in PositionData_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out PositionData_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "symbol_id_exchange", Value.Symbol_Id_Exchange);
Swagger.Streams.Deserialize (Object, "symbol_id_coinapi", Value.Symbol_Id_Coinapi);
Swagger.Streams.Deserialize (Object, "avg_entry_price", Value.Avg_Entry_Price);
Swagger.Streams.Deserialize (Object, "quantity", Value.Quantity);
Deserialize (Object, "side", Value.Side);
Swagger.Streams.Deserialize (Object, "unrealized_pnl", Value.Unrealized_Pnl);
Swagger.Streams.Deserialize (Object, "leverage", Value.Leverage);
Swagger.Streams.Deserialize (Object, "cross_margin", Value.Cross_Margin);
Swagger.Streams.Deserialize (Object, "liquidation_price", Value.Liquidation_Price);
Deserialize (Object, "raw_data", Value.Raw_Data);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out PositionData_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : PositionData_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
end .Models;
|
Rodeo-McCabe/orka | Ada | 5,130 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <[email protected]>
--
-- 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.Calendar.Formatting;
with Ada.Characters.Latin_1;
with Ada.Real_Time;
with Ada.Strings.Fixed;
with Ada.Text_IO;
with Orka.Strings;
package body Orka.Terminals is
Style_Codes : constant array (Style) of Natural :=
(Default => 0,
Bold => 1,
Dark => 2,
Italic => 3,
Underline => 4,
Blink => 5,
Reversed => 7,
Cross_Out => 9);
Foreground_Color_Codes : constant array (Color) of Natural :=
(Default => 0,
Grey => 30,
Red => 31,
Green => 32,
Yellow => 33,
Blue => 34,
Magenta => 35,
Cyan => 36,
White => 37);
Background_Color_Codes : constant array (Color) of Natural :=
(Default => 0,
Grey => 40,
Red => 41,
Green => 42,
Yellow => 43,
Blue => 44,
Magenta => 45,
Cyan => 46,
White => 47);
package L renames Ada.Characters.Latin_1;
package SF renames Ada.Strings.Fixed;
Reset : constant String := L.ESC & "[0m";
function Sequence (Code : Natural) return String is
Image : constant String := SF.Trim (Code'Image, Ada.Strings.Both);
begin
return (if Code /= 0 then L.ESC & "[" & Image & "m" else "");
end Sequence;
function Colorize (Text : String; Foreground, Background : Color := Default;
Attribute : Style := Default) return String is
FG : constant String := Sequence (Foreground_Color_Codes (Foreground));
BG : constant String := Sequence (Background_Color_Codes (Background));
ST : constant String := Sequence (Style_Codes (Attribute));
begin
return Reset & FG & BG & ST & Text & Reset;
end Colorize;
-----------------------------------------------------------------------------
Time_Zero : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
Days_Since_Zero : Natural := 0;
function Time_Image return String is
use Ada.Real_Time;
use Ada.Calendar.Formatting;
Hour : Hour_Number;
Minute : Minute_Number;
Second : Second_Number;
Sub_Second : Second_Duration;
Seconds_Since_Zero : Duration := To_Duration (Clock - Time_Zero);
begin
if Seconds_Since_Zero > Ada.Calendar.Day_Duration'Last then
Seconds_Since_Zero := Seconds_Since_Zero - Ada.Calendar.Day_Duration'Last;
Days_Since_Zero := Days_Since_Zero + 1;
end if;
Split (Seconds_Since_Zero, Hour, Minute, Second, Sub_Second);
declare
-- Remove first character (space) from ' hhmmss' image and then pad it to six digits
Image1 : constant String := Natural'Image
((Days_Since_Zero * 24 + Hour) * 1e4 + Minute * 1e2 + Second);
Image2 : constant String := SF.Tail (Image1 (2 .. Image1'Last), 6, '0');
-- Insert ':' characters to get 'hh:mm:ss'
Image3 : constant String := SF.Insert (Image2, 5, ":");
Image4 : constant String := SF.Insert (Image3, 3, ":");
-- Take image without first character (space) and then pad it to six digits
Image5 : constant String := Natural'Image (Natural (Sub_Second * 1e6));
Image6 : constant String := SF.Tail (Image5 (2 .. Image5'Last), 6, '0');
begin
return Image4 & "." & Image6;
end;
end Time_Image;
package Duration_IO is new Ada.Text_IO.Fixed_IO (Duration);
type String_Access is not null access String;
Suffices : constant array (1 .. 3) of String_Access
:= (new String'("s"),
new String'("ms"),
new String'("us"));
Last_Suffix : constant String_Access := Suffices (Suffices'Last);
function Image (Value : Duration) return String is
Result : String := "-9999.999";
Number : Duration := Value;
Suffix : String_Access := Suffices (Suffices'First);
begin
for S of Suffices loop
Suffix := S;
exit when Number >= 1.0 or else Number <= -1.0 or else S = Last_Suffix;
Number := Number * 1e3;
end loop;
begin
Duration_IO.Put (Result, Item => Number, Aft => 3);
exception
when others =>
return Number'Image & " " & Suffix.all;
end;
return Result & " " & Suffix.all;
end Image;
function Trim (Value : String) return String renames Orka.Strings.Trim;
function Strip_Line_Term (Value : String) return String renames Orka.Strings.Strip_Line_Term;
end Orka.Terminals;
|
zhmu/ananas | Ada | 6,246 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 5 9 --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.Storage_Elements;
with System.Unsigned_Types;
package body System.Pack_59 is
subtype Bit_Order is System.Bit_Order;
Reverse_Bit_Order : constant Bit_Order :=
Bit_Order'Val (1 - Bit_Order'Pos (System.Default_Bit_Order));
subtype Ofs is System.Storage_Elements.Storage_Offset;
subtype Uns is System.Unsigned_Types.Unsigned;
subtype N07 is System.Unsigned_Types.Unsigned range 0 .. 7;
use type System.Storage_Elements.Storage_Offset;
use type System.Unsigned_Types.Unsigned;
type Cluster is record
E0, E1, E2, E3, E4, E5, E6, E7 : Bits_59;
end record;
for Cluster use record
E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1;
E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1;
E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1;
E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1;
E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1;
E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1;
E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1;
E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1;
end record;
for Cluster'Size use Bits * 8;
for Cluster'Alignment use Integer'Min (Standard'Maximum_Alignment,
1 +
1 * Boolean'Pos (Bits mod 2 = 0) +
2 * Boolean'Pos (Bits mod 4 = 0));
-- Use maximum possible alignment, given the bit field size, since this
-- will result in the most efficient code possible for the field.
type Cluster_Ref is access Cluster;
type Rev_Cluster is new Cluster
with Bit_Order => Reverse_Bit_Order,
Scalar_Storage_Order => Reverse_Bit_Order;
type Rev_Cluster_Ref is access Rev_Cluster;
------------
-- Get_59 --
------------
function Get_59
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_59
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : Cluster_Ref with Address => A'Address, Import;
RC : Rev_Cluster_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => return RC.E0;
when 1 => return RC.E1;
when 2 => return RC.E2;
when 3 => return RC.E3;
when 4 => return RC.E4;
when 5 => return RC.E5;
when 6 => return RC.E6;
when 7 => return RC.E7;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => return C.E0;
when 1 => return C.E1;
when 2 => return C.E2;
when 3 => return C.E3;
when 4 => return C.E4;
when 5 => return C.E5;
when 6 => return C.E6;
when 7 => return C.E7;
end case;
end if;
end Get_59;
------------
-- Set_59 --
------------
procedure Set_59
(Arr : System.Address;
N : Natural;
E : Bits_59;
Rev_SSO : Boolean)
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : Cluster_Ref with Address => A'Address, Import;
RC : Rev_Cluster_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => RC.E0 := E;
when 1 => RC.E1 := E;
when 2 => RC.E2 := E;
when 3 => RC.E3 := E;
when 4 => RC.E4 := E;
when 5 => RC.E5 := E;
when 6 => RC.E6 := E;
when 7 => RC.E7 := E;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => C.E0 := E;
when 1 => C.E1 := E;
when 2 => C.E2 := E;
when 3 => C.E3 := E;
when 4 => C.E4 := E;
when 5 => C.E5 := E;
when 6 => C.E6 := E;
when 7 => C.E7 := E;
end case;
end if;
end Set_59;
end System.Pack_59;
|
reznikmm/matreshka | Ada | 3,719 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 XML.DOM.Elements;
package ODF.DOM.Presentation_Footer_Decl_Elements is
pragma Preelaborate;
type ODF_Presentation_Footer_Decl is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Presentation_Footer_Decl_Access is
access all ODF_Presentation_Footer_Decl'Class
with Storage_Size => 0;
end ODF.DOM.Presentation_Footer_Decl_Elements;
|
reznikmm/matreshka | Ada | 3,729 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 XML.DOM.Attributes;
package ODF.DOM.Text_Current_Value_Attributes is
pragma Preelaborate;
type ODF_Text_Current_Value_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Text_Current_Value_Attribute_Access is
access all ODF_Text_Current_Value_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Text_Current_Value_Attributes;
|
AdaCore/gpr | Ada | 28 | ads | package Lpck2 is
end Lpck2;
|
Gabriel-Degret/adalib | Ada | 6,731 | ads | -- Standard Ada library specification
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
with Ada.Iterator_Interfaces;
generic
type Key_Type is private;
type Element_Type is private;
with function "<" (Left, Right : Key_Type) return Boolean is <>;
with function "=" (Left, Right : Element_Type) return Boolean is <>;
package Ada.Containers.Bounded_Ordered_Maps is
pragma Pure(Bounded_Ordered_Maps);
pragma Remote_Types(Bounded_Ordered_Maps);
function Equivalent_Keys (Left, Right : Key_Type) return Boolean;
type Map (Capacity : Count_Type) is tagged private
with Constant_Indexing => Constant_Reference,
Variable_Indexing => Reference,
Default_Iterator => Iterate,
Iterator_Element => Element_Type;
pragma Preelaborable_Initialization(Map);
type Cursor is private;
pragma Preelaborable_Initialization(Cursor);
Empty_Map : constant Map;
No_Element : constant Cursor;
function Has_Element (Position : Cursor) return Boolean;
package Map_Iterator_Interfaces is new
Ada.Iterator_Interfaces (Cursor, Has_Element);
function "=" (Left, Right : Map) return Boolean;
function Length (Container : Map) return Count_Type;
function Is_Empty (Container : Map) return Boolean;
procedure Clear (Container : in out Map);
function Key (Position : Cursor) return Key_Type;
function Element (Position : Cursor) return Element_Type;
procedure Replace_Element (Container : in out Map;
Position : in Cursor;
New_Item : in Element_Type);
procedure Query_Element
(Position : in Cursor;
Process : not null access procedure (Key : in Key_Type;
Element : in Element_Type));
procedure Update_Element
(Container : in out Map;
Position : in Cursor;
Process : not null access procedure
(Key : in Key_Type;
Element : in out Element_Type));
type Constant_Reference_Type
(Element : not null access constant Element_Type) is private
with Implicit_Dereference => Element;
type Reference_Type (Element : not null access Element_Type) is private
with Implicit_Dereference => Element;
function Constant_Reference (Container : aliased in Map;
Position : in Cursor)
return Constant_Reference_Type;
function Reference (Container : aliased in out Map;
Position : in Cursor)
return Reference_Type;
function Constant_Reference (Container : aliased in Map;
Key : in Key_Type)
return Constant_Reference_Type;
function Reference (Container : aliased in out Map;
Key : in Key_Type)
return Reference_Type;
procedure Assign (Target : in out Map; Source : in Map);
function Copy (Source : Map;
Capacity : Count_Type := 0) return Map;
procedure Move (Target : in out Map;
Source : in out Map);
procedure Insert (Container : in out Map;
Key : in Key_Type;
New_Item : in Element_Type;
Position : out Cursor;
Inserted : out Boolean);
procedure Insert (Container : in out Map;
Key : in Key_Type;
Position : out Cursor;
Inserted : out Boolean);
procedure Insert (Container : in out Map;
Key : in Key_Type;
New_Item : in Element_Type);
procedure Include (Container : in out Map;
Key : in Key_Type;
New_Item : in Element_Type);
procedure Replace (Container : in out Map;
Key : in Key_Type;
New_Item : in Element_Type);
procedure Exclude (Container : in out Map;
Key : in Key_Type);
procedure Delete (Container : in out Map;
Key : in Key_Type);
procedure Delete (Container : in out Map;
Position : in out Cursor);
procedure Delete_First (Container : in out Map);
procedure Delete_Last (Container : in out Map);
function First (Container : Map) return Cursor;
function First_Element (Container : Map) return Element_Type;
function First_Key (Container : Map) return Key_Type;
function Last (Container : Map) return Cursor;
function Last_Element (Container : Map) return Element_Type;
function Last_Key (Container : Map) return Key_Type;
function Next (Position : Cursor) return Cursor;
procedure Next (Position : in out Cursor);
function Previous (Position : Cursor) return Cursor;
procedure Previous (Position : in out Cursor);
function Find (Container : Map;
Key : Key_Type) return Cursor;
function Element (Container : Map;
Key : Key_Type) return Element_Type;
function Floor (Container : Map;
Key : Key_Type) return Cursor;
function Ceiling (Container : Map;
Key : Key_Type) return Cursor;
function Contains (Container : Map;
Key : Key_Type) return Boolean;
function "<" (Left, Right : Cursor) return Boolean;
function ">" (Left, Right : Cursor) return Boolean;
function "<" (Left : Cursor; Right : Key_Type) return Boolean;
function ">" (Left : Cursor; Right : Key_Type) return Boolean;
function "<" (Left : Key_Type; Right : Cursor) return Boolean;
function ">" (Left : Key_Type; Right : Cursor) return Boolean;
procedure Iterate
(Container : in Map;
Process : not null access procedure (Position : in Cursor));
procedure Reverse_Iterate
(Container : in Map;
Process : not null access procedure (Position : in Cursor));
function Iterate (Container : in Map)
return Map_Iterator_Interfaces.Reversible_Iterator'Class;
function Iterate (Container : in Map; Start : in Cursor)
return Map_Iterator_Interfaces.Reversible_Iterator'Class;
private
-- not specified by the language
end Ada.Containers.Bounded_Ordered_Maps;
|
tum-ei-rcs/StratoX | Ada | 18,146 | adb |
with Units; use Units;
with Fletcher16;
with HIL; use HIL;
with HIL.Config; use HIL.Config;
with HIL.Devices;
with Interfaces; use Interfaces;
--with Bounded_Image; use Bounded_Image;
with Logger;
with ublox8.Protocol; use ublox8.Protocol;
with Ada.Real_Time; use Ada.Real_Time;
package body ublox8.Driver with
SPARK_Mode,
Refined_State => (State => (G_GPS_Message, last_msg_time))
is
package Fletcher16_Byte is new Fletcher16 (Index_Type => Natural,
Element_Type => Byte,
Array_Type => Byte_Array);
G_heading : constant Heading_Type := NORTH;
last_msg_time : Ada.Real_Time.Time := Ada.Real_Time.Time_Last;
G_GPS_Message : GPS_Message_Type :=
( itow => 0,
datetime => (year => Year_Type'First,
mon => Month_Type'First,
day => Day_Of_Month_Type'First,
hour => Hour_Type'First,
min => Minute_Type'First,
sec => Second_Type'First
),
fix => NO_FIX,
sats => 0,
lon => 0.0 * Degree,
lat => 0.0 * Degree,
alt => 0.0 * Meter,
vacc => 100.0 * Meter,
speed => 0.0 * Meter / Second );
UBLOX_M8N : constant HIL.UART.Device_ID_Type := HIL.Devices.GPS;
procedure reset is
begin
null;
end reset;
procedure waitForSync(isReceived : out Boolean) is
sync : Byte_Array (1 .. 2) := (others => Byte( 0 ));
start : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
now : Ada.Real_Time.Time := Ada.Real_Time.Clock;
timeout : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Microseconds( 100 );
n_read : Natural := 0;
begin
while now < start + timeout and then (n_read = 0 or sync(1) /= UBX_SYNC1) loop
HIL.UART.read(UBLOX_M8N, sync(1 .. 1), n_read);
now := Ada.Real_Time.Clock;
end loop;
HIL.UART.read(UBLOX_M8N, sync(2 .. 2), n_read);
if n_read > 0 and sync(1) = UBX_SYNC1 and sync(2) = UBX_SYNC2 then
isReceived := True;
else
isReceived := False;
end if;
end waitForSync;
procedure waitForAck(isReceived : out Boolean) is
head : Byte_Array (3 .. 6) := (others => Byte( 0 ));
n_read : Natural;
begin
waitForSync(isReceived);
if isReceived then
HIL.UART.read(UBLOX_M8N, head, n_read);
if n_read = head'Length then
if head(3) = UBX_CLASS_ACK and head(4) = UBX_ID_ACK_ACK and head(5) = UBX_LENGTH_ACK_ACK then
Logger.log_console(Logger.DEBUG, "UBX Ack");
elsif head(3) = UBX_CLASS_ACK and head(4) = UBX_ID_ACK_NAK and head(5) = UBX_LENGTH_ACK_ACK then
Logger.log_console(Logger.DEBUG, "UBX NAK");
isReceived := False;
end if;
end if;
end if;
end waitForAck;
procedure writeToDevice(header: UBX_Header_Array; data : Data_Type)
with Pre => data'Length <= Natural'Last - 4 - header'Length;
procedure writeToDevice(header: UBX_Header_Array; data : Data_Type) is
cks : constant Fletcher16_Byte.Checksum_Type := Fletcher16_Byte.Checksum( header(3 .. 6) & data );
check : constant UBX_Checksum_Array := (1 => cks.ck_a, 2 => cks.ck_b);
isReceived : Boolean := False;
retries : Natural := 1;
now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
begin
while isReceived = False and retries > 0 loop
HIL.UART.write(UBLOX_M8N, header & data & check);
delay until now + Milliseconds(2);
waitForAck(isReceived);
retries := retries - 1;
end loop;
if retries = 0 then
Logger.log_console(Logger.DEBUG, "UBX write Timeout");
end if;
end writeToDevice;
subtype UBX_Data is Data_Type (0 .. 91);
type Buffer_Wrap_Idx is mod HIL.UART.BUFFER_MAX;
procedure readFromDevice(data : out UBX_Data; isValid : out Boolean);
-- FIXME: this is unsynchronized. It reads as much as it can, and then tries to find one message
-- if no message, then it discards all. If message found, then remainder is also discarded
procedure readFromDevice(data : out UBX_Data; isValid : out Boolean) is
ubxhead : Byte_Array (3 .. 6);
data_rx : Byte_Array (0 .. HIL.UART.BUFFER_MAX - 1);
message : Byte_Array (0 .. 91) := (others => Byte( 0 ));
check : Byte_Array (1 .. 2) := (others => Byte( 0 ));
cks : Fletcher16_Byte.Checksum_Type;
msg_start_idx : Buffer_Wrap_Idx;
n_read : Natural;
begin
isValid := False;
data := (others => Byte( 0 ) );
HIL.UART.read(UBLOX_M8N, data_rx, n_read);
if n_read > 0 then
for i in 0 .. data_rx'Length - 2 loop -- scan for message. FIXME: why start at one?
if data_rx (i) = UBX_SYNC1 and data_rx (i + 1) = UBX_SYNC2 then
declare
now : constant Ada.Real_Time.Time := Clock;
begin
last_msg_time := now;
end;
msg_start_idx := Buffer_Wrap_Idx (i);
-- get header (bytes 3 .. 6)
declare
idx_start : constant Buffer_Wrap_Idx := msg_start_idx + 2;
idx_end : constant Buffer_Wrap_Idx := msg_start_idx + 5;
pragma Assert (idx_start + 3 = idx_end); -- modulo works as expected
begin
if idx_start > idx_end then
-- wrap
ubxhead := data_rx (Integer (idx_start) .. data_rx'Last)
& data_rx (data_rx'First .. Integer (idx_end));
else
-- no wrap
ubxhead := data_rx (Integer (idx_start) .. Integer (idx_end));
end if;
end;
if ubxhead (3) = UBX_CLASS_NAV and
then ubxhead (4) = UBX_ID_NAV_PVT and
then ubxhead (5) = UBX_LENGTH_NAV_PVT
then
-- copy message
declare
idx_datastart : constant Buffer_Wrap_Idx := msg_start_idx + 6;
idx_dataend : constant Buffer_Wrap_Idx := msg_start_idx + 97;
idx_crcstart : constant Buffer_Wrap_Idx := msg_start_idx + 98;
idx_crcend : constant Buffer_Wrap_Idx := msg_start_idx + 99;
begin
if idx_datastart < idx_crcend then
-- no wrap
message := data_rx (Integer (idx_datastart) .. Integer (idx_dataend));
check := data_rx (Integer (idx_crcstart) .. Integer (idx_crcend));
else
null; -- TODO: implement wrap
end if;
end;
-- checksum the message
cks := Fletcher16_Byte.Checksum (ubxhead & message);
if check(1) = cks.ck_a and check(2) = cks.ck_b then
Logger.log_console(Logger.TRACE, "UBX valid");
data := message;
if message(20) /= 0 then
isValid := True;
end if;
else
data := (others => Byte( 0 ));
-- Logger.log_console(Logger.DEBUG, "UBX invalid");
end if;
elsif ubxhead (3) = UBX_CLASS_ACK and
then ubxhead (4) = UBX_ID_ACK_ACK and
then ubxhead (5) = UBX_LENGTH_ACK_ACK
then
null;
-- Logger.log_console(Logger.TRACE, "UBX Ack");
end if;
exit;
end if;
end loop;
-- got class 1, id 3, length 16 -> NAV_STATUS
-- Logger.log_console(Logger.TRACE, "UBX msg class " & Integer_Img (Integer (ubxhead (3))) & ", id "
-- & Integer_Img (Integer (ubxhead (4))));
else
-- no data
isValid := False;
end if;
end readFromDevice;
procedure init is
msg_cfg_prt_head : constant UBX_Header_Array := (1 => UBX_SYNC1,
2 => UBX_SYNC2,
3 => UBX_CLASS_CFG,
4 => UBX_ID_CFG_PRT,
5 => Byte(20),
6 => Byte(0));
msg_cfg_prt : constant Data_Type(0 .. 19) := (0 => UBX_TX_CFG_PRT_PORTID,
2 => Byte(0),
4 => HIL.toBytes( UBX_TX_CFG_PRT_MODE )(1), -- uart mode 8N1
5 => HIL.toBytes( UBX_TX_CFG_PRT_MODE )(2), -- uart mode no parity, 1 stop bit
8 => HIL.toBytes( HIL.Config.UBLOX_BAUD_RATE_HZ )(1),
9 => HIL.toBytes( HIL.Config.UBLOX_BAUD_RATE_HZ )(2),
12 => Byte( 1 ), -- ubx protocol
14 => Byte( 1 ), -- ubx protocol
16 => Byte( 0 ), -- flags
others => Byte( 0 ) );
msg_cfg_msg_head : constant UBX_Header_Array := (1 => UBX_SYNC1,
2 => UBX_SYNC2,
3 => UBX_CLASS_CFG,
4 => UBX_ID_CFG_MSG,
5 => Byte(3), -- length
6 => Byte(0));
msg_cfg_msg : Data_Type(0 .. 2) := (0 => UBX_CLASS_NAV,
1 => UBX_ID_NAV_PVT,
2 => Byte( 10 ) ); -- rate in multiple of measurement rate: 2 => 2*1Hz
-- msg_cfg_rate_head : UBX_Header_Array := (1 => UBX_SYNC1,
-- 2 => UBX_SYNC2,
-- 3 => UBX_CLASS_CFG,
-- 4 => UBX_ID_CFG_RATE,
-- 5 => Byte(3), -- length
-- 6 => Byte(0));
current_time : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
pragma Unreferenced (current_time);
MESSAGE_DELAY_MS : constant Ada.Real_Time.Time_Span := Milliseconds( 10 );
pragma Unreferenced (MESSAGE_DELAY_MS);
procedure delay_ms( ms : Natural) is
current_time : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
begin
delay until current_time + Ada.Real_Time.Milliseconds( ms );
end delay_ms;
begin
for i in Integer range 1 .. 2 loop
-- 1. Set binary protocol (CFG-PRT, own message)
writeToDevice(msg_cfg_prt_head, msg_cfg_prt); -- no ACK is expected here
-- 2. Set baudrate (CFG-PRT, again own message)
-- 3. Set message rates (CFG-MSG)
-- delay_ms( 10 );
-- msg_cfg_msg(2) := Byte( 5 );
-- msg_cfg_msg(1) := UBX_ID_NAV_PVT;
-- writeToDevice(msg_cfg_msg_head, msg_cfg_msg); -- implemented for ubx7+ modules only
--
-- set other to 0
msg_cfg_msg(2) := Byte( 0 );
msg_cfg_msg(1) := UBX_ID_NAV_POSLLH;
delay_ms( 10 );
writeToDevice(msg_cfg_msg_head, msg_cfg_msg);
msg_cfg_msg(1) := UBX_ID_NAV_SOL;
delay_ms( 10 );
writeToDevice(msg_cfg_msg_head, msg_cfg_msg);
msg_cfg_msg(1) := UBX_ID_NAV_VELNED;
delay_ms( 10 );
writeToDevice(msg_cfg_msg_head, msg_cfg_msg);
msg_cfg_msg(1) := UBX_ID_NAV_STATUS;
delay_ms( 10 );
writeToDevice(msg_cfg_msg_head, msg_cfg_msg);
delay_ms( 10 );
-- limit NAV_PVT rate to every second time (=0.5Hz)
msg_cfg_msg(2) := Byte( 2 );
msg_cfg_msg(1) := UBX_ID_NAV_PVT;
writeToDevice(msg_cfg_msg_head, msg_cfg_msg); -- implemented for ubx7+ modules only
delay_ms( 10 );
end loop;
-- 4. set dynamic model
end init;
-- read measurements values. Should be called periodically.
-- Parses Ublox message UBX-NAV-PVT
-- FIXME: declare packed record and use Unchecked_Union or use Unchecked_Conversion
procedure update_val is
data_rx : UBX_Data := (others => 0);
isValid : Boolean;
-- these look weird below, but they avoid that too large values coming from
-- the GPS device multiplied by degree & co. get out of range:
function Sat_Cast_Lat is new Units.Saturated_Cast (Latitude_Type);
function Sat_Cast_Lon is new Units.Saturated_Cast (Longitude_Type);
function Sat_Cast_Alt is new Units.Saturated_Cast (Altitude_Type);
function Sat_Cast_Length is new Units.Saturated_Cast (Length_Type);
begin
readFromDevice (data_rx, isValid);
if isValid then
G_GPS_Message.itow := GPS_Time_Of_Week_Type (HIL.toUnsigned_32 (data_rx (0 .. 3)));
G_GPS_Message.datetime.year := Year_Type (HIL.toUnsigned_16 (data_rx (4 .. 5)));
G_GPS_Message.datetime.mon := (if Integer (data_rx (6)) in Month_Type then Month_Type (data_rx (6)) else Month_Type'First);
G_GPS_Message.datetime.day := (if Integer (data_rx (7)) in Day_Of_Month_Type then Day_Of_Month_Type (data_rx (7)) else Day_Of_Month_Type'First);
G_GPS_Message.datetime.hour := (if Integer (data_rx (8)) in Integer (Hour_Type'First) .. Integer (Hour_Type'Last) then Hour_Type (data_rx (8)) else Hour_Type'First);
G_GPS_Message.datetime.min := (if Integer (data_rx (9)) in Integer (Minute_Type'First) .. Integer (Minute_Type'Last) then Minute_Type (data_rx (9)) else Minute_Type'First);
G_GPS_Message.datetime.sec := (if Integer (data_rx (10)) in Integer (Second_Type'First) .. Integer (Second_Type'Last) then Second_Type (data_rx (10)) else Second_Type'First);
G_GPS_Message.lon := Sat_Cast_Lon (Float (HIL.toInteger_32 (data_rx (24 .. 27))) * 1.0e-7 * Float (Degree));
G_GPS_Message.lat := Sat_Cast_Lat (Float (HIL.toInteger_32 (data_rx (28 .. 31))) * 1.0e-7 * Float (Degree));
G_GPS_Message.alt := Sat_Cast_Alt (Float (HIL.toInteger_32 (data_rx (36 .. 39))) * Float (Milli * Meter));
G_GPS_Message.vacc := Sat_Cast_Length (Float (HIL.toUnsigned_32 (data_rx (44 .. 47))) * Float (Milli*Meter));
pragma Annotate (GNATprove, False_Positive, "precondition might fail", "pre of toUnsigned_32 is valid; proven in SPARK 18");
G_GPS_Message.sats := Unsigned_8 (data_rx (23));
declare
i32_speed : constant Integer_32 := HIL.toInteger_32 (data_rx (60 .. 63));
pragma Annotate (GNATprove, False_Positive, "precondition might fail", "pre of toInteger_32 is valid; proven in SPARK 18");
begin
G_GPS_Message.speed := Units.Linear_Velocity_Type (Float (i32_speed) / 1000.0);
end;
case data_rx(20) is
when HIL.Byte(2) => G_GPS_Message.fix := FIX_2D;
when HIL.Byte(3) => G_GPS_Message.fix := FIX_3D;
when others => G_GPS_Message.fix := NO_FIX;
end case;
--Logger.log_console (Logger.DEBUG, "Sats: " & Unsigned_8'Image (G_GPS_Message.sats));
--Logger.log_console(Logger.TRACE, "Long: " & AImage( G_GPS_Message.lon ) );
else
G_GPS_Message.fix := NO_FIX;
end if;
end update_val;
function get_Position return GPS_Loacation_Type is
begin
return (G_GPS_Message.lon, G_GPS_Message.lat, G_GPS_Message.alt);
end get_Position;
function get_GPS_Message return GPS_Message_Type is
begin
return G_GPS_Message;
end get_GPS_Message;
function get_Fix return GPS_Fix_Type is
begin
return G_GPS_Message.fix;
end get_Fix;
function get_Velo return Linear_Velocity_Type is
begin
return G_GPS_Message.speed;
end get_Velo;
function get_Vertical_Accuracy return Length_Type is
begin
return G_GPS_Message.vacc;
end get_Vertical_Accuracy;
function get_Time return GPS_DateTime_Type is
begin
return G_GPS_Message.datetime;
end get_Time;
function get_Nsat return Unsigned_8 is
begin
return G_GPS_Message.sats;
end get_Nsat;
function get_Direction return Heading_Type is
begin
return G_heading;
end get_Direction;
pragma Unreferenced (get_Direction);
-- Self Check: wait until we see valid GPS messages (not necessarily a FIX)
procedure perform_Self_Check (Status : out Error_Type) is
now : Ada.Real_Time.Time := Clock;
timeout : constant Ada.Real_Time.Time := now + Seconds (30);
begin
Status := FAILURE;
Wait_Message_Loop:
while now < timeout loop
update_val;
now := Clock;
if last_msg_time <= now then
declare
msg_age : constant Ada.Real_Time.Time_Span := now - last_msg_time;
begin
if msg_age < Seconds (1) then
Status := SUCCESS;
exit Wait_Message_Loop;
end if;
end;
end if;
end loop Wait_Message_Loop;
end perform_Self_Check;
end ublox8.Driver;
|
stcarrez/ada-util | Ada | 1,511 | adb | -----------------------------------------------------------------------
-- util-http-mimes -- HTTP Headers
-- Copyright (C) 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- 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.Characters.Handling;
with Ada.Strings.Equal_Case_Insensitive;
package body Util.Http.Mimes is
use Ada.Characters.Handling;
use Ada.Strings;
function Is_Mime (Header : in String;
Mime : in String) return Boolean is
Sep : Natural;
begin
Sep := Util.Strings.Index (Header, ';');
if Sep = 0 then
Sep := Header'Last;
else
Sep := Sep - 1;
while Sep > Header'First and then Is_Space (Header (Sep)) loop
Sep := Sep - 1;
end loop;
end if;
return Equal_Case_Insensitive (Header (Header'First .. Sep), Mime);
end Is_Mime;
end Util.Http.Mimes;
|
AdaCore/libadalang | Ada | 228 | adb | procedure Testbinop is
package Pkg is
type Typ is range 1 .. 1000;
end Pkg;
A, B : Pkg.Typ := 10;
begin
A := Pkg."+" (A, B);
if Pkg."=" (A, B) then
null;
end if;
end Testbinop;
pragma Test_Block;
|
skordal/ada-regex | Ada | 1,248 | adb | -- Ada regular expression library
-- (c) Kristian Klomsten Skordal 2020-2023 <[email protected]>
-- Report bugs and issues on <https://github.com/skordal/ada-regex>
with AUnit.Test_Caller;
with Utilities_Test_Cases;
package body Utilities_Test_Suite is
package Utilities_Test_Caller is new AUnit.Test_Caller (Utilities_Test_Cases.Test_Fixture);
function Test_Suite return AUnit.Test_Suites.Access_Test_Suite is
Retval : constant AUnit.Test_Suites.Access_Test_Suite := new AUnit.Test_Suites.Test_Suite;
begin
Retval.Add_Test (Utilities_Test_Caller.Create ("escape",
Utilities_Test_Cases.Test_Escape'Access));
Retval.Add_Test (Utilities_Test_Caller.Create ("sorted-set-empty",
Utilities_Test_Cases.Test_Empty_Set'Access));
Retval.Add_Test (Utilities_Test_Caller.Create ("sorted-set-basics",
Utilities_Test_Cases.Test_Basic_Ops'Access));
Retval.Add_Test (Utilities_Test_Caller.Create ("sorted-set-assignment",
Utilities_Test_Cases.Test_Assignment'Access));
Retval.Add_Test (Utilities_Test_Caller.Create ("sorted-set-ordering",
Utilities_Test_Cases.Test_Ordering'Access));
return Retval;
end Test_Suite;
end Utilities_Test_Suite;
|
reznikmm/matreshka | Ada | 3,641 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- 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 XML.DOM.Elements;
package ODF.DOM.Elements.Style.Footer_Style is
type ODF_Style_Footer_Style is
new XML.DOM.Elements.DOM_Element with private;
private
type ODF_Style_Footer_Style is
new XML.DOM.Elements.DOM_Element with null record;
end ODF.DOM.Elements.Style.Footer_Style;
|
tum-ei-rcs/StratoX | Ada | 4,365 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . T A S K _ I D E N T I F I C A T I O N --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2015, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System;
with System.Tasking;
package Ada.Task_Identification with
SPARK_Mode,
Abstract_State => (Tasking_State with Synchronous,
External => (Async_Readers,
Async_Writers)),
Initializes => Tasking_State
is
pragma Preelaborate;
-- In accordance with Ada 2005 AI-362
type Task_Id is private;
pragma Preelaborable_Initialization (Task_Id);
Null_Task_Id : constant Task_Id;
function "=" (Left, Right : Task_Id) return Boolean with
Global => null;
pragma Inline ("=");
function Image (T : Task_Id) return String with
Global => null;
function Current_Task return Task_Id with
Volatile_Function,
Global => Tasking_State;
pragma Inline (Current_Task);
function Environment_Task return Task_Id with
SPARK_Mode => Off,
Global => null;
pragma Inline (Environment_Task);
procedure Abort_Task (T : Task_Id) with
Global => null;
pragma Inline (Abort_Task);
-- Note: parameter is mode IN, not IN OUT, per AI-00101
function Is_Terminated (T : Task_Id) return Boolean with
Volatile_Function,
Global => Tasking_State;
pragma Inline (Is_Terminated);
function Is_Callable (T : Task_Id) return Boolean with
Volatile_Function,
Global => Tasking_State;
pragma Inline (Is_Callable);
function Activation_Is_Complete (T : Task_Id) return Boolean with
Volatile_Function,
Global => Tasking_State;
private
pragma SPARK_Mode (Off);
type Task_Id is new System.Tasking.Task_Id;
Null_Task_Id : constant Task_Id := null;
end Ada.Task_Identification;
|
pombredanne/ravenadm | Ada | 30,689 | ads | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
-- GCC 6.0 only
-- pragma Suppress (Tampering_Check);
private with HelperText;
private with Ada.Containers.Vectors;
private with Ada.Containers.Hashed_Maps;
package Port_Specification is
type Portspecs is tagged private;
misordered : exception;
contains_spaces : exception;
wrong_type : exception;
wrong_value : exception;
dupe_spec_key : exception;
dupe_list_value : exception;
missing_group : exception;
invalid_option : exception;
type spec_field is (sp_namebase, sp_version, sp_revision, sp_epoch, sp_keywords,
sp_variants, sp_taglines, sp_homepage, sp_contacts, sp_dl_groups,
sp_dl_sites, sp_distfiles, sp_distsubdir, sp_df_index, sp_subpackages,
sp_opts_avail, sp_opts_standard, sp_vopts, sp_exc_opsys, sp_inc_opsys,
sp_exc_arch, sp_ext_only, sp_ext_zip, sp_ext_7z, sp_ext_lha, sp_ext_head,
sp_ext_tail, sp_ext_dirty, sp_distname, sp_skip_build, sp_single_job,
sp_destdir_env, sp_destdirname, sp_build_wrksrc, sp_makefile,
sp_make_args, sp_make_env, sp_build_target, sp_cflags, sp_cxxflags,
sp_cppflags, sp_ldflags, sp_makefile_targets, sp_skip_install,
sp_opt_level, sp_options_on, sp_broken, sp_opt_helper, sp_patchfiles,
sp_uses, sp_sub_list, sp_sub_files, sp_config_args, sp_config_env,
sp_build_deps, sp_buildrun_deps, sp_run_deps, sp_cmake_args, sp_qmake_args,
sp_info, sp_install_tgt, sp_patch_strip, sp_pfiles_strip,
sp_patch_wrksrc, sp_extra_patches, sp_must_config,
sp_config_wrksrc, sp_config_script, sp_gnu_cfg_prefix, sp_cfg_outsrc,
sp_config_target, sp_deprecated, sp_expiration, sp_install_wrksrc,
sp_plist_sub, sp_prefix, sp_licenses, sp_users, sp_groups, sp_catchall,
sp_notes, sp_inst_tchain, sp_var_opsys, sp_var_arch, sp_lic_name,
sp_lic_file, sp_lic_scheme, sp_skip_ccache, sp_test_tgt, sp_exrun,
sp_mandirs, sp_rpath_warning, sp_debugging, sp_broken_ssl, sp_test_args,
sp_gnome, sp_rcscript, sp_ug_pkg, sp_broken_mysql, sp_broken_pgsql,
sp_og_radio, sp_og_unlimited, sp_og_restrict, sp_opt_descr, sp_opt_group,
sp_ext_deb, sp_os_bdep, sp_os_rdep, sp_os_brdep, sp_test_env, sp_generated,
sp_xorg, sp_sdl, sp_phpext, sp_job_limit);
type spec_option is (not_helper_format, not_supported_helper, broken_on, buildrun_depends_off,
buildrun_depends_on, build_depends_off, build_depends_on,
build_target_on, cflags_off, cflags_on, cmake_args_off, cmake_args_on,
cmake_bool_f_both, cmake_bool_t_both, configure_args_off,
configure_args_on, configure_enable_both, configure_env_on,
configure_with_both, cppflags_on, cxxflags_on, df_index_off, df_index_on,
extra_patches_on, extract_only_on, implies_on, info_off, info_on,
install_target_on, keywords_on, ldflags_on, make_args_off, make_args_on,
make_env_on, patchfiles_on, plist_sub_on, prevents_on, qmake_off,
qmake_on, run_depends_off, run_depends_on, sub_files_off, sub_files_on,
sub_list_off, sub_list_on, test_target_on, uses_off, uses_on,
makefile_off, makefile_on, description, only_for_opsys_on,
xorg_comp_off, xorg_comp_on, gnome_comp_off, gnome_comp_on);
-- Initialize specification data
procedure initialize (specs : out Portspecs);
-- Generic function to set single string types.
-- Throws misordered exception if set too early (or late depending on perspective)
-- Throws contains spaces exception if space found anywhere in string
-- Throws wrong_type exception if field isn't a single string type.
procedure set_single_string
(specs : in out Portspecs;
field : spec_field;
value : String);
-- Generic function to populate lists
-- Throws misordered exception if set out of order.
-- Throws contains spaces exception if space found anywhere in string
-- Throws wrong_type exception if field isn't a list type.
procedure append_list
(specs : in out Portspecs;
field : spec_field;
value : String);
-- Generic function to set integers
-- Throws misordered exception if set out of order.
-- Throws wrong_type exception if field isn't a natural integer type
procedure set_natural_integer
(specs : in out Portspecs;
field : spec_field;
value : Natural);
-- Generic function to set boolean values
-- Throws wrong_type exception if field isn't a boolean type
procedure set_boolean
(specs : in out Portspecs;
field : spec_field;
value : Boolean);
-- Generic function to populate arrays
-- Throws misordered exception if set out of order.
-- Throws contains spaces exception if space found anywhere in string
-- Throws wrong_type exception if field isn't a list type.
-- Throws duplicate exception if key has already been seen.
procedure append_array
(specs : in out Portspecs;
field : spec_field;
key : String;
value : String;
allow_spaces : Boolean);
-- Generic function to establish groups of string arrays.
-- Throws misordered exception if set out of order.
-- Throws contains spaces exception if space found anywhere in string
-- Throws wrong_type exception if field isn't a list type.
-- Throws duplicate exception if key has already been seen.
procedure establish_group
(specs : in out Portspecs;
field : spec_field;
group : String);
-- Generic function to populate option helper
-- Throws misordered exception if called before standard options
-- Throws contains spaces exception if spaces aren't permitted but found
-- Throws wrong_type exception if field isn't supported
-- Throws wrong_value exception if option doesn't exist (caller should check first)
procedure build_option_helper
(specs : in out Portspecs;
field : spec_option;
option : String;
value : String);
-- Return True if provided variant is known
function variant_exists (specs : Portspecs; variant : String) return Boolean;
-- Return True if provided option name is known
function option_exists (specs : Portspecs; option : String) return Boolean;
-- Given the provided option name, return True if setting is "ON" and False otherwise
-- If option name is not valid, raise invalid option
function option_current_setting (specs : Portspecs; option : String) return Boolean;
-- Generic function to determine if group exists, returns True if so
function group_exists
(specs : Portspecs;
field : spec_field;
group : String) return Boolean;
-- Developer routine which shows contents of specification
procedure dump_specification (specs : Portspecs);
-- Iterate through all non-standard variants to check if all options are accounted for.
-- Return blank string if all of them pass or the name of the first variant that doesn't
-- concatenated with the missing option.
function check_variants (specs : Portspecs) return String;
-- Return False if deprecation set without expiration or vice versa.
function deprecation_valid (specs : Portspecs) return Boolean;
-- Perform any post-parsing adjustments necessary
procedure adjust_defaults_port_parse (specs : in out Portspecs);
-- Returns true if indicated option helper is empty
function option_helper_unset
(specs : Portspecs;
field : spec_option;
option : String) return Boolean;
-- After parsing, this is used to return the port name
function get_namebase (specs : Portspecs) return String;
-- Generic retrieve data function
function get_field_value (specs : Portspecs; field : spec_field) return String;
-- Specialized variant-specific list esp. for package manifest
function get_options_list (specs : Portspecs; variant : String) return String;
-- Retrieve the tagline on a given variant
function get_tagline (specs : Portspecs; variant : String) return String;
-- Calculate the surprisingly complex pkgversion string
function calculate_pkgversion (specs : Portspecs) return String;
-- Return count on variants list
function get_number_of_variants (specs : Portspecs) return Natural;
-- Return the list length of the data indicated by field
function get_list_length (specs : Portspecs; field : spec_field) return Natural;
-- Return item given by number when the list is indicated by the field
function get_list_item (specs : Portspecs; field : spec_field; item : Natural) return String;
-- Return number of subpackage for a given variant
function get_subpackage_length (specs : Portspecs; variant : String) return Natural;
-- Return subpackage given a variant and index
function get_subpackage_item
(specs : Portspecs;
variant : String;
item : Natural) return String;
-- Return number of extra runtime dependences on a named subpackage
function get_number_extra_run (specs : Portspecs; subpackage : String) return Natural;
-- Return extra runtime specification of a named subpackage given an index
function get_extra_runtime
(specs : Portspecs;
subpackage : String;
item : Natural) return String;
-- Return aggregate and formatted reason(s) for ignoring the port.
function aggregated_ignore_reason (specs : Portspecs) return String;
-- Returns a formatted block of lines to represent the current option settings
function options_summary (specs : Portspecs; variant : String) return String;
-- Returns True if one or more variants have no defined subpackages.
function missing_subpackage_definition (specs : Portspecs) return Boolean;
-- Return string block (delimited by LF) of unique build + buildrun + run depends (optional)
-- If limit_to_run is true, only run dependencies are returned
function combined_dependency_origins
(specs : Portspecs;
include_run : Boolean;
limit_to_run : Boolean) return String;
-- Runs through specs to ensure all license framework information is present.
function post_parse_license_check_passes (specs : Portspecs) return Boolean;
-- Ensures USERGROUP_SPKG is set if USERS or GROUP is set.
function post_parse_usergroup_check_passes (specs : Portspecs) return Boolean;
-- Return "single", "dual" or "multi";
function get_license_scheme (specs : Portspecs) return String;
-- Return True if rpath check failures need to break the build.
function rpath_check_errors_are_fatal (specs : Portspecs) return Boolean;
-- Return True if debugging is set on.
function debugging_is_on (specs : Portspecs) return Boolean;
-- Returns the key of the last catchall insertion
function last_catchall_key (specs : Portspecs) return String;
-- Returns true if all the options have a description
-- It also outputs to standard out which ones fail
function post_parse_opt_desc_check_passes (specs : Portspecs) return Boolean;
-- Returns true if all the option groups have at least 2 members
-- It also outputs to standard out which groups have only one member
function post_parse_option_group_size_passes (specs : Portspecs) return Boolean;
-- Checks radio and restricted groups. Radio groups have to have exactly one option
-- set by (by default) and restricted groups need at least one.
function post_transform_option_group_defaults_passes (specs : Portspecs) return Boolean;
-- Return "joined" table of group + options
function option_block_for_dialog (specs : Portspecs) return String;
-- Return true if options_avail is not "none"
function global_options_present (specs : Portspecs) return Boolean;
-- Return true if ops_standard is not "none"
function standard_options_present (specs : Portspecs) return Boolean;
-- Return True if the port is generated
function port_is_generated (specs : Portspecs) return Boolean;
-- If catchall FPC_EQUIVALENT is defined, return its value, otherwise return "N/A".
function equivalent_fpc_port (specs : Portspecs) return String;
-- Returns True if given dependency is present as run_depends or buildrun_depends
function run_dependency (specs : Portspecs; dependency : String) return Boolean;
-- Used for json-repology report only (returns full download URL (1) given distfile number)
function get_repology_distfile (specs : Portspecs; item : Natural) return String;
-- Format contacts with html (span, mailto)
function get_web_contacts (specs : Portspecs; subject : String) return String;
-- Ensure opsys dependencies are not applied (only for web page generation)
procedure do_not_apply_opsys_dependencies (specs : in out Portspecs);
private
package HT renames HelperText;
package CON renames Ada.Containers;
type spec_order is (so_initialized, so_namebase, so_version, so_revision, so_epoch,
so_keywords, so_variants, so_taglines, so_homepage, so_contacts,
so_dl_groups, so_dl_sites, so_distfiles, so_distsubdir, so_df_index,
so_subpackages, so_opts_avail, so_opts_std, so_vopts);
type license_type is
(AGPLv3, AGPLv3x, APACHE10, APACHE11, APACHE20, ART10, ART20, ARTPERL10,
BSD2CLAUSE, BSD3CLAUSE, BSD4CLAUSE, BSDGROUP,
CUSTOM1, CUSTOM2, CUSTOM3, CUSTOM4,
GPLv1, GPLv1x, GPLv2, GPLv2x, GPLv3, GPLv3x,
GPLv3RLE, GPLv3RLEx, GMGPL, INVALID, ISCL,
LGPL20, LGPL20x, LGPL21, LGPL21x, LGPL3, LGPL3x,
MIT, MPL, POSTGRESQL, PSFL, PUBDOM, OPENSSL, RUBY, ZLIB);
type described_option_set is
(AALIB, ALSA, ASM, COLORD, CUPS, DBUS, DEBUG, DOCS, FIREBIRD, ICONV, IDN, IPV4, IPV6, JAVA,
LANG_CN, LANG_KO, LANG_RU,
LDAP, LDAPS, MYSQL, NAS, NLS, OPENGL, OSS, PERL524, PERL526, PGSQL, PNG, PULSEAUDIO,
PY27, PY35, PY36,
READLINE,
SNDIO, SOUND, SQLITE, STATIC, SYSLOG, TCL, TCLTK, THREADS, X11, ZLIB,
OPT_NOT_DEFINED);
type gnome_type is
(atk, cairo, glib, gtk2, gtk3, gdkpixbuf, intltool, introspection, pango, pygobject,
libcroco, libgsf, librsvg, libxml2, libxslt, invalid_component);
type xorg_type is
(bigreqsproto, compositeproto, damageproto, dmxproto, dri2proto, dri3proto, evieproto,
fixesproto, fontcacheproto, fontsproto, glproto, inputproto, kbproto, presentproto,
printproto, randrproto, recordproto, renderproto, resourceproto, scrnsaverproto, trapproto,
videoproto, xcmiscproto, xextproto, xf86bigfontproto, xf86dgaproto, xf86driproto,
xf86miscproto, xf86rushproto, xf86vidmodeproto, xineramaproto, xproto, xproxymngproto,
xtransproto, dmx, fontenc, fontutil, ice, pciaccess, pixman, sm, x11, xau, xaw, xcb,
xcb_util, xcb_util_image, xcb_util_keysyms, xcb_util_wm, xcb_render_util, xcomposite,
xcursor, xdamage, xdmcp, xext, xfixes, xfont, xfont2, xft, xi, xinerama, xkbfile, xmu,
xp, xpm, xrandr, xrender, xres, xscrnsaver, xshmfence, xt, xtst, xv, xvmc, xxf86vm,
invalid_component);
type sdl_type is
(sdl1, sdl2, gfx1, gfx2, image1, image2, mixer1, mixer2, net1, net2, ttf1, ttf2,
invalid_component);
type phpext_type is
(bcmath, bitset, bz2, calendar, ctype, curl, dba, dom, enchant, exif, fileinfo, filter,
ftp, gd, gettext, gmp, hash, iconv, igbinary, imap, interbase, intl, jsonext, ldap, mbstring,
mcrypt, memcache, memcached, mysqli, odbc, opcache, openssl, pcntl, pdf, pdo,
pdo_dblib, pdo_firebird, pdo_mysql, pdo_odbc, pdo_pgsql, pdo_sqlite, pgsql, phar, posix,
pspell, radius, readline, recode, redis, session, shmop, simplexml, snmp, soap, sockets,
sqlite3, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, wddx, xml, xmlreader, xmlrpc,
xmlwriter, xsl, zip, zlib, invalid_extension);
package string_crate is new CON.Vectors
(Element_Type => HT.Text,
Index_Type => Positive,
"=" => HT.SU."=");
package sorter is new string_crate.Generic_Sorting ("<" => HT.SU."<");
package def_crate is new CON.Hashed_Maps
(Key_Type => HT.Text,
Element_Type => HT.Text,
Hash => HT.hash,
Equivalent_Keys => HT.equivalent,
"=" => HT.SU."=");
type group_list is
record
group : HT.Text;
list : string_crate.Vector;
end record;
package list_crate is new CON.Hashed_Maps
(Key_Type => HT.Text,
Element_Type => group_list,
Hash => HT.hash,
Equivalent_Keys => HT.equivalent);
type Option_Helper is
record
option_name : HT.Text;
option_description : HT.Text;
currently_set_ON : Boolean := False;
set_ON_by_default : Boolean := False;
standard_option : Boolean := False;
BROKEN_ON : HT.Text;
BUILDRUN_DEPENDS_OFF : string_crate.Vector;
BUILDRUN_DEPENDS_ON : string_crate.Vector;
BUILD_DEPENDS_OFF : string_crate.Vector;
BUILD_DEPENDS_ON : string_crate.Vector;
BUILD_TARGET_ON : string_crate.Vector;
CFLAGS_OFF : string_crate.Vector;
CFLAGS_ON : string_crate.Vector;
CMAKE_ARGS_OFF : string_crate.Vector;
CMAKE_ARGS_ON : string_crate.Vector;
CMAKE_BOOL_F_BOTH : string_crate.Vector;
CMAKE_BOOL_T_BOTH : string_crate.Vector;
CONFIGURE_ARGS_ON : string_crate.Vector;
CONFIGURE_ARGS_OFF : string_crate.Vector;
CONFIGURE_ENABLE_BOTH : string_crate.Vector;
CONFIGURE_ENV_ON : string_crate.Vector;
CONFIGURE_WITH_BOTH : string_crate.Vector;
CPPFLAGS_ON : string_crate.Vector;
CXXFLAGS_ON : string_crate.Vector;
DF_INDEX_OFF : string_crate.Vector;
DF_INDEX_ON : string_crate.Vector;
EXTRA_PATCHES_ON : string_crate.Vector;
EXTRACT_ONLY_ON : string_crate.Vector;
IMPLIES_ON : string_crate.Vector;
INFO_OFF : string_crate.Vector;
INFO_ON : string_crate.Vector;
INSTALL_TARGET_ON : string_crate.Vector;
KEYWORDS_ON : string_crate.Vector;
LDFLAGS_ON : string_crate.Vector;
MAKEFILE_OFF : string_crate.Vector;
MAKEFILE_ON : string_crate.Vector;
MAKE_ARGS_OFF : string_crate.Vector;
MAKE_ARGS_ON : string_crate.Vector;
MAKE_ENV_ON : string_crate.Vector;
ONLY_FOR_OPSYS_ON : string_crate.Vector;
PATCHFILES_ON : string_crate.Vector;
PLIST_SUB_ON : string_crate.Vector;
PREVENTS_ON : string_crate.Vector;
QMAKE_OFF : string_crate.Vector;
QMAKE_ON : string_crate.Vector;
RUN_DEPENDS_OFF : string_crate.Vector;
RUN_DEPENDS_ON : string_crate.Vector;
SUB_FILES_OFF : string_crate.Vector;
SUB_FILES_ON : string_crate.Vector;
SUB_LIST_OFF : string_crate.Vector;
SUB_LIST_ON : string_crate.Vector;
TEST_TARGET_ON : string_crate.Vector;
USES_OFF : string_crate.Vector;
USES_ON : string_crate.Vector;
XORG_COMPONENTS_OFF : string_crate.Vector;
XORG_COMPONENTS_ON : string_crate.Vector;
GNOME_COMPONENTS_OFF : string_crate.Vector;
GNOME_COMPONENTS_ON : string_crate.Vector;
end record;
package option_crate is new CON.Hashed_Maps
(Key_Type => HT.Text,
Element_Type => Option_Helper,
Hash => HT.hash,
Equivalent_Keys => HT.equivalent);
type Portspecs is tagged
record
namebase : HT.Text;
version : HT.Text;
revision : Natural;
epoch : Natural;
job_limit : Natural;
keywords : string_crate.Vector;
variants : string_crate.Vector;
taglines : def_crate.Map;
homepage : HT.Text;
contacts : string_crate.Vector;
dl_sites : list_crate.Map;
distfiles : string_crate.Vector;
dist_subdir : HT.Text;
df_index : string_crate.Vector;
subpackages : list_crate.Map;
ops_avail : string_crate.Vector;
ops_standard : string_crate.Vector;
ops_helpers : option_crate.Map;
last_set : spec_order;
variantopts : list_crate.Map;
options_on : list_crate.Map;
broken : list_crate.Map;
exc_opsys : string_crate.Vector;
inc_opsys : string_crate.Vector;
exc_arch : string_crate.Vector;
deprecated : HT.Text;
expire_date : HT.Text;
uses : string_crate.Vector;
uses_base : string_crate.Vector;
sub_list : string_crate.Vector;
sub_files : string_crate.Vector;
extract_only : string_crate.Vector;
extract_zip : string_crate.Vector;
extract_lha : string_crate.Vector;
extract_7z : string_crate.Vector;
extract_deb : string_crate.Vector;
extract_dirty : string_crate.Vector;
extract_head : list_crate.Map;
extract_tail : list_crate.Map;
distname : HT.Text;
patchfiles : string_crate.Vector;
extra_patches : string_crate.Vector;
patch_strip : string_crate.Vector;
pfiles_strip : string_crate.Vector;
patch_wrksrc : HT.Text;
config_args : string_crate.Vector;
config_env : string_crate.Vector;
config_must : HT.Text;
config_prefix : HT.Text;
config_script : HT.Text;
config_target : HT.Text;
config_wrksrc : HT.Text;
config_outsrc : Boolean;
skip_build : Boolean;
skip_install : Boolean;
skip_ccache : Boolean;
destdir_env : Boolean;
single_job : Boolean;
shift_install : Boolean;
fatal_rpath : Boolean;
debugging_on : Boolean;
generated : Boolean;
opt_df_index : Boolean;
skip_opsys_dep : Boolean;
prefix : HT.Text;
build_wrksrc : HT.Text;
makefile : HT.Text;
destdirname : HT.Text;
make_env : string_crate.Vector;
make_args : string_crate.Vector;
build_target : string_crate.Vector;
build_deps : string_crate.Vector;
buildrun_deps : string_crate.Vector;
run_deps : string_crate.Vector;
opsys_b_deps : list_crate.Map;
opsys_r_deps : list_crate.Map;
opsys_br_deps : list_crate.Map;
cflags : string_crate.Vector;
cxxflags : string_crate.Vector;
cppflags : string_crate.Vector;
ldflags : string_crate.Vector;
optimizer_lvl : Natural;
cmake_args : string_crate.Vector;
qmake_args : string_crate.Vector;
gnome_comps : string_crate.Vector;
xorg_comps : string_crate.Vector;
sdl_comps : string_crate.Vector;
php_extensions : string_crate.Vector;
info : string_crate.Vector;
install_tgt : string_crate.Vector;
test_tgt : string_crate.Vector;
test_args : string_crate.Vector;
test_env : string_crate.Vector;
install_wrksrc : HT.Text;
plist_sub : string_crate.Vector;
make_targets : list_crate.Map;
licenses : string_crate.Vector;
lic_names : string_crate.Vector;
lic_files : string_crate.Vector;
lic_scheme : HT.Text;
usergroup_pkg : HT.Text;
users : string_crate.Vector;
groups : string_crate.Vector;
mandirs : string_crate.Vector;
mk_verbatim : string_crate.Vector;
subr_scripts : string_crate.Vector;
broken_ssl : string_crate.Vector;
broken_mysql : string_crate.Vector;
broken_pgsql : string_crate.Vector;
catch_all : list_crate.Map;
pkg_notes : def_crate.Map;
var_opsys : list_crate.Map;
var_arch : list_crate.Map;
extra_rundeps : list_crate.Map;
last_catchkey : HT.Text;
opt_radio : string_crate.Vector;
opt_restrict : string_crate.Vector;
opt_unlimited : string_crate.Vector;
optgroup_desc : list_crate.Map;
optgroups : list_crate.Map;
end record;
-- Compares given keyword against known values
function keyword_is_valid (keyword : String) return Boolean;
-- Returns true if there is a short description defined for each variant.
function all_taglines_defined (specs : Portspecs) return Boolean;
-- Returns true if given string can convert to an integer between 1 and
-- distfiles count.
function dist_index_is_valid (specs : Portspecs; test_index : String) return Boolean;
-- Returns true if space exists outside of quotation marks
function contains_nonquoted_spaces (word : String) return Boolean;
-- OPT_ON can only match existing option names exactly, or
-- have "/" separator with digits and full_stop only or
-- have above with "/" followed by one or more valid arch separated by "|" or
-- same as above except nothing between the two "/" separators
function valid_OPT_ON_value (specs : Portspecs;
key : String;
word : String) return Boolean;
-- Return True if same option is already defined in all.
function option_present_in_OPT_ON_all (specs : Portspecs;
option_name : String) return Boolean;
-- Return True if in format YYYY-MM-DD and YYYY > 2016 and MM is 01..12 and DD is 01..31
-- and it succesfully converts to a date.
function ISO8601_format (value : String) return Boolean;
-- checks for exactly two colons
-- checks the three components are not empty strings
-- Does not do existence checks on namebase, variants or subpackages.
function valid_dependency_format (value : String) return Boolean;
-- If illegal characters in the namebase are detected, return True.
function invalid_namebase (value : String; allow_comma : Boolean) return Boolean;
-- Returns true if value is a known USES module.
function valid_uses_module (value : String) return Boolean;
-- Returns true if value is a known mysql group setting
function valid_broken_mysql_value (value : String) return Boolean;
-- Returns true if value is a known postgresql setting
function valid_broken_pgsql_value (value : String) return Boolean;
-- Return true if INFO appendum is valid (compared against existing entries)
-- Specifically it's checking the subdirectory (if it exists) to make sure it matches
-- previous entries. It will define INFO_SUBDIR in catchall (once)
function valid_info_page (specs : in out Portspecs; value : String) return Boolean;
-- Checks against a list of known licenses or CUSTOM(1,2,3,4)
function determine_license (value : String) return license_type;
-- Returns enumeration of described option or OPT_NOT_FOUND if the option isn't described
function described_option (value : String) return described_option_set;
-- Returns true if subpackage exists in any variant.
function subpackage_exists (specs : Portspecs; subpackage : String) return Boolean;
-- Returns True if terminfo module exists and it doesn't have a subpackage argument
function terminfo_failed (specs : Portspecs; module : String) return Boolean;
-- Checks against known list of gnome components and identifies it
function determine_gnome_component (component : String) return gnome_type;
-- Checks against known list of xorg components and identifies it
function determine_xorg_component (component : String) return xorg_type;
-- Checks against known list of SDL components and identifies it
function determine_sdl_component (component : String) return sdl_type;
-- Checks against known list of PHP extensions and identifies it
function determine_php_extension (component : String) return phpext_type;
-- Given a string GITHUB/account:project:tag(:directory) return a standard
-- distribution file name. Also works for GH/ prefix.
function generate_github_distfile (download_site : String) return String;
-- Returns True if a given option already present in radio, restricted or unlimited group
function option_already_in_group (specs : Portspecs; option_name : String) return Boolean;
-- Given an option enumeration, return the default option description
function default_description (option : described_option_set) return String;
-- Split distfile translation to separate function (needed more than once)
-- It converts "generated" to a filename mainly
function translate_distfile (specs : Portspecs; distfile : String) return String;
-- Give full download URL (one) for each distfile.
-- Represent macros with "mirror://" prefix
function repology_distfile (specs : Portspecs; distfile : String) return String;
-- split out info entry validation (returns non-black on failed check)
function info_page_check_message (specs : Portspecs; value : String) return String;
end Port_Specification;
|
AdaCore/libadalang | Ada | 38 | ads | package P is
procedure B;
end P;
|
zhmu/ananas | Ada | 3,323 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- G N A T . W I D E _ W I D E _ S P E L L I N G _ C H E C K E R --
-- --
-- S p e c --
-- --
-- Copyright (C) 1998-2022, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Spelling checker
-- This package provides a utility routine for checking for bad spellings
-- for the case of Wide_Wide_String arguments.
package GNAT.Wide_Wide_Spelling_Checker is
pragma Pure;
function Is_Bad_Spelling_Of
(Found : Wide_Wide_String;
Expect : Wide_Wide_String) return Boolean;
-- Determines if the string Found is a plausible misspelling of the string
-- Expect. Returns True for an exact match or a probably misspelling, False
-- if no near match is detected. This routine is case sensitive, so the
-- caller should fold both strings to get a case insensitive match.
--
-- Note: the spec of this routine is deliberately rather vague. It is used
-- by GNAT itself to detect misspelled keywords and identifiers, and is
-- heuristically adjusted to be appropriate to this usage. It will work
-- well in any similar case of named entities.
end GNAT.Wide_Wide_Spelling_Checker;
|
stcarrez/ada-asf | Ada | 4,367 | ads | -----------------------------------------------------------------------
-- messages - A simple memory-based forum
-- Copyright (C) 2012 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- 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 Ada.Containers.Vectors;
with Util.Beans.Objects;
with Util.Beans.Basic;
with Util.Beans.Methods;
package Messages is
-- Identifies a message in the forum.
type Message_Id is new Positive;
type Message_Bean is new Util.Beans.Basic.Bean and Util.Beans.Methods.Method_Bean with private;
type Message_Bean_Access is access all Message_Bean'Class;
-- Get the value identified by the name.
overriding
function Get_Value (From : Message_Bean;
Name : String) return Util.Beans.Objects.Object;
-- Set the value identified by the name.
overriding
procedure Set_Value (From : in out Message_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object);
-- Post the message.
procedure Post (From : in out Message_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
-- This bean provides some methods that can be used in a Method_Expression
overriding
function Get_Method_Bindings (From : in Message_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access;
-- Create a message bean instance.
function Create_Message_Bean return Util.Beans.Basic.Readonly_Bean_Access;
-- The <tt>Forum_Bean</tt> contains a list of messages.
-- It is intended to be shared by every user, hence there will be only one instance
-- in the server.
type Forum_Bean is new Util.Beans.Basic.List_Bean with private;
-- Get the value identified by the name.
overriding
function Get_Value (From : Forum_Bean;
Name : String) return Util.Beans.Objects.Object;
-- Get the number of elements in the list.
overriding
function Get_Count (From : in Forum_Bean) return Natural;
-- Set the current row index. Valid row indexes start at 1.
overriding
procedure Set_Row_Index (From : in out Forum_Bean;
Index : in Natural);
-- Get the element at the current row index.
overriding
function Get_Row (From : in Forum_Bean) return Util.Beans.Objects.Object;
-- Create the list of messages.
function Create_Message_List return Util.Beans.Basic.Readonly_Bean_Access;
private
type Message_Bean is new Util.Beans.Basic.Bean and Util.Beans.Methods.Method_Bean with record
Id : Message_Id;
Text : Ada.Strings.Unbounded.Unbounded_String;
Email : Ada.Strings.Unbounded.Unbounded_String;
end record;
package Message_Vector is
new Ada.Containers.Vectors (Index_Type => Message_Id,
Element_Type => Message_Bean,
"=" => "=");
protected type Forum is
-- Post the message in the forum.
procedure Post (Message : in Message_Bean);
-- Delete the message identified by <b>Id</b>.
procedure Delete (Id : in Message_Id);
-- Get the message identified by <b>Id</b>.
function Get_Message (Id : in Message_Id) return Message_Bean;
-- Get the number of messages in the forum.
function Get_Message_Count return Natural;
private
Messages : Message_Vector.Vector;
end Forum;
type Forum_Bean is new Util.Beans.Basic.List_Bean with record
Msg : aliased Message_Bean;
Pos : Message_Id;
Current : Util.Beans.Objects.Object;
end record;
type Forum_Bean_Access is access all Forum_Bean'Class;
end Messages;
|
io7m/coreland-vector-ada | Ada | 1,208 | adb | package body vector.negate is
-- C imports
procedure vec_negate_f
(a : in out vector_f_t;
n : ic.int);
pragma import (c, vec_negate_f, "vec_negaNf_aligned");
procedure vec_negate_fx
(a : vector_f_t;
x : out vector_f_t;
n : ic.int);
pragma import (c, vec_negate_fx, "vec_negaNfx_aligned");
procedure vec_negate_d
(a : in out vector_d_t;
n : ic.int);
pragma import (c, vec_negate_d, "vec_negaNd_aligned");
procedure vec_negate_dx
(a : vector_d_t;
x : out vector_d_t;
n : ic.int);
pragma import (c, vec_negate_dx, "vec_negaNdx_aligned");
-- negate, in place
procedure f (a : in out vector_f_t) is
begin
vec_negate_f (a, ic.int (size));
end f;
pragma inline (f);
procedure d (a : in out vector_d_t) is
begin
vec_negate_d (a, ic.int (size));
end d;
pragma inline (d);
-- negate, external storage
procedure f_ext
(a : vector_f_t;
x : out vector_f_t) is
begin
vec_negate_fx (a, x, ic.int (size));
end f_ext;
pragma inline (f_ext);
procedure d_ext
(a : vector_d_t;
x : out vector_d_t) is
begin
vec_negate_dx (a, x, ic.int (size));
end d_ext;
pragma inline (d_ext);
end vector.negate;
|
reznikmm/matreshka | Ada | 4,297 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2016-2017, Vadim Godunko <[email protected]> --
-- 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.Strings;
with WebAPI.HTML.Elements;
with WUI.Actions;
with WUI.Widgets;
package WUI.Widgets.Menus is
type Menu is new WUI.Widgets.Abstract_Widget with private;
type Menu_Access is access all Menu'Class;
-- with Storage_Size => 0;
not overriding function Title (Self : Menu)
return League.Strings.Universal_String;
not overriding procedure Add_Action
(Self : in out Menu;
Item : WUI.Actions.Action_Access);
not overriding procedure Add_Menu
(Self : in out Menu;
Item : WUI.Widgets.Menus.Menu_Access);
package Constructors is
procedure Initialize
(Self : in out Menu'Class;
Parent : not null access WUI.Widgets.Abstract_Widget'Class;
Title : League.Strings.Universal_String);
end Constructors;
private
type Menu is new WUI.Widgets.Abstract_Widget with record
Menu_Title : League.Strings.Universal_String;
end record;
end WUI.Widgets.Menus;
|
gabemgem/LITEC | Ada | 11,259 | adb | M:lab2
F:G$SYSCLK_Init$0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$UART0_Init$0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$Sys_Init$0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$putchar$0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$getchar$0$0({2}DF,SC:U),C,0,0,0,0,0
F:G$getchar_nw$0$0({2}DF,SC:U),C,0,0,0,0,0
F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$Port_Init$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$Interrupt_Init$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$Timer_Init$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$ADC_Init$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$Timer0_ISR$0$0({2}DF,SV:S),Z,0,0,1,1,0
F:G$ADC_Convert$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$random$0$0({2}DF,SC:U),Z,0,0,0,0,0
S:Llab2.getchar$c$1$10({1}SC:U),R,0,0,[]
S:Llab2.getchar_nw$c$1$12({1}SC:U),R,0,0,[]
S:G$counts$0$0({2}SI:U),E,0,0
S:G$temp$0$0({2}SI:U),E,0,0
S:G$input$0$0({1}SC:U),E,0,0
S:G$speed$0$0({1}SC:U),E,0,0
S:G$wait$0$0({2}SI:U),E,0,0
S:G$score$0$0({2}SI:U),E,0,0
S:G$points$0$0({2}SI:U),E,0,0
S:G$num$0$0({1}SC:U),E,0,0
S:G$i$0$0({1}SC:U),E,0,0
S:G$tryn$0$0({1}SC:U),E,0,0
S:Llab2.aligned_alloc$size$1$39({2}SI:U),E,0,0
S:Llab2.aligned_alloc$alignment$1$39({2}SI:U),E,0,0
S:G$P0$0$0({1}SC:U),I,0,0
S:G$SP$0$0({1}SC:U),I,0,0
S:G$DPL$0$0({1}SC:U),I,0,0
S:G$DPH$0$0({1}SC:U),I,0,0
S:G$P4$0$0({1}SC:U),I,0,0
S:G$P5$0$0({1}SC:U),I,0,0
S:G$P6$0$0({1}SC:U),I,0,0
S:G$PCON$0$0({1}SC:U),I,0,0
S:G$TCON$0$0({1}SC:U),I,0,0
S:G$TMOD$0$0({1}SC:U),I,0,0
S:G$TL0$0$0({1}SC:U),I,0,0
S:G$TL1$0$0({1}SC:U),I,0,0
S:G$TH0$0$0({1}SC:U),I,0,0
S:G$TH1$0$0({1}SC:U),I,0,0
S:G$CKCON$0$0({1}SC:U),I,0,0
S:G$PSCTL$0$0({1}SC:U),I,0,0
S:G$P1$0$0({1}SC:U),I,0,0
S:G$TMR3CN$0$0({1}SC:U),I,0,0
S:G$TMR3RLL$0$0({1}SC:U),I,0,0
S:G$TMR3RLH$0$0({1}SC:U),I,0,0
S:G$TMR3L$0$0({1}SC:U),I,0,0
S:G$TMR3H$0$0({1}SC:U),I,0,0
S:G$P7$0$0({1}SC:U),I,0,0
S:G$SCON$0$0({1}SC:U),I,0,0
S:G$SCON0$0$0({1}SC:U),I,0,0
S:G$SBUF$0$0({1}SC:U),I,0,0
S:G$SBUF0$0$0({1}SC:U),I,0,0
S:G$SPI0CFG$0$0({1}SC:U),I,0,0
S:G$SPI0DAT$0$0({1}SC:U),I,0,0
S:G$ADC1$0$0({1}SC:U),I,0,0
S:G$SPI0CKR$0$0({1}SC:U),I,0,0
S:G$CPT0CN$0$0({1}SC:U),I,0,0
S:G$CPT1CN$0$0({1}SC:U),I,0,0
S:G$P2$0$0({1}SC:U),I,0,0
S:G$EMI0TC$0$0({1}SC:U),I,0,0
S:G$EMI0CF$0$0({1}SC:U),I,0,0
S:G$PRT0CF$0$0({1}SC:U),I,0,0
S:G$P0MDOUT$0$0({1}SC:U),I,0,0
S:G$PRT1CF$0$0({1}SC:U),I,0,0
S:G$P1MDOUT$0$0({1}SC:U),I,0,0
S:G$PRT2CF$0$0({1}SC:U),I,0,0
S:G$P2MDOUT$0$0({1}SC:U),I,0,0
S:G$PRT3CF$0$0({1}SC:U),I,0,0
S:G$P3MDOUT$0$0({1}SC:U),I,0,0
S:G$IE$0$0({1}SC:U),I,0,0
S:G$SADDR0$0$0({1}SC:U),I,0,0
S:G$ADC1CN$0$0({1}SC:U),I,0,0
S:G$ADC1CF$0$0({1}SC:U),I,0,0
S:G$AMX1SL$0$0({1}SC:U),I,0,0
S:G$P3IF$0$0({1}SC:U),I,0,0
S:G$SADEN1$0$0({1}SC:U),I,0,0
S:G$EMI0CN$0$0({1}SC:U),I,0,0
S:G$_XPAGE$0$0({1}SC:U),I,0,0
S:G$P3$0$0({1}SC:U),I,0,0
S:G$OSCXCN$0$0({1}SC:U),I,0,0
S:G$OSCICN$0$0({1}SC:U),I,0,0
S:G$P74OUT$0$0({1}SC:U),I,0,0
S:G$FLSCL$0$0({1}SC:U),I,0,0
S:G$FLACL$0$0({1}SC:U),I,0,0
S:G$IP$0$0({1}SC:U),I,0,0
S:G$SADEN0$0$0({1}SC:U),I,0,0
S:G$AMX0CF$0$0({1}SC:U),I,0,0
S:G$AMX0SL$0$0({1}SC:U),I,0,0
S:G$ADC0CF$0$0({1}SC:U),I,0,0
S:G$P1MDIN$0$0({1}SC:U),I,0,0
S:G$ADC0L$0$0({1}SC:U),I,0,0
S:G$ADC0H$0$0({1}SC:U),I,0,0
S:G$SMB0CN$0$0({1}SC:U),I,0,0
S:G$SMB0STA$0$0({1}SC:U),I,0,0
S:G$SMB0DAT$0$0({1}SC:U),I,0,0
S:G$SMB0ADR$0$0({1}SC:U),I,0,0
S:G$ADC0GTL$0$0({1}SC:U),I,0,0
S:G$ADC0GTH$0$0({1}SC:U),I,0,0
S:G$ADC0LTL$0$0({1}SC:U),I,0,0
S:G$ADC0LTH$0$0({1}SC:U),I,0,0
S:G$T2CON$0$0({1}SC:U),I,0,0
S:G$T4CON$0$0({1}SC:U),I,0,0
S:G$RCAP2L$0$0({1}SC:U),I,0,0
S:G$RCAP2H$0$0({1}SC:U),I,0,0
S:G$TL2$0$0({1}SC:U),I,0,0
S:G$TH2$0$0({1}SC:U),I,0,0
S:G$SMB0CR$0$0({1}SC:U),I,0,0
S:G$PSW$0$0({1}SC:U),I,0,0
S:G$REF0CN$0$0({1}SC:U),I,0,0
S:G$DAC0L$0$0({1}SC:U),I,0,0
S:G$DAC0H$0$0({1}SC:U),I,0,0
S:G$DAC0CN$0$0({1}SC:U),I,0,0
S:G$DAC1L$0$0({1}SC:U),I,0,0
S:G$DAC1H$0$0({1}SC:U),I,0,0
S:G$DAC1CN$0$0({1}SC:U),I,0,0
S:G$PCA0CN$0$0({1}SC:U),I,0,0
S:G$PCA0MD$0$0({1}SC:U),I,0,0
S:G$PCA0CPM0$0$0({1}SC:U),I,0,0
S:G$PCA0CPM1$0$0({1}SC:U),I,0,0
S:G$PCA0CPM2$0$0({1}SC:U),I,0,0
S:G$PCA0CPM3$0$0({1}SC:U),I,0,0
S:G$PCA0CPM4$0$0({1}SC:U),I,0,0
S:G$ACC$0$0({1}SC:U),I,0,0
S:G$XBR0$0$0({1}SC:U),I,0,0
S:G$XBR1$0$0({1}SC:U),I,0,0
S:G$XBR2$0$0({1}SC:U),I,0,0
S:G$RCAP4L$0$0({1}SC:U),I,0,0
S:G$RCAP4H$0$0({1}SC:U),I,0,0
S:G$EIE1$0$0({1}SC:U),I,0,0
S:G$EIE2$0$0({1}SC:U),I,0,0
S:G$ADC0CN$0$0({1}SC:U),I,0,0
S:G$PCA0L$0$0({1}SC:U),I,0,0
S:G$PCA0CPL0$0$0({1}SC:U),I,0,0
S:G$PCA0CPL1$0$0({1}SC:U),I,0,0
S:G$PCA0CPL2$0$0({1}SC:U),I,0,0
S:G$PCA0CPL3$0$0({1}SC:U),I,0,0
S:G$PCA0CPL4$0$0({1}SC:U),I,0,0
S:G$RSTSRC$0$0({1}SC:U),I,0,0
S:G$B$0$0({1}SC:U),I,0,0
S:G$SCON1$0$0({1}SC:U),I,0,0
S:G$SBUF1$0$0({1}SC:U),I,0,0
S:G$SADDR1$0$0({1}SC:U),I,0,0
S:G$TL4$0$0({1}SC:U),I,0,0
S:G$TH4$0$0({1}SC:U),I,0,0
S:G$EIP1$0$0({1}SC:U),I,0,0
S:G$EIP2$0$0({1}SC:U),I,0,0
S:G$SPI0CN$0$0({1}SC:U),I,0,0
S:G$PCA0H$0$0({1}SC:U),I,0,0
S:G$PCA0CPH0$0$0({1}SC:U),I,0,0
S:G$PCA0CPH1$0$0({1}SC:U),I,0,0
S:G$PCA0CPH2$0$0({1}SC:U),I,0,0
S:G$PCA0CPH3$0$0({1}SC:U),I,0,0
S:G$PCA0CPH4$0$0({1}SC:U),I,0,0
S:G$WDTCN$0$0({1}SC:U),I,0,0
S:G$TMR0$0$0({2}SI:U),I,0,0
S:G$TMR1$0$0({2}SI:U),I,0,0
S:G$TMR2$0$0({2}SI:U),I,0,0
S:G$RCAP2$0$0({2}SI:U),I,0,0
S:G$TMR3$0$0({2}SI:U),I,0,0
S:G$TMR3RL$0$0({2}SI:U),I,0,0
S:G$TMR4$0$0({2}SI:U),I,0,0
S:G$RCAP4$0$0({2}SI:U),I,0,0
S:G$ADC0$0$0({2}SI:U),I,0,0
S:G$ADC0GT$0$0({2}SI:U),I,0,0
S:G$ADC0LT$0$0({2}SI:U),I,0,0
S:G$DAC0$0$0({2}SI:U),I,0,0
S:G$DAC1$0$0({2}SI:U),I,0,0
S:G$PCA0$0$0({2}SI:U),I,0,0
S:G$PCA0CP0$0$0({2}SI:U),I,0,0
S:G$PCA0CP1$0$0({2}SI:U),I,0,0
S:G$PCA0CP2$0$0({2}SI:U),I,0,0
S:G$PCA0CP3$0$0({2}SI:U),I,0,0
S:G$PCA0CP4$0$0({2}SI:U),I,0,0
S:G$P0_0$0$0({1}SX:U),J,0,0
S:G$P0_1$0$0({1}SX:U),J,0,0
S:G$P0_2$0$0({1}SX:U),J,0,0
S:G$P0_3$0$0({1}SX:U),J,0,0
S:G$P0_4$0$0({1}SX:U),J,0,0
S:G$P0_5$0$0({1}SX:U),J,0,0
S:G$P0_6$0$0({1}SX:U),J,0,0
S:G$P0_7$0$0({1}SX:U),J,0,0
S:G$IT0$0$0({1}SX:U),J,0,0
S:G$IE0$0$0({1}SX:U),J,0,0
S:G$IT1$0$0({1}SX:U),J,0,0
S:G$IE1$0$0({1}SX:U),J,0,0
S:G$TR0$0$0({1}SX:U),J,0,0
S:G$TF0$0$0({1}SX:U),J,0,0
S:G$TR1$0$0({1}SX:U),J,0,0
S:G$TF1$0$0({1}SX:U),J,0,0
S:G$P1_0$0$0({1}SX:U),J,0,0
S:G$P1_1$0$0({1}SX:U),J,0,0
S:G$P1_2$0$0({1}SX:U),J,0,0
S:G$P1_3$0$0({1}SX:U),J,0,0
S:G$P1_4$0$0({1}SX:U),J,0,0
S:G$P1_5$0$0({1}SX:U),J,0,0
S:G$P1_6$0$0({1}SX:U),J,0,0
S:G$P1_7$0$0({1}SX:U),J,0,0
S:G$RI$0$0({1}SX:U),J,0,0
S:G$RI0$0$0({1}SX:U),J,0,0
S:G$TI$0$0({1}SX:U),J,0,0
S:G$TI0$0$0({1}SX:U),J,0,0
S:G$RB8$0$0({1}SX:U),J,0,0
S:G$RB80$0$0({1}SX:U),J,0,0
S:G$TB8$0$0({1}SX:U),J,0,0
S:G$TB80$0$0({1}SX:U),J,0,0
S:G$REN$0$0({1}SX:U),J,0,0
S:G$REN0$0$0({1}SX:U),J,0,0
S:G$SM2$0$0({1}SX:U),J,0,0
S:G$SM20$0$0({1}SX:U),J,0,0
S:G$MCE0$0$0({1}SX:U),J,0,0
S:G$SM1$0$0({1}SX:U),J,0,0
S:G$SM10$0$0({1}SX:U),J,0,0
S:G$SM0$0$0({1}SX:U),J,0,0
S:G$SM00$0$0({1}SX:U),J,0,0
S:G$S0MODE$0$0({1}SX:U),J,0,0
S:G$P2_0$0$0({1}SX:U),J,0,0
S:G$P2_1$0$0({1}SX:U),J,0,0
S:G$P2_2$0$0({1}SX:U),J,0,0
S:G$P2_3$0$0({1}SX:U),J,0,0
S:G$P2_4$0$0({1}SX:U),J,0,0
S:G$P2_5$0$0({1}SX:U),J,0,0
S:G$P2_6$0$0({1}SX:U),J,0,0
S:G$P2_7$0$0({1}SX:U),J,0,0
S:G$EX0$0$0({1}SX:U),J,0,0
S:G$ET0$0$0({1}SX:U),J,0,0
S:G$EX1$0$0({1}SX:U),J,0,0
S:G$ET1$0$0({1}SX:U),J,0,0
S:G$ES0$0$0({1}SX:U),J,0,0
S:G$ES$0$0({1}SX:U),J,0,0
S:G$ET2$0$0({1}SX:U),J,0,0
S:G$EA$0$0({1}SX:U),J,0,0
S:G$P3_0$0$0({1}SX:U),J,0,0
S:G$P3_1$0$0({1}SX:U),J,0,0
S:G$P3_2$0$0({1}SX:U),J,0,0
S:G$P3_3$0$0({1}SX:U),J,0,0
S:G$P3_4$0$0({1}SX:U),J,0,0
S:G$P3_5$0$0({1}SX:U),J,0,0
S:G$P3_6$0$0({1}SX:U),J,0,0
S:G$P3_7$0$0({1}SX:U),J,0,0
S:G$PX0$0$0({1}SX:U),J,0,0
S:G$PT0$0$0({1}SX:U),J,0,0
S:G$PX1$0$0({1}SX:U),J,0,0
S:G$PT1$0$0({1}SX:U),J,0,0
S:G$PS0$0$0({1}SX:U),J,0,0
S:G$PS$0$0({1}SX:U),J,0,0
S:G$PT2$0$0({1}SX:U),J,0,0
S:G$SMBTOE$0$0({1}SX:U),J,0,0
S:G$SMBFTE$0$0({1}SX:U),J,0,0
S:G$AA$0$0({1}SX:U),J,0,0
S:G$SI$0$0({1}SX:U),J,0,0
S:G$STO$0$0({1}SX:U),J,0,0
S:G$STA$0$0({1}SX:U),J,0,0
S:G$ENSMB$0$0({1}SX:U),J,0,0
S:G$BUSY$0$0({1}SX:U),J,0,0
S:G$CPRL2$0$0({1}SX:U),J,0,0
S:G$CT2$0$0({1}SX:U),J,0,0
S:G$TR2$0$0({1}SX:U),J,0,0
S:G$EXEN2$0$0({1}SX:U),J,0,0
S:G$TCLK$0$0({1}SX:U),J,0,0
S:G$RCLK$0$0({1}SX:U),J,0,0
S:G$EXF2$0$0({1}SX:U),J,0,0
S:G$TF2$0$0({1}SX:U),J,0,0
S:G$P$0$0({1}SX:U),J,0,0
S:G$F1$0$0({1}SX:U),J,0,0
S:G$OV$0$0({1}SX:U),J,0,0
S:G$RS0$0$0({1}SX:U),J,0,0
S:G$RS1$0$0({1}SX:U),J,0,0
S:G$F0$0$0({1}SX:U),J,0,0
S:G$AC$0$0({1}SX:U),J,0,0
S:G$CY$0$0({1}SX:U),J,0,0
S:G$CCF0$0$0({1}SX:U),J,0,0
S:G$CCF1$0$0({1}SX:U),J,0,0
S:G$CCF2$0$0({1}SX:U),J,0,0
S:G$CCF3$0$0({1}SX:U),J,0,0
S:G$CCF4$0$0({1}SX:U),J,0,0
S:G$CR$0$0({1}SX:U),J,0,0
S:G$CF$0$0({1}SX:U),J,0,0
S:G$ADLJST$0$0({1}SX:U),J,0,0
S:G$AD0LJST$0$0({1}SX:U),J,0,0
S:G$ADWINT$0$0({1}SX:U),J,0,0
S:G$AD0WINT$0$0({1}SX:U),J,0,0
S:G$ADSTM0$0$0({1}SX:U),J,0,0
S:G$AD0CM0$0$0({1}SX:U),J,0,0
S:G$ADSTM1$0$0({1}SX:U),J,0,0
S:G$AD0CM1$0$0({1}SX:U),J,0,0
S:G$ADBUSY$0$0({1}SX:U),J,0,0
S:G$AD0BUSY$0$0({1}SX:U),J,0,0
S:G$ADCINT$0$0({1}SX:U),J,0,0
S:G$AD0INT$0$0({1}SX:U),J,0,0
S:G$ADCTM$0$0({1}SX:U),J,0,0
S:G$AD0TM$0$0({1}SX:U),J,0,0
S:G$ADCEN$0$0({1}SX:U),J,0,0
S:G$AD0EN$0$0({1}SX:U),J,0,0
S:G$SPIEN$0$0({1}SX:U),J,0,0
S:G$MSTEN$0$0({1}SX:U),J,0,0
S:G$SLVSEL$0$0({1}SX:U),J,0,0
S:G$TXBSY$0$0({1}SX:U),J,0,0
S:G$RXOVRN$0$0({1}SX:U),J,0,0
S:G$MODF$0$0({1}SX:U),J,0,0
S:G$WCOL$0$0({1}SX:U),J,0,0
S:G$SPIF$0$0({1}SX:U),J,0,0
S:G$POT$0$0({1}SX:U),J,0,0
S:G$PB0$0$0({1}SX:U),J,0,0
S:G$PB1$0$0({1}SX:U),J,0,0
S:G$PBEnter$0$0({1}SX:U),J,0,0
S:G$PB2$0$0({1}SX:U),J,0,0
S:G$SS$0$0({1}SX:U),J,0,0
S:G$BILED1$0$0({1}SX:U),J,0,0
S:G$BILED2$0$0({1}SX:U),J,0,0
S:G$LED2$0$0({1}SX:U),J,0,0
S:G$LED1$0$0({1}SX:U),J,0,0
S:G$LED0$0$0({1}SX:U),J,0,0
S:G$BUZZER$0$0({1}SX:U),J,0,0
S:G$SYSCLK_Init$0$0({2}DF,SV:S),C,0,0
S:G$UART0_Init$0$0({2}DF,SV:S),C,0,0
S:G$Sys_Init$0$0({2}DF,SV:S),C,0,0
S:G$getchar_nw$0$0({2}DF,SC:U),C,0,0
S:G$_print_format$0$0({2}DF,SI:S),C,0,0
S:G$printf_small$0$0({2}DF,SV:S),C,0,0
S:G$printf$0$0({2}DF,SI:S),C,0,0
S:G$vprintf$0$0({2}DF,SI:S),C,0,0
S:G$sprintf$0$0({2}DF,SI:S),C,0,0
S:G$vsprintf$0$0({2}DF,SI:S),C,0,0
S:G$puts$0$0({2}DF,SI:S),C,0,0
S:G$getchar$0$0({2}DF,SC:U),C,0,0
S:G$putchar$0$0({2}DF,SV:S),C,0,0
S:G$printf_fast$0$0({2}DF,SV:S),C,0,0
S:G$printf_fast_f$0$0({2}DF,SV:S),C,0,0
S:G$printf_tiny$0$0({2}DF,SV:S),C,0,0
S:G$atof$0$0({2}DF,SF:S),C,0,0
S:G$atoi$0$0({2}DF,SI:S),C,0,0
S:G$atol$0$0({2}DF,SL:S),C,0,0
S:G$_uitoa$0$0({2}DF,SV:S),C,0,0
S:G$_itoa$0$0({2}DF,SV:S),C,0,0
S:G$_ultoa$0$0({2}DF,SV:S),C,0,0
S:G$_ltoa$0$0({2}DF,SV:S),C,0,0
S:G$rand$0$0({2}DF,SI:S),C,0,0
S:G$srand$0$0({2}DF,SV:S),C,0,0
S:G$calloc$0$0({2}DF,DX,SV:S),C,0,0
S:G$malloc$0$0({2}DF,DX,SV:S),C,0,0
S:G$realloc$0$0({2}DF,DX,SV:S),C,0,0
S:G$aligned_alloc$0$0({2}DF,DG,SV:S),C,0,0
S:G$free$0$0({2}DF,SV:S),C,0,0
S:G$abs$0$0({2}DF,SI:S),C,0,0
S:G$labs$0$0({2}DF,SL:S),C,0,0
S:G$mblen$0$0({2}DF,SI:S),C,0,0
S:G$mbtowc$0$0({2}DF,SI:S),C,0,0
S:G$wctomb$0$0({2}DF,SI:S),C,0,0
S:G$main$0$0({2}DF,SV:S),C,0,0
S:Flab2$__str_0$0$0({10}DA10d,SC:S),D,0,0
S:Flab2$__str_1$0$0({24}DA24d,SC:S),D,0,0
S:Flab2$__str_2$0$0({33}DA33d,SC:S),D,0,0
S:Flab2$__str_3$0$0({76}DA76d,SC:S),D,0,0
S:Flab2$__str_4$0$0({63}DA63d,SC:S),D,0,0
S:Flab2$__str_5$0$0({60}DA60d,SC:S),D,0,0
S:Flab2$__str_6$0$0({61}DA61d,SC:S),D,0,0
S:Flab2$__str_7$0$0({53}DA53d,SC:S),D,0,0
S:Flab2$__str_8$0$0({52}DA52d,SC:S),D,0,0
S:Flab2$__str_9$0$0({40}DA40d,SC:S),D,0,0
S:Flab2$__str_10$0$0({20}DA20d,SC:S),D,0,0
S:Flab2$__str_11$0$0({59}DA59d,SC:S),D,0,0
S:Flab2$__str_12$0$0({67}DA67d,SC:S),D,0,0
S:Flab2$__str_13$0$0({39}DA39d,SC:S),D,0,0
S:Flab2$__str_14$0$0({13}DA13d,SC:S),D,0,0
S:Flab2$__str_15$0$0({38}DA38d,SC:S),D,0,0
S:Flab2$__str_16$0$0({18}DA18d,SC:S),D,0,0
|
databuzzword/ai-api-marketplace | Ada | 1,087 | ads | -- FastAPI
-- No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
--
-- The version of the OpenAPI document: 0.1.0
--
--
-- NOTE: This package is auto generated by OpenAPI-Generator 4.0.0.
-- https://openapi-generator.tech
-- Do not edit the class manually.
with .Models;
with Swagger.Clients;
package .Clients is
type Client_Type is new Swagger.Clients.Client_Type with null record;
-- Read Users
procedure Read_Users_Image_Image_Uncolorization_Users_Get
(Client : in out Client_Type;
Result : out Swagger.Object);
-- Root
procedure Root_Get
(Client : in out Client_Type;
Result : out Swagger.Object);
-- Read User
procedure Read_User_Image_Image_Uncolorization_Users_Username_Post
(Client : in out Client_Type;
Username : in Swagger.UString;
Result : out Swagger.Object);
-- Read User Me
procedure Read_User_Me_Image_Image_Uncolorization_Users_Me_Get
(Client : in out Client_Type;
Result : out Swagger.Object);
end .Clients;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 3,755 | ads | -- This spec has been automatically generated from STM32F103.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.STK is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CTRL_ENABLE_Field is STM32_SVD.Bit;
subtype CTRL_TICKINT_Field is STM32_SVD.Bit;
subtype CTRL_CLKSOURCE_Field is STM32_SVD.Bit;
subtype CTRL_COUNTFLAG_Field is STM32_SVD.Bit;
-- SysTick control and status register
type CTRL_Register is record
-- Counter enable
ENABLE : CTRL_ENABLE_Field := 16#0#;
-- SysTick exception request enable
TICKINT : CTRL_TICKINT_Field := 16#0#;
-- Clock source selection
CLKSOURCE : CTRL_CLKSOURCE_Field := 16#0#;
-- unspecified
Reserved_3_15 : STM32_SVD.UInt13 := 16#0#;
-- COUNTFLAG
COUNTFLAG : CTRL_COUNTFLAG_Field := 16#0#;
-- unspecified
Reserved_17_31 : STM32_SVD.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CTRL_Register use record
ENABLE at 0 range 0 .. 0;
TICKINT at 0 range 1 .. 1;
CLKSOURCE at 0 range 2 .. 2;
Reserved_3_15 at 0 range 3 .. 15;
COUNTFLAG at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype LOAD_RELOAD_Field is STM32_SVD.UInt24;
-- SysTick reload value register
type LOAD_Register is record
-- RELOAD value
RELOAD : LOAD_RELOAD_Field := 16#0#;
-- unspecified
Reserved_24_31 : STM32_SVD.Byte := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for LOAD_Register use record
RELOAD at 0 range 0 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype VAL_CURRENT_Field is STM32_SVD.UInt24;
-- SysTick current value register
type VAL_Register is record
-- Current counter value
CURRENT : VAL_CURRENT_Field := 16#0#;
-- unspecified
Reserved_24_31 : STM32_SVD.Byte := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for VAL_Register use record
CURRENT at 0 range 0 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype CALIB_TENMS_Field is STM32_SVD.UInt24;
-- SysTick calibration value register
type CALIB_Register is record
-- Calibration value
TENMS : CALIB_TENMS_Field := 16#0#;
-- unspecified
Reserved_24_31 : STM32_SVD.Byte := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CALIB_Register use record
TENMS at 0 range 0 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- SysTick timer
type STK_Peripheral is record
-- SysTick control and status register
CTRL : aliased CTRL_Register;
-- SysTick reload value register
LOAD : aliased LOAD_Register;
-- SysTick current value register
VAL : aliased VAL_Register;
-- SysTick calibration value register
CALIB : aliased CALIB_Register;
end record
with Volatile;
for STK_Peripheral use record
CTRL at 16#0# range 0 .. 31;
LOAD at 16#4# range 0 .. 31;
VAL at 16#8# range 0 .. 31;
CALIB at 16#C# range 0 .. 31;
end record;
-- SysTick timer
STK_Periph : aliased STK_Peripheral
with Import, Address => System'To_Address (16#E000E010#);
end STM32_SVD.STK;
|
Rodeo-McCabe/orka | Ada | 2,931 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <[email protected]>
--
-- 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 GL.Types;
package Orka.Inputs.Pointers.Default is
pragma Preelaborate;
type Abstract_Pointer_Input is abstract new Pointer_Input with private;
overriding
function Position_X (Object : Abstract_Pointer_Input) return GL.Types.Double;
overriding
function Position_Y (Object : Abstract_Pointer_Input) return GL.Types.Double;
overriding
function Delta_X (Object : Abstract_Pointer_Input) return GL.Types.Double;
overriding
function Delta_Y (Object : Abstract_Pointer_Input) return GL.Types.Double;
overriding
function Scroll_X (Object : Abstract_Pointer_Input) return GL.Types.Double;
overriding
function Scroll_Y (Object : Abstract_Pointer_Input) return GL.Types.Double;
overriding
function Locked (Object : Abstract_Pointer_Input) return Boolean;
overriding
function Visible (Object : Abstract_Pointer_Input) return Boolean;
overriding
procedure Lock_Pointer (Object : in out Abstract_Pointer_Input; Locked : Boolean);
overriding
procedure Set_Visible (Object : in out Abstract_Pointer_Input; Visible : Boolean);
overriding
function Button_Pressed
(Object : Abstract_Pointer_Input;
Subject : Pointers.Button) return Boolean;
procedure Set_Position (Object : in out Abstract_Pointer_Input; X, Y : GL.Types.Double);
procedure Set_Scroll_Offset (Object : in out Abstract_Pointer_Input; X, Y : GL.Types.Double);
procedure Set_Button_State
(Object : in out Abstract_Pointer_Input;
Subject : Pointers.Button;
State : Pointers.Button_State);
type Cursor_Mode is (Normal, Hidden, Disabled);
procedure Set_Cursor_Mode
(Object : in out Abstract_Pointer_Input;
Mode : Cursor_Mode) is abstract;
private
type Button_Array is array (Pointers.Button) of Boolean;
type Abstract_Pointer_Input is abstract new Pointer_Input with record
X, Y : GL.Types.Double := 0.0;
Prev_X, Prev_Y : GL.Types.Double := 0.0;
Last_X, Last_Y : GL.Types.Double := 0.0;
Scroll_X : GL.Types.Double := 0.0;
Scroll_Y : GL.Types.Double := 0.0;
Buttons : Button_Array := (others => False);
Locked : Boolean := False;
Visible : Boolean := True;
end record;
end Orka.Inputs.Pointers.Default;
|
faelys/natools | Ada | 5,171 | adb | ------------------------------------------------------------------------------
-- Copyright (c) 2014, 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. --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
package body Natools.HMAC is
function To_Stream_Element_Array (Key : String)
return Ada.Streams.Stream_Element_Array;
pragma Inline (To_Stream_Element_Array);
-- Convert a String into a Stream_Element_Array
function Pad
(Key : Ada.Streams.Stream_Element_Array;
Pattern : Ada.Streams.Stream_Element)
return Ada.Streams.Stream_Element_Array;
-- Scramble Key with the given pattern
Outer_Pattern : constant Ada.Streams.Stream_Element := 16#5C#;
Inner_Pattern : constant Ada.Streams.Stream_Element := 16#36#;
------------------------------
-- Local Helper Subprograms --
------------------------------
function To_Stream_Element_Array (Key : String)
return Ada.Streams.Stream_Element_Array
is
subtype Ad_Hoc_String is String (Key'Range);
subtype Ad_Hoc_Array
is Ada.Streams.Stream_Element_Array (1 .. Key'Length);
function Unchecked_Conversion is new Ada.Unchecked_Conversion
(Ad_Hoc_String, Ad_Hoc_Array);
begin
return Unchecked_Conversion (Key);
end To_Stream_Element_Array;
function Pad
(Key : Ada.Streams.Stream_Element_Array;
Pattern : Ada.Streams.Stream_Element)
return Ada.Streams.Stream_Element_Array
is
use type Ada.Streams.Stream_Element;
Result : Ada.Streams.Stream_Element_Array (Key'Range);
begin
for I in Result'Range loop
Result (I) := Key (I) xor Pattern;
end loop;
return Result;
end Pad;
--------------------
-- HAMC Interface --
--------------------
procedure Setup
(C : out Context;
Key : in Ada.Streams.Stream_Element_Array) is
begin
C := Create (Key);
end Setup;
procedure Setup
(C : out Context;
Key : in String) is
begin
C := Create (Key);
end Setup;
function Create (Key : Ada.Streams.Stream_Element_Array) return Context is
Result : Context
:= (Key => (others => 0),
Hash => Initial_Context);
use type Ada.Streams.Stream_Element_Count;
begin
if Key'Length <= Block_Size_In_SE then
Result.Key (1 .. Key'Length) := Key;
else
declare
Local_Hash : Hash_Context := Initial_Context;
begin
Update (Local_Hash, Key);
declare
Hashed_Key : constant Ada.Streams.Stream_Element_Array
:= Digest (Local_Hash);
begin
Result.Key (1 .. Hashed_Key'Length) := Hashed_Key;
end;
end;
end if;
Update (Result.Hash, Pad (Result.Key, Inner_Pattern));
return Result;
end Create;
function Create (Key : String) return Context is
begin
return Create (To_Stream_Element_Array (Key));
end Create;
procedure Update
(C : in out Context;
Input : in Ada.Streams.Stream_Element_Array) is
begin
Update (C.Hash, Input);
end Update;
procedure Update
(C : in out Context;
Input : in String) is
begin
Update (C.Hash, To_Stream_Element_Array (Input));
end Update;
function Digest (C : Context) return Ada.Streams.Stream_Element_Array is
Local_Hash : Hash_Context := Initial_Context;
begin
Update (Local_Hash, Pad (C.Key, Outer_Pattern));
Update (Local_Hash, Digest (C.Hash));
return Digest (Local_Hash);
end Digest;
function Digest (Key : String; Message : Ada.Streams.Stream_Element_Array)
return Ada.Streams.Stream_Element_Array
is
Local_Context : Context := Create (Key);
begin
Update (Local_Context, Message);
return Digest (Local_Context);
end Digest;
function Digest (Key, Message : Ada.Streams.Stream_Element_Array)
return Ada.Streams.Stream_Element_Array
is
Local_Context : Context := Create (Key);
begin
Update (Local_Context, Message);
return Digest (Local_Context);
end Digest;
end Natools.HMAC;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 587 | adb | with STM32GD.Board; use STM32GD.Board;
procedure Main is
Now : RTC.Date_Time_Type;
Wait_Time : RTC.Second_Delta_Type := 5;
begin
Init;
Text_IO.Put_Line ("RTC Test Starting");
loop
RTC.Read (Now);
LED.Set;
Text_IO.Put ("Seconds: ");
Text_IO.Put_Integer (RTC.To_Seconds (Now));
Text_IO.New_Line;
RTC.Add_Seconds (Now, Wait_Time);
RTC.Set_Alarm (Now);
Text_IO.Put ("Waking up in: ");
Text_IO.Put_Integer (RTC.To_Seconds (Now));
Text_IO.New_Line;
LED.Clear;
RTC.Wait_For_Alarm;
end loop;
end Main;
|
reznikmm/matreshka | Ada | 5,083 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 Matreshka.ODF_String_Constants;
package body Matreshka.ODF_Chart is
------------------
-- Constructors --
------------------
package body Constructors is
----------------
-- Initialize --
----------------
procedure Initialize
(Self : not null access Abstract_Chart_Attribute_Node'Class;
Document : not null Matreshka.DOM_Nodes.Document_Access;
Prefix : League.Strings.Universal_String) is
begin
Matreshka.DOM_Attributes.Constructors.Initialize (Self, Document);
Self.Prefix := Prefix;
end Initialize;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : not null access Abstract_Chart_Element_Node'Class;
Document : not null Matreshka.DOM_Nodes.Document_Access;
Prefix : League.Strings.Universal_String) is
begin
Matreshka.DOM_Elements.Constructors.Initialize (Self, Document);
Self.Prefix := Prefix;
end Initialize;
end Constructors;
-----------------------
-- Get_Namespace_URI --
-----------------------
overriding function Get_Namespace_URI
(Self : not null access constant Abstract_Chart_Attribute_Node)
return League.Strings.Universal_String is
begin
return Matreshka.ODF_String_Constants.Chart_URI;
end Get_Namespace_URI;
-----------------------
-- Get_Namespace_URI --
-----------------------
overriding function Get_Namespace_URI
(Self : not null access constant Abstract_Chart_Element_Node)
return League.Strings.Universal_String is
begin
return Matreshka.ODF_String_Constants.Chart_URI;
end Get_Namespace_URI;
end Matreshka.ODF_Chart;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.