content stringlengths 23 1.05M |
|---|
package Enum1_Pkg is
type Enum is (One, Two, Three);
subtype Sub_Enum is Enum;
My_N : Sub_Enum := One;
end Enum1_Pkg;
|
-- AoC 2020, Day 1
with Ada.Text_IO;
package body Day is
package TIO renames Ada.Text_IO;
function load_file(filename : in String) return Expense_Vector.Vector is
file : TIO.File_Type;
expenses : Expense_Vector.Vector;
begin
TIO.open(File => file, Mode => TIO.In_File, Name => filename);
while not TIO.end_of_file(file) loop
expenses.append(Expense'Value(TIO.get_line(file)));
end loop;
TIO.close(file);
return expenses;
end load_file;
function matching_product(expenses : in Expense_Vector.Vector) return Expense is
begin
i_loop:
for i of expenses loop
j_loop:
for j of expenses loop
if i + j = 2020 then
return i * j;
end if;
end loop j_loop;
end loop i_loop;
return 0;
end matching_product;
function triple_matching_product(expenses : in Expense_Vector.Vector) return Expense is
begin
i_loop:
for i of expenses loop
j_loop:
for j of expenses loop
if i + j < 2020 then
k_loop:
for k of expenses loop
if i + j + k = 2020 then
return i * j * k;
end if;
end loop k_loop;
end if;
end loop j_loop;
end loop i_loop;
return 0;
end triple_matching_product;
-- Find two entries that sum to 2020 and return their product
function part1(filename : in String) return Expense is
expenses : Expense_Vector.Vector;
begin
expenses := load_file(filename);
return matching_product(expenses);
end part1;
-- Find three entries that sum to 2020 and return their product
function part2(filename : in String) return Expense is
expenses : Expense_Vector.Vector;
begin
expenses := load_file(filename);
return triple_matching_product(expenses);
end part2;
end Day;
|
with Interfaces;
with Fmt.Generic_Mod_Int_Argument;
package Fmt.Uint64_Argument is
new Generic_Mod_Int_Argument(Interfaces.Unsigned_64);
|
-- Score PIXAL le 05/10/2020 à 18:21 : 92%
-- Score PIXAL le 07/10/2020 à 15:36 : 100%
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
procedure Ecrire_Entier is
function Puissance_Iteratif (Nombre: in Float ; Exposant : in Integer) return Float with
Pre => Exposant >= 0 or Nombre /= 0.0;
--! Ceci est une déclaration en avant. La fonction Ecrire_Recursive
--! est connue et peut être utilisée (sa signature suffit pour que le
--! compilateur puisse vérifier l'appel)
--!
--! Remarque : les contrats ne doivent apparaître que lors de la première
--! apparition. Ceci évite les redondances toujours sources d'erreurs.
-- Retourne Nombre à la puissance Exposant.
function Puissance_Recursif (Nombre: in Float ; Exposant : in Integer) return Float with
Pre => Exposant >= 0 or Nombre /= 0.0
is
begin
if Exposant = 0 then
return 1.0;
end if;
if Exposant > 0 then
if Exposant mod 2 = 1 then
return Nombre * Puissance_Recursif(Nombre, Exposant - 1);
else
return Puissance_Recursif(Nombre * Nombre, Exposant / 2);
end if;
else
if Exposant mod 2 = 1 then
return Puissance_Recursif(Nombre, Exposant + 1) / Nombre;
else
return Puissance_Recursif(1.0/(Nombre*Nombre), -1*Exposant / 2);
end if;
end if;
end Puissance_Recursif;
function Puissance_Iteratif (Nombre: in Float ; Exposant : in Integer) return Float is
Indice: Integer;
Nbr: Float;
Puissance: Float;
begin
Puissance := 1.0;
Indice := Abs(Exposant);
Nbr := Nombre;
while Indice /= 0 loop
if Indice mod 2 = 1 then
Puissance := Nbr * Puissance;
Indice := Indice - 1;
else
Nbr := Nbr * Nbr;
Indice := Indice / 2;
end if;
end loop;
if Exposant > 0 then
return Puissance;
else
return 1.0/Puissance;
end if;
end Puissance_Iteratif;
Un_Reel: Float; -- un réel lu au clavier
Un_Entier: Integer; -- un entier lu au clavier
begin
-- Demander le réel
Put ("Un nombre réel : ");
Get (Un_Reel);
-- Demander l'entier
Put ("Un nombre entier : ");
Get (Un_Entier);
-- Afficher la puissance en version itérative
if Un_Entier >= 0 or Un_Reel /= 0.0 then
Put ("Puissance (itérative) : ");
Put (Puissance_Iteratif (Un_Reel, Un_Entier), Fore => 0, Exp => 0, Aft => 4);
New_Line;
else
Put_Line("Division par zéro");
end if;
-- Afficher la puissance en version récursive
if Un_Entier >= 0 or Un_Reel /= 0.0 then
Put ("Puissance (récursive) : ");
Put (Puissance_Recursif (Un_Reel, Un_Entier), Fore => 0, Exp => 0, Aft => 4);
New_Line;
else
Put_Line("Division par zéro");
end if;
end Ecrire_Entier;
|
-- --
-- package Copyright (c) Francois Fabien --
-- AdaPcre --
-- Body --
-- --
-- Last revision : 15 Oct 2012 --
-- --
------------------------------------------------------------------------
-- interface to PCRE
--
-- partial binding : substring extraction is not implemented.
--
------------------------------------------------------------------------
with Interfaces.C.Strings; use Interfaces.C.Strings;
with Interfaces.C; use Interfaces.C;
with Ada.Unchecked_Conversion;
with Ada.Strings.Fixed; use Ada.Strings;
with System; use System;
package body AdaPcre is
pragma Linker_Options ("-lpcre");
use Interfaces;
function To_chars_ptr is new Ada.Unchecked_Conversion (Address, chars_ptr);
function Pcre_Compile
(pattern : chars_ptr; option : Options; errptr : access chars_ptr;
erroffset : access Integer; tableptr : Table_Type) return Pcre_Type;
pragma Import (C, Pcre_Compile, "pcre_compile");
procedure Compile
(Matcher : out Pcre_Type; Pattern : String; Error_Msg : out Message;
Last_Msg : out Natural; Error_Offset : out Natural;
Option : Options := 0; Table : Table_Type := Null_Table)
is
Unknown : constant String := "Unknown error in pcre_compile";
Error_Ptr : aliased chars_ptr;
ErrOffset : aliased Integer := 0;
Pat : chars_ptr := New_String (Pattern);
begin
Last_Msg := 0;
Error_Offset := 0;
Matcher :=
Pcre_Compile (Pat, Option, Error_Ptr'Access, ErrOffset'Access, Table);
Free (Pat);
if Matcher = Null_Pcre then
if Error_Ptr /= Null_Ptr then
-- copy C error message to an Ada string.
Last_Msg := Natural (Strlen (Error_Ptr));
Error_Msg (1 .. Last_Msg) := Value (Error_Ptr);
else
-- oops ! no error message is available.
Last_Msg := Unknown'Last;
Error_Msg (1 .. Last_Msg) := Unknown;
end if;
if ErrOffset > 0 then
Error_Offset := ErrOffset;
else
Error_Offset := 0;
end if;
end if;
end Compile;
---------------------------------------------------------
-- Imports of GNAT alloc routines that are thread-safe --
--
-- so there are no dependency on external library
-- like ms*.dll on Windows
---------------------------------------------------------
function Gnat_Malloc (Size : C.size_t) return System.Address;
pragma Import (C, Gnat_Malloc, "__gnat_malloc");
procedure Gnat_Free (Add : System.Address);
pragma Import (C, Gnat_Free, "__gnat_free");
---------------------------------------------------------
-- Exporting the Gnat routines to pcre
---------------------------------------------------------
type Access_Free is access procedure (Item : System.Address);
pragma Convention (C, Access_Free);
Pcre_Free : Access_Free := Gnat_Free'Access;
pragma Export (C, Pcre_Free, "pcre_free");
---------------------------------------------------------
-- Free routines
---------------------------------------------------------
procedure Free (T : Table_Type) is
begin
Pcre_Free (System.Address (T));
end Free;
procedure Free (M : Pcre_Type) is
begin
Pcre_Free (System.Address (M));
end Free;
------------------------------------------------------------
-- If your version is > 8.20 consider using pcre_free_study
------------------------------------------------------------
procedure Free (M : Extra_type) is
begin
Pcre_Free (System.Address (M));
end Free;
function Pcre_Exec
(code : Pcre_Type; extra : Extra_type; subject : chars_ptr;
length : Integer; startoffset : Integer; option : Options;
ovector : System.Address; ovecsize : Integer) return Integer;
pragma Import (C, Pcre_Exec, "pcre_exec");
procedure Match
(Result : out Integer; Match_Vec : out Match_Array; Matcher : Pcre_Type;
Extra : Extra_type := Null_Extra; Subject : String; Length : Natural;
Startoffset : Natural := 0; Option : Options := 0)
is
Match_Size : constant Natural := Match_Vec'Length;
m : array (0 .. Match_Size - 1) of C.int := (others => 0);
pragma Convention (C, m);
pragma Volatile (m); -- used by the C library
-- Passing reference of the subject string (without nul terminator)
-- pcre handle string termination using Length parameter.
Start : constant chars_ptr :=
To_chars_ptr (Subject (Subject'First)'Address);
begin
Result :=
Pcre_Exec
(Matcher, Extra, Start, Length, Startoffset, Option, m (0)'Address,
Match_Size);
for I in 0 .. Match_Size - 1 loop
if m (I) > 0 then
Match_Vec (I) := Integer (m (I));
else
Match_Vec (I) := 0;
end if;
end loop;
end Match;
type Access_Malloc is access function
(Size : C.size_t) return System.Address;
pragma Convention (C, Access_Malloc);
Pcre_Malloc : Access_Malloc := Gnat_Malloc'Access;
pragma Export (C, Pcre_Malloc, "pcre_malloc");
function Pcre_Version return String is
function Pcre_Version return chars_ptr;
pragma Import (C, Pcre_Version, "pcre_version");
begin
return Value (Pcre_Version);
end Pcre_Version;
function Pcre_Study
(code : Pcre_Type; option : Options; errptr : access chars_ptr)
return Extra_type;
pragma Import (C, Pcre_Study, "pcre_study");
procedure Study
(Matcher_Extra : out Extra_type; Code : Pcre_Type;
Error_Msg : out Message; Last_Msg : out Natural; Option : Options := 0)
is
Error_Ptr : aliased chars_ptr;
begin
Last_Msg := 0;
Matcher_Extra := Pcre_Study (Code, Option, Error_Ptr'Access);
if Matcher_Extra = Null_Extra and then Error_Ptr /= Null_Ptr then
-- an error occured
Last_Msg := Natural (Strlen (Error_Ptr));
Error_Msg (1 .. Last_Msg) := Value (Error_Ptr);
end if;
end Study;
begin
-- Assignement of Global data Version
declare
Version_Str : constant String := Pcre_Version;
P : Natural;
begin
P := Fixed.Index (Version_Str (1 .. 5), ".");
Version := Version_Number'Value (Version_Str (1 .. P + 2));
end;
end AdaPcre;
|
package Component_Declaration is
type The_Record is record
The_Component : Integer;
end record;
end Component_Declaration;
|
-- { dg-do compile }
-- { dg-options "-fdump-tree-gimple" }
with Atomic6_Pkg; use Atomic6_Pkg;
procedure Atomic6_8 is
Ptr : Int_Ptr := new Int;
Temp : Integer;
begin
Ptr.all := Counter1;
Counter1 := Ptr.all;
Ptr.all := Int(Timer1);
Timer1 := Integer(Ptr.all);
Temp := Integer(Ptr.all);
Ptr.all := Int(Temp);
end;
-- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&atomic6_pkg__counter1" 1 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&atomic6_pkg__counter2" 0 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&atomic6_pkg__timer1" 1 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&atomic6_pkg__timer2" 0 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&temp" 0 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*ptr" 3 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&atomic6_pkg__counter1" 1 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&atomic6_pkg__counter2" 0 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&atomic6_pkg__timer1" 1 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&atomic6_pkg__timer2" 0 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&temp" 0 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*ptr" 3 "gimple"} }
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Adventofcode.Day_9.Main is
D : Decoder (1024);
Key : Long_Integer := 0;
Answer : Long_Integer := 0;
begin
D.Read ("src/day-9/input.test");
D.Scan (5, Key);
Put_Line (Key'Img);
D.Read ("src/day-9/input.test.2");
D.Scan2 (Key, Answer);
Put_Line (Answer'Img);
D.Read ("src/day-9/input");
D.Scan (25, Key);
Put_Line (Key'Img);
D.Read ("src/day-9/input");
D.Scan2 (Key, Answer);
Put_Line (Answer'Img);
end Adventofcode.Day_9.Main;
|
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
with Apsepp.Generic_Discrete_Operations;
generic
type Index_Type is (<>);
type Element_Type is private;
type Array_Type is array (Index_Type range <>) of Element_Type;
with function "<" (Left, Right : Element_Type) return Boolean;
package Apsepp.Generic_Array_Operations is
package D is new Apsepp.Generic_Discrete_Operations (Index_Type);
function Monotonic_Incr (A : Array_Type;
Strict : Boolean := True) return Boolean
is (for all K in A'Range => K = A'First
or else
A(D.Pr (K)) < A(K)
or else
(
not Strict
and then
A(D.Pr (K)) = A(K)
));
procedure Insert_Incr (A : in out Array_Type;
Max_Insert_Index : Index_Type;
Elem : Element_Type;
Rev : Boolean := False)
with Pre => Monotonic_Incr (A(A'First .. D.Pr (Max_Insert_Index)),
Strict => False)
and then
Max_Insert_Index in A'Range,
Post => Monotonic_Incr (A(A'First .. Max_Insert_Index),
Strict => False);
end Apsepp.Generic_Array_Operations;
|
-- { dg-do run }
procedure alignment2 is
pragma COMPONENT_ALIGNMENT(STORAGE_UNIT);
MAX_LIST_SIZE : constant INTEGER := 128*16;
LEVEL2_SIZE : constant INTEGER := 128;
LEVEL1_SIZE : constant INTEGER
:= (MAX_LIST_SIZE - 1) / LEVEL2_SIZE + 1;
type LEVEL2_ARRAY_TYPE is
array (1..LEVEL2_SIZE) of Integer;
type LEVEL2_TYPE is
record
NUM : INTEGER := 0;
DATA : LEVEL2_ARRAY_TYPE := ( others => 0 );
end record;
type LEVEL2_PTR_TYPE is access all LEVEL2_TYPE;
type LEVEL1_ARRAY_TYPE is
array( 1..LEVEL1_SIZE ) of LEVEL2_PTR_TYPE;
type LEVEL1_TYPE is
record
LAST_LINE : INTEGER := 0;
LEVEL2_PTR : LEVEL1_ARRAY_TYPE;
end record;
L1 : LEVEL1_TYPE;
L2 : aliased LEVEL2_TYPE;
procedure q (LA : in out LEVEL1_ARRAY_TYPE) is
begin
LA (1) := L2'Access;
end;
begin
q (L1.LEVEL2_PTR);
if L1.LEVEL2_PTR (1) /= L2'Access then
raise Program_Error;
end if;
end;
|
with
Asis;
package AdaM.Assist.Query.find_Entities.context_Processing
is
procedure Process_Context
(The_Context : in Asis.Context;
Trace : in Boolean := False);
function Get_Unit_From_File_Name
(Ada_File_Name : in String;
The_Context : in Asis.Context) return Asis.Compilation_Unit;
end AdaM.Assist.Query.find_Entities.context_Processing;
|
with
gel.Sprite;
package gel.Dolly.following
--
-- Provides a camera dolly which follows a sprite.
--
is
type Item is new gel.Dolly.item with private;
type View is access all Item'Class;
---------
--- Forge
--
overriding
procedure define (Self : in out Item);
overriding
procedure destroy (Self : in out Item);
--------------
--- Attributes
--
overriding
procedure allow_linear_Motion (Self : in out Item; Allow : in Boolean := True);
overriding
procedure allow_orbital_Motion (Self : in out Item; Allow : in Boolean := True);
procedure Offset_is (Self : in out Item; Now : in math.Vector_3);
function Offset (Self : in Item) return math.Vector_3;
--------------
--- Operations
--
overriding
procedure freshen (Self : in out Item);
procedure follow (Self : in out Item; the_Sprite : in gel.Sprite.view);
private
type Item is new gel.Dolly.item with
record
Sprite : gel.Sprite.view;
sprite_Offset : math.Vector_3 := (0.0, 30.0, 0.0);
allow_linear_Motion : Boolean := True;
allow_orbital_Motion : Boolean := True;
camera_x_Spin : math.Real := 0.0;
camera_y_Spin : math.Real := 0.0;
camera_z_Spin : math.Real := 0.0;
end record;
end gel.Dolly.following;
|
-----------------------------------------------------------------------
-- util-http-clients-web -- HTTP Clients with AWS implementation
-- Copyright (C) 2011, 2012 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
private with AWS.Headers;
private with AWS.Response;
package Util.Http.Clients.Web is
-- Register the Http manager.
procedure Register;
private
type AWS_Http_Manager is new Http_Manager with null record;
type AWS_Http_Manager_Access is access all Http_Manager'Class;
procedure Create (Manager : in AWS_Http_Manager;
Http : in out Client'Class);
procedure Do_Get (Manager : in AWS_Http_Manager;
Http : in Client'Class;
URI : in String;
Reply : out Response'Class);
procedure Do_Post (Manager : in AWS_Http_Manager;
Http : in Client'Class;
URI : in String;
Data : in String;
Reply : out Response'Class);
type AWS_Http_Request is new Http_Request with record
Headers : AWS.Headers.List;
end record;
type AWS_Http_Request_Access is access all AWS_Http_Request'Class;
-- Returns a boolean indicating whether the named request header has already
-- been set.
overriding
function Contains_Header (Http : in AWS_Http_Request;
Name : in String) return Boolean;
-- Returns the value of the specified request header as a String. If the request
-- did not include a header of the specified name, this method returns null.
-- If there are multiple headers with the same name, this method returns the
-- first head in the request. The header name is case insensitive. You can use
-- this method with any response header.
overriding
function Get_Header (Request : in AWS_Http_Request;
Name : in String) return String;
-- Sets a request header with the given name and value. If the header had already
-- been set, the new value overwrites the previous one. The containsHeader
-- method can be used to test for the presence of a header before setting its value.
overriding
procedure Set_Header (Http : in out AWS_Http_Request;
Name : in String;
Value : in String);
-- Adds a request header with the given name and value.
-- This method allows request headers to have multiple values.
overriding
procedure Add_Header (Http : in out AWS_Http_Request;
Name : in String;
Value : in String);
-- Iterate over the request headers and executes the <b>Process</b> procedure.
overriding
procedure Iterate_Headers (Request : in AWS_Http_Request;
Process : not null access
procedure (Name : in String;
Value : in String));
type AWS_Http_Response is new Http_Response with record
Data : AWS.Response.Data;
end record;
type AWS_Http_Response_Access is access all AWS_Http_Response'Class;
-- Returns a boolean indicating whether the named response header has already
-- been set.
overriding
function Contains_Header (Reply : in AWS_Http_Response;
Name : in String) return Boolean;
-- Returns the value of the specified response header as a String. If the response
-- did not include a header of the specified name, this method returns null.
-- If there are multiple headers with the same name, this method returns the
-- first head in the request. The header name is case insensitive. You can use
-- this method with any response header.
overriding
function Get_Header (Reply : in AWS_Http_Response;
Name : in String) return String;
-- Sets a message header with the given name and value. If the header had already
-- been set, the new value overwrites the previous one. The containsHeader
-- method can be used to test for the presence of a header before setting its value.
overriding
procedure Set_Header (Reply : in out AWS_Http_Response;
Name : in String;
Value : in String);
-- Adds a request header with the given name and value.
-- This method allows request headers to have multiple values.
overriding
procedure Add_Header (Reply : in out AWS_Http_Response;
Name : in String;
Value : in String);
-- Iterate over the response headers and executes the <b>Process</b> procedure.
overriding
procedure Iterate_Headers (Reply : in AWS_Http_Response;
Process : not null access
procedure (Name : in String;
Value : in String));
-- Get the response body as a string.
function Get_Body (Reply : in AWS_Http_Response) return String;
-- Get the response status code.
overriding
function Get_Status (Reply : in AWS_Http_Response) return Natural;
end Util.Http.Clients.Web;
|
with agar.core.timeout;
package agar.gui.widget.slider is
use type c.unsigned;
type flags_t is new c.unsigned;
SLIDER_HFILL : constant flags_t := 16#01#;
SLIDER_VFILL : constant flags_t := 16#02#;
SLIDER_FOCUSABLE : constant flags_t := 16#04#;
SLIDER_EXPAND : constant flags_t := SLIDER_HFILL or SLIDER_VFILL;
type type_t is (SLIDER_HORIZ, SLIDER_VERT);
for type_t use (SLIDER_HORIZ => 0, SLIDER_VERT => 1);
for type_t'size use c.unsigned'size;
pragma convention (c, type_t);
type button_t is (
SLIDER_BUTTON_NONE,
SLIDER_BUTTON_DEC,
SLIDER_BUTTON_INC,
SLIDER_BUTTON_SCROLL
);
for button_t use (
SLIDER_BUTTON_NONE => 0,
SLIDER_BUTTON_DEC => 1,
SLIDER_BUTTON_INC => 2,
SLIDER_BUTTON_SCROLL => 3
);
for button_t'size use c.unsigned'size;
pragma convention (c, button_t);
type slider_t is limited private;
type slider_access_t is access all slider_t;
pragma convention (c, slider_access_t);
-- API
function allocate_integer
(parent : widget_access_t;
bar_type : type_t;
flags : flags_t;
value : agar.core.types.integer_access_t;
min : agar.core.types.integer_access_t;
max : agar.core.types.integer_access_t) return slider_access_t;
pragma import (c, allocate_integer, "AG_SliderNewInt");
function allocate_unsigned
(parent : widget_access_t;
bar_type : type_t;
flags : flags_t;
value : agar.core.types.unsigned_access_t;
min : agar.core.types.unsigned_access_t;
max : agar.core.types.unsigned_access_t) return slider_access_t;
pragma import (c, allocate_unsigned, "AG_SliderNewUint");
function allocate_float
(parent : widget_access_t;
bar_type : type_t;
flags : flags_t;
value : agar.core.types.float_access_t;
min : agar.core.types.float_access_t;
max : agar.core.types.float_access_t) return slider_access_t;
pragma import (c, allocate_float, "AG_SliderNewFloat");
function allocate_double
(parent : widget_access_t;
bar_type : type_t;
flags : flags_t;
value : agar.core.types.double_access_t;
min : agar.core.types.double_access_t;
max : agar.core.types.double_access_t) return slider_access_t;
pragma import (c, allocate_double, "AG_SliderNewDouble");
function allocate_uint8
(parent : widget_access_t;
bar_type : type_t;
flags : flags_t;
value : agar.core.types.uint8_ptr_t;
min : agar.core.types.uint8_ptr_t;
max : agar.core.types.uint8_ptr_t) return slider_access_t;
pragma import (c, allocate_uint8, "AG_SliderNewUint8");
function allocate_int8
(parent : widget_access_t;
bar_type : type_t;
flags : flags_t;
value : agar.core.types.int8_ptr_t;
min : agar.core.types.int8_ptr_t;
max : agar.core.types.int8_ptr_t) return slider_access_t;
pragma import (c, allocate_int8, "AG_SliderNewSint8");
function allocate_uint16
(parent : widget_access_t;
bar_type : type_t;
flags : flags_t;
value : agar.core.types.uint16_ptr_t;
min : agar.core.types.uint16_ptr_t;
max : agar.core.types.uint16_ptr_t) return slider_access_t;
pragma import (c, allocate_uint16, "AG_SliderNewUint16");
function allocate_int16
(parent : widget_access_t;
bar_type : type_t;
flags : flags_t;
value : agar.core.types.int16_ptr_t;
min : agar.core.types.int16_ptr_t;
max : agar.core.types.int16_ptr_t) return slider_access_t;
pragma import (c, allocate_int16, "AG_SliderNewSint16");
function allocate_uint32
(parent : widget_access_t;
bar_type : type_t;
flags : flags_t;
value : agar.core.types.uint32_ptr_t;
min : agar.core.types.uint32_ptr_t;
max : agar.core.types.uint32_ptr_t) return slider_access_t;
pragma import (c, allocate_uint32, "AG_SliderNewUint32");
function allocate_int32
(parent : widget_access_t;
bar_type : type_t;
flags : flags_t;
value : agar.core.types.int32_ptr_t;
min : agar.core.types.int32_ptr_t;
max : agar.core.types.int32_ptr_t) return slider_access_t;
pragma import (c, allocate_int32, "AG_SliderNewSint32");
procedure set_increment
(slider : slider_access_t;
increment : positive);
pragma inline (set_increment);
procedure set_increment
(slider : slider_access_t;
increment : long_float);
pragma inline (set_increment);
function widget (slider : slider_access_t) return widget_access_t;
pragma inline (widget);
private
type slider_t is record
widget : aliased widget_t;
flags : flags_t;
value : c.int;
min : c.int;
max : c.int;
slider_type : type_t;
ctl_pressed : c.int;
w_control_pref : c.int;
w_control : c.int;
inc_to : agar.core.timeout.timeout_t;
dec_to : agar.core.timeout.timeout_t;
x_offset : c.int;
extent : c.int;
r_inc : c.double;
i_inc : c.int;
end record;
pragma convention (c, slider_t);
end agar.gui.widget.slider;
|
-----------------------------------------------------------------------
-- awa-storages-beans -- Storage Ada Beans
-- Copyright (C) 2012, 2013, 2016 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Containers;
with ADO.Utils;
with ADO.Queries;
with ADO.Sessions;
with ADO.Objects;
with ADO.Sessions.Entities;
with AWA.Helpers.Requests;
with AWA.Workspaces.Models;
with AWA.Services.Contexts;
with AWA.Storages.Services;
package body AWA.Storages.Beans is
-- ------------------------------
-- Get the value identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Upload_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "folderId" then
return ADO.Utils.To_Object (From.Folder_Id);
elsif From.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return AWA.Storages.Models.Storage_Ref (From).Get_Value (Name);
end if;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name.
-- ------------------------------
overriding
procedure Set_Value (From : in out Upload_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
Manager : constant Services.Storage_Service_Access := From.Module.Get_Storage_Manager;
Folder : Models.Storage_Folder_Ref;
Found : Boolean;
begin
if Name = "folderId" then
From.Folder_Id := ADO.Utils.To_Identifier (Value);
Manager.Load_Folder (Folder, From.Folder_Id);
From.Set_Folder (Folder);
elsif Name = "id" and then not Util.Beans.Objects.Is_Empty (Value) then
Manager.Load_Storage (From, ADO.Utils.To_Identifier (Value));
elsif Name = "name" then
Folder := Models.Storage_Folder_Ref (From.Get_Folder);
Manager.Load_Storage (From, From.Folder_Id, Util.Beans.Objects.To_String (Value), Found);
if not Found then
From.Set_Name (Util.Beans.Objects.To_String (Value));
end if;
From.Set_Folder (Folder);
end if;
end Set_Value;
-- ------------------------------
-- Save the uploaded file in the storage service.
-- ------------------------------
procedure Save_Part (Bean : in out Upload_Bean;
Part : in ASF.Parts.Part'Class) is
Manager : constant Services.Storage_Service_Access := Bean.Module.Get_Storage_Manager;
Name : constant String := Bean.Get_Name;
begin
if Name'Length = 0 then
Bean.Set_Name (Part.Get_Name);
end if;
Bean.Set_Mime_Type (Part.Get_Content_Type);
Bean.Set_File_Size (Part.Get_Size);
Manager.Save (Bean, Part, AWA.Storages.Models.DATABASE);
end Save_Part;
-- ------------------------------
-- Upload the file.
-- ------------------------------
procedure Upload (Bean : in out Upload_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
pragma Unreferenced (Bean);
begin
Outcome := Ada.Strings.Unbounded.To_Unbounded_String ("success");
end Upload;
-- ------------------------------
-- Delete the file.
-- ------------------------------
procedure Delete (Bean : in out Upload_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
Manager : constant Services.Storage_Service_Access := Bean.Module.Get_Storage_Manager;
begin
Manager.Delete (Bean);
Outcome := Ada.Strings.Unbounded.To_Unbounded_String ("success");
end Delete;
-- ------------------------------
-- Publish the file.
-- ------------------------------
overriding
procedure Publish (Bean : in out Upload_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
Manager : constant Services.Storage_Service_Access := Bean.Module.Get_Storage_Manager;
Id : constant ADO.Identifier := Helpers.Requests.Get_Parameter ("id");
Value : constant Util.Beans.Objects.Object := Helpers.Requests.Get_Parameter ("status");
begin
Manager.Publish (Id, Util.Beans.Objects.To_Boolean (Value), Bean);
Outcome := Ada.Strings.Unbounded.To_Unbounded_String ("success");
end Publish;
-- ------------------------------
-- Create the Upload_Bean bean instance.
-- ------------------------------
function Create_Upload_Bean (Module : in AWA.Storages.Modules.Storage_Module_Access)
return Util.Beans.Basic.Readonly_Bean_Access is
Result : constant Upload_Bean_Access := new Upload_Bean;
begin
Result.Module := Module;
return Result.all'Access;
end Create_Upload_Bean;
-- ------------------------------
-- Get the value identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Folder_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if ADO.Objects.Is_Null (From) then
return Util.Beans.Objects.Null_Object;
else
return AWA.Storages.Models.Storage_Folder_Ref (From).Get_Value (Name);
end if;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name.
-- ------------------------------
overriding
procedure Set_Value (From : in out Folder_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "name" then
From.Set_Name (Util.Beans.Objects.To_String (Value));
end if;
end Set_Value;
-- ------------------------------
-- Create or save the folder.
-- ------------------------------
procedure Save (Bean : in out Folder_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
Manager : constant Services.Storage_Service_Access := Bean.Module.Get_Storage_Manager;
begin
Manager.Save_Folder (Bean);
Outcome := Ada.Strings.Unbounded.To_Unbounded_String ("success");
end Save;
-- ------------------------------
-- Load the folder instance.
-- ------------------------------
procedure Load_Folder (Storage : in Storage_List_Bean) is
use AWA.Storages.Models;
use AWA.Services;
use type Ada.Containers.Count_Type;
Manager : constant Services.Storage_Service_Access := Storage.Module.Get_Storage_Manager;
begin
Load_Folders (Storage);
if Storage.Folder_List.List.Length > 0 then
Manager.Load_Folder (Storage.Folder_Bean.all,
Storage.Folder_List.List.Element (0).Id);
end if;
Storage.Flags (INIT_FOLDER) := True;
end Load_Folder;
-- ------------------------------
-- Load the list of folders.
-- ------------------------------
procedure Load_Folders (Storage : in Storage_List_Bean) is
use AWA.Storages.Models;
use AWA.Services;
use type ADO.Identifier;
Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
User : constant ADO.Identifier := Ctx.Get_User_Identifier;
Session : ADO.Sessions.Session := Storage.Module.Get_Session;
Query : ADO.Queries.Context;
begin
Query.Set_Query (AWA.Storages.Models.Query_Storage_Folder_List);
Query.Bind_Param ("user_id", User);
ADO.Sessions.Entities.Bind_Param (Query, "table",
AWA.Workspaces.Models.WORKSPACE_TABLE, Session);
AWA.Storages.Models.List (Storage.Folder_List_Bean.all, Session, Query);
Storage.Flags (INIT_FOLDER_LIST) := True;
end Load_Folders;
-- ------------------------------
-- Load the list of files associated with the current folder.
-- ------------------------------
procedure Load_Files (Storage : in Storage_List_Bean) is
use AWA.Storages.Models;
use AWA.Services;
Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
User : constant ADO.Identifier := Ctx.Get_User_Identifier;
Session : ADO.Sessions.Session := Storage.Module.Get_Session;
Query : ADO.Queries.Context;
begin
if not Storage.Init_Flags (INIT_FOLDER) then
Load_Folder (Storage);
end if;
Query.Set_Query (AWA.Storages.Models.Query_Storage_List);
Query.Bind_Param ("user_id", User);
ADO.Sessions.Entities.Bind_Param (Query, "table",
AWA.Workspaces.Models.WORKSPACE_TABLE, Session);
if Storage.Folder_Bean.Is_Null then
Query.Bind_Null_Param ("folder_id");
else
Query.Bind_Param ("folder_id", Storage.Folder_Bean.Get_Id);
end if;
AWA.Storages.Models.List (Storage.Files_List_Bean.all, Session, Query);
Storage.Flags (INIT_FILE_LIST) := True;
end Load_Files;
-- ------------------------------
-- Set the value identified by the name.
-- ------------------------------
overriding
procedure Set_Value (From : in out Storage_List_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
Manager : constant Services.Storage_Service_Access := From.Module.Get_Storage_Manager;
begin
if Name = "folderId" and not Util.Beans.Objects.Is_Empty (Value) then
Manager.Load_Folder (From.Folder, ADO.Identifier (Util.Beans.Objects.To_Integer (Value)));
From.Flags (INIT_FOLDER) := True;
end if;
end Set_Value;
overriding
function Get_Value (List : in Storage_List_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "files" then
if not List.Init_Flags (INIT_FILE_LIST) then
Load_Files (List);
end if;
return Util.Beans.Objects.To_Object (Value => List.Files_List_Bean,
Storage => Util.Beans.Objects.STATIC);
elsif Name = "folders" then
if not List.Init_Flags (INIT_FOLDER_LIST) then
Load_Folders (List);
end if;
return Util.Beans.Objects.To_Object (Value => List.Folder_List_Bean,
Storage => Util.Beans.Objects.STATIC);
elsif Name = "folder" then
if not List.Init_Flags (INIT_FOLDER) then
Load_Folder (List);
end if;
if List.Folder_Bean.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
return Util.Beans.Objects.To_Object (Value => List.Folder_Bean,
Storage => Util.Beans.Objects.STATIC);
else
return Util.Beans.Objects.Null_Object;
end if;
end Get_Value;
-- ------------------------------
-- Load the files and folder information.
-- ------------------------------
overriding
procedure Load (List : in out Storage_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
pragma Unreferenced (Outcome);
begin
Storage_List_Bean'Class (List).Load_Folders;
Storage_List_Bean'Class (List).Load_Files;
end Load;
-- ------------------------------
-- Create the Folder_List_Bean bean instance.
-- ------------------------------
function Create_Folder_List_Bean (Module : in AWA.Storages.Modules.Storage_Module_Access)
return Util.Beans.Basic.Readonly_Bean_Access is
use AWA.Storages.Models;
use AWA.Services;
use type ADO.Identifier;
Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
User : constant ADO.Identifier := Ctx.Get_User_Identifier;
Object : constant Folder_Info_List_Bean_Access := new Folder_Info_List_Bean;
Session : ADO.Sessions.Session := Module.Get_Session;
Query : ADO.Queries.Context;
begin
Query.Set_Query (AWA.Storages.Models.Query_Storage_Folder_List);
Query.Bind_Param ("user_id", User);
ADO.Sessions.Entities.Bind_Param (Query, "table",
AWA.Workspaces.Models.WORKSPACE_TABLE, Session);
AWA.Storages.Models.List (Object.all, Session, Query);
return Object.all'Access;
end Create_Folder_List_Bean;
-- ------------------------------
-- Create the Storage_List_Bean bean instance.
-- ------------------------------
function Create_Storage_List_Bean (Module : in AWA.Storages.Modules.Storage_Module_Access)
return Util.Beans.Basic.Readonly_Bean_Access is
Object : constant Storage_List_Bean_Access := new Storage_List_Bean;
begin
Object.Module := Module;
Object.Folder_Bean := Object.Folder'Access;
Object.Folder_List_Bean := Object.Folder_List'Access;
Object.Files_List_Bean := Object.Files_List'Access;
Object.Flags := Object.Init_Flags'Access;
return Object.all'Access;
end Create_Storage_List_Bean;
end AWA.Storages.Beans;
|
-------------------------------------------------------------------------------
-- This file is part of libsparkcrypto.
--
-- @author Alexander Senier
-- @date 2019-01-16
--
-- Copyright (C) 2018 Componolit GmbH
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
--
-- * Neither the name of the nor the names of its contributors may be used
-- to endorse or promote products derived from this software without
-- specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
-- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with AUnit.Assertions; use AUnit.Assertions;
with Util;
with LSC.Types;
pragma Style_Checks (Off);
package body Util_Tests
is
use type LSC.Types.Bytes;
pragma Warnings (Off, "formal parameter ""T"" is not referenced");
procedure Test_Bytes_To_String_Simple (T : in out Test_Cases.Test_Case'Class)
is
Result : constant String := Util.B2S ((16#de#, 16#ad#, 16#be#, 16#ef#));
begin
Assert (Result = "deadbeef", "Invalid result: " & Result);
end Test_Bytes_To_String_Simple;
---------------------------------------------------------------------------
procedure Test_Bytes_To_String_Odd (T : in out Test_Cases.Test_Case'Class)
is
Result : constant String := Util.B2S ((16#c#, 16#af#, 16#ef#, 16#ee#));
begin
Assert (Result = "cafefee", "Invalid result: " & Result);
end Test_Bytes_To_String_Odd;
---------------------------------------------------------------------------
procedure Test_String_To_Bytes_Simple (T : in out Test_Cases.Test_Case'Class)
is
Result : constant LSC.Types.Bytes := Util.S2B ("deadbeef");
begin
Assert (Result = (16#de#, 16#ad#, 16#be#, 16#ef#), "Invalid result: " & Util.B2S (Result));
end Test_String_To_Bytes_Simple;
---------------------------------------------------------------------------
procedure Test_String_To_Bytes_Whitespace (T : in out Test_Cases.Test_Case'Class)
is
Result : constant LSC.Types.Bytes := Util.S2B ("01 23" & ASCII.HT & "45 67 89 ab cd ef");
begin
Assert (Result = (16#01#, 16#23#, 16#45#, 16#67#, 16#89#, 16#ab#, 16#cd#, 16#ef#),
"Invalid result: " & Util.B2S (Result));
end Test_String_To_Bytes_Whitespace;
---------------------------------------------------------------------------
procedure Test_String_To_Bytes_Odd (T : in out Test_Cases.Test_Case'Class)
is
Result : constant LSC.Types.Bytes := Util.S2B ("dead bee"); -- ;-(
begin
Assert (Result = (16#d#, 16#ea#, 16#db#, 16#ee#), "Invalid result: " & Util.B2S (Result));
end Test_String_To_Bytes_Odd;
---------------------------------------------------------------------------
procedure Test_String_To_Bytes_Surrounding (T : in out Test_Cases.Test_Case'Class)
is
Result : constant LSC.Types.Bytes := Util.S2B (" 0123456789abcdef" & ASCII.HT & " ");
begin
Assert (Result = (16#01#, 16#23#, 16#45#, 16#67#, 16#89#, 16#ab#, 16#cd#, 16#ef#),
"Invalid result: " & Util.B2S (Result));
end Test_String_To_Bytes_Surrounding;
---------------------------------------------------------------------------
procedure Test_String_To_Bytes_Uppercase (T : in out Test_Cases.Test_Case'Class)
is
Result : constant LSC.Types.Bytes := Util.S2B ("ADF3456789aBCdEf");
begin
Assert (Result = (16#ad#, 16#f3#, 16#45#, 16#67#, 16#89#, 16#ab#, 16#cd#, 16#ef#),
"Invalid result: " & Util.B2S (Result));
end Test_String_To_Bytes_Uppercase;
---------------------------------------------------------------------------
procedure Invalid_Conversion
is
Result : constant LSC.Types.Bytes := Util.S2B ("An invalid hex string does not belong here!");
pragma Unreferenced (Result);
begin
null;
end Invalid_Conversion;
procedure Test_String_To_Bytes_Invalid (T : in out Test_Cases.Test_Case'Class)
is
begin
Assert_Exception (Invalid_Conversion'Access, "Exception expected");
end Test_String_To_Bytes_Invalid;
---------------------------------------------------------------------------
procedure Test_Text_To_Bytes_Simple (T : in out Test_Cases.Test_Case'Class)
is
Result : constant LSC.Types.Bytes := Util.T2B ("Dead Beef!");
begin
Assert (Result = (16#44#, 16#65#, 16#61#, 16#64#, 16#20#,
16#42#, 16#65#, 16#65#, 16#66#, 16#21#), "Invalid result: " & Util.B2S (Result));
end Test_Text_To_Bytes_Simple;
---------------------------------------------------------------------------
procedure Test_Bytes_To_Text_Simple (T : in out Test_Cases.Test_Case'Class)
is
Result : constant String := Util.B2T ((16#44#, 16#65#, 16#61#, 16#64#, 16#20#,
16#42#, 16#65#, 16#65#, 16#66#, 16#21#));
begin
Assert (Result = "Dead Beef!", "Invalid result: " & Result);
end Test_Bytes_To_Text_Simple;
---------------------------------------------------------------------------
procedure Test_Bytes_To_Text_To_Bytes (T : in out Test_Cases.Test_Case'Class)
is
Expected : constant LSC.Types.Bytes :=
(16#0B#, 16#46#, 16#D9#, 16#8D#, 16#A1#, 16#04#, 16#64#, 16#84#,
16#60#, 16#55#, 16#8B#, 16#3F#, 16#2B#, 16#22#, 16#4E#, 16#FE#,
16#CB#, 16#EF#, 16#32#, 16#95#, 16#A7#, 16#0E#, 16#E0#, 16#E9#,
16#CA#, 16#79#, 16#28#, 16#C9#, 16#8B#, 16#31#, 16#64#, 16#81#,
16#93#, 16#85#, 16#56#, 16#B2#, 16#28#, 16#22#, 16#A7#, 16#55#,
16#BA#, 16#4D#, 16#B2#, 16#90#, 16#D3#, 16#E4#, 16#D7#, 16#9F#);
Result : constant LSC.Types.Bytes := Util.T2B (Util.B2T (Expected));
begin
Assert (Result = Expected, "Invalid result: " & Util.B2S (Result));
end Test_Bytes_To_Text_To_Bytes;
---------------------------------------------------------------------------
procedure Test_Text_To_Bytes_To_Text (T : in out Test_Cases.Test_Case'Class)
is
Expected : constant String :=
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do "&
"eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim " &
"ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " &
"aliquip ex ea commodo consequat. Duis aute irure dolor in";
Result : constant String := Util.B2T (Util.T2B (Expected));
begin
Assert (Result = Expected, "Invalid result: " & Result);
end Test_Text_To_Bytes_To_Text;
---------------------------------------------------------------------------
procedure Register_Tests (T: in out Test_Case) is
use AUnit.Test_Cases.Registration;
begin
Register_Routine (T, Test_Bytes_To_String_Simple'Access, "Bytes to string (simple)");
Register_Routine (T, Test_Bytes_To_String_Odd'Access, "Bytes to string (odd)");
Register_Routine (T, Test_String_To_Bytes_Simple'Access, "String to bytes (simple)");
Register_Routine (T, Test_String_To_Bytes_Whitespace'Access, "String to bytes (whitespace)");
Register_Routine (T, Test_String_To_Bytes_Odd'Access, "String to bytes (odd)");
Register_Routine (T, Test_String_To_Bytes_Surrounding'Access, "String to bytes (surrounding whitespace)");
Register_Routine (T, Test_String_To_Bytes_Uppercase'Access, "String to bytes (uppercase)");
Register_Routine (T, Test_String_To_Bytes_Invalid'Access, "String to bytes (invalid)");
Register_Routine (T, Test_Text_To_Bytes_Simple'Access, "Text to bytes (simple)");
Register_Routine (T, Test_Bytes_To_Text_Simple'Access, "Bytes to text (simple)");
Register_Routine (T, Test_Bytes_To_Text_To_Bytes'Access, "Bytes to text to bytes");
Register_Routine (T, Test_Text_To_Bytes_To_Text'Access, "Text to bytes to text");
end Register_Tests;
---------------------------------------------------------------------------
function Name (T : Test_Case) return Test_String is
begin
return Format ("Utils");
end Name;
end Util_Tests;
|
with Ada.Numerics; use Ada.Numerics;
with System;
package Init13 is
type Complex is record
R : Float;
I : Float;
end record;
pragma Complex_Representation (Complex);
type R1 is record
F : Complex;
end record;
for R1'Bit_Order use System.Low_Order_First;
for R1'Scalar_Storage_Order use System.Low_Order_First;
for R1 use record
F at 0 range 0 .. 63;
end record;
type R2 is record
F : Complex;
end record;
for R2'Bit_Order use System.High_Order_First;
for R2'Scalar_Storage_Order use System.High_Order_First;
for R2 use record
F at 0 range 0 .. 63;
end record;
My_R1 : constant R1 := (F => (Pi, -Pi));
My_R2 : constant R2 := (F => (Pi, -Pi));
end Init13;
|
package surface.elements is
procedure quad (X,Y, Width, Height : Integer ; Border : Boolean := False);
procedure print (X,Y : Integer; Text : String; Size : Integer := 16);
end surface.elements;
|
with Ada.Real_Time; use Ada.Real_Time;
with STM32GD.Board; use STM32GD.Board;
procedure Main is
Next_Release : Time := Clock;
Period : constant Time_Span := Milliseconds (500);
begin
Init;
LED.Set;
Text_IO.Put_Line ("Starting");
loop
Text_IO.Put_Line ("Waiting");
Next_Release := Next_Release + Period;
delay until Next_Release;
LED.Toggle;
end loop;
end Main;
|
-----------------------------------------------------------------------
-- security-random -- Random numbers for nonce, secret keys, token generation
-- Copyright (C) 2017 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Streams;
with Ada.Finalization;
with Interfaces;
with Util.Encoders.AES;
private with Ada.Numerics.Discrete_Random;
-- == Random Generator ==
-- The <tt>Security.Random</tt> package defines the <tt>Generator</tt> tagged type
-- which provides operations to generate random tokens intended to be used for
-- a nonce, access token, salt or other purposes. The generator is intended to be
-- used in multi-task environments as it implements the low level random generation
-- within a protected type. The generator defines a <tt>Generate</tt> operation
-- that returns either a binary random array or the base64url encoding of the
-- binary array.
package Keystore.Random is
type Generator is limited new Ada.Finalization.Limited_Controlled with private;
-- Initialize the random generator.
overriding
procedure Initialize (Gen : in out Generator);
-- Fill the array with pseudo-random numbers.
procedure Generate (Gen : in out Generator;
Into : out Ada.Streams.Stream_Element_Array);
-- Fill the secret with pseudo-random numbers.
procedure Generate (Gen : in out Generator;
Into : out Secret_Key);
procedure Generate (Gen : in out Generator;
Into : out UUID_Type);
-- Generate a random sequence of bits and convert the result
-- into a string in base64url.
function Generate (Gen : in out Generator'Class;
Bits : in Positive) return String;
function Generate (Gen : in out Generator'Class) return Interfaces.Unsigned_32;
private
package Id_Random is new Ada.Numerics.Discrete_Random (Interfaces.Unsigned_32);
-- Protected type to allow using the random generator by several tasks.
protected type Raw_Generator is
procedure Generate (Into : out Ada.Streams.Stream_Element_Array);
procedure Generate (Value : out Interfaces.Unsigned_32);
procedure Reset;
private
-- Random number generator used for ID generation.
Rand : Id_Random.Generator;
end Raw_Generator;
type Generator is limited new Ada.Finalization.Limited_Controlled with record
Rand : Raw_Generator;
end record;
end Keystore.Random;
|
-- This spec has been automatically generated from STM32F40x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.SDIO is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype POWER_PWRCTRL_Field is HAL.UInt2;
-- power control register
type POWER_Register is record
-- PWRCTRL
PWRCTRL : POWER_PWRCTRL_Field := 16#0#;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for POWER_Register use record
PWRCTRL at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
subtype CLKCR_CLKDIV_Field is HAL.UInt8;
subtype CLKCR_WIDBUS_Field is HAL.UInt2;
-- SDI clock control register
type CLKCR_Register is record
-- Clock divide factor
CLKDIV : CLKCR_CLKDIV_Field := 16#0#;
-- Clock enable bit
CLKEN : Boolean := False;
-- Power saving configuration bit
PWRSAV : Boolean := False;
-- Clock divider bypass enable bit
BYPASS : Boolean := False;
-- Wide bus mode enable bit
WIDBUS : CLKCR_WIDBUS_Field := 16#0#;
-- SDIO_CK dephasing selection bit
NEGEDGE : Boolean := False;
-- HW Flow Control enable
HWFC_EN : Boolean := False;
-- unspecified
Reserved_15_31 : HAL.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CLKCR_Register use record
CLKDIV at 0 range 0 .. 7;
CLKEN at 0 range 8 .. 8;
PWRSAV at 0 range 9 .. 9;
BYPASS at 0 range 10 .. 10;
WIDBUS at 0 range 11 .. 12;
NEGEDGE at 0 range 13 .. 13;
HWFC_EN at 0 range 14 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
subtype CMD_CMDINDEX_Field is HAL.UInt6;
subtype CMD_WAITRESP_Field is HAL.UInt2;
-- command register
type CMD_Register is record
-- Command index
CMDINDEX : CMD_CMDINDEX_Field := 16#0#;
-- Wait for response bits
WAITRESP : CMD_WAITRESP_Field := 16#0#;
-- CPSM waits for interrupt request
WAITINT : Boolean := False;
-- CPSM Waits for ends of data transfer (CmdPend internal signal).
WAITPEND : Boolean := False;
-- Command path state machine (CPSM) Enable bit
CPSMEN : Boolean := False;
-- SD I/O suspend command
SDIOSuspend : Boolean := False;
-- Enable CMD completion
ENCMDcompl : Boolean := False;
-- not Interrupt Enable
nIEN : Boolean := False;
-- CE-ATA command
CE_ATACMD : Boolean := False;
-- unspecified
Reserved_15_31 : HAL.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CMD_Register use record
CMDINDEX at 0 range 0 .. 5;
WAITRESP at 0 range 6 .. 7;
WAITINT at 0 range 8 .. 8;
WAITPEND at 0 range 9 .. 9;
CPSMEN at 0 range 10 .. 10;
SDIOSuspend at 0 range 11 .. 11;
ENCMDcompl at 0 range 12 .. 12;
nIEN at 0 range 13 .. 13;
CE_ATACMD at 0 range 14 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
subtype RESPCMD_RESPCMD_Field is HAL.UInt6;
-- command response register
type RESPCMD_Register is record
-- Read-only. Response command index
RESPCMD : RESPCMD_RESPCMD_Field;
-- unspecified
Reserved_6_31 : HAL.UInt26;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RESPCMD_Register use record
RESPCMD at 0 range 0 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
subtype DLEN_DATALENGTH_Field is HAL.UInt25;
-- data length register
type DLEN_Register is record
-- Data length value
DATALENGTH : DLEN_DATALENGTH_Field := 16#0#;
-- unspecified
Reserved_25_31 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DLEN_Register use record
DATALENGTH at 0 range 0 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
subtype DCTRL_DBLOCKSIZE_Field is HAL.UInt4;
-- data control register
type DCTRL_Register is record
-- DTEN
DTEN : Boolean := False;
-- Data transfer direction selection
DTDIR : Boolean := False;
-- Data transfer mode selection 1: Stream or SDIO multibyte data
-- transfer.
DTMODE : Boolean := False;
-- DMA enable bit
DMAEN : Boolean := False;
-- Data block size
DBLOCKSIZE : DCTRL_DBLOCKSIZE_Field := 16#0#;
-- Read wait start
RWSTART : Boolean := False;
-- Read wait stop
RWSTOP : Boolean := False;
-- Read wait mode
RWMOD : Boolean := False;
-- SD I/O enable functions
SDIOEN : Boolean := False;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DCTRL_Register use record
DTEN at 0 range 0 .. 0;
DTDIR at 0 range 1 .. 1;
DTMODE at 0 range 2 .. 2;
DMAEN at 0 range 3 .. 3;
DBLOCKSIZE at 0 range 4 .. 7;
RWSTART at 0 range 8 .. 8;
RWSTOP at 0 range 9 .. 9;
RWMOD at 0 range 10 .. 10;
SDIOEN at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype DCOUNT_DATACOUNT_Field is HAL.UInt25;
-- data counter register
type DCOUNT_Register is record
-- Read-only. Data count value
DATACOUNT : DCOUNT_DATACOUNT_Field;
-- unspecified
Reserved_25_31 : HAL.UInt7;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DCOUNT_Register use record
DATACOUNT at 0 range 0 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
-- status register
type STA_Register is record
-- Read-only. Command response received (CRC check failed)
CCRCFAIL : Boolean;
-- Read-only. Data block sent/received (CRC check failed)
DCRCFAIL : Boolean;
-- Read-only. Command response timeout
CTIMEOUT : Boolean;
-- Read-only. Data timeout
DTIMEOUT : Boolean;
-- Read-only. Transmit FIFO underrun error
TXUNDERR : Boolean;
-- Read-only. Received FIFO overrun error
RXOVERR : Boolean;
-- Read-only. Command response received (CRC check passed)
CMDREND : Boolean;
-- Read-only. Command sent (no response required)
CMDSENT : Boolean;
-- Read-only. Data end (data counter, SDIDCOUNT, is zero)
DATAEND : Boolean;
-- Read-only. Start bit not detected on all data signals in wide bus
-- mode
STBITERR : Boolean;
-- Read-only. Data block sent/received (CRC check passed)
DBCKEND : Boolean;
-- Read-only. Command transfer in progress
CMDACT : Boolean;
-- Read-only. Data transmit in progress
TXACT : Boolean;
-- Read-only. Data receive in progress
RXACT : Boolean;
-- Read-only. Transmit FIFO half empty: at least 8 words can be written
-- into the FIFO
TXFIFOHE : Boolean;
-- Read-only. Receive FIFO half full: there are at least 8 words in the
-- FIFO
RXFIFOHF : Boolean;
-- Read-only. Transmit FIFO full
TXFIFOF : Boolean;
-- Read-only. Receive FIFO full
RXFIFOF : Boolean;
-- Read-only. Transmit FIFO empty
TXFIFOE : Boolean;
-- Read-only. Receive FIFO empty
RXFIFOE : Boolean;
-- Read-only. Data available in transmit FIFO
TXDAVL : Boolean;
-- Read-only. Data available in receive FIFO
RXDAVL : Boolean;
-- Read-only. SDIO interrupt received
SDIOIT : Boolean;
-- Read-only. CE-ATA command completion signal received for CMD61
CEATAEND : Boolean;
-- unspecified
Reserved_24_31 : HAL.UInt8;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for STA_Register use record
CCRCFAIL at 0 range 0 .. 0;
DCRCFAIL at 0 range 1 .. 1;
CTIMEOUT at 0 range 2 .. 2;
DTIMEOUT at 0 range 3 .. 3;
TXUNDERR at 0 range 4 .. 4;
RXOVERR at 0 range 5 .. 5;
CMDREND at 0 range 6 .. 6;
CMDSENT at 0 range 7 .. 7;
DATAEND at 0 range 8 .. 8;
STBITERR at 0 range 9 .. 9;
DBCKEND at 0 range 10 .. 10;
CMDACT at 0 range 11 .. 11;
TXACT at 0 range 12 .. 12;
RXACT at 0 range 13 .. 13;
TXFIFOHE at 0 range 14 .. 14;
RXFIFOHF at 0 range 15 .. 15;
TXFIFOF at 0 range 16 .. 16;
RXFIFOF at 0 range 17 .. 17;
TXFIFOE at 0 range 18 .. 18;
RXFIFOE at 0 range 19 .. 19;
TXDAVL at 0 range 20 .. 20;
RXDAVL at 0 range 21 .. 21;
SDIOIT at 0 range 22 .. 22;
CEATAEND at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- interrupt clear register
type ICR_Register is record
-- CCRCFAIL flag clear bit
CCRCFAILC : Boolean := False;
-- DCRCFAIL flag clear bit
DCRCFAILC : Boolean := False;
-- CTIMEOUT flag clear bit
CTIMEOUTC : Boolean := False;
-- DTIMEOUT flag clear bit
DTIMEOUTC : Boolean := False;
-- TXUNDERR flag clear bit
TXUNDERRC : Boolean := False;
-- RXOVERR flag clear bit
RXOVERRC : Boolean := False;
-- CMDREND flag clear bit
CMDRENDC : Boolean := False;
-- CMDSENT flag clear bit
CMDSENTC : Boolean := False;
-- DATAEND flag clear bit
DATAENDC : Boolean := False;
-- STBITERR flag clear bit
STBITERRC : Boolean := False;
-- DBCKEND flag clear bit
DBCKENDC : Boolean := False;
-- unspecified
Reserved_11_21 : HAL.UInt11 := 16#0#;
-- SDIOIT flag clear bit
SDIOITC : Boolean := False;
-- CEATAEND flag clear bit
CEATAENDC : Boolean := False;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ICR_Register use record
CCRCFAILC at 0 range 0 .. 0;
DCRCFAILC at 0 range 1 .. 1;
CTIMEOUTC at 0 range 2 .. 2;
DTIMEOUTC at 0 range 3 .. 3;
TXUNDERRC at 0 range 4 .. 4;
RXOVERRC at 0 range 5 .. 5;
CMDRENDC at 0 range 6 .. 6;
CMDSENTC at 0 range 7 .. 7;
DATAENDC at 0 range 8 .. 8;
STBITERRC at 0 range 9 .. 9;
DBCKENDC at 0 range 10 .. 10;
Reserved_11_21 at 0 range 11 .. 21;
SDIOITC at 0 range 22 .. 22;
CEATAENDC at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- mask register
type MASK_Register is record
-- Command CRC fail interrupt enable
CCRCFAILIE : Boolean := False;
-- Data CRC fail interrupt enable
DCRCFAILIE : Boolean := False;
-- Command timeout interrupt enable
CTIMEOUTIE : Boolean := False;
-- Data timeout interrupt enable
DTIMEOUTIE : Boolean := False;
-- Tx FIFO underrun error interrupt enable
TXUNDERRIE : Boolean := False;
-- Rx FIFO overrun error interrupt enable
RXOVERRIE : Boolean := False;
-- Command response received interrupt enable
CMDRENDIE : Boolean := False;
-- Command sent interrupt enable
CMDSENTIE : Boolean := False;
-- Data end interrupt enable
DATAENDIE : Boolean := False;
-- Start bit error interrupt enable
STBITERRIE : Boolean := False;
-- Data block end interrupt enable
DBCKENDIE : Boolean := False;
-- Command acting interrupt enable
CMDACTIE : Boolean := False;
-- Data transmit acting interrupt enable
TXACTIE : Boolean := False;
-- Data receive acting interrupt enable
RXACTIE : Boolean := False;
-- Tx FIFO half empty interrupt enable
TXFIFOHEIE : Boolean := False;
-- Rx FIFO half full interrupt enable
RXFIFOHFIE : Boolean := False;
-- Tx FIFO full interrupt enable
TXFIFOFIE : Boolean := False;
-- Rx FIFO full interrupt enable
RXFIFOFIE : Boolean := False;
-- Tx FIFO empty interrupt enable
TXFIFOEIE : Boolean := False;
-- Rx FIFO empty interrupt enable
RXFIFOEIE : Boolean := False;
-- Data available in Tx FIFO interrupt enable
TXDAVLIE : Boolean := False;
-- Data available in Rx FIFO interrupt enable
RXDAVLIE : Boolean := False;
-- SDIO mode interrupt received interrupt enable
SDIOITIE : Boolean := False;
-- CE-ATA command completion signal received interrupt enable
CEATAENDIE : Boolean := False;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MASK_Register use record
CCRCFAILIE at 0 range 0 .. 0;
DCRCFAILIE at 0 range 1 .. 1;
CTIMEOUTIE at 0 range 2 .. 2;
DTIMEOUTIE at 0 range 3 .. 3;
TXUNDERRIE at 0 range 4 .. 4;
RXOVERRIE at 0 range 5 .. 5;
CMDRENDIE at 0 range 6 .. 6;
CMDSENTIE at 0 range 7 .. 7;
DATAENDIE at 0 range 8 .. 8;
STBITERRIE at 0 range 9 .. 9;
DBCKENDIE at 0 range 10 .. 10;
CMDACTIE at 0 range 11 .. 11;
TXACTIE at 0 range 12 .. 12;
RXACTIE at 0 range 13 .. 13;
TXFIFOHEIE at 0 range 14 .. 14;
RXFIFOHFIE at 0 range 15 .. 15;
TXFIFOFIE at 0 range 16 .. 16;
RXFIFOFIE at 0 range 17 .. 17;
TXFIFOEIE at 0 range 18 .. 18;
RXFIFOEIE at 0 range 19 .. 19;
TXDAVLIE at 0 range 20 .. 20;
RXDAVLIE at 0 range 21 .. 21;
SDIOITIE at 0 range 22 .. 22;
CEATAENDIE at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype FIFOCNT_FIFOCOUNT_Field is HAL.UInt24;
-- FIFO counter register
type FIFOCNT_Register is record
-- Read-only. Remaining number of words to be written to or read from
-- the FIFO.
FIFOCOUNT : FIFOCNT_FIFOCOUNT_Field;
-- unspecified
Reserved_24_31 : HAL.UInt8;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FIFOCNT_Register use record
FIFOCOUNT at 0 range 0 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Secure digital input/output interface
type SDIO_Peripheral is record
-- power control register
POWER : aliased POWER_Register;
-- SDI clock control register
CLKCR : aliased CLKCR_Register;
-- argument register
ARG : aliased HAL.UInt32;
-- command register
CMD : aliased CMD_Register;
-- command response register
RESPCMD : aliased RESPCMD_Register;
-- response 1..4 register
RESP1 : aliased HAL.UInt32;
-- response 1..4 register
RESP2 : aliased HAL.UInt32;
-- response 1..4 register
RESP3 : aliased HAL.UInt32;
-- response 1..4 register
RESP4 : aliased HAL.UInt32;
-- data timer register
DTIMER : aliased HAL.UInt32;
-- data length register
DLEN : aliased DLEN_Register;
-- data control register
DCTRL : aliased DCTRL_Register;
-- data counter register
DCOUNT : aliased DCOUNT_Register;
-- status register
STA : aliased STA_Register;
-- interrupt clear register
ICR : aliased ICR_Register;
-- mask register
MASK : aliased MASK_Register;
-- FIFO counter register
FIFOCNT : aliased FIFOCNT_Register;
-- data FIFO register
FIFO : aliased HAL.UInt32;
end record
with Volatile;
for SDIO_Peripheral use record
POWER at 16#0# range 0 .. 31;
CLKCR at 16#4# range 0 .. 31;
ARG at 16#8# range 0 .. 31;
CMD at 16#C# range 0 .. 31;
RESPCMD at 16#10# range 0 .. 31;
RESP1 at 16#14# range 0 .. 31;
RESP2 at 16#18# range 0 .. 31;
RESP3 at 16#1C# range 0 .. 31;
RESP4 at 16#20# range 0 .. 31;
DTIMER at 16#24# range 0 .. 31;
DLEN at 16#28# range 0 .. 31;
DCTRL at 16#2C# range 0 .. 31;
DCOUNT at 16#30# range 0 .. 31;
STA at 16#34# range 0 .. 31;
ICR at 16#38# range 0 .. 31;
MASK at 16#3C# range 0 .. 31;
FIFOCNT at 16#48# range 0 .. 31;
FIFO at 16#80# range 0 .. 31;
end record;
-- Secure digital input/output interface
SDIO_Periph : aliased SDIO_Peripheral
with Import, Address => System'To_Address (16#40012C00#);
end STM32_SVD.SDIO;
|
pragma Ada_2012;
with Ada.Strings.Fixed;
package body Latex_Writer is
-- The result of function 'Image associated to discrete types has
-- a space at the beginning. That space is quite annoying and needs
-- to be trimmed. This function is here so that everyone can use it
function Chop (X : String) return String
is (Ada.Strings.Fixed.Trim (X, Ada.Strings.Both));
function Image (X : Integer) return String
is (Chop (Integer'Image (X)));
-------------------------
-- Print_Default_Macro --
-------------------------
procedure Print_Default_Macro (Output : File_Access;
Command_Name : String;
Definition : String;
N_Parameters : Natural)
is
begin
Put (File =>
Output.all,
Item =>
"\ifdef{" & Command_Name & "}"
& "{}"
& "{\newcommand{" & Command_Name & "}");
if N_Parameters > 0 then
Put (Output.all, "[" & Image (N_Parameters) & "]");
end if;
Put_Line (Output.all, "{" & Definition & "}}");
end Print_Default_Macro;
------------
-- Within --
------------
procedure Within
(Output : File_Access;
Env_Name : String;
Callback : access procedure (Output : File_Access);
Parameter : String := "")
is
begin
Put (Output.all, "\begin{" & Env_Name & "}");
if Parameter /= "" then
Put (Output.all, "{" & Parameter & "}");
end if;
New_Line (Output.all);
Callback (Output);
New_Line (Output.all);
Put_Line (Output.all, "\end{" & Env_Name & "}");
end Within;
-----------------------
-- Within_Table_Like --
-----------------------
procedure Within_Table_Like
(Output : File_Access;
Env_Name : String;
Callback : access procedure (Output : File_Access;
Table : in out Table_Handler))
is
Arg : constant Parameter_List (2 .. 1) := (others => <>);
begin
Within_Table_Like (Output => Output,
Env_Name => Env_Name,
Callback => Callback,
Parameters => Arg);
end Within_Table_Like;
-----------------------
-- Within_Table_Like --
-----------------------
procedure Within_Table_Like
(Output : File_Access;
Env_Name : String;
Callback : access procedure (Output : File_Access;
Table : in out Table_Handler);
Parameter : String)
is
begin
Within_Table_Like (Output => Output,
Env_Name => Env_Name,
Callback => Callback,
Parameters => (1 => To_Unbounded_String (Parameter)));
end Within_Table_Like;
-----------------------
-- Within_Table_Like --
-----------------------
procedure Within_Table_Like
(Output : File_Access;
Env_Name : String;
Callback : access procedure (Output : File_Access;
Table : in out Table_Handler);
Parameters : Parameter_List)
is
T : Table_Handler := Table_Handler'(State => Begin_Row,
Output => Output,
Default_Style => To_Unbounded_String (""),
Default_Head => To_Unbounded_String (""));
begin
Put (Output.all, "\begin{" & Env_Name & "}");
for K in Parameters'Range loop
Put (Output.all, "{" & To_String (Parameters (K)) & "}");
end loop;
New_Line (Output.all);
Callback (Output, T);
New_Line (Output.all);
Put_Line (Output.all, "\end{" & Env_Name & "}");
end Within_Table_Like;
------------------
-- Within_Table --
------------------
procedure Within_Table
(Output : File_Access;
Table_Spec : String;
Callback : access procedure (Output : File_Access;
Table : in out Table_Handler);
Default_Style : String := "";
Default_Head : String := "";
Caption : String := "";
Width : String := "\textwidth")
is
use Ada.Strings.Fixed;
T : Table_Handler := Table_Handler'(State => Begin_Row,
Output => Output,
Default_Style => To_Unbounded_String (Default_Style),
Default_Head => To_Unbounded_String (Default_Head));
Use_Tabularx : constant Boolean := Index (Table_Spec, "X") > 0;
Env_Name : constant String :=
(if Use_Tabularx then "tabularx" else "tabular");
Width_Spec : constant String := (if Use_Tabularx then "{" & Width & "}" else "");
begin
if Caption /= "" then
Put_Line (Output.all, "\begin{table}");
Put_Line (Output.all, "\caption{" & Caption & "}");
end if;
Put_Line (Output.all, "\centering");
Put_Line (Output.all,
"\begin{" & Env_Name & "}"
& Width_Spec
& "{" & Table_Spec & "}");
Callback (Output, T);
New_Line (Output.all);
Put_Line (Output.all, "\end{" & Env_Name & "}");
if Caption /= "" then
Put_Line (Output.all, "\end{table}");
end if;
end Within_Table;
-----------------
-- Apply_Style --
-----------------
function Apply_Style (Content : String;
Style : Style_Spec;
Default_Style : Unbounded_String)
return String
is
begin
if Style /= "" then
return String (Style) & "{" & Content & "}";
elsif Default_Style /= "" then
return To_String (Default_Style) & "{" & Content & "}";
else
return Content;
end if;
end Apply_Style;
procedure Put_If_In_State (Table : in out Table_Handler;
Content : String;
State : Table_State)
is
begin
if Table.State = State then
Put (Table.Output.all, Content);
end if;
end Put_If_In_State;
---------
-- Put --
---------
procedure Put
(Table : in out Table_Handler; Content : String; Style : String := "")
is
begin
Put_If_In_State (Table, " & ", Middle_Row);
Put (Table.Output.all, Apply_Style (Content, Style_Spec (Style), Table.Default_Style));
Table.State := Middle_Row;
end Put;
-------------
-- New_Row --
-------------
procedure New_Row (Table : in out Table_Handler) is
begin
Put_Line (Table.Output.all, "\\");
Table.State := Begin_Row;
end New_Row;
-----------
-- hline --
-----------
procedure Hline (Table : in out Table_Handler;
Full : Boolean := True) is
begin
Put_If_In_State (Table, "\\", Middle_Row);
if Full then
Put_Line (Table.Output.all, "\hline");
end if;
Table.State := Begin_Row;
end Hline;
procedure Cline (Table : in out Table_Handler; From, To : Positive)
is
begin
Put_If_In_State (Table, "\\", Middle_Row);
Put_Line (Table.Output.all, "\cline{" & Image (From) & "-" & Image (To) & "}");
Table.State := Begin_Row;
end Cline;
-----------------
-- Multicolumn --
-----------------
procedure Multicolumn (Table : in out Table_Handler;
Span : Positive;
Spec : String;
Content : String)
is
begin
Put_If_In_State (Table, "&", Middle_Row);
Put (Table.Output.all, "\multicolumn{" & Image (Span) & "}{" & Spec & "}");
Put_Line (Table.Output.all, "{" & Content & "}");
Table.State := Middle_Row;
end Multicolumn;
----------
-- Head --
----------
procedure Head (Table : in out Table_Handler;
Content : String;
Bar : Bar_Position := Default;
Style : String := "")
is
True_Bar : constant Bar_Position :=
(if Bar /= Default
then
Bar
elsif Table.State = Begin_Row then
Both
else
Right);
function Bar_Maybe (X : Boolean) return String
is (if X then "|" else "");
begin
Table.Multicolumn (Span => 1,
Content => Apply_Style (Content => Content,
Style => Style_Spec (Style),
Default_Style => Table.Default_Head),
Spec =>
Bar_Maybe (True_Bar = Left or True_Bar = Both) &
"c" &
Bar_Maybe (True_Bar = Right or True_Bar = Both));
end Head;
----------
-- Hbox --
----------
function Hbox (Content : String;
Size : Latex_Length := Zero;
Align : Align_Type := Center)
return String
is
begin
return "\hbox to "
& Image (Size)
& "{"
& (case Align is
when Center | Left => "\hss",
when Right => "")
& "{" & Content & "}"
& (case Align is
when Center | Right => "\hss",
when Left => "")
& "}";
end Hbox;
end Latex_Writer;
|
pragma Ada_2012;
with Tokenize.Token_Vectors;
with Ada.Text_IO; use Ada.Text_IO;
package body EU_Projects is
function Verbose_To_ID (X : String) return Dotted_Identifier
is
begin
Put_Line ("TT(" & X & ")" & Is_Valid_ID (X)'Image);
return To_Bounded_String (X);
end Verbose_To_ID;
----------------
-- To_ID_List --
----------------
function To_ID_List (Input : String;
Separators : String := " ,")
return ID_List
is
use Tokenize;
Result : ID_List;
Splitted : constant Token_Vectors.Vector :=
Token_Vectors.To_Vector(Split (To_Be_Splitted => Input,
Separator => Separators,
Collate_Separator => True));
OK : Boolean;
Consumed : Natural;
Tmp : Dotted_Identifier;
begin
for ID of Splitted loop
-- Put_Line ("[" & Id & "]");
ID_Readers.Reader (Input => ID,
Success => OK,
Consumed => Consumed,
Result => Tmp);
-- Put_Line (Ok'Image & " " & Consumed'Image & "(" & To_String (Tmp) & ")");
if not OK or Consumed < ID'Length then
raise Bad_Identifier with "Bad ID in '" & ID & "'";
else
Result.Append (Tmp);
end if;
end loop;
return Result;
end To_ID_List;
end EU_Projects;
|
-- Copyright (c) 2020 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Element_Visitors;
with Program.Elements;
private with Program.Elements.Pragmas;
private with Program.Elements.Defining_Identifiers;
private with Program.Elements.Defining_Character_Literals;
private with Program.Elements.Defining_Operator_Symbols;
private with Program.Elements.Defining_Expanded_Names;
private with Program.Elements.Type_Declarations;
private with Program.Elements.Task_Type_Declarations;
private with Program.Elements.Protected_Type_Declarations;
private with Program.Elements.Subtype_Declarations;
private with Program.Elements.Object_Declarations;
private with Program.Elements.Single_Task_Declarations;
private with Program.Elements.Single_Protected_Declarations;
private with Program.Elements.Number_Declarations;
private with Program.Elements.Enumeration_Literal_Specifications;
private with Program.Elements.Discriminant_Specifications;
private with Program.Elements.Component_Declarations;
private with Program.Elements.Loop_Parameter_Specifications;
private with Program.Elements.Generalized_Iterator_Specifications;
private with Program.Elements.Element_Iterator_Specifications;
private with Program.Elements.Procedure_Declarations;
private with Program.Elements.Function_Declarations;
private with Program.Elements.Parameter_Specifications;
private with Program.Elements.Procedure_Body_Declarations;
private with Program.Elements.Function_Body_Declarations;
private with Program.Elements.Return_Object_Specifications;
private with Program.Elements.Package_Declarations;
private with Program.Elements.Package_Body_Declarations;
private with Program.Elements.Object_Renaming_Declarations;
private with Program.Elements.Exception_Renaming_Declarations;
private with Program.Elements.Procedure_Renaming_Declarations;
private with Program.Elements.Function_Renaming_Declarations;
private with Program.Elements.Package_Renaming_Declarations;
private with Program.Elements.Generic_Package_Renaming_Declarations;
private with Program.Elements.Generic_Procedure_Renaming_Declarations;
private with Program.Elements.Generic_Function_Renaming_Declarations;
private with Program.Elements.Task_Body_Declarations;
private with Program.Elements.Protected_Body_Declarations;
private with Program.Elements.Entry_Declarations;
private with Program.Elements.Entry_Body_Declarations;
private with Program.Elements.Entry_Index_Specifications;
private with Program.Elements.Procedure_Body_Stubs;
private with Program.Elements.Function_Body_Stubs;
private with Program.Elements.Package_Body_Stubs;
private with Program.Elements.Task_Body_Stubs;
private with Program.Elements.Protected_Body_Stubs;
private with Program.Elements.Exception_Declarations;
private with Program.Elements.Choice_Parameter_Specifications;
private with Program.Elements.Generic_Package_Declarations;
private with Program.Elements.Generic_Procedure_Declarations;
private with Program.Elements.Generic_Function_Declarations;
private with Program.Elements.Package_Instantiations;
private with Program.Elements.Procedure_Instantiations;
private with Program.Elements.Function_Instantiations;
private with Program.Elements.Formal_Object_Declarations;
private with Program.Elements.Formal_Type_Declarations;
private with Program.Elements.Formal_Procedure_Declarations;
private with Program.Elements.Formal_Function_Declarations;
private with Program.Elements.Formal_Package_Declarations;
private with Program.Elements.Subtype_Indications;
private with Program.Elements.Component_Definitions;
private with Program.Elements.Discrete_Subtype_Indications;
private with Program.Elements.Discrete_Range_Attribute_References;
private with Program.Elements.Discrete_Simple_Expression_Ranges;
private with Program.Elements.Unknown_Discriminant_Parts;
private with Program.Elements.Known_Discriminant_Parts;
private with Program.Elements.Record_Definitions;
private with Program.Elements.Null_Components;
private with Program.Elements.Variant_Parts;
private with Program.Elements.Variants;
private with Program.Elements.Others_Choices;
private with Program.Elements.Anonymous_Access_To_Objects;
private with Program.Elements.Anonymous_Access_To_Procedures;
private with Program.Elements.Anonymous_Access_To_Functions;
private with Program.Elements.Private_Type_Definitions;
private with Program.Elements.Private_Extension_Definitions;
private with Program.Elements.Incomplete_Type_Definitions;
private with Program.Elements.Task_Definitions;
private with Program.Elements.Protected_Definitions;
private with Program.Elements.Aspect_Specifications;
private with Program.Elements.Real_Range_Specifications;
private with Program.Elements.Numeric_Literals;
private with Program.Elements.String_Literals;
private with Program.Elements.Identifiers;
private with Program.Elements.Operator_Symbols;
private with Program.Elements.Character_Literals;
private with Program.Elements.Explicit_Dereferences;
private with Program.Elements.Infix_Operators;
private with Program.Elements.Function_Calls;
private with Program.Elements.Indexed_Components;
private with Program.Elements.Slices;
private with Program.Elements.Selected_Components;
private with Program.Elements.Attribute_References;
private with Program.Elements.Record_Aggregates;
private with Program.Elements.Extension_Aggregates;
private with Program.Elements.Array_Aggregates;
private with Program.Elements.Short_Circuit_Operations;
private with Program.Elements.Membership_Tests;
private with Program.Elements.Null_Literals;
private with Program.Elements.Parenthesized_Expressions;
private with Program.Elements.Raise_Expressions;
private with Program.Elements.Type_Conversions;
private with Program.Elements.Qualified_Expressions;
private with Program.Elements.Allocators;
private with Program.Elements.Case_Expressions;
private with Program.Elements.If_Expressions;
private with Program.Elements.Quantified_Expressions;
private with Program.Elements.Discriminant_Associations;
private with Program.Elements.Record_Component_Associations;
private with Program.Elements.Array_Component_Associations;
private with Program.Elements.Parameter_Associations;
private with Program.Elements.Formal_Package_Associations;
private with Program.Elements.Null_Statements;
private with Program.Elements.Assignment_Statements;
private with Program.Elements.If_Statements;
private with Program.Elements.Case_Statements;
private with Program.Elements.Loop_Statements;
private with Program.Elements.While_Loop_Statements;
private with Program.Elements.For_Loop_Statements;
private with Program.Elements.Block_Statements;
private with Program.Elements.Exit_Statements;
private with Program.Elements.Goto_Statements;
private with Program.Elements.Call_Statements;
private with Program.Elements.Simple_Return_Statements;
private with Program.Elements.Extended_Return_Statements;
private with Program.Elements.Accept_Statements;
private with Program.Elements.Requeue_Statements;
private with Program.Elements.Delay_Statements;
private with Program.Elements.Terminate_Alternative_Statements;
private with Program.Elements.Select_Statements;
private with Program.Elements.Abort_Statements;
private with Program.Elements.Raise_Statements;
private with Program.Elements.Code_Statements;
private with Program.Elements.Elsif_Paths;
private with Program.Elements.Case_Paths;
private with Program.Elements.Select_Paths;
private with Program.Elements.Case_Expression_Paths;
private with Program.Elements.Elsif_Expression_Paths;
private with Program.Elements.Use_Clauses;
private with Program.Elements.With_Clauses;
private with Program.Elements.Component_Clauses;
private with Program.Elements.Derived_Types;
private with Program.Elements.Derived_Record_Extensions;
private with Program.Elements.Enumeration_Types;
private with Program.Elements.Signed_Integer_Types;
private with Program.Elements.Modular_Types;
private with Program.Elements.Root_Types;
private with Program.Elements.Floating_Point_Types;
private with Program.Elements.Ordinary_Fixed_Point_Types;
private with Program.Elements.Decimal_Fixed_Point_Types;
private with Program.Elements.Unconstrained_Array_Types;
private with Program.Elements.Constrained_Array_Types;
private with Program.Elements.Record_Types;
private with Program.Elements.Interface_Types;
private with Program.Elements.Object_Access_Types;
private with Program.Elements.Procedure_Access_Types;
private with Program.Elements.Function_Access_Types;
private with Program.Elements.Formal_Private_Type_Definitions;
private with Program.Elements.Formal_Derived_Type_Definitions;
private with Program.Elements.Formal_Discrete_Type_Definitions;
private with Program.Elements.Formal_Signed_Integer_Type_Definitions;
private with Program.Elements.Formal_Modular_Type_Definitions;
private with Program.Elements.Formal_Floating_Point_Definitions;
private with Program.Elements.Formal_Ordinary_Fixed_Point_Definitions;
private with Program.Elements.Formal_Decimal_Fixed_Point_Definitions;
private with Program.Elements.Formal_Unconstrained_Array_Types;
private with Program.Elements.Formal_Constrained_Array_Types;
private with Program.Elements.Formal_Object_Access_Types;
private with Program.Elements.Formal_Procedure_Access_Types;
private with Program.Elements.Formal_Function_Access_Types;
private with Program.Elements.Formal_Interface_Types;
private with Program.Elements.Range_Attribute_References;
private with Program.Elements.Simple_Expression_Ranges;
private with Program.Elements.Digits_Constraints;
private with Program.Elements.Delta_Constraints;
private with Program.Elements.Index_Constraints;
private with Program.Elements.Discriminant_Constraints;
private with Program.Elements.Attribute_Definition_Clauses;
private with Program.Elements.Enumeration_Representation_Clauses;
private with Program.Elements.Record_Representation_Clauses;
private with Program.Elements.At_Clauses;
private with Program.Elements.Exception_Handlers;
package Program.Safe_Element_Visitors is
pragma Pure;
type Safe_Element_Visitor is limited
new Program.Element_Visitors.Element_Visitor with
record
Failed : Boolean := False;
end record;
procedure Visit
(Self : in out Safe_Element_Visitor'Class;
Element : not null access Program.Elements.Element'Class);
private
overriding procedure Pragma_Element
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Pragmas.Pragma_Access);
overriding procedure Defining_Identifier
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access);
overriding procedure Defining_Character_Literal
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Defining_Character_Literals
.Defining_Character_Literal_Access);
overriding procedure Defining_Operator_Symbol
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Defining_Operator_Symbols
.Defining_Operator_Symbol_Access);
overriding procedure Defining_Expanded_Name
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Defining_Expanded_Names
.Defining_Expanded_Name_Access);
overriding procedure Type_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Type_Declarations
.Type_Declaration_Access);
overriding procedure Task_Type_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Task_Type_Declarations
.Task_Type_Declaration_Access);
overriding procedure Protected_Type_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Protected_Type_Declarations
.Protected_Type_Declaration_Access);
overriding procedure Subtype_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Subtype_Declarations
.Subtype_Declaration_Access);
overriding procedure Object_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Object_Declarations
.Object_Declaration_Access);
overriding procedure Single_Task_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Single_Task_Declarations
.Single_Task_Declaration_Access);
overriding procedure Single_Protected_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Single_Protected_Declarations
.Single_Protected_Declaration_Access);
overriding procedure Number_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Number_Declarations
.Number_Declaration_Access);
overriding procedure Enumeration_Literal_Specification
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Enumeration_Literal_Specifications
.Enumeration_Literal_Specification_Access);
overriding procedure Discriminant_Specification
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Discriminant_Specifications
.Discriminant_Specification_Access);
overriding procedure Component_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Component_Declarations
.Component_Declaration_Access);
overriding procedure Loop_Parameter_Specification
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Loop_Parameter_Specifications
.Loop_Parameter_Specification_Access);
overriding procedure Generalized_Iterator_Specification
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Generalized_Iterator_Specifications
.Generalized_Iterator_Specification_Access);
overriding procedure Element_Iterator_Specification
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Element_Iterator_Specifications
.Element_Iterator_Specification_Access);
overriding procedure Procedure_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Procedure_Declarations
.Procedure_Declaration_Access);
overriding procedure Function_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Function_Declarations
.Function_Declaration_Access);
overriding procedure Parameter_Specification
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Parameter_Specifications
.Parameter_Specification_Access);
overriding procedure Procedure_Body_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Procedure_Body_Declarations
.Procedure_Body_Declaration_Access);
overriding procedure Function_Body_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Function_Body_Declarations
.Function_Body_Declaration_Access);
overriding procedure Return_Object_Specification
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Return_Object_Specifications
.Return_Object_Specification_Access);
overriding procedure Package_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Package_Declarations
.Package_Declaration_Access);
overriding procedure Package_Body_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Package_Body_Declarations
.Package_Body_Declaration_Access);
overriding procedure Object_Renaming_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration_Access);
overriding procedure Exception_Renaming_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Exception_Renaming_Declarations
.Exception_Renaming_Declaration_Access);
overriding procedure Procedure_Renaming_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Procedure_Renaming_Declarations
.Procedure_Renaming_Declaration_Access);
overriding procedure Function_Renaming_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Function_Renaming_Declarations
.Function_Renaming_Declaration_Access);
overriding procedure Package_Renaming_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Package_Renaming_Declarations
.Package_Renaming_Declaration_Access);
overriding procedure Generic_Package_Renaming_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Generic_Package_Renaming_Declarations
.Generic_Package_Renaming_Declaration_Access);
overriding procedure Generic_Procedure_Renaming_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements
.Generic_Procedure_Renaming_Declarations
.Generic_Procedure_Renaming_Declaration_Access);
overriding procedure Generic_Function_Renaming_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Generic_Function_Renaming_Declarations
.Generic_Function_Renaming_Declaration_Access);
overriding procedure Task_Body_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Task_Body_Declarations
.Task_Body_Declaration_Access);
overriding procedure Protected_Body_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Protected_Body_Declarations
.Protected_Body_Declaration_Access);
overriding procedure Entry_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Entry_Declarations
.Entry_Declaration_Access);
overriding procedure Entry_Body_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Entry_Body_Declarations
.Entry_Body_Declaration_Access);
overriding procedure Entry_Index_Specification
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Entry_Index_Specifications
.Entry_Index_Specification_Access);
overriding procedure Procedure_Body_Stub
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Procedure_Body_Stubs
.Procedure_Body_Stub_Access);
overriding procedure Function_Body_Stub
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Function_Body_Stubs
.Function_Body_Stub_Access);
overriding procedure Package_Body_Stub
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Package_Body_Stubs
.Package_Body_Stub_Access);
overriding procedure Task_Body_Stub
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Task_Body_Stubs.Task_Body_Stub_Access);
overriding procedure Protected_Body_Stub
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Protected_Body_Stubs
.Protected_Body_Stub_Access);
overriding procedure Exception_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Exception_Declarations
.Exception_Declaration_Access);
overriding procedure Choice_Parameter_Specification
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Choice_Parameter_Specifications
.Choice_Parameter_Specification_Access);
overriding procedure Generic_Package_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Generic_Package_Declarations
.Generic_Package_Declaration_Access);
overriding procedure Generic_Procedure_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Generic_Procedure_Declarations
.Generic_Procedure_Declaration_Access);
overriding procedure Generic_Function_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Generic_Function_Declarations
.Generic_Function_Declaration_Access);
overriding procedure Package_Instantiation
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Package_Instantiations
.Package_Instantiation_Access);
overriding procedure Procedure_Instantiation
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Procedure_Instantiations
.Procedure_Instantiation_Access);
overriding procedure Function_Instantiation
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Function_Instantiations
.Function_Instantiation_Access);
overriding procedure Formal_Object_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Object_Declarations
.Formal_Object_Declaration_Access);
overriding procedure Formal_Type_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Type_Declarations
.Formal_Type_Declaration_Access);
overriding procedure Formal_Procedure_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Procedure_Declarations
.Formal_Procedure_Declaration_Access);
overriding procedure Formal_Function_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Function_Declarations
.Formal_Function_Declaration_Access);
overriding procedure Formal_Package_Declaration
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Package_Declarations
.Formal_Package_Declaration_Access);
overriding procedure Subtype_Indication
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Subtype_Indications
.Subtype_Indication_Access);
overriding procedure Component_Definition
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Component_Definitions
.Component_Definition_Access);
overriding procedure Discrete_Subtype_Indication
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Discrete_Subtype_Indications
.Discrete_Subtype_Indication_Access);
overriding procedure Discrete_Range_Attribute_Reference
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Discrete_Range_Attribute_References
.Discrete_Range_Attribute_Reference_Access);
overriding procedure Discrete_Simple_Expression_Range
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Discrete_Simple_Expression_Ranges
.Discrete_Simple_Expression_Range_Access);
overriding procedure Unknown_Discriminant_Part
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Unknown_Discriminant_Parts
.Unknown_Discriminant_Part_Access);
overriding procedure Known_Discriminant_Part
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Known_Discriminant_Parts
.Known_Discriminant_Part_Access);
overriding procedure Record_Definition
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Record_Definitions
.Record_Definition_Access);
overriding procedure Null_Component
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Null_Components.Null_Component_Access);
overriding procedure Variant_Part
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Variant_Parts.Variant_Part_Access);
overriding procedure Variant
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Variants.Variant_Access);
overriding procedure Others_Choice
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Others_Choices.Others_Choice_Access);
overriding procedure Anonymous_Access_To_Object
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Anonymous_Access_To_Objects
.Anonymous_Access_To_Object_Access);
overriding procedure Anonymous_Access_To_Procedure
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Anonymous_Access_To_Procedures
.Anonymous_Access_To_Procedure_Access);
overriding procedure Anonymous_Access_To_Function
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Anonymous_Access_To_Functions
.Anonymous_Access_To_Function_Access);
overriding procedure Private_Type_Definition
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Private_Type_Definitions
.Private_Type_Definition_Access);
overriding procedure Private_Extension_Definition
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Private_Extension_Definitions
.Private_Extension_Definition_Access);
overriding procedure Incomplete_Type_Definition
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Incomplete_Type_Definitions
.Incomplete_Type_Definition_Access);
overriding procedure Task_Definition
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Task_Definitions
.Task_Definition_Access);
overriding procedure Protected_Definition
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Protected_Definitions
.Protected_Definition_Access);
overriding procedure Aspect_Specification
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Aspect_Specifications
.Aspect_Specification_Access);
overriding procedure Real_Range_Specification
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Real_Range_Specifications
.Real_Range_Specification_Access);
overriding procedure Numeric_Literal
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Numeric_Literals
.Numeric_Literal_Access);
overriding procedure String_Literal
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.String_Literals.String_Literal_Access);
overriding procedure Identifier
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Identifiers.Identifier_Access);
overriding procedure Operator_Symbol
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Operator_Symbols
.Operator_Symbol_Access);
overriding procedure Character_Literal
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Character_Literals
.Character_Literal_Access);
overriding procedure Explicit_Dereference
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Explicit_Dereferences
.Explicit_Dereference_Access);
overriding procedure Infix_Operator
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Infix_Operators.Infix_Operator_Access);
overriding procedure Function_Call
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Function_Calls.Function_Call_Access);
overriding procedure Indexed_Component
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Indexed_Components
.Indexed_Component_Access);
overriding procedure Slice
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Slices.Slice_Access);
overriding procedure Selected_Component
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Selected_Components
.Selected_Component_Access);
overriding procedure Attribute_Reference
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Attribute_References
.Attribute_Reference_Access);
overriding procedure Record_Aggregate
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Record_Aggregates
.Record_Aggregate_Access);
overriding procedure Extension_Aggregate
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Extension_Aggregates
.Extension_Aggregate_Access);
overriding procedure Array_Aggregate
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Array_Aggregates
.Array_Aggregate_Access);
overriding procedure Short_Circuit_Operation
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Short_Circuit_Operations
.Short_Circuit_Operation_Access);
overriding procedure Membership_Test
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Membership_Tests
.Membership_Test_Access);
overriding procedure Null_Literal
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Null_Literals.Null_Literal_Access);
overriding procedure Parenthesized_Expression
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Parenthesized_Expressions
.Parenthesized_Expression_Access);
overriding procedure Raise_Expression
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Raise_Expressions
.Raise_Expression_Access);
overriding procedure Type_Conversion
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Type_Conversions
.Type_Conversion_Access);
overriding procedure Qualified_Expression
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Qualified_Expressions
.Qualified_Expression_Access);
overriding procedure Allocator
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Allocators.Allocator_Access);
overriding procedure Case_Expression
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Case_Expressions
.Case_Expression_Access);
overriding procedure If_Expression
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.If_Expressions.If_Expression_Access);
overriding procedure Quantified_Expression
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Quantified_Expressions
.Quantified_Expression_Access);
overriding procedure Discriminant_Association
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Discriminant_Associations
.Discriminant_Association_Access);
overriding procedure Record_Component_Association
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Record_Component_Associations
.Record_Component_Association_Access);
overriding procedure Array_Component_Association
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Array_Component_Associations
.Array_Component_Association_Access);
overriding procedure Parameter_Association
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Parameter_Associations
.Parameter_Association_Access);
overriding procedure Formal_Package_Association
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Package_Associations
.Formal_Package_Association_Access);
overriding procedure Null_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Null_Statements.Null_Statement_Access);
overriding procedure Assignment_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Assignment_Statements
.Assignment_Statement_Access);
overriding procedure If_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.If_Statements.If_Statement_Access);
overriding procedure Case_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Case_Statements.Case_Statement_Access);
overriding procedure Loop_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Loop_Statements.Loop_Statement_Access);
overriding procedure While_Loop_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.While_Loop_Statements
.While_Loop_Statement_Access);
overriding procedure For_Loop_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.For_Loop_Statements
.For_Loop_Statement_Access);
overriding procedure Block_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Block_Statements
.Block_Statement_Access);
overriding procedure Exit_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Exit_Statements.Exit_Statement_Access);
overriding procedure Goto_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Goto_Statements.Goto_Statement_Access);
overriding procedure Call_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Call_Statements.Call_Statement_Access);
overriding procedure Simple_Return_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Simple_Return_Statements
.Simple_Return_Statement_Access);
overriding procedure Extended_Return_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Extended_Return_Statements
.Extended_Return_Statement_Access);
overriding procedure Accept_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Accept_Statements
.Accept_Statement_Access);
overriding procedure Requeue_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Requeue_Statements
.Requeue_Statement_Access);
overriding procedure Delay_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Delay_Statements
.Delay_Statement_Access);
overriding procedure Terminate_Alternative_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Terminate_Alternative_Statements
.Terminate_Alternative_Statement_Access);
overriding procedure Select_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Select_Statements
.Select_Statement_Access);
overriding procedure Abort_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Abort_Statements
.Abort_Statement_Access);
overriding procedure Raise_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Raise_Statements
.Raise_Statement_Access);
overriding procedure Code_Statement
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Code_Statements.Code_Statement_Access);
overriding procedure Elsif_Path
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Elsif_Paths.Elsif_Path_Access);
overriding procedure Case_Path
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Case_Paths.Case_Path_Access);
overriding procedure Select_Path
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Select_Paths.Select_Path_Access);
overriding procedure Case_Expression_Path
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Case_Expression_Paths
.Case_Expression_Path_Access);
overriding procedure Elsif_Expression_Path
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Elsif_Expression_Paths
.Elsif_Expression_Path_Access);
overriding procedure Use_Clause
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Use_Clauses.Use_Clause_Access);
overriding procedure With_Clause
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.With_Clauses.With_Clause_Access);
overriding procedure Component_Clause
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Component_Clauses
.Component_Clause_Access);
overriding procedure Derived_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Derived_Types.Derived_Type_Access);
overriding procedure Derived_Record_Extension
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Derived_Record_Extensions
.Derived_Record_Extension_Access);
overriding procedure Enumeration_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Enumeration_Types
.Enumeration_Type_Access);
overriding procedure Signed_Integer_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Signed_Integer_Types
.Signed_Integer_Type_Access);
overriding procedure Modular_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Modular_Types.Modular_Type_Access);
overriding procedure Root_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Root_Types.Root_Type_Access);
overriding procedure Floating_Point_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Floating_Point_Types
.Floating_Point_Type_Access);
overriding procedure Ordinary_Fixed_Point_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Ordinary_Fixed_Point_Types
.Ordinary_Fixed_Point_Type_Access);
overriding procedure Decimal_Fixed_Point_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Decimal_Fixed_Point_Types
.Decimal_Fixed_Point_Type_Access);
overriding procedure Unconstrained_Array_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Unconstrained_Array_Types
.Unconstrained_Array_Type_Access);
overriding procedure Constrained_Array_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Constrained_Array_Types
.Constrained_Array_Type_Access);
overriding procedure Record_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Record_Types.Record_Type_Access);
overriding procedure Interface_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Interface_Types.Interface_Type_Access);
overriding procedure Object_Access_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Object_Access_Types
.Object_Access_Type_Access);
overriding procedure Procedure_Access_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Procedure_Access_Types
.Procedure_Access_Type_Access);
overriding procedure Function_Access_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Function_Access_Types
.Function_Access_Type_Access);
overriding procedure Formal_Private_Type_Definition
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Private_Type_Definitions
.Formal_Private_Type_Definition_Access);
overriding procedure Formal_Derived_Type_Definition
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Derived_Type_Definitions
.Formal_Derived_Type_Definition_Access);
overriding procedure Formal_Discrete_Type_Definition
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Discrete_Type_Definitions
.Formal_Discrete_Type_Definition_Access);
overriding procedure Formal_Signed_Integer_Type_Definition
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Signed_Integer_Type_Definitions
.Formal_Signed_Integer_Type_Definition_Access);
overriding procedure Formal_Modular_Type_Definition
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Modular_Type_Definitions
.Formal_Modular_Type_Definition_Access);
overriding procedure Formal_Floating_Point_Definition
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Floating_Point_Definitions
.Formal_Floating_Point_Definition_Access);
overriding procedure Formal_Ordinary_Fixed_Point_Definition
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements
.Formal_Ordinary_Fixed_Point_Definitions
.Formal_Ordinary_Fixed_Point_Definition_Access);
overriding procedure Formal_Decimal_Fixed_Point_Definition
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Decimal_Fixed_Point_Definitions
.Formal_Decimal_Fixed_Point_Definition_Access);
overriding procedure Formal_Unconstrained_Array_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Unconstrained_Array_Types
.Formal_Unconstrained_Array_Type_Access);
overriding procedure Formal_Constrained_Array_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Constrained_Array_Types
.Formal_Constrained_Array_Type_Access);
overriding procedure Formal_Object_Access_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Object_Access_Types
.Formal_Object_Access_Type_Access);
overriding procedure Formal_Procedure_Access_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Procedure_Access_Types
.Formal_Procedure_Access_Type_Access);
overriding procedure Formal_Function_Access_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Function_Access_Types
.Formal_Function_Access_Type_Access);
overriding procedure Formal_Interface_Type
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Formal_Interface_Types
.Formal_Interface_Type_Access);
overriding procedure Range_Attribute_Reference
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Range_Attribute_References
.Range_Attribute_Reference_Access);
overriding procedure Simple_Expression_Range
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Simple_Expression_Ranges
.Simple_Expression_Range_Access);
overriding procedure Digits_Constraint
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Digits_Constraints
.Digits_Constraint_Access);
overriding procedure Delta_Constraint
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Delta_Constraints
.Delta_Constraint_Access);
overriding procedure Index_Constraint
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Index_Constraints
.Index_Constraint_Access);
overriding procedure Discriminant_Constraint
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Discriminant_Constraints
.Discriminant_Constraint_Access);
overriding procedure Attribute_Definition_Clause
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Attribute_Definition_Clauses
.Attribute_Definition_Clause_Access);
overriding procedure Enumeration_Representation_Clause
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Enumeration_Representation_Clauses
.Enumeration_Representation_Clause_Access);
overriding procedure Record_Representation_Clause
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Record_Representation_Clauses
.Record_Representation_Clause_Access);
overriding procedure At_Clause
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.At_Clauses.At_Clause_Access);
overriding procedure Exception_Handler
(Self : in out Safe_Element_Visitor;
Ignore : not null Program.Elements.Exception_Handlers
.Exception_Handler_Access);
end Program.Safe_Element_Visitors;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with GL.Types;
private with GL.Enums;
-- Matrix stack API. This API is deprecated as of OpenGL 3.0.
package GL.Fixed.Matrix is
use GL.Types.Doubles;
type Matrix_Stack (<>) is tagged private;
Modelview : constant Matrix_Stack;
Projection : constant Matrix_Stack;
Texture : constant Matrix_Stack;
Color : constant Matrix_Stack;
procedure Apply_Frustum (Stack : Matrix_Stack;
Left, Right, Bottom, Top, Near, Far : Double);
procedure Apply_Orthogonal (Stack : Matrix_Stack;
Left, Right, Bottom, Top, Near, Far : Double);
procedure Load_Identity (Stack : Matrix_Stack);
procedure Load_Matrix (Stack : Matrix_Stack; Value : Matrix4);
procedure Apply_Multiplication (Stack : Matrix_Stack; Factor : Matrix4);
procedure Apply_Multiplication (Stack : Matrix_Stack; Factor : Double);
procedure Push (Stack : Matrix_Stack);
procedure Pop (Stack : Matrix_Stack);
procedure Apply_Rotation (Stack : Matrix_Stack; Angle : Double;
Axis : Vector3);
procedure Apply_Rotation (Stack : Matrix_Stack; Angle, X, Y, Z : Double);
procedure Apply_Scaling (Stack : Matrix_Stack; X, Y, Z : Double);
procedure Apply_Translation (Stack : Matrix_Stack; Along : Vector3);
procedure Apply_Translation (Stack : Matrix_Stack; X, Y, Z : Double);
private
type Matrix_Stack (Mode : Enums.Matrix_Mode) is tagged null record;
Modelview : constant Matrix_Stack := Matrix_Stack'(Mode => Enums.Modelview);
Projection : constant Matrix_Stack := Matrix_Stack'(Mode => Enums.Projection);
Texture : constant Matrix_Stack := Matrix_Stack'(Mode => Enums.Texture);
Color : constant Matrix_Stack := Matrix_Stack'(Mode => Enums.Color);
end GL.Fixed.Matrix;
|
pragma License (Unrestricted);
with Ada.Numerics.Generic_Real_Arrays;
package Ada.Numerics.Real_Arrays is
new Generic_Real_Arrays (Float);
pragma Pure (Ada.Numerics.Real_Arrays);
|
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with Ada.Directories;
with Ada.Text_IO;
with Ada.Characters.Latin_1;
with GNAT.OS_Lib;
with Unix;
package body Parameters is
package AD renames Ada.Directories;
package TIO renames Ada.Text_IO;
package LAT renames Ada.Characters.Latin_1;
package OSL renames GNAT.OS_Lib;
--------------------------
-- load_configuration --
--------------------------
function load_configuration (num_cores : cpu_range) return Boolean
is
fields_present : Boolean;
global_present : Boolean;
sel_profile : JT.Text;
begin
if not AD.Exists (conf_location) then
declare
test : String := determine_portsdirs;
begin
if test = "" then
return False;
end if;
end;
declare
File_Handle : TIO.File_Type;
begin
mkdirp_from_file (conf_location);
TIO.Create (File => File_Handle,
Mode => TIO.Out_File,
Name => conf_location);
TIO.Put_Line (File_Handle, "; This Synth configuration file is " &
"automatically generated");
TIO.Put_Line (File_Handle, "; Take care when hand editing!");
TIO.Close (File => File_Handle);
exception
when Error : others =>
TIO.Put_Line ("Failed to create " & conf_location);
return False;
end;
end if;
internal_config.Init (File_Name => conf_location,
On_Type_Mismatch => Config.Be_Quiet);
if section_exists (master_section, global_01) then
global_present := all_global_present;
else
write_blank_section (master_section);
global_present := False;
end if;
declare
envprofile : String := OSL.Getenv ("SYNTHPROFILE").all;
begin
sel_profile := extract_string (master_section, global_01, live_system);
if envprofile /= "" then
if section_exists (envprofile, Field_01) then
sel_profile := JT.SUS (envprofile);
end if;
end if;
end;
declare
profile : constant String := JT.USS (sel_profile);
begin
if section_exists (profile, Field_01) then
fields_present := all_params_present (profile);
else
write_blank_section (section => profile);
fields_present := False;
end if;
configuration := load_specific_profile (profile, num_cores);
end;
if not fields_present then
write_configuration (JT.USS (configuration.profile));
end if;
if not global_present then
write_master_section;
end if;
return True;
exception
when mishap : others => return False;
end load_configuration;
---------------------------
-- determine_portsdirs --
---------------------------
function determine_portsdirs return String
is
function get_varname return String;
function get_mkconf return String;
function get_varname return String is
begin
case software_framework is
when pkgsrc => return "PKGSRCDIR";
when ports_collection => return "PORTSDIR";
end case;
end get_varname;
function get_mkconf return String is
begin
case software_framework is
when pkgsrc => return "mk.conf";
when ports_collection => return "/etc/make.conf";
end case;
end get_mkconf;
varname : constant String := get_varname;
mkconf : constant String := get_mkconf;
begin
-- PORTSDIR in environment takes precedence
declare
portsdir : String := OSL.Getenv (varname).all;
begin
if portsdir /= "" then
if AD.Exists (portsdir) then
return portsdir;
end if;
end if;
end;
case software_framework is
when pkgsrc =>
if AD.Exists (std_pkgsrc_loc & "/mk/pkgformat/pkgng") then
return std_pkgsrc_loc;
end if;
when ports_collection =>
declare
portsdir : String := query_portsdir;
begin
if portsdir = "" then
TIO.Put_Line ("It seems that a blank " & varname &
" is defined in " & mkconf);
return "";
end if;
if AD.Exists (portsdir) then
return portsdir;
end if;
end;
if AD.Exists (std_dports_loc) then
return std_dports_loc;
elsif AD.Exists (std_ports_loc) then
return std_ports_loc;
end if;
end case;
TIO.Put_Line (varname & " cannot be determined.");
TIO.Put_Line ("Please set " & varname & " to a valid path in the environment or " &
mkconf);
return "";
end determine_portsdirs;
-----------------------------
-- load_specific_profile --
-----------------------------
function load_specific_profile (profile : String; num_cores : cpu_range)
return configuration_record
is
function opsys_ok return Boolean;
def_builders : Integer;
def_jlimit : Integer;
res : configuration_record;
function opsys_ok return Boolean is
begin
case software_framework is
when ports_collection =>
return (JT.equivalent (res.operating_sys, "FreeBSD") or else
JT.equivalent (res.operating_sys, "DragonFly"));
when pkgsrc =>
-- OpenBSD and derivatives are not supported because they lack mount_null (!)
return (JT.equivalent (res.operating_sys, "FreeBSD") or else
JT.equivalent (res.operating_sys, "DragonFly") or else
JT.equivalent (res.operating_sys, "NetBSD") or else
JT.equivalent (res.operating_sys, "Linux") or else
JT.equivalent (res.operating_sys, "SunOS")
);
end case;
end opsys_ok;
begin
-- The profile *must* exist before this procedure is called!
default_parallelism (num_cores => num_cores,
num_builders => def_builders,
jobs_per_builder => def_jlimit);
res.dir_packages := extract_string (profile, Field_01, LS_Packages);
if param_set (profile, Field_03) then
-- We can only check determine_portsdirs when no synth.ini file
-- exists. It's possible that it was configured with PORTSDIR
-- set which can be removed later. Use the dummy std_ports_loc
-- when we are sure the parameter is set (so dummy will NOT be used)
res.dir_portsdir := extract_string (profile, Field_03,
std_ports_loc);
else
res.dir_portsdir := extract_string (profile, Field_03,
determine_portsdirs);
end if;
res.dir_repository := res.dir_packages;
JT.SU.Append (res.dir_repository, "/All");
if param_set (profile, Field_04) then
res.dir_distfiles := extract_string (profile, Field_04, std_distfiles);
else
res.dir_distfiles := extract_string
(profile, Field_04, query_distfiles (JT.USS (res.dir_portsdir)));
end if;
res.dir_buildbase := extract_string (profile, Field_05, LS_Buildbase);
res.dir_logs := extract_string (profile, Field_06, LS_Logs);
res.dir_ccache := extract_string (profile, Field_07, no_ccache);
res.num_builders := builders
(extract_integer (profile, Field_08, def_builders));
res.jobs_limit := builders
(extract_integer (profile, Field_09, def_jlimit));
if param_set (profile, Field_12) then
res.operating_sys := extract_string (profile, Field_12, std_opsys);
else
res.operating_sys := extract_string
(profile, Field_12, query_opsys (JT.USS (res.dir_portsdir)));
end if;
if not opsys_ok then
TIO.Put_Line ("Unknown operating system: " & JT.USS (res.operating_sys));
case software_framework is
when ports_collection =>
TIO.Put_Line ("This configuration entry must be either 'FreeBSD' or 'DragonFly'");
when pkgsrc =>
TIO.Put_Line ("This configuration entry must be one of: FreeBSD,DragonFly," &
"NetBSD,Linux,SunOS");
end case;
TIO.Put_Line ("Manually edit " & Definitions.host_localbase &
"/etc/synth/synth.ini file to remove the line of the");
TIO.Put_Line (profile & " profile starting with 'Operating_system='");
TIO.Put_Line ("The synth.ini file should regenerate properly on the next Synth command.");
TIO.Put_Line ("");
raise bad_opsys;
end if;
if param_set (profile, Field_10) then
res.tmpfs_workdir := extract_boolean (profile, Field_10, False);
else
res.tmpfs_workdir := extract_boolean
(profile, Field_10, enough_memory (res.num_builders, res.operating_sys));
end if;
if param_set (profile, Field_11) then
res.tmpfs_localbase := extract_boolean (profile, Field_11, False);
else
res.tmpfs_localbase := extract_boolean
(profile, Field_11, enough_memory (res.num_builders, res.operating_sys));
end if;
res.dir_options := extract_string (profile, Field_13, std_options);
res.dir_system := extract_string (profile, Field_14, std_sysbase);
res.avec_ncurses := extract_boolean (profile, Field_15, True);
res.defer_prebuilt := extract_boolean (profile, Field_16, False);
res.profile := JT.SUS (profile);
return res;
end load_specific_profile;
---------------------------
-- write_configuration --
---------------------------
procedure write_configuration (profile : String := live_system)
is
contents : String := generated_section;
begin
internal_config.Replace_Section (profile, contents);
exception
when Error : others =>
raise update_config
with "Failed to update [" & profile & "] at " & conf_location;
end write_configuration;
---------------------------
-- write_blank_section --
---------------------------
procedure write_blank_section (section : String)
is
File_Handle : TIO.File_Type;
begin
TIO.Open (File => File_Handle,
Mode => TIO.Append_File,
Name => conf_location);
TIO.Put_Line (File_Handle, "");
TIO.Put_Line (File_Handle, "[" & section & "]");
TIO.Close (File_Handle);
exception
when Error : others =>
raise update_config
with "Failed to append [" & section & "] at " & conf_location;
end write_blank_section;
---------------------------
-- default_parallelism --
---------------------------
procedure default_parallelism (num_cores : cpu_range;
num_builders : out Integer;
jobs_per_builder : out Integer)
is
begin
case num_cores is
when 1 =>
num_builders := 1;
jobs_per_builder := 1;
when 2 | 3 =>
num_builders := 2;
jobs_per_builder := 2;
when 4 | 5 =>
num_builders := 3;
jobs_per_builder := 3;
when 6 | 7 =>
num_builders := 4;
jobs_per_builder := 3;
when 8 | 9 =>
num_builders := 6;
jobs_per_builder := 4;
when 10 | 11 =>
num_builders := 8;
jobs_per_builder := 4;
when others =>
num_builders := (Integer (num_cores) * 3) / 4;
jobs_per_builder := 5;
end case;
end default_parallelism;
----------------------
-- extract_string --
----------------------
function extract_string (profile, mark, default : String) return JT.Text
is
begin
return JT.SUS (internal_config.Value_Of (profile, mark, default));
end extract_string;
-----------------------
-- extract_boolean --
-----------------------
function extract_boolean (profile, mark : String; default : Boolean)
return Boolean
is
begin
return internal_config.Value_Of (profile, mark, default);
end extract_boolean;
-----------------------
-- extract_integer --
-----------------------
function extract_integer (profile, mark : String; default : Integer)
return Integer is
begin
return internal_config.Value_Of (profile, mark, default);
end extract_integer;
-----------------
-- param_set --
-----------------
function param_set (profile, field : String) return Boolean
is
garbage : constant String := "this-is-garbage";
begin
return internal_config.Value_Of (profile, field, garbage) /= garbage;
end param_set;
----------------------
-- section_exists --
----------------------
function section_exists (profile, mark : String) return Boolean is
begin
return param_set (profile, mark);
end section_exists;
--------------------------
-- all_params_present --
--------------------------
function all_params_present (profile : String) return Boolean is
begin
return
param_set (profile, Field_01) and then
param_set (profile, Field_02) and then
param_set (profile, Field_03) and then
param_set (profile, Field_04) and then
param_set (profile, Field_05) and then
param_set (profile, Field_06) and then
param_set (profile, Field_07) and then
param_set (profile, Field_08) and then
param_set (profile, Field_09) and then
param_set (profile, Field_10) and then
param_set (profile, Field_11) and then
param_set (profile, Field_12) and then
param_set (profile, Field_13) and then
param_set (profile, Field_14) and then
param_set (profile, Field_15) and then
param_set (profile, Field_16);
end all_params_present;
--------------------------
-- all_global_present --
--------------------------
function all_global_present return Boolean is
begin
return
param_set (master_section, global_01);
end all_global_present;
-------------------------
-- generated_section --
-------------------------
function generated_section return String
is
function USS (US : JT.Text) return String;
function BDS (BD : builders) return String;
function TFS (TF : Boolean) return String;
function USS (US : JT.Text) return String is
begin
return "= " & JT.USS (US) & LAT.LF;
end USS;
function BDS (BD : builders) return String
is
BDI : constant String := Integer'Image (Integer (BD));
begin
return LAT.Equals_Sign & BDI & LAT.LF;
end BDS;
function TFS (TF : Boolean) return String is
begin
if TF then
return LAT.Equals_Sign & " true" & LAT.LF;
else
return LAT.Equals_Sign & " false" & LAT.LF;
end if;
end TFS;
begin
return
Field_12 & USS (configuration.operating_sys) &
Field_01 & USS (configuration.dir_packages) &
Field_02 & USS (configuration.dir_repository) &
Field_03 & USS (configuration.dir_portsdir) &
Field_13 & USS (configuration.dir_options) &
Field_04 & USS (configuration.dir_distfiles) &
Field_05 & USS (configuration.dir_buildbase) &
Field_06 & USS (configuration.dir_logs) &
Field_07 & USS (configuration.dir_ccache) &
Field_14 & USS (configuration.dir_system) &
Field_08 & BDS (configuration.num_builders) &
Field_09 & BDS (configuration.jobs_limit) &
Field_10 & TFS (configuration.tmpfs_workdir) &
Field_11 & TFS (configuration.tmpfs_localbase) &
Field_15 & TFS (configuration.avec_ncurses) &
Field_16 & TFS (configuration.defer_prebuilt);
end generated_section;
-----------------------
-- query_distfiles --
-----------------------
function query_distfiles (portsdir : String) return String
is
-- DISTDIR is used by both pkgsrc and ports collection
begin
return query_generic (portsdir, "DISTDIR");
end query_distfiles;
------------------
-- query_opsys --
-------------------
function query_opsys (portsdir : String) return String
is
-- OPSYS is used by both pkgsrc and ports collection
begin
return query_generic (portsdir, "OPSYS");
end query_opsys;
---------------------
-- query_generic --
---------------------
function query_generic (portsdir, value : String) return String
is
-- devel/gmake exists on both pkgsrc and the ports collection
-- The actual port is not significant
command : constant String := host_make_program & " -C " & portsdir &
"/devel/gmake .MAKE.EXPAND_VARIABLES=yes -V " & value;
begin
return query_generic_core (command);
end query_generic;
--------------------------
-- query_generic_core --
--------------------------
function query_generic_core (command : String) return String
is
content : JT.Text;
status : Integer;
CR_loc : Integer;
CR : constant String (1 .. 1) := (1 => Character'Val (10));
begin
content := Unix.piped_command (command, status);
if status /= 0 then
raise make_query with command;
end if;
CR_loc := JT.SU.Index (Source => content, Pattern => CR);
return JT.SU.Slice (Source => content, Low => 1, High => CR_loc - 1);
end query_generic_core;
----------------------
-- query_portsdir --
----------------------
function query_portsdir return String
is
-- This is specific to the ports collection (invalid for pkgsrc)
command : constant String := host_make_program &
" -f /usr/share/mk/bsd.port.mk -V PORTSDIR";
begin
return query_generic_core (command);
exception
when others => return "";
end query_portsdir;
-----------------------------
-- query_physical_memory --
-----------------------------
procedure query_physical_memory is
-- Works for *BSD, DragonFly, Bitrig
-- DF/Free "hw.physmem: 8525971456" (8G)
-- NetBSD "hw.physmem = 1073278976" (1G)
command : constant String := "/sbin/sysctl hw.physmem";
content : JT.Text;
status : Integer;
begin
memory_megs := 1024;
content := Unix.piped_command (command, status);
if status /= 0 then
TIO.Put_Line ("command failed: " & command);
return;
end if;
declare
type styles is (unknown, dragonfly, netbsd);
function get_number_string return String;
style : styles := unknown;
response : constant String :=
JT.USS (content) (1 .. JT.SU.Length (content) - 1);
SP1 : constant String (1 .. 2) := (1 => LAT.Colon,
2 => LAT.Space);
SP2 : constant String (1 .. 2) := (1 => LAT.Equals_Sign,
2 => LAT.Space);
function get_number_string return String is
begin
case style is
when dragonfly => return JT.part_2 (response, SP1);
when netbsd => return JT.part_2 (response, SP2);
when unknown => return "1073741824";
end case;
end get_number_string;
begin
if JT.contains (response, SP1) then
style := dragonfly;
elsif JT.contains (response, SP2) then
style := netbsd;
else
TIO.Put_Line ("Anomaly, unable to detect physical memory");
TIO.Put_Line (response);
return;
end if;
declare
type memtype is mod 2**64;
numbers : String := get_number_string;
bytes : constant memtype := memtype'Value (numbers);
megs : constant memtype := bytes / 1024 / 1024;
begin
memory_megs := Natural (megs);
end;
end;
end query_physical_memory;
-----------------------------------
-- query_physical_memory_linux --
-----------------------------------
procedure query_physical_memory_linux
is
-- On linux, MemTotal should be on first line and that's what we're looking for
command : constant String := "/usr/bin/head /proc/meminfo";
found : Boolean := False;
status : Integer;
comres : JT.Text;
topline : JT.Text;
crlen1 : Natural;
crlen2 : Natural;
begin
comres := Unix.piped_command (command, status);
if status /= 0 then
raise make_query with command;
end if;
crlen1 := JT.SU.Length (comres);
loop
exit when found;
JT.nextline (lineblock => comres, firstline => topline);
crlen2 := JT.SU.Length (comres);
exit when crlen1 = crlen2;
crlen1 := crlen2;
if JT.SU.Length (topline) > 12 then
declare
line : String := JT.USS (topline);
begin
if line (line'First .. line'First + 8) = "MemTotal:" then
declare
type memtype is mod 2**64;
numbers : String :=
JT.part_1 (S => JT.trim (line (line'First + 9 .. line'Last)),
separator => " ");
kilobytes : constant memtype := memtype'Value (numbers);
megs : constant memtype := kilobytes / 1024;
begin
memory_megs := Natural (megs);
end;
found := True;
end if;
end;
end if;
end loop;
end query_physical_memory_linux;
-----------------------------------
-- query_physical_memory_sunos --
-----------------------------------
procedure query_physical_memory_sunos
is
-- On Solaris, we're looking for "Memory size" which should be on second line
command : constant String := "/usr/sbin/prtconf";
found : Boolean := False;
status : Integer;
comres : JT.Text;
topline : JT.Text;
crlen1 : Natural;
crlen2 : Natural;
begin
comres := Unix.piped_command (command, status);
if status /= 0 then
raise make_query with command;
end if;
crlen1 := JT.SU.Length (comres);
loop
exit when found;
JT.nextline (lineblock => comres, firstline => topline);
crlen2 := JT.SU.Length (comres);
exit when crlen1 = crlen2;
crlen1 := crlen2;
if JT.SU.Length (topline) > 12 then
declare
line : String := JT.USS (topline);
begin
if line (line'First .. line'First + 11) = "Memory size:" then
declare
type memtype is mod 2**64;
numbers : String :=
JT.part_1 (line (line'First + 13 .. line'Last), " ");
megabytes : constant memtype := memtype'Value (numbers);
begin
memory_megs := Natural (megabytes);
end;
found := True;
end if;
end;
end if;
end loop;
end query_physical_memory_sunos;
---------------------
-- enough_memory --
---------------------
function enough_memory (num_builders : builders; opsys : JT.Text) return Boolean is
megs_per_slave : Natural;
begin
if memory_megs = 0 then
if JT.equivalent (opsys, "Linux") then
query_physical_memory_linux;
elsif JT.equivalent (opsys, "SunOS") then
query_physical_memory_sunos;
else
query_physical_memory;
end if;
end if;
megs_per_slave := memory_megs / Positive (num_builders);
return megs_per_slave >= 1280;
end enough_memory;
----------------------------
-- write_master_section --
----------------------------
procedure write_master_section
is
function USS (US : JT.Text) return String;
function USS (US : JT.Text) return String is
begin
return "= " & JT.USS (US) & LAT.LF;
end USS;
contents : String :=
global_01 & USS (configuration.profile);
begin
internal_config.Replace_Section (master_section, contents);
exception
when Error : others =>
raise update_config
with "Failed to update [" & master_section & "] at " & conf_location;
end write_master_section;
---------------------
-- sections_list --
---------------------
function sections_list return JT.Text
is
handle : TIO.File_Type;
result : JT.Text;
begin
TIO.Open (File => handle, Mode => TIO.In_File, Name => conf_location);
while not TIO.End_Of_File (handle) loop
declare
Line : String := TIO.Get_Line (handle);
begin
if Line'Length > 0 and then
Line (1) = '[' and then
Line /= "[" & master_section & "]"
then
JT.SU.Append (result, Line (2 .. Line'Last - 1) & LAT.LF);
end if;
end;
end loop;
TIO.Close (handle);
return result;
end sections_list;
-----------------------
-- default_profile --
-----------------------
function default_profile (new_profile : String;
num_cores : cpu_range) return configuration_record
is
result : configuration_record;
def_builders : Integer;
def_jlimit : Integer;
begin
default_parallelism (num_cores => num_cores,
num_builders => def_builders,
jobs_per_builder => def_jlimit);
result.dir_portsdir := JT.SUS (std_ports_loc);
result.operating_sys := JT.SUS (query_opsys (std_ports_loc));
result.profile := JT.SUS (new_profile);
result.dir_system := JT.SUS (std_sysbase);
result.dir_repository := JT.SUS (LS_Packages & "/All");
result.dir_packages := JT.SUS (LS_Packages);
result.dir_distfiles := JT.SUS (std_distfiles);
result.dir_buildbase := JT.SUS (LS_Buildbase);
result.dir_logs := JT.SUS (LS_Logs);
result.dir_ccache := JT.SUS (no_ccache);
result.dir_options := JT.SUS (std_options);
result.num_builders := builders (def_builders);
result.jobs_limit := builders (def_jlimit);
result.tmpfs_workdir := enough_memory (result.num_builders, result.operating_sys);
result.tmpfs_localbase := enough_memory (result.num_builders, result.operating_sys);
result.avec_ncurses := True;
result.defer_prebuilt := False;
write_blank_section (section => new_profile);
return result;
end default_profile;
------------------------
-- mkdirp_from_file --
------------------------
procedure mkdirp_from_file (filename : String)
is
condir : String := AD.Containing_Directory (Name => filename);
begin
AD.Create_Path (New_Directory => condir);
exception
when others =>
raise update_config;
end mkdirp_from_file;
-----------------------
-- all_paths_valid --
-----------------------
function all_paths_valid return Boolean
is
use type AD.File_Kind;
function invalid_directory (folder : JT.Text; desc : String)
return Boolean;
function invalid_directory (folder : JT.Text; desc : String)
return Boolean
is
dossier : constant String := JT.USS (folder);
errmsg : constant String := "Configuration invalid: ";
begin
if AD.Exists (dossier) and then AD.Kind (dossier) = AD.Directory then
return False;
else
TIO.Put_Line (errmsg & desc & " directory: " & dossier);
return True;
end if;
end invalid_directory;
begin
declare
synth_tmp : constant String := "/var/synth";
begin
if invalid_directory (JT.SUS (synth_tmp), "xxx") then
if AD.Exists (synth_tmp) then
AD.Delete_File (synth_tmp);
end if;
AD.Create_Path (New_Directory => synth_tmp);
end if;
exception
when others =>
TIO.Put_Line ("Failed to create " & synth_tmp);
return False;
end;
if invalid_directory (configuration.dir_system, "[G] System root") then
return False;
elsif invalid_directory (configuration.dir_packages, "[B] Packages") then
return False;
elsif invalid_directory (configuration.dir_portsdir, "[A] Ports") then
return False;
elsif invalid_directory (configuration.dir_distfiles, "[C] Distfiles")
then
if JT.equivalent (configuration.dir_distfiles, "/usr/ports/distfiles")
then
TIO.Put_Line
("Rather than manually creating a directory at this location, " &
"consider" & LAT.LF &
"using a location outside of the ports tree. Don't forget " &
"to set" & LAT.LF &
"'DISTDIR' to this new location in /etc/make.conf though.");
end if;
return False;
elsif invalid_directory (configuration.dir_logs, "[E] Build logs") then
return False;
elsif invalid_directory (configuration.dir_options, "[D] Port options")
then
return False;
end if;
if JT.USS (configuration.dir_ccache) = no_ccache then
return True;
end if;
return not invalid_directory (configuration.dir_ccache,
"[H] Compiler cache");
end all_paths_valid;
----------------------
-- delete_profile --
----------------------
procedure delete_profile (profile : String)
is
old_file : TIO.File_Type;
new_file : TIO.File_Type;
nextgen : constant String := synth_confdir & "/synth.ini.next";
pattern : constant String := "[" & profile & "]";
blocking : Boolean := False;
begin
if not AD.Exists (conf_location) then
raise update_config
with "The " & conf_location & " configuration file does not exist.";
end if;
-- Try to defend malicious symlink: https://en.wikipedia.org/wiki/Symlink_race
if AD.Exists (nextgen) then
AD.Delete_File (nextgen);
end if;
TIO.Create (File => new_file, Mode => TIO.Out_File, Name => nextgen);
TIO.Open (File => old_file, Mode => TIO.In_File, Name => conf_location);
while not TIO.End_Of_File (old_file) loop
declare
Line : constant String := TIO.Get_Line (old_file);
bracket : Boolean := False;
begin
if not JT.IsBlank (Line) then
bracket := Line (1) = '[';
end if;
if bracket and then blocking then
blocking := False;
end if;
if not blocking and then Line = pattern then
blocking := True;
end if;
if not blocking then
TIO.Put_Line (new_file, Line);
end if;
end;
end loop;
TIO.Close (old_file);
TIO.Close (new_file);
AD.Delete_File (conf_location);
AD.Rename (Old_Name => nextgen, New_Name => conf_location);
exception
when others =>
if TIO.Is_Open (new_file) then
TIO.Close (new_file);
end if;
if AD.Exists (nextgen) then
AD.Delete_File (nextgen);
end if;
if TIO.Is_Open (old_file) then
TIO.Close (old_file);
end if;
raise update_config
with "Failed to remove " & profile & " profile";
end delete_profile;
----------------------------------
-- alternative_profiles_exist --
----------------------------------
function alternative_profiles_exist return Boolean
is
counter : Natural := 0;
conf_file : TIO.File_Type;
begin
if not AD.Exists (conf_location) then
return False;
end if;
TIO.Open (File => conf_file, Mode => TIO.In_File, Name => conf_location);
while not TIO.End_Of_File (conf_file) loop
declare
Line : constant String := TIO.Get_Line (conf_file);
bracket : Boolean := False;
begin
if not JT.IsBlank (Line) then
bracket := Line (1) = '[';
end if;
if bracket and then Line /= "[" & master_section & "]"
then
counter := counter + 1;
end if;
end;
end loop;
TIO.Close (conf_file);
return counter > 1;
exception
when others =>
if TIO.Is_Open (conf_file) then
TIO.Close (conf_file);
end if;
return False;
end alternative_profiles_exist;
end Parameters;
|
{% load kdev_filters %}
{% block license_header %}
{% if license %}
--
{{ license|lines_prepend:"-- " }}
--
{% endif %}
{% endblock license_header %}
with Ada.Command_Line, GNAT.Command_Line;
with Ada.Directories, Ada.Environment_Variables;
with Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
-- all methods in .Unbounded are easy to ident and have unique names, no need to hide visibility
procedure {{ name }} is
procedure printUsage is
use Ada.Text_IO;
begin
Put_Line ("!!!DESCRIPTION!!!");
New_Line;
Put_Line ("usage:");
Put_Line (" " & Ada.Command_Line.Command_Name & " [-h -g -n: -v] positional");
New_Line;
Put_Line ("options:");
-- only short options for now
Put_Line ("-h print this help");
Put_Line ("-g turn on debug output");
Put_Line ("-v be verbose");
Put_Line ("-n enter some number");
end printUsage;
Finish : exception; -- normal termination
-- Ada doesn't have an analog of sys.exit() in the standard, because of multitasking
-- support directly by the language. So just raise this anywhere and catch at the top..
--
-- If you really miss this function, OS_Exit/OS_Abort are defined in
-- GNAT.OS_Lib (one of gnat extensions). Just be aware that it does not play well with Spawn and other
-- process-controll features!!
type ParamRec is record
-- mostly the commandline params. DepGraph and USE flags will go as separate vars
name : Unbounded_String := Null_Unbounded_String;
workDir : Unbounded_String := Null_Unbounded_String;
val : Integer := 0;
Debug : Boolean := False;
end record;
procedure processCommandLine (params : in out ParamRec) is
-- this works very similarly to GNU getopt, except this one uses single '-'
-- for both short and long options
use Ada.Command_Line, GNAT.Command_Line, Ada.Text_IO;
Options : constant String := "g h n: v";
Last:Positive;
begin
if Argument_Count < 1 then
printUsage;
raise Finish;
end if;
begin -- need to process local exceptions
loop
case Getopt (Options) is
when ASCII.NUL =>
exit;
-- end of option list
when 'g' or 'v' => params.Debug := True;
when 'h' =>
printUsage;
raise Finish;
when 'n' => Get(Parameter,Positive(params.val),Last);
when others =>
raise Program_Error;
-- serves to catch "damn, forgot to include that option here"
end case;
end loop;
exception
when Invalid_Switch =>
Put_Line ("Invalid Switch " & Full_Switch);
raise Finish;
when Invalid_Parameter =>
Put_Line ("No parameter for " & Full_Switch);
raise Finish;
when Data_Error =>
Put_Line ("Invalid numeric format for switch" & Full_Switch);
raise Finish;
end;
params.name := To_Unbounded_String (Get_Argument (Do_Expansion => True));
--
-- Set WorkDir
declare -- just a visibility wrapper
use Ada.Directories;
begin
if Ada.Environment_Variables.Exists ("ENV_VAR") then
params.WorkDir :=
To_Unbounded_String (Ada.Environment_Variables.Value ("ENV_VAR"));
else
params.WorkDir := To_Unbounded_String (Current_Directory);
end if;
--
if not Exists (To_String (params.WorkDir))
or else Kind (To_String (params.WorkDir)) /= Directory
then
Put_Line
("The directory " & To_String (params.WorkDir) & " does not exist!");
raise Finish;
end if;
end;
end processCommandLine;
params : ParamRec;
begin -- main
processCommandLine (params);
exception
when Finish => null;
end {{ name }};
|
--
-- Jan & Uwe R. Zimmer, Australia, July 2011
--
package body Keyboard is
-----------------------
-- Keyboard Commands --
-----------------------
procedure Get_Keys (Commands : in out Commands_Array;
Selected_Keyboard : access GLUT.Devices.Keyboard := GLUT.Devices.default_Keyboard'Access) is
begin
if Selected_Keyboard.all.modif_set (GLUT.Active_Alt) then -- Alt Button Commands
Commands (Full_Screen) := Selected_Keyboard.all.normal_set ('F');
Commands (Reset_Camera) := Selected_Keyboard.all.normal_set ('C');
Commands (Text_Overlay) := Selected_Keyboard.all.normal_set ('T');
Commands (Toggle_Axis) := Selected_Keyboard.all.normal_set (',');
Commands (Toggle_Lines) := Selected_Keyboard.all.normal_set ('.');
Commands (Screen_Shot) := Selected_Keyboard.all.normal_set ('S');
else
Commands (Move_Accelerator) := Selected_Keyboard.all.modif_set (GLUT.Active_Shift);
Commands (Space) := Selected_Keyboard.all.normal_set (' ');
-- Rotate Commands --
Commands (Rotate_Up) := Selected_Keyboard.all.normal_set ('I');
Commands (Rotate_Down) := Selected_Keyboard.all.normal_set ('K');
Commands (Rotate_Left) := Selected_Keyboard.all.normal_set ('J');
Commands (Rotate_Right) := Selected_Keyboard.all.normal_set ('L');
Commands (Rotate_CW) := Selected_Keyboard.all.normal_set ('O');
Commands (Rotate_AntiCW) := Selected_Keyboard.all.normal_set ('U');
-- Strafe Commands --
Commands (Strafe_Up) := Selected_Keyboard.all.normal_set ('Q');
Commands (Strafe_Down) := Selected_Keyboard.all.normal_set ('E');
Commands (Strafe_Left) := Selected_Keyboard.all.normal_set ('A');
Commands (Strafe_Right) := Selected_Keyboard.all.normal_set ('D');
Commands (Strafe_Forward) := Selected_Keyboard.all.normal_set ('W');
Commands (Strafe_Backward) := Selected_Keyboard.all.normal_set ('S');
-- Swarm
Commands (Add_Vehicle) := Selected_Keyboard.all.normal_set ('+');
Commands (Remove_Vehicle) := Selected_Keyboard.all.normal_set ('-');
end if;
end Get_Keys;
end Keyboard;
|
with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package body Rejuvenation.File_Utils is
procedure Write_String_To_File (Contents : String; File_Name : String) is
F : Ada.Streams.Stream_IO.File_Type;
begin
Create_Path (Containing_Directory (File_Name));
Create (F, Out_File, File_Name);
String'Write (Stream (F), Contents);
Close (F);
end Write_String_To_File;
function Get_String_From_File (File_Name : String) return String is
F : Ada.Streams.Stream_IO.File_Type;
Return_Value : Unbounded_String;
begin
Open (F, In_File, File_Name);
while not End_Of_File (F) loop
declare
C : Character;
begin
Character'Read (Stream (F), C);
Append (Return_Value, C);
end;
end loop;
Close (F);
return To_String (Return_Value);
end Get_String_From_File;
procedure Walk_Files
(Directory_Name : String; File_Pattern : String;
Process_File : not null access procedure (Item : Directory_Entry_Type);
Recursive : Boolean := True)
is
procedure Process_Directory (Item : Directory_Entry_Type);
procedure Process_Directory (Item : Directory_Entry_Type) is
begin
if Simple_Name (Item) not in "." | ".." then
Walk_Files (Full_Name (Item), File_Pattern, Process_File);
end if;
exception
when Ada.Directories.Name_Error =>
null;
end Process_Directory;
begin
Search (Directory_Name, File_Pattern, (others => True), Process_File);
Search
(Directory_Name, "", (Directory => Recursive, others => False),
Process_Directory'Access);
end Walk_Files;
end Rejuvenation.File_Utils;
|
package body Test_Solution is
procedure Assert( Test : Boolean ) is
begin
if not Test then
raise Assertion_Error;
end if;
end Assert;
procedure Set_Name( C : in out Solution_Case; Name : String ) is
begin
C.Name := SU.To_Unbounded_String(Name);
end Set_Name;
function Get_Name( C : in Solution_Case ) return String is
begin
return SU.To_String(C.Name);
end Get_Name;
procedure Add_Test( C : in out Solution_Case; Func : Solution ) is
begin
C.Tests.Append(Func);
end Add_Test;
end Test_Solution;
|
-- Copyright (c) 1990 Regents of the University of California.
-- All rights reserved.
--
-- The primary authors of ayacc were David Taback and Deepak Tolani.
-- Enhancements were made by Ronald J. Schmalz.
--
-- Send requests for ayacc information to ayacc-info@ics.uci.edu
-- Send bug reports for ayacc to ayacc-bugs@ics.uci.edu
--
-- Redistribution and use in source and binary forms are permitted
-- provided that the above copyright notice and this paragraph are
-- duplicated in all such forms and that any documentation,
-- advertising materials, and other materials related to such
-- distribution and use acknowledge that the software was developed
-- by the University of California, Irvine. The name of the
-- University may not be used to endorse or promote products derived
-- from this software without specific prior written permission.
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-- Module : symbol_table_body.ada
-- Component of : ayacc
-- Version : 1.2
-- Date : 11/21/86 12:37:53
-- SCCS File : disk21~/rschm/hasee/sccs/ayacc/sccs/sxsymbol_table_body.ada
-- $Header: symbol_table_body.a,v 0.1 86/04/01 15:13:55 ada Exp $
-- $Log: symbol_table_body.a,v $
-- Revision 0.1 86/04/01 15:13:55 ada
-- This version fixes some minor bugs with empty grammars
-- and $$ expansion. It also uses vads5.1b enhancements
-- such as pragma inline.
--
--
-- Revision 0.0 86/02/19 18:54:02 ada
--
-- These files comprise the initial version of Ayacc
-- designed and implemented by David Taback and Deepak Tolani.
-- Ayacc has been compiled and tested under the Verdix Ada compiler
-- version 4.06 on a vax 11/750 running Unix 4.2BSD.
--
package body Symbol_Table is
SCCS_ID : constant String := "@(#) symbol_table_body.ada, Version 1.2";
Next_Free_Terminal : Grammar_Symbol := 0;
Next_Free_Nonterminal : Grammar_Symbol := -1;
Start_Symbol_Pos, End_Symbol_Pos : Grammar_Symbol;
type String_Pointer is access String;
type Table_Entry(ID : Grammar_Symbol);
type Entry_Pointer is access Table_Entry;
type Table_Entry(ID :Grammar_Symbol) is
record
Name : String_Pointer;
Next : Entry_Pointer;
case ID is
when 0..Grammar_Symbol'Last => -- Terminal
Prec : Precedence;
Assoc : Associativity;
when others => -- Nonterminal
null;
end case;
end record;
Hash_Table_Size : constant := 613; -- A large prime number
type Hash_Index is range 0..Hash_Table_Size-1;
Hash_Table : array(Hash_Index) of Entry_Pointer;
--
-- Create a 'dynamic' array for looking up an entry
-- for a given grammar_symbol.
--
Block_Size : constant Grammar_Symbol := 100;
type Lookup_Array is
array(Grammar_Symbol range 0..Block_Size-1) of Entry_Pointer;
type Block;
type Block_Pointer is access Block;
type Block is
record
Lookup : Lookup_Array;
Next : Block_Pointer := null;
end record;
-- have separate blocks for terminals and nonterminals.
Terminal_Blocks, Nonterminal_Blocks : Block_Pointer := new Block;
procedure Make_Lookup_Table_Entry
(ID : in Grammar_Symbol;
Entry_Ptr : in Entry_Pointer) is
ID_Block : Block_Pointer;
Block_Number : Integer;
begin
if ID >= 0 then
ID_Block := Terminal_Blocks;
else
ID_Block := Nonterminal_Blocks;
end if;
Block_Number := Integer (abs ID / Block_Size);
for I in 1..Block_Number loop
if ID_Block.Next = null then
ID_Block.Next := new Block;
end if;
ID_Block := ID_Block.Next;
end loop;
ID_Block.Lookup((abs ID) mod Block_Size) := Entry_Ptr;
end Make_Lookup_Table_Entry;
function Get_Lookup_Table_Entry(ID: Grammar_Symbol) return Entry_Pointer is
ID_Block : Block_Pointer;
begin
if ID >= 0 then
ID_Block := Terminal_Blocks;
else
ID_Block := Nonterminal_Blocks;
end if;
for I in 1.. abs ID / Block_Size loop
ID_Block := ID_Block.Next;
end loop;
return ID_Block.Lookup((abs ID) mod Block_Size);
end Get_Lookup_Table_Entry;
-- some day someone should put in a good hash function.
function Hash_Value (S : String) return Hash_Index is
H : Integer;
Mid : Integer;
begin
Mid := (S'First + S'Last) / 2;
H := ((Character'Pos(S(S'First)) +
Character'Pos(S(Mid)) +
Character'Pos(S(S'Last)))
* S'Length * 16 ) mod Hash_Table_Size;
return Hash_Index(H);
end Hash_Value;
function Insert_Identifier (Name: in String) return Grammar_Symbol is
Index : Hash_Index;
Entry_Ptr : Entry_Pointer;
begin
Index := Hash_Value(Name);
Entry_Ptr := Hash_Table(Index);
if Entry_Ptr = null then
Entry_Ptr := new Table_Entry(Next_Free_Nonterminal);
Entry_Ptr.Name := new String(1..Name'Length);
Entry_Ptr.Name.all := Name;
Hash_Table(Index) := Entry_Ptr;
Make_Lookup_Table_Entry(Next_Free_Nonterminal, Entry_Ptr);
Next_Free_Nonterminal := Next_Free_Nonterminal - 1;
else
loop
if Entry_Ptr.Name.all = Name then
return Entry_Ptr.ID;
end if;
if Entry_Ptr.Next = null then
exit;
end if;
Entry_Ptr := Entry_Ptr.Next;
end loop;
Entry_Ptr.Next := new Table_Entry(Next_Free_Nonterminal);
Entry_Ptr := Entry_Ptr.Next;
Entry_Ptr.Name := new String(1..Name'Length);
Entry_Ptr.Name.all := Name;
Make_Lookup_Table_Entry(Next_Free_Nonterminal, Entry_Ptr);
Next_Free_Nonterminal := Next_Free_Nonterminal - 1;
end if;
return Next_Free_Nonterminal + 1;
end Insert_Identifier;
function Insert_Terminal
(Name : String;
Prec : Precedence := 0;
Assoc : Associativity := Undefined) return Grammar_Symbol is
Index : Hash_Index;
Entry_Ptr : Entry_Pointer;
begin
Index := Hash_Value(Name);
Entry_Ptr := Hash_Table(Index);
if Entry_Ptr = null then
Entry_Ptr := new Table_Entry(Next_Free_Terminal);
Entry_Ptr.Name := new String(1..Name'Length);
Entry_Ptr.Name.all := Name;
Entry_Ptr.Assoc := Assoc;
Entry_Ptr.Prec := Prec;
Hash_Table(Index) := Entry_Ptr;
Make_Lookup_Table_Entry(Next_Free_Terminal, Entry_Ptr);
Next_Free_Terminal := Next_Free_Terminal + 1;
else
loop
if Entry_Ptr.Name.all = Name then
if Entry_Ptr.ID < 0 then -- Look out for nonterminals
raise Illegal_Entry;
end if;
if Prec /= 0 then
if Entry_Ptr.Prec /= 0 then
raise Redefined_Precedence_Error;
end if;
Entry_Ptr.Prec := Prec;
Entry_Ptr.Assoc := Assoc;
end if;
return Entry_Ptr.ID;
end if;
if Entry_Ptr.Next = null then
exit;
end if;
Entry_Ptr := Entry_Ptr.Next;
end loop;
Entry_Ptr.Next := new Table_Entry(Next_Free_Terminal);
Entry_Ptr := Entry_Ptr.Next;
Entry_Ptr.Name := new String(1..Name'Length);
Entry_Ptr.Name.all := Name;
Entry_Ptr.Assoc := Assoc;
Entry_Ptr.Prec := Prec;
Make_Lookup_Table_Entry(Next_Free_Terminal, Entry_Ptr);
Next_Free_Terminal := Next_Free_Terminal + 1;
end if;
return Next_Free_Terminal - 1;
end Insert_Terminal;
function Get_Associativity (ID: Grammar_Symbol) return Associativity is
begin
return Get_Lookup_Table_Entry(ID).Assoc;
end;
function Get_Precedence (ID: Grammar_Symbol) return Precedence is
begin
return Get_Lookup_Table_Entry(ID).Prec;
end;
function Get_Symbol_Name (ID: Grammar_Symbol) return String is
begin
return Get_Lookup_Table_Entry(ID).Name.all;
end;
function First_Symbol (Kind: Symbol_Type) return Grammar_Symbol is
begin
if Kind = Terminal then
return 0;
else
return Next_Free_Nonterminal + 1;
end if;
end;
function Last_Symbol (Kind: Symbol_Type) return Grammar_Symbol is
begin
if Kind = Terminal then
return Next_Free_Terminal - 1;
else
return -1;
end if;
end;
function First_Terminal return Grammar_Symbol is
begin
return 0;
end;
function Last_Terminal return Grammar_Symbol is
begin
return Next_Free_Terminal - 1;
end;
function Start_Symbol return Grammar_Symbol is
begin
return Start_Symbol_Pos;
end;
function End_Symbol return Grammar_Symbol is
begin
return End_Symbol_Pos;
end;
function Is_Terminal (ID: Grammar_Symbol) return Boolean is
begin
return ID >= 0;
end;
function Is_Nonterminal (ID: Grammar_Symbol) return Boolean is
begin
return ID < 0;
end;
begin
End_Symbol_Pos := Insert_Terminal("END_OF_INPUT");
Start_Symbol_Pos := Insert_Identifier("$accept");
-- declare a dummy symbol to insert the "error" token.
declare
Dummy_Sym : Grammar_Symbol;
begin
Dummy_Sym := Insert_Terminal("ERROR");
end;
end Symbol_Table;
|
with ada.text_io, ada.Integer_text_IO, Ada.Text_IO.Text_Streams, Ada.Strings.Fixed, Interfaces.C;
use ada.text_io, ada.Integer_text_IO, Ada.Strings, Ada.Strings.Fixed, Interfaces.C;
procedure test_returns is
type stringptr is access all char_array;
function is_pair(i : in Integer) return Boolean is
j : Integer;
begin
j := 1;
if i < 10
then
j := 2;
if i = 0
then
j := 4;
return TRUE;
end if;
j := 3;
if i = 2
then
j := 4;
return TRUE;
end if;
j := 5;
end if;
j := 6;
if i < 20
then
if i = 22
then
j := 0;
end if;
j := 8;
end if;
return i rem 2 = 0;
end;
begin
NULL;
end;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Atomic.Unsigned;
package body Offmt_Lib.Parser is
function Parse_Format (Str : String) return Trace_Element;
function Create_Plain_String (Str : String) return Trace_Element;
package Atomic_Id_Counter is new Atomic.Unsigned (Trace_ID);
Id_Counter : aliased Atomic_Id_Counter.Instance :=
Atomic_Id_Counter.Init (0);
------------------
-- Parse_Format --
------------------
function Parse_Format (Str : String) return Trace_Element is
Result : Format;
Col : Natural;
begin
Result.Kind := Decimal;
Put_Line ("Parsing Format: '" & Str & "'");
Col := Index (Str, ":", Str'First);
if Col = 0 then
raise Program_Error with "Invalid fmt (no :)";
end if;
Result.Expression := To_Unbounded_String (Str (Col + 1 .. Str'Last));
declare
Fmt_Param : constant String := Str (Str'First .. Col - 1);
Last : Natural := Fmt_Param'First;
begin
if Fmt_Param'Length = 0 then
raise Program_Error with "Invalid fmt (no param)";
end if;
case Fmt_Param (Last) is
when 'd' =>
Result.Kind := Decimal;
Last := Last + 1;
when 'x' =>
Result.Kind := Hexadecimal;
Last := Last + 1;
when 'b' =>
Result.Kind := Binary;
Last := Last + 1;
when others =>
null;
end case;
declare
Type_Str : constant String := Fmt_Param (Last .. Fmt_Param'Last);
begin
if Fmt_Param'Length = 0 then
raise Program_Error with "Invalid fmt (no format type)";
end if;
if Type_Str = "u8" then
Result.Typ := Type_U8;
elsif Type_Str = "u16" then
Result.Typ := Type_U16;
elsif Type_Str = "u32" then
Result.Typ := Type_U32;
else
raise Program_Error with "Invalid fmt (unknown type: '" &
Type_Str & "')";
end if;
end;
end;
return (Kind => Format_String, Fmt => Result);
end Parse_Format;
-------------------------
-- Create_Plain_String --
-------------------------
function Create_Plain_String (Str : String) return Trace_Element is
begin
return (Kind => Plain_String, Str => To_Unbounded_String (Str));
end Create_Plain_String;
-----------
-- Parse --
-----------
function Parse (Str : String) return Trace is
Result : Trace;
Last : Natural := Str'First;
From : Natural;
To : Natural;
begin
Put_Line ("Parsing Trace: '" & Str & "'");
Result.Original := To_Unbounded_String (Str);
while Last in Str'Range loop
From := Index (Str, "{", Last);
if From /= 0 then
if From - 1 >= Last then
Result.List.Append
(Create_Plain_String (Str (Last .. From - 1)));
end if;
To := Index (Str, "}", From + 1);
if To /= 0 then
Put_Line ("Slice: " & From'Img & " .." & To'Img);
declare
Fmt : constant Trace_Element :=
Parse_Format (Str (From + 1 .. To - 1));
begin
Put_Line (Fmt.Fmt.Kind'Img);
Put_Line (To_String (Fmt.Fmt.Expression));
Result.List.Append (Fmt);
end;
Last := To + 1;
else
raise Program_Error with "unmatched '}'";
end if;
else
exit;
end if;
end loop;
if Last in Str'Range then
Result.List.Append (Create_Plain_String (Str (Last .. Str'Last)));
end if;
Result.Id := Atomic_Id_Counter.Add_Fetch (Id_Counter, 1);
return Result;
end Parse;
end Offmt_Lib.Parser;
|
with AdaBase;
with Connect;
with MyLogger;
with Ada.Text_IO;
with AdaBase.Logger.Facility;
procedure Fruit4 is
package CON renames Connect;
package TIO renames Ada.Text_IO;
package ALF renames AdaBase.Logger.Facility;
numrows : AdaBase.Affected_Rows;
cmd1 : constant String := "INSERT INTO fruits (fruit, color, calories) " &
"VALUES ('blueberry', 'purple', 1)";
cmd2 : constant String := "INSERT INTO fruits (fruit, color, calories) " &
"VALUES ('date', 'brown', 66)";
atch : constant String := "The custom logger has been attached.";
dtch : constant String := "The custom logger has been detached.";
begin
CON.DR.attach_custom_logger (logger_access => MyLogger.clogger'Access);
TIO.Put_Line (atch);
CON.connect_database;
numrows := CON.DR.execute (sql => cmd1);
TIO.Put_Line ("SQL: " & cmd1);
TIO.Put_Line ("Result: Inserted" & numrows'Img & " rows");
TIO.Put_Line ("ID of last inserted row:" & CON.DR.last_insert_id'Img);
CON.DR.detach_custom_logger;
TIO.Put_Line (dtch);
numrows := CON.DR.execute (sql => cmd2);
TIO.Put_Line ("SQL: " & cmd2);
TIO.Put_Line ("Result: Inserted" & numrows'Img & " rows");
TIO.Put_Line ("ID of last inserted row:" & CON.DR.last_insert_id'Img);
CON.DR.attach_custom_logger (logger_access => MyLogger.clogger'Access);
TIO.Put_Line (atch);
CON.DR.commit;
CON.DR.disconnect;
end Fruit4;
|
package body Other_Basic_Subprogram_Calls is
function Other_F1 return Integer is
begin
return 42;
end Other_F1;
procedure Other_P1 is
begin
null;
end Other_P1;
end Other_Basic_Subprogram_Calls;
|
package body Brackelib.Queues is
procedure Enqueue (Self : in out Queue; Item : T) is
begin
Self.Container.Append (Item);
end Enqueue;
function Dequeue (Self : in out Queue) return T is
Result: T;
begin
if Is_Empty (Self) then
raise Queue_Empty;
end if;
Result := Last_Element (Self.Container);
Delete_Last (Self.Container);
return Result;
end Dequeue;
function Size (Self : Queue) return Integer is
begin
return Natural (Length (Self.Container));
end Size;
function Is_Empty (Self : Queue) return Boolean is
begin
return Size(Self) = 0;
end Is_Empty;
procedure Clear (Self : in out Queue) is
begin
Self.Container.Clear;
end Clear;
end Brackelib.Queues; |
-- Abstract:
--
-- A generic queue, allowing definite non-limited item types.
--
-- Copyright (C) 2004, 2008, 2009, 2011, 2017, 2019 Free Software Foundation All Rights Reserved.
--
-- This library is free software; you can redistribute it and/or modify it
-- under terms of the GNU General Public License as published by the Free
-- Software Foundation; either version 3, or (at your option) any later
-- version. This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--
-- As a special exception under Section 7 of GPL version 3, you are granted
-- additional permissions described in the GCC Runtime Library Exception,
-- version 3.1, as published by the Free Software Foundation.
pragma License (Modified_GPL);
generic
type Item_Type is private;
package SAL.Gen_Bounded_Definite_Queues is
pragma Pure;
type Queue_Type (Size : Positive) is tagged private;
-- Size is maximum number of items in the queue.
-- Tagged to allow Object.Method syntax.
function Get_Overflow_Handling (Queue : in Queue_Type) return Overflow_Action_Type;
procedure Set_Overflow_Handling (Queue : in out Queue_Type; Handling : in Overflow_Action_Type);
-- See Add for meaning of Overflow_Handling. Default is Error.
procedure Clear (Queue : in out Queue_Type);
-- Empty Queue of all items.
function Count (Queue : in Queue_Type) return Natural;
-- Returns count of items in the Queue
function Is_Empty (Queue : in Queue_Type) return Boolean;
-- Returns true if no items are in Queue.
function Is_Full (Queue : in Queue_Type) return Boolean;
-- Returns true if Queue is full.
function Remove (Queue : in out Queue_Type) return Item_Type;
-- Remove head item from Queue, return it.
--
-- Raises Container_Empty if Is_Empty.
function Get (Queue : in out Queue_Type) return Item_Type renames Remove;
procedure Drop (Queue : in out Queue_Type);
-- Remove head item from Queue, discard it.
--
-- Raises Container_Empty if Is_Empty.
function Peek (Queue : in Queue_Type; N : Integer := 0) return Item_Type;
-- Return a copy of a queue item, without removing it. N = 0 is
-- the queue head.
procedure Add (Queue : in out Queue_Type; Item : in Item_Type);
-- Add Item to the tail of Queue.
--
-- If Queue is full, result depends on Queue.Overflow_Handling:
--
-- when Overwrite, an implicit Remove is done (and the data
-- discarded), then Add is done.
--
-- when Error, raises Container_Full.
procedure Put (Queue : in out Queue_Type; Item : in Item_Type) renames Add;
procedure Add_To_Head (Queue : in out Queue_Type; Item : in Item_Type);
-- Add Item to the head of Queue.
--
-- If Queue is full, result depends on Queue.Overflow_Handling:
--
-- when Overwrite, an implicit Remove is done (and the data
-- discarded), then Add is done.
--
-- when Error, raises Container_Full.
private
type Item_Array_Type is array (Positive range <>) of Item_Type;
type Queue_Type (Size : Positive) is tagged record
Overflow_Handling : Overflow_Action_Type := Error;
Head : Natural := 0;
Tail : Natural := 0;
Count : Natural := 0;
Data : Item_Array_Type (1 .. Size);
-- Add at Tail + 1, remove at Head. Count is current count;
-- easier to keep track of that than to compute Is_Empty for
-- each Add and Remove.
end record;
end SAL.Gen_Bounded_Definite_Queues;
|
--
-- PACKAGE Chebychev_Quadrature
--
-- The package provides tables and procedures for Gaussian quadrature
-- based on Chebychev polynomials (Gaussian-Chebychev quadrature).
-- The number of points used in the quadrature (callocation points)
-- is the generic formal parameter: No_Of_Gauss_Points.
--
-- Usually not the best quadrature routine, but works well in special
-- cases.
--
-- Use the following fragment to calculate the definite integral
-- of a function F(X) in an interval (X_Starting, X_Final):
--
-- Find_Gauss_Nodes (X_Starting, X_Final, X_gauss);
--
-- for I in Gauss_Index loop
-- F_val(I) := F (X_gauss(I));
-- end loop;
-- -- Evaluate the function at the callocation points just once.
--
-- Get_Integral (F_val, X_Starting, X_Final, Area);
--
generic
type Real is digits <>;
No_Of_Gauss_Points : Positive;
with function Cos (X : Real) return Real is <>;
with function Sin (X : Real) return Real is <>;
package Chebychev_Quadrature is
type Gauss_Index is new Positive range 1 .. No_Of_Gauss_Points;
type Gauss_Values is array(Gauss_Index) of Real;
-- Plug X_Starting and X_Final into the following to get the
-- the points X_gauss at which the function to
-- be integrated must be evaluated:
procedure Find_Gauss_Nodes
(X_Starting : in Real;
X_Final : in Real;
X_gauss : out Gauss_Values);
type Function_Values is array(Gauss_Index) of Real;
-- Fill array F_val of this type with values function F:
--
-- for I in Gauss_Index loop
-- F_val(I) := F (X_gauss(I));
-- end loop;
procedure Get_Integral
(F_val : in Function_Values;
X_Starting : in Real;
X_Final : in Real;
Area : out Real);
end Chebychev_Quadrature;
|
-- Shoot'n'loot
-- Copyright (c) 2020 Fabien Chouteau
with GESTE;
with PyGamer.Time;
package Score_Display is
procedure Init (Pos : GESTE.Pix_Point);
procedure Update (Time_In_Game : PyGamer.Time.Time_Ms);
end Score_Display;
|
with Generic_Collection_Test;
with Generic_Table_Test;
with Remote_Node_Test;
package body Unit_Tests is
function Suite return Access_Test_Suite is
type T_GenericTableTest is access all Generic_Table_Test.Test'Class;
type T_GenericCollectionTest is access all Generic_Collection_Test.Test'Class;
type T_RemoteNodeTest is access all Remote_Node_Test.Test'Class;
Ret : constant Access_Test_Suite := new Test_Suite;
GenericTableTest : constant T_GenericTableTest := new Generic_Table_Test.Test;
GenericCollectionTest : constant T_GenericCollectionTest := new Generic_Collection_Test.Test;
RemoteNodeTest : constant T_RemoteNodeTest := new Remote_Node_Test.Test;
begin
Ret.Add_Test (GenericTableTest);
Ret.Add_Test (GenericCollectionTest);
Ret.Add_Test (RemoteNodeTest);
return Ret;
end Suite;
end Unit_Tests;
|
-- AOC 2020, Day 15
with Ada.Text_IO; use Ada.Text_IO;
with Day; use Day;
procedure main is
s : constant Input_Array := (0, 8, 15, 2, 12, 1, 4);
num : constant Natural := 2020;
part1 : constant Natural := sequence(s, num);
num2 : constant Natural := 30000000;
part2 : constant Natural := sequence(s, num2);
begin
put_line("Part 1: " & Natural'Image(part1));
put_line("Part 2: " & Natural'Image(part2));
end main;
|
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
with Ada.Tags;
with Ada.Assertions;
with Apsepp.Test_Node_Class.Private_Test_Reporter;
procedure Apsepp.Test_Node_Class.Generic_Case_And_Suite_Run_Body
(Obj : Test_Node_Interfa'Class;
Outcome : out Test_Outcome;
Kind : Run_Kind;
Cond : not null access function return Boolean) is
use Private_Test_Reporter,
Ada.Assertions;
T : constant Tag := Obj'Tag;
-----------------------------------------------------
function Cond_Check_Succeed return Boolean is
Ret : Boolean;
begin
begin
Ret := Cond.all;
exception
when Cond_E : others =>
Ret := False;
Test_Reporter.Report_Unexpected_Node_Cond_Check_Error (T, Cond_E);
end;
return Ret;
end Cond_Check_Succeed;
-----------------------------------------------------
begin
case Kind is
when Check_Cond =>
Test_Reporter.Report_Node_Cond_Check_Start (T);
if Cond_Check_Succeed then
Outcome := Passed;
Test_Reporter.Report_Passed_Node_Cond_Check (T);
else
Outcome := Failed;
Test_Reporter.Report_Failed_Node_Cond_Check (T);
end if;
when Assert_Cond_And_Run_Test =>
Test_Reporter.Report_Node_Run_Start (T);
if not Cond_Check_Succeed then
Test_Reporter.Report_Failed_Node_Cond_Assert (T);
raise Assertion_Error
with "Unmet run condition for object with tag "
& Ada.Tags.Expanded_Name (T);
else
Test_Reporter.Report_Passed_Node_Cond_Assert (T);
end if;
begin
Work (Obj, Outcome, Assert_Cond_And_Run_Test);
exception
when Run_E : others =>
Outcome := Failed;
Test_Reporter.Report_Unexpected_Node_Run_Error (T, Run_E);
end;
case Outcome is
when Passed =>
Test_Reporter.Report_Passed_Node_Run (T);
when Failed =>
Test_Reporter.Report_Failed_Node_Run (T);
end case;
end case;
end Apsepp.Test_Node_Class.Generic_Case_And_Suite_Run_Body;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A namespace is an element in a model that contains a set of named elements
-- that can be identified by name.
------------------------------------------------------------------------------
with AMF.String_Collections;
limited with AMF.UML.Constraints.Collections;
limited with AMF.UML.Element_Imports.Collections;
with AMF.UML.Named_Elements;
limited with AMF.UML.Named_Elements.Collections;
limited with AMF.UML.Package_Imports.Collections;
limited with AMF.UML.Packageable_Elements.Collections;
package AMF.UML.Namespaces is
pragma Preelaborate;
type UML_Namespace is limited interface
and AMF.UML.Named_Elements.UML_Named_Element;
type UML_Namespace_Access is
access all UML_Namespace'Class;
for UML_Namespace_Access'Storage_Size use 0;
not overriding function Get_Element_Import
(Self : not null access constant UML_Namespace)
return AMF.UML.Element_Imports.Collections.Set_Of_UML_Element_Import is abstract;
-- Getter of Namespace::elementImport.
--
-- References the ElementImports owned by the Namespace.
not overriding function Get_Imported_Member
(Self : not null access constant UML_Namespace)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is abstract;
-- Getter of Namespace::importedMember.
--
-- References the PackageableElements that are members of this Namespace
-- as a result of either PackageImports or ElementImports.
not overriding function Get_Member
(Self : not null access constant UML_Namespace)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is abstract;
-- Getter of Namespace::member.
--
-- A collection of NamedElements identifiable within the Namespace, either
-- by being owned or by being introduced by importing or inheritance.
not overriding function Get_Owned_Member
(Self : not null access constant UML_Namespace)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is abstract;
-- Getter of Namespace::ownedMember.
--
-- A collection of NamedElements owned by the Namespace.
not overriding function Get_Owned_Rule
(Self : not null access constant UML_Namespace)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint is abstract;
-- Getter of Namespace::ownedRule.
--
-- Specifies a set of Constraints owned by this Namespace.
not overriding function Get_Package_Import
(Self : not null access constant UML_Namespace)
return AMF.UML.Package_Imports.Collections.Set_Of_UML_Package_Import is abstract;
-- Getter of Namespace::packageImport.
--
-- References the PackageImports owned by the Namespace.
not overriding function Exclude_Collisions
(Self : not null access constant UML_Namespace;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is abstract;
-- Operation Namespace::excludeCollisions.
--
-- The query excludeCollisions() excludes from a set of
-- PackageableElements any that would not be distinguishable from each
-- other in this namespace.
not overriding function Get_Names_Of_Member
(Self : not null access constant UML_Namespace;
Element : AMF.UML.Named_Elements.UML_Named_Element_Access)
return AMF.String_Collections.Set_Of_String is abstract;
-- Operation Namespace::getNamesOfMember.
--
-- The query getNamesOfMember() takes importing into account. It gives
-- back the set of names that an element would have in an importing
-- namespace, either because it is owned, or if not owned then imported
-- individually, or if not individually then from a package.
-- The query getNamesOfMember() gives a set of all of the names that a
-- member would have in a Namespace. In general a member can have multiple
-- names in a Namespace if it is imported more than once with different
-- aliases. The query takes account of importing. It gives back the set of
-- names that an element would have in an importing namespace, either
-- because it is owned, or if not owned then imported individually, or if
-- not individually then from a package.
not overriding function Import_Members
(Self : not null access constant UML_Namespace;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is abstract;
-- Operation Namespace::importMembers.
--
-- The query importMembers() defines which of a set of PackageableElements
-- are actually imported into the namespace. This excludes hidden ones,
-- i.e., those which have names that conflict with names of owned members,
-- and also excludes elements which would have the same name when imported.
not overriding function Imported_Member
(Self : not null access constant UML_Namespace)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is abstract;
-- Operation Namespace::importedMember.
--
-- The importedMember property is derived from the ElementImports and the
-- PackageImports. References the PackageableElements that are members of
-- this Namespace as a result of either PackageImports or ElementImports.
not overriding function Members_Are_Distinguishable
(Self : not null access constant UML_Namespace)
return Boolean is abstract;
-- Operation Namespace::membersAreDistinguishable.
--
-- The Boolean query membersAreDistinguishable() determines whether all of
-- the namespace's members are distinguishable within it.
not overriding function Owned_Member
(Self : not null access constant UML_Namespace)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is abstract;
-- Operation Namespace::ownedMember.
--
-- Missing derivation for Namespace::/ownedMember : NamedElement
end AMF.UML.Namespaces;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E X P _ D I S P --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Atree; use Atree;
with Checks; use Checks;
with Einfo; use Einfo;
with Elists; use Elists;
with Errout; use Errout;
with Exp_Ch7; use Exp_Ch7;
with Exp_Tss; use Exp_Tss;
with Exp_Util; use Exp_Util;
with Fname; use Fname;
with Itypes; use Itypes;
with Lib; use Lib;
with Nlists; use Nlists;
with Nmake; use Nmake;
with Opt; use Opt;
with Rtsfind; use Rtsfind;
with Sem_Disp; use Sem_Disp;
with Sem_Res; use Sem_Res;
with Sem_Util; use Sem_Util;
with Sinfo; use Sinfo;
with Snames; use Snames;
with Stand; use Stand;
with Tbuild; use Tbuild;
with Uintp; use Uintp;
package body Exp_Disp is
Ada_Actions : constant array (DT_Access_Action) of RE_Id :=
(CW_Membership => RE_CW_Membership,
DT_Entry_Size => RE_DT_Entry_Size,
DT_Prologue_Size => RE_DT_Prologue_Size,
Get_Expanded_Name => RE_Get_Expanded_Name,
Get_External_Tag => RE_Get_External_Tag,
Get_Prim_Op_Address => RE_Get_Prim_Op_Address,
Get_RC_Offset => RE_Get_RC_Offset,
Get_Remotely_Callable => RE_Get_Remotely_Callable,
Get_TSD => RE_Get_TSD,
Inherit_DT => RE_Inherit_DT,
Inherit_TSD => RE_Inherit_TSD,
Register_Tag => RE_Register_Tag,
Set_Expanded_Name => RE_Set_Expanded_Name,
Set_External_Tag => RE_Set_External_Tag,
Set_Prim_Op_Address => RE_Set_Prim_Op_Address,
Set_RC_Offset => RE_Set_RC_Offset,
Set_Remotely_Callable => RE_Set_Remotely_Callable,
Set_TSD => RE_Set_TSD,
TSD_Entry_Size => RE_TSD_Entry_Size,
TSD_Prologue_Size => RE_TSD_Prologue_Size);
CPP_Actions : constant array (DT_Access_Action) of RE_Id :=
(CW_Membership => RE_CPP_CW_Membership,
DT_Entry_Size => RE_CPP_DT_Entry_Size,
DT_Prologue_Size => RE_CPP_DT_Prologue_Size,
Get_Expanded_Name => RE_CPP_Get_Expanded_Name,
Get_External_Tag => RE_CPP_Get_External_Tag,
Get_Prim_Op_Address => RE_CPP_Get_Prim_Op_Address,
Get_RC_Offset => RE_CPP_Get_RC_Offset,
Get_Remotely_Callable => RE_CPP_Get_Remotely_Callable,
Get_TSD => RE_CPP_Get_TSD,
Inherit_DT => RE_CPP_Inherit_DT,
Inherit_TSD => RE_CPP_Inherit_TSD,
Register_Tag => RE_CPP_Register_Tag,
Set_Expanded_Name => RE_CPP_Set_Expanded_Name,
Set_External_Tag => RE_CPP_Set_External_Tag,
Set_Prim_Op_Address => RE_CPP_Set_Prim_Op_Address,
Set_RC_Offset => RE_CPP_Set_RC_Offset,
Set_Remotely_Callable => RE_CPP_Set_Remotely_Callable,
Set_TSD => RE_CPP_Set_TSD,
TSD_Entry_Size => RE_CPP_TSD_Entry_Size,
TSD_Prologue_Size => RE_CPP_TSD_Prologue_Size);
Action_Is_Proc : constant array (DT_Access_Action) of Boolean :=
(CW_Membership => False,
DT_Entry_Size => False,
DT_Prologue_Size => False,
Get_Expanded_Name => False,
Get_External_Tag => False,
Get_Prim_Op_Address => False,
Get_Remotely_Callable => False,
Get_RC_Offset => False,
Get_TSD => False,
Inherit_DT => True,
Inherit_TSD => True,
Register_Tag => True,
Set_Expanded_Name => True,
Set_External_Tag => True,
Set_Prim_Op_Address => True,
Set_RC_Offset => True,
Set_Remotely_Callable => True,
Set_TSD => True,
TSD_Entry_Size => False,
TSD_Prologue_Size => False);
Action_Nb_Arg : constant array (DT_Access_Action) of Int :=
(CW_Membership => 2,
DT_Entry_Size => 0,
DT_Prologue_Size => 0,
Get_Expanded_Name => 1,
Get_External_Tag => 1,
Get_Prim_Op_Address => 2,
Get_RC_Offset => 1,
Get_Remotely_Callable => 1,
Get_TSD => 1,
Inherit_DT => 3,
Inherit_TSD => 2,
Register_Tag => 1,
Set_Expanded_Name => 2,
Set_External_Tag => 2,
Set_Prim_Op_Address => 3,
Set_RC_Offset => 2,
Set_Remotely_Callable => 2,
Set_TSD => 2,
TSD_Entry_Size => 0,
TSD_Prologue_Size => 0);
function Original_View_In_Visible_Part (Typ : Entity_Id) return Boolean;
-- Check if the type has a private view or if the public view appears
-- in the visible part of a package spec.
--------------------------
-- Expand_Dispatch_Call --
--------------------------
procedure Expand_Dispatch_Call (Call_Node : Node_Id) is
Loc : constant Source_Ptr := Sloc (Call_Node);
Call_Typ : constant Entity_Id := Etype (Call_Node);
Ctrl_Arg : constant Node_Id := Controlling_Argument (Call_Node);
Param_List : constant List_Id := Parameter_Associations (Call_Node);
Subp : Entity_Id := Entity (Name (Call_Node));
CW_Typ : Entity_Id;
New_Call : Node_Id;
New_Call_Name : Node_Id;
New_Params : List_Id := No_List;
Param : Node_Id;
Res_Typ : Entity_Id;
Subp_Ptr_Typ : Entity_Id;
Subp_Typ : Entity_Id;
Typ : Entity_Id;
Eq_Prim_Op : Entity_Id := Empty;
function New_Value (From : Node_Id) return Node_Id;
-- From is the original Expression. New_Value is equivalent to
-- Duplicate_Subexpr with an explicit dereference when From is an
-- access parameter
function New_Value (From : Node_Id) return Node_Id is
Res : constant Node_Id := Duplicate_Subexpr (From);
begin
if Is_Access_Type (Etype (From)) then
return Make_Explicit_Dereference (Sloc (From), Res);
else
return Res;
end if;
end New_Value;
-- Start of processing for Expand_Dispatch_Call
begin
-- If this is an inherited operation that was overriden, the body
-- that is being called is its alias.
if Present (Alias (Subp))
and then Is_Inherited_Operation (Subp)
and then No (DTC_Entity (Subp))
then
Subp := Alias (Subp);
end if;
-- Expand_Dispatch is called directly from the semantics, so we need
-- a check to see whether expansion is active before proceeding
if not Expander_Active then
return;
end if;
-- Definition of the ClassWide Type and the Tagged type
if Is_Access_Type (Etype (Ctrl_Arg)) then
CW_Typ := Designated_Type (Etype (Ctrl_Arg));
else
CW_Typ := Etype (Ctrl_Arg);
end if;
Typ := Root_Type (CW_Typ);
if not Is_Limited_Type (Typ) then
Eq_Prim_Op := Find_Prim_Op (Typ, Name_Op_Eq);
end if;
if Is_CPP_Class (Root_Type (Typ)) then
-- Create a new parameter list with the displaced 'this'
New_Params := New_List;
Param := First_Actual (Call_Node);
while Present (Param) loop
-- We assume that dispatching through the main dispatch table
-- (referenced by Tag_Component) doesn't require a displacement
-- so the expansion below is only done when dispatching on
-- another vtable pointer, in which case the first argument
-- is expanded into :
-- typ!(Displaced_This (Address!(Param)))
if Param = Ctrl_Arg
and then DTC_Entity (Subp) /= Tag_Component (Typ)
then
Append_To (New_Params,
Unchecked_Convert_To (Etype (Param),
Make_Function_Call (Loc,
Name => New_Reference_To (RTE (RE_Displaced_This), Loc),
Parameter_Associations => New_List (
-- Current_This
Make_Unchecked_Type_Conversion (Loc,
Subtype_Mark =>
New_Reference_To (RTE (RE_Address), Loc),
Expression => Relocate_Node (Param)),
-- Vptr
Make_Selected_Component (Loc,
Prefix => Duplicate_Subexpr (Ctrl_Arg),
Selector_Name =>
New_Reference_To (DTC_Entity (Subp), Loc)),
-- Position
Make_Integer_Literal (Loc, DT_Position (Subp))))));
else
Append_To (New_Params, Relocate_Node (Param));
end if;
Next_Actual (Param);
end loop;
elsif Present (Param_List) then
-- Generate the Tag checks when appropriate
New_Params := New_List;
Param := First_Actual (Call_Node);
while Present (Param) loop
-- No tag check with itself
if Param = Ctrl_Arg then
Append_To (New_Params, Duplicate_Subexpr (Param));
-- No tag check for parameter whose type is neither tagged nor
-- access to tagged (for access parameters)
elsif No (Find_Controlling_Arg (Param)) then
Append_To (New_Params, Relocate_Node (Param));
-- No tag check for function dispatching on result it the
-- Tag given by the context is this one
elsif Find_Controlling_Arg (Param) = Ctrl_Arg then
Append_To (New_Params, Relocate_Node (Param));
-- "=" is the only dispatching operation allowed to get
-- operands with incompatible tags (it just returns false).
-- We use Duplicate_subexpr instead of relocate_node because
-- the value will be duplicated to check the tags.
elsif Subp = Eq_Prim_Op then
Append_To (New_Params, Duplicate_Subexpr (Param));
-- No check in presence of suppress flags
elsif Tag_Checks_Suppressed (Etype (Param))
or else (Is_Access_Type (Etype (Param))
and then Tag_Checks_Suppressed
(Designated_Type (Etype (Param))))
then
Append_To (New_Params, Relocate_Node (Param));
-- Optimization: no tag checks if the parameters are identical
elsif Is_Entity_Name (Param)
and then Is_Entity_Name (Ctrl_Arg)
and then Entity (Param) = Entity (Ctrl_Arg)
then
Append_To (New_Params, Relocate_Node (Param));
-- Now we need to generate the Tag check
else
-- Generate code for tag equality check
-- Perhaps should have Checks.Apply_Tag_Equality_Check???
Insert_Action (Ctrl_Arg,
Make_Implicit_If_Statement (Call_Node,
Condition =>
Make_Op_Ne (Loc,
Left_Opnd =>
Make_Selected_Component (Loc,
Prefix => New_Value (Ctrl_Arg),
Selector_Name =>
New_Reference_To (Tag_Component (Typ), Loc)),
Right_Opnd =>
Make_Selected_Component (Loc,
Prefix =>
Unchecked_Convert_To (Typ, New_Value (Param)),
Selector_Name =>
New_Reference_To (Tag_Component (Typ), Loc))),
Then_Statements =>
New_List (New_Constraint_Error (Loc))));
Append_To (New_Params, Relocate_Node (Param));
end if;
Next_Actual (Param);
end loop;
end if;
-- Generate the appropriate subprogram pointer type
if Etype (Subp) = Typ then
Res_Typ := CW_Typ;
else
Res_Typ := Etype (Subp);
end if;
Subp_Typ := Create_Itype (E_Subprogram_Type, Call_Node);
Subp_Ptr_Typ := Create_Itype (E_Access_Subprogram_Type, Call_Node);
Set_Etype (Subp_Typ, Res_Typ);
Init_Size_Align (Subp_Ptr_Typ);
Set_Returns_By_Ref (Subp_Typ, Returns_By_Ref (Subp));
-- Create a new list of parameters which is a copy of the old formal
-- list including the creation of a new set of matching entities.
declare
Old_Formal : Entity_Id := First_Formal (Subp);
New_Formal : Entity_Id;
Extra : Entity_Id;
begin
if Present (Old_Formal) then
New_Formal := New_Copy (Old_Formal);
Set_First_Entity (Subp_Typ, New_Formal);
Param := First_Actual (Call_Node);
loop
Set_Scope (New_Formal, Subp_Typ);
-- Change all the controlling argument types to be class-wide
-- to avoid a recursion in dispatching
if Is_Controlling_Actual (Param) then
Set_Etype (New_Formal, Etype (Param));
end if;
if Is_Itype (Etype (New_Formal)) then
Extra := New_Copy (Etype (New_Formal));
if Ekind (Extra) = E_Record_Subtype
or else Ekind (Extra) = E_Class_Wide_Subtype
then
Set_Cloned_Subtype (Extra, Etype (New_Formal));
end if;
Set_Etype (New_Formal, Extra);
Set_Scope (Etype (New_Formal), Subp_Typ);
end if;
Extra := New_Formal;
Next_Formal (Old_Formal);
exit when No (Old_Formal);
Set_Next_Entity (New_Formal, New_Copy (Old_Formal));
Next_Entity (New_Formal);
Next_Actual (Param);
end loop;
Set_Last_Entity (Subp_Typ, Extra);
-- Copy extra formals
New_Formal := First_Entity (Subp_Typ);
while Present (New_Formal) loop
if Present (Extra_Constrained (New_Formal)) then
Set_Extra_Formal (Extra,
New_Copy (Extra_Constrained (New_Formal)));
Extra := Extra_Formal (Extra);
Set_Extra_Constrained (New_Formal, Extra);
elsif Present (Extra_Accessibility (New_Formal)) then
Set_Extra_Formal (Extra,
New_Copy (Extra_Accessibility (New_Formal)));
Extra := Extra_Formal (Extra);
Set_Extra_Accessibility (New_Formal, Extra);
end if;
Next_Formal (New_Formal);
end loop;
end if;
end;
Set_Etype (Subp_Ptr_Typ, Subp_Ptr_Typ);
Set_Directly_Designated_Type (Subp_Ptr_Typ, Subp_Typ);
-- Generate:
-- Subp_Ptr_Typ!(Get_Prim_Op_Address (Ctrl._Tag, pos));
New_Call_Name :=
Unchecked_Convert_To (Subp_Ptr_Typ,
Make_DT_Access_Action (Typ,
Action => Get_Prim_Op_Address,
Args => New_List (
-- Vptr
Make_Selected_Component (Loc,
Prefix => Duplicate_Subexpr (Ctrl_Arg),
Selector_Name => New_Reference_To (DTC_Entity (Subp), Loc)),
-- Position
Make_Integer_Literal (Loc, DT_Position (Subp)))));
if Nkind (Call_Node) = N_Function_Call then
New_Call :=
Make_Function_Call (Loc,
Name => New_Call_Name,
Parameter_Associations => New_Params);
-- if this is a dispatching "=", we must first compare the tags so
-- we generate: x.tag = y.tag and then x = y
if Subp = Eq_Prim_Op then
Param := First_Actual (Call_Node);
New_Call :=
Make_And_Then (Loc,
Left_Opnd =>
Make_Op_Eq (Loc,
Left_Opnd =>
Make_Selected_Component (Loc,
Prefix => New_Value (Param),
Selector_Name =>
New_Reference_To (Tag_Component (Typ), Loc)),
Right_Opnd =>
Make_Selected_Component (Loc,
Prefix =>
Unchecked_Convert_To (Typ,
New_Value (Next_Actual (Param))),
Selector_Name =>
New_Reference_To (Tag_Component (Typ), Loc))),
Right_Opnd => New_Call);
end if;
else
New_Call :=
Make_Procedure_Call_Statement (Loc,
Name => New_Call_Name,
Parameter_Associations => New_Params);
end if;
Rewrite (Call_Node, New_Call);
Analyze_And_Resolve (Call_Node, Call_Typ);
end Expand_Dispatch_Call;
-------------
-- Fill_DT --
-------------
function Fill_DT_Entry
(Loc : Source_Ptr;
Prim : Entity_Id)
return Node_Id
is
Typ : constant Entity_Id := Scope (DTC_Entity (Prim));
DT_Ptr : constant Entity_Id := Access_Disp_Table (Typ);
begin
return
Make_DT_Access_Action (Typ,
Action => Set_Prim_Op_Address,
Args => New_List (
New_Reference_To (DT_Ptr, Loc), -- DTptr
Make_Integer_Literal (Loc, DT_Position (Prim)), -- Position
Make_Attribute_Reference (Loc, -- Value
Prefix => New_Reference_To (Prim, Loc),
Attribute_Name => Name_Address)));
end Fill_DT_Entry;
---------------------------
-- Get_Remotely_Callable --
---------------------------
function Get_Remotely_Callable (Obj : Node_Id) return Node_Id is
Loc : constant Source_Ptr := Sloc (Obj);
begin
return Make_DT_Access_Action
(Typ => Etype (Obj),
Action => Get_Remotely_Callable,
Args => New_List (
Make_Selected_Component (Loc,
Prefix => Obj,
Selector_Name => Make_Identifier (Loc, Name_uTag))));
end Get_Remotely_Callable;
-------------
-- Make_DT --
-------------
function Make_DT (Typ : Entity_Id) return List_Id is
Loc : constant Source_Ptr := Sloc (Typ);
Result : constant List_Id := New_List;
Elab_Code : constant List_Id := New_List;
Tname : constant Name_Id := Chars (Typ);
Name_DT : constant Name_Id := New_External_Name (Tname, 'T');
Name_DT_Ptr : constant Name_Id := New_External_Name (Tname, 'P');
Name_TSD : constant Name_Id := New_External_Name (Tname, 'B');
Name_Exname : constant Name_Id := New_External_Name (Tname, 'E');
Name_No_Reg : constant Name_Id := New_External_Name (Tname, 'F');
DT : constant Node_Id := Make_Defining_Identifier (Loc, Name_DT);
DT_Ptr : constant Node_Id := Make_Defining_Identifier (Loc, Name_DT_Ptr);
TSD : constant Node_Id := Make_Defining_Identifier (Loc, Name_TSD);
Exname : constant Node_Id := Make_Defining_Identifier (Loc, Name_Exname);
No_Reg : constant Node_Id := Make_Defining_Identifier (Loc, Name_No_Reg);
I_Depth : Int;
Generalized_Tag : Entity_Id;
Size_Expr_Node : Node_Id;
Old_Tag : Node_Id;
Old_TSD : Node_Id;
begin
if Is_CPP_Class (Root_Type (Typ)) then
Generalized_Tag := RTE (RE_Vtable_Ptr);
else
Generalized_Tag := RTE (RE_Tag);
end if;
-- Dispatch table and related entities are allocated statically
Set_Ekind (DT, E_Variable);
Set_Is_Statically_Allocated (DT);
Set_Ekind (DT_Ptr, E_Variable);
Set_Is_Statically_Allocated (DT_Ptr);
Set_Ekind (TSD, E_Variable);
Set_Is_Statically_Allocated (TSD);
Set_Ekind (Exname, E_Variable);
Set_Is_Statically_Allocated (Exname);
Set_Ekind (No_Reg, E_Variable);
Set_Is_Statically_Allocated (No_Reg);
-- Generate code to create the storage for the Dispatch_Table object:
-- DT : Storage_Array (1..DT_Prologue_Size+nb_prim*DT_Entry_Size);
-- for DT'Alignment use Address'Alignment
Size_Expr_Node :=
Make_Op_Add (Loc,
Left_Opnd => Make_DT_Access_Action (Typ, DT_Prologue_Size, No_List),
Right_Opnd =>
Make_Op_Multiply (Loc,
Left_Opnd =>
Make_DT_Access_Action (Typ, DT_Entry_Size, No_List),
Right_Opnd =>
Make_Integer_Literal (Loc,
DT_Entry_Count (Tag_Component (Typ)))));
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => DT,
Aliased_Present => True,
Object_Definition =>
Make_Subtype_Indication (Loc,
Subtype_Mark => New_Reference_To (RTE (RE_Storage_Array), Loc),
Constraint => Make_Index_Or_Discriminant_Constraint (Loc,
Constraints => New_List (
Make_Range (Loc,
Low_Bound => Make_Integer_Literal (Loc, 1),
High_Bound => Size_Expr_Node))))));
Append_To (Result,
Make_Attribute_Definition_Clause (Loc,
Name => New_Reference_To (DT, Loc),
Chars => Name_Alignment,
Expression =>
Make_Attribute_Reference (Loc,
Prefix => New_Reference_To (RTE (RE_Integer_Address), Loc),
Attribute_Name => Name_Alignment)));
-- Generate code to create the pointer to the dispatch table
-- DT_Ptr : Tag := Tag!(DT'Address); Ada case
-- or
-- DT_Ptr : Vtable_Ptr := Vtable_Ptr!(DT'Address); CPP case
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => DT_Ptr,
Constant_Present => True,
Object_Definition => New_Reference_To (Generalized_Tag, Loc),
Expression =>
Unchecked_Convert_To (Generalized_Tag,
Make_Attribute_Reference (Loc,
Prefix => New_Reference_To (DT, Loc),
Attribute_Name => Name_Address))));
-- Generate code to define the boolean that controls registration, in
-- order to avoid multiple registrations for tagged types defined in
-- multiple-called scopes
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => No_Reg,
Object_Definition => New_Reference_To (Standard_Boolean, Loc),
Expression => New_Reference_To (Standard_True, Loc)));
-- Set Access_Disp_Table field to be the dispatch table pointer
Set_Access_Disp_Table (Typ, DT_Ptr);
-- Count ancestors to compute the inheritance depth. For private
-- extensions, always go to the full view in order to compute the real
-- inheritance depth.
declare
Parent_Type : Entity_Id := Typ;
P : Entity_Id;
begin
I_Depth := 0;
loop
P := Etype (Parent_Type);
if Is_Private_Type (P) then
P := Full_View (Base_Type (P));
end if;
exit when P = Parent_Type;
I_Depth := I_Depth + 1;
Parent_Type := P;
end loop;
end;
-- Generate code to create the storage for the type specific data object
-- TSD: Storage_Array (1..TSD_Prologue_Size+(1+Idepth)*TSD_Entry_Size);
-- for TSD'Alignment use Address'Alignment
Size_Expr_Node :=
Make_Op_Add (Loc,
Left_Opnd =>
Make_DT_Access_Action (Typ, TSD_Prologue_Size, No_List),
Right_Opnd =>
Make_Op_Multiply (Loc,
Left_Opnd =>
Make_DT_Access_Action (Typ, TSD_Entry_Size, No_List),
Right_Opnd =>
Make_Op_Add (Loc,
Left_Opnd => Make_Integer_Literal (Loc, 1),
Right_Opnd =>
Make_Integer_Literal (Loc, I_Depth))));
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => TSD,
Aliased_Present => True,
Object_Definition =>
Make_Subtype_Indication (Loc,
Subtype_Mark => New_Reference_To (RTE (RE_Storage_Array), Loc),
Constraint => Make_Index_Or_Discriminant_Constraint (Loc,
Constraints => New_List (
Make_Range (Loc,
Low_Bound => Make_Integer_Literal (Loc, 1),
High_Bound => Size_Expr_Node))))));
Append_To (Result,
Make_Attribute_Definition_Clause (Loc,
Name => New_Reference_To (TSD, Loc),
Chars => Name_Alignment,
Expression =>
Make_Attribute_Reference (Loc,
Prefix => New_Reference_To (RTE (RE_Integer_Address), Loc),
Attribute_Name => Name_Alignment)));
-- Generate code to put the Address of the TSD in the dispatch table
-- Set_TSD (DT_Ptr, TSD);
Append_To (Elab_Code,
Make_DT_Access_Action (Typ,
Action => Set_TSD,
Args => New_List (
New_Reference_To (DT_Ptr, Loc), -- DTptr
Make_Attribute_Reference (Loc, -- Value
Prefix => New_Reference_To (TSD, Loc),
Attribute_Name => Name_Address))));
if Typ = Etype (Typ)
or else Is_CPP_Class (Etype (Typ))
then
Old_Tag :=
Unchecked_Convert_To (Generalized_Tag,
Make_Integer_Literal (Loc, 0));
Old_TSD :=
Unchecked_Convert_To (RTE (RE_Address),
Make_Integer_Literal (Loc, 0));
else
Old_Tag := New_Reference_To (Access_Disp_Table (Etype (Typ)), Loc);
Old_TSD :=
Make_DT_Access_Action (Typ,
Action => Get_TSD,
Args => New_List (
New_Reference_To (Access_Disp_Table (Etype (Typ)), Loc)));
end if;
-- Generate: Inherit_DT (parent'tag, DT_Ptr, nb_prim of parent);
Append_To (Elab_Code,
Make_DT_Access_Action (Typ,
Action => Inherit_DT,
Args => New_List (
Node1 => Old_Tag,
Node2 => New_Reference_To (DT_Ptr, Loc),
Node3 => Make_Integer_Literal (Loc,
DT_Entry_Count (Tag_Component (Etype (Typ)))))));
-- Generate: Inherit_TSD (Get_TSD (parent), DT_Ptr);
Append_To (Elab_Code,
Make_DT_Access_Action (Typ,
Action => Inherit_TSD,
Args => New_List (
Node1 => Old_TSD,
Node2 => New_Reference_To (DT_Ptr, Loc))));
-- Generate: Exname : constant String := full_qualified_name (typ);
-- The type itself may be an anonymous parent type, so use the first
-- subtype to have a user-recognizable name.
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => Exname,
Constant_Present => True,
Object_Definition => New_Reference_To (Standard_String, Loc),
Expression =>
Make_String_Literal (Loc,
Full_Qualified_Name (First_Subtype (Typ)))));
-- Generate: Set_Expanded_Name (DT_Ptr, exname'Address);
Append_To (Elab_Code,
Make_DT_Access_Action (Typ,
Action => Set_Expanded_Name,
Args => New_List (
Node1 => New_Reference_To (DT_Ptr, Loc),
Node2 =>
Make_Attribute_Reference (Loc,
Prefix => New_Reference_To (Exname, Loc),
Attribute_Name => Name_Address))));
-- for types with no controlled components
-- Generate: Set_RC_Offset (DT_Ptr, 0);
-- for simple types with controlled components
-- Generate: Set_RC_Offset (DT_Ptr, type._record_controller'position);
-- for complex types with controlled components where the position
-- of the record controller
-- Generate: Set_RC_Offset (DT_Ptr, -1);
declare
Position : Node_Id;
begin
if not Has_Controlled_Component (Typ) then
Position := Make_Integer_Literal (Loc, 0);
elsif Etype (Typ) /= Typ and then Has_Discriminants (Etype (Typ)) then
Position := Make_Integer_Literal (Loc, -1);
else
Position :=
Make_Attribute_Reference (Loc,
Prefix =>
Make_Selected_Component (Loc,
Prefix => New_Reference_To (Typ, Loc),
Selector_Name =>
New_Reference_To (Controller_Component (Typ), Loc)),
Attribute_Name => Name_Position);
-- This is not proper Ada code to use the attribute component
-- on something else than an object but this is supported by
-- the back end (see comment on the Bit_Component attribute in
-- sem_attr). So we avoid semantic checking here.
Set_Analyzed (Position);
Set_Etype (Prefix (Position), RTE (RE_Record_Controller));
Set_Etype (Prefix (Prefix (Position)), Typ);
Set_Etype (Selector_Name (Prefix (Position)),
RTE (RE_Record_Controller));
Set_Etype (Position, RTE (RE_Storage_Offset));
end if;
Append_To (Elab_Code,
Make_DT_Access_Action (Typ,
Action => Set_RC_Offset,
Args => New_List (
Node1 => New_Reference_To (DT_Ptr, Loc),
Node2 => Position)));
end;
-- Generate: Set_Remotely_Callable (DT_Ptr, status);
-- where status is described in E.4 (18)
declare
Status : Entity_Id;
begin
if Is_Pure (Typ)
or else Is_Shared_Passive (Typ)
or else
((Is_Remote_Types (Typ) or else Is_Remote_Call_Interface (Typ))
and then Original_View_In_Visible_Part (Typ))
or else not Comes_From_Source (Typ)
then
Status := Standard_True;
else
Status := Standard_False;
end if;
Append_To (Elab_Code,
Make_DT_Access_Action (Typ,
Action => Set_Remotely_Callable,
Args => New_List (
New_Occurrence_Of (DT_Ptr, Loc),
New_Occurrence_Of (Status, Loc))));
end;
-- Generate: Set_External_Tag (DT_Ptr, exname'Address);
-- Should be the external name not the qualified name???
if not Has_External_Tag_Rep_Clause (Typ) then
Append_To (Elab_Code,
Make_DT_Access_Action (Typ,
Action => Set_External_Tag,
Args => New_List (
Node1 => New_Reference_To (DT_Ptr, Loc),
Node2 =>
Make_Attribute_Reference (Loc,
Prefix => New_Reference_To (Exname, Loc),
Attribute_Name => Name_Address))));
-- Generate code to register the Tag in the External_Tag hash
-- table for the pure Ada type only. We skip this in No_Run_Time
-- mode where the External_Tag attribute is not allowed anyway.
-- Register_Tag (Dt_Ptr);
if Is_RTE (Generalized_Tag, RE_Tag)
and then not No_Run_Time
then
Append_To (Elab_Code,
Make_Procedure_Call_Statement (Loc,
Name => New_Reference_To (RTE (RE_Register_Tag), Loc),
Parameter_Associations =>
New_List (New_Reference_To (DT_Ptr, Loc))));
end if;
end if;
-- Generate:
-- if No_Reg then
-- <elab_code>
-- No_Reg := False;
-- end if;
Append_To (Elab_Code,
Make_Assignment_Statement (Loc,
Name => New_Reference_To (No_Reg, Loc),
Expression => New_Reference_To (Standard_False, Loc)));
Append_To (Result,
Make_Implicit_If_Statement (Typ,
Condition => New_Reference_To (No_Reg, Loc),
Then_Statements => Elab_Code));
return Result;
end Make_DT;
---------------------------
-- Make_DT_Access_Action --
---------------------------
function Make_DT_Access_Action
(Typ : Entity_Id;
Action : DT_Access_Action;
Args : List_Id)
return Node_Id
is
Action_Name : Entity_Id;
Loc : Source_Ptr;
begin
if Is_CPP_Class (Root_Type (Typ)) then
Action_Name := RTE (CPP_Actions (Action));
else
Action_Name := RTE (Ada_Actions (Action));
end if;
if No (Args) then
-- This is a constant
return New_Reference_To (Action_Name, Sloc (Typ));
end if;
pragma Assert (List_Length (Args) = Action_Nb_Arg (Action));
Loc := Sloc (First (Args));
if Action_Is_Proc (Action) then
return
Make_Procedure_Call_Statement (Loc,
Name => New_Reference_To (Action_Name, Loc),
Parameter_Associations => Args);
else
return
Make_Function_Call (Loc,
Name => New_Reference_To (Action_Name, Loc),
Parameter_Associations => Args);
end if;
end Make_DT_Access_Action;
-----------------------------------
-- Original_View_In_Visible_Part --
-----------------------------------
function Original_View_In_Visible_Part (Typ : Entity_Id) return Boolean is
Scop : constant Entity_Id := Scope (Typ);
begin
-- The scope must be a package
if Ekind (Scop) /= E_Package
and then Ekind (Scop) /= E_Generic_Package
then
return False;
end if;
-- A type with a private declaration has a private view declared in
-- the visible part.
if Has_Private_Declaration (Typ) then
return True;
end if;
return List_Containing (Parent (Typ)) =
Visible_Declarations (Specification (Unit_Declaration_Node (Scop)));
end Original_View_In_Visible_Part;
-------------------------
-- Set_All_DT_Position --
-------------------------
procedure Set_All_DT_Position (Typ : Entity_Id) is
Parent_Typ : constant Entity_Id := Etype (Typ);
Root_Typ : constant Entity_Id := Root_Type (Typ);
First_Prim : constant Elmt_Id := First_Elmt (Primitive_Operations (Typ));
The_Tag : constant Entity_Id := Tag_Component (Typ);
Adjusted : Boolean := False;
Finalized : Boolean := False;
Parent_EC : Int;
Nb_Prim : Int;
Prim : Entity_Id;
Prim_Elmt : Elmt_Id;
begin
-- Get Entry_Count of the parent
if Parent_Typ /= Typ
and then DT_Entry_Count (Tag_Component (Parent_Typ)) /= No_Uint
then
Parent_EC := UI_To_Int (DT_Entry_Count (Tag_Component (Parent_Typ)));
else
Parent_EC := 0;
end if;
-- C++ Case, check that pragma CPP_Class, CPP_Virtual and CPP_Vtable
-- give a coherent set of information
if Is_CPP_Class (Root_Typ) then
-- Compute the number of primitive operations in the main Vtable
-- Set their position:
-- - where it was set if overriden or inherited
-- - after the end of the parent vtable otherwise
Prim_Elmt := First_Prim;
Nb_Prim := 0;
while Present (Prim_Elmt) loop
Prim := Node (Prim_Elmt);
if not Is_CPP_Class (Typ) then
Set_DTC_Entity (Prim, The_Tag);
elsif Present (Alias (Prim)) then
Set_DTC_Entity (Prim, DTC_Entity (Alias (Prim)));
Set_DT_Position (Prim, DT_Position (Alias (Prim)));
elsif No (DTC_Entity (Prim)) and then Is_CPP_Class (Typ) then
Error_Msg_NE ("is a primitive operation of&," &
" pragma Cpp_Virtual required", Prim, Typ);
end if;
if DTC_Entity (Prim) = The_Tag then
-- Get the slot from the parent subprogram if any
declare
H : Entity_Id := Homonym (Prim);
begin
while Present (H) loop
if Present (DTC_Entity (H))
and then Root_Type (Scope (DTC_Entity (H))) = Root_Typ
then
Set_DT_Position (Prim, DT_Position (H));
exit;
end if;
H := Homonym (H);
end loop;
end;
-- Otherwise take the canonical slot after the end of the
-- parent Vtable
if DT_Position (Prim) = No_Uint then
Nb_Prim := Nb_Prim + 1;
Set_DT_Position (Prim, UI_From_Int (Parent_EC + Nb_Prim));
elsif UI_To_Int (DT_Position (Prim)) > Parent_EC then
Nb_Prim := Nb_Prim + 1;
end if;
end if;
Next_Elmt (Prim_Elmt);
end loop;
-- Check that the declared size of the Vtable is bigger or equal
-- than the number of primitive operations (if bigger it means that
-- some of the c++ virtual functions were not imported, that is
-- allowed)
if DT_Entry_Count (The_Tag) = No_Uint
or else not Is_CPP_Class (Typ)
then
Set_DT_Entry_Count (The_Tag, UI_From_Int (Parent_EC + Nb_Prim));
elsif UI_To_Int (DT_Entry_Count (The_Tag)) < Parent_EC + Nb_Prim then
Error_Msg_N ("not enough room in the Vtable for all virtual"
& " functions", The_Tag);
end if;
-- Check that Positions are not duplicate nor outside the range of
-- the Vtable
declare
Size : constant Int := UI_To_Int (DT_Entry_Count (The_Tag));
Pos : Int;
Prim_Pos_Table : array (1 .. Size) of Entity_Id :=
(others => Empty);
begin
Prim_Elmt := First_Prim;
while Present (Prim_Elmt) loop
Prim := Node (Prim_Elmt);
if DTC_Entity (Prim) = The_Tag then
Pos := UI_To_Int (DT_Position (Prim));
if Pos not in Prim_Pos_Table'Range then
Error_Msg_N
("position not in range of virtual table", Prim);
elsif Present (Prim_Pos_Table (Pos)) then
Error_Msg_NE ("cannot be at the same position in the"
& " vtable than&", Prim, Prim_Pos_Table (Pos));
else
Prim_Pos_Table (Pos) := Prim;
end if;
end if;
Next_Elmt (Prim_Elmt);
end loop;
end;
-- For regular Ada tagged types, just set the DT_Position for
-- each primitive operation. Perform some sanity checks to avoid
-- to build completely inconsistant dispatch tables.
else
Nb_Prim := 0;
Prim_Elmt := First_Prim;
while Present (Prim_Elmt) loop
Nb_Prim := Nb_Prim + 1;
Prim := Node (Prim_Elmt);
Set_DTC_Entity (Prim, The_Tag);
Set_DT_Position (Prim, UI_From_Int (Nb_Prim));
if Chars (Prim) = Name_Finalize
and then (Is_Predefined_File_Name
(Unit_File_Name (Current_Sem_Unit))
or else
not Is_Predefined_File_Name
(Unit_File_Name (Get_Source_Unit (Prim))))
then
Finalized := True;
end if;
if Chars (Prim) = Name_Adjust then
Adjusted := True;
end if;
-- An abstract operation cannot be declared in the private part
-- for a visible abstract type, because it could never be over-
-- ridden. For explicit declarations this is checked at the point
-- of declaration, but for inherited operations it must be done
-- when building the dispatch table. Input is excluded because
-- Limited_Controlled inherits a useless Input stream operation
-- from Root_Controlled, which cannot be overridden.
if Is_Abstract (Typ)
and then Is_Abstract (Prim)
and then Present (Alias (Prim))
and then Is_Derived_Type (Typ)
and then In_Private_Part (Current_Scope)
and then List_Containing (Parent (Prim))
= Private_Declarations
(Specification (Unit_Declaration_Node (Current_Scope)))
and then Original_View_In_Visible_Part (Typ)
and then Chars (Prim) /= Name_uInput
then
Error_Msg_NE ("abstract inherited private operation&"
& " must be overriden", Parent (Typ), Prim);
end if;
Next_Elmt (Prim_Elmt);
end loop;
if Is_Controlled (Typ) then
if not Finalized then
Error_Msg_N
("controlled type has no explicit Finalize method?", Typ);
elsif not Adjusted then
Error_Msg_N
("controlled type has no explicit Adjust method?", Typ);
end if;
end if;
Set_DT_Entry_Count (The_Tag, UI_From_Int (Nb_Prim));
-- The derived type must have at least as many components than
-- its parent (for root types, the etype points back to itself
-- and the test should not fail)
pragma Assert (
DT_Entry_Count (The_Tag) >=
DT_Entry_Count (Tag_Component (Parent_Typ)));
end if;
end Set_All_DT_Position;
-----------------------------
-- Set_Default_Constructor --
-----------------------------
procedure Set_Default_Constructor (Typ : Entity_Id) is
Loc : Source_Ptr;
Init : Entity_Id;
Param : Entity_Id;
Decl : Node_Id;
E : Entity_Id;
begin
-- Look for the default constructor entity. For now only the
-- default constructor has the flag Is_Constructor.
E := Next_Entity (Typ);
while Present (E)
and then (Ekind (E) /= E_Function or else not Is_Constructor (E))
loop
Next_Entity (E);
end loop;
-- Create the init procedure
if Present (E) then
Loc := Sloc (E);
Init := Make_Defining_Identifier (Loc, Name_uInit_Proc);
Param := Make_Defining_Identifier (Loc, Name_X);
Decl :=
Make_Subprogram_Declaration (Loc,
Make_Procedure_Specification (Loc,
Defining_Unit_Name => Init,
Parameter_Specifications => New_List (
Make_Parameter_Specification (Loc,
Defining_Identifier => Param,
Parameter_Type => New_Reference_To (Typ, Loc)))));
Set_Init_Proc (Typ, Init);
Set_Is_Imported (Init);
Set_Interface_Name (Init, Interface_Name (E));
Set_Convention (Init, Convention_C);
Set_Is_Public (Init);
Set_Has_Completion (Init);
-- if there are no constructors, mark the type as abstract since we
-- won't be able to declare objects of that type.
else
Set_Is_Abstract (Typ);
end if;
end Set_Default_Constructor;
end Exp_Disp;
|
------------------------------------------------------------------------------
-- G P S --
-- --
-- Copyright (C) 2000-2016, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with this software; see file --
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
-- of the license. --
------------------------------------------------------------------------------
with GNAT.Strings; use GNAT.Strings;
with Ada.Characters.Handling; use Ada.Characters.Handling;
package body Basic_Types is
--------------
-- Is_Equal --
--------------
function Is_Equal
(List1, List2 : GNAT.OS_Lib.Argument_List;
Case_Sensitive : Boolean := True;
Ordered : Boolean := False) return Boolean is
begin
if List1'Length /= List2'Length then
return False;
elsif Ordered then
for L in List1'Range loop
if List1 (L).all /= List2 (L - List1'First + List2'First).all then
return False;
end if;
end loop;
return True;
else
declare
L1 : GNAT.OS_Lib.Argument_List := List1;
L2 : GNAT.OS_Lib.Argument_List := List2;
begin
for A in L1'Range loop
for B in L2'Range loop
if L2 (B) /= null and then
((Case_Sensitive and then L1 (A).all = L2 (B).all)
or else
(not Case_Sensitive
and then To_Lower (L1 (A).all) = To_Lower (L2 (B).all)))
then
L1 (A) := null;
L2 (B) := null;
exit;
end if;
end loop;
end loop;
return L1 = (L1'Range => null)
and then L2 = (L2'Range => null);
end;
end if;
end Is_Equal;
--------------
-- Contains --
--------------
function Contains
(List : GNAT.OS_Lib.Argument_List;
Str : String;
Case_Sensitive : Boolean := True) return Boolean is
begin
if not Case_Sensitive then
declare
S : constant String := To_Lower (Str);
begin
for L in List'Range loop
if To_Lower (List (L).all) = S then
return True;
end if;
end loop;
end;
else
for L in List'Range loop
if List (L).all = Str then
return True;
end if;
end loop;
end if;
return False;
end Contains;
---------
-- "<" --
---------
function "<" (Left, Right : Date_Type) return Boolean is
begin
if Left.Year < Right.Year then
return True;
elsif Left.Year = Right.Year then
if Left.Month < Right.Month then
return True;
elsif Left.Month = Right.Month then
if Left.Day < Right.Day then
return True;
end if;
end if;
end if;
return False;
end "<";
----------
-- "<=" --
----------
function "<=" (Left, Right : Date_Type) return Boolean is
begin
return Left < Right or else Left = Right;
end "<=";
---------
-- ">" --
---------
function ">" (Left, Right : Date_Type) return Boolean is
begin
return not (Left < Right or else Left = Right);
end ">";
----------
-- ">=" --
----------
function ">=" (Left, Right : Date_Type) return Boolean is
begin
return not (Left < Right);
end ">=";
end Basic_Types;
|
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../../License.txt
package body AdaBase.Driver.Base.SQLite is
---------------
-- execute --
---------------
overriding
function execute (driver : SQLite_Driver; sql : String)
return Affected_Rows
is
trsql : String := CT.trim_sql (sql);
nquery : Natural := CT.count_queries (trsql);
aborted : constant Affected_Rows := 0;
err1 : constant CT.Text :=
CT.SUS ("ACK! Execution attempted on inactive connection");
err2 : constant String :=
"Driver is configured to allow only one query at " &
"time, but this SQL contains multiple queries: ";
begin
if not driver.connection_active then
-- Fatal attempt to query an unccnnected database
driver.log_problem (category => execution,
message => err1,
break => True);
return aborted;
end if;
if nquery > 1 and then not driver.trait_multiquery_enabled then
-- Fatal attempt to execute multiple queries when it's not permitted
driver.log_problem (category => execution,
message => CT.SUS (err2 & trsql),
break => True);
return aborted;
end if;
declare
result : Affected_Rows;
begin
-- SQLITE3 execute supports multiquery in all cases, so it is not
-- necessary to loop through subqueries. We send the trimmed
-- compound query as it was received.
driver.connection.execute (trsql);
driver.log_nominal (execution, CT.SUS (trsql));
result := driver.connection.rows_affected_by_execution;
return result;
exception
when ACS.QUERY_FAIL =>
driver.log_problem (category => execution,
message => CT.SUS (trsql),
pull_codes => True);
return aborted;
end;
end execute;
------------------------------------------------------------------------
-- ROUTINES OF ALL DRIVERS NOT COVERED BY INTERFACES (TECH REASON) --
------------------------------------------------------------------------
-------------
-- query --
-------------
function query (driver : SQLite_Driver; sql : String)
return ASS.SQLite_statement is
begin
return driver.private_statement (sql => sql, prepared => False);
end query;
---------------
-- prepare --
---------------
function prepare (driver : SQLite_Driver; sql : String)
return ASS.SQLite_statement is
begin
return driver.private_statement (sql => sql, prepared => True);
end prepare;
--------------------
-- query_select --
--------------------
function query_select (driver : SQLite_Driver;
distinct : Boolean := False;
tables : String;
columns : String;
conditions : String := blankstring;
groupby : String := blankstring;
having : String := blankstring;
order : String := blankstring;
null_sort : Null_Priority := native;
limit : Trax_ID := 0;
offset : Trax_ID := 0)
return ASS.SQLite_statement is
begin
return driver.private_statement
(prepared => False,
sql => driver.sql_assemble (distinct => distinct,
tables => tables,
columns => columns,
conditions => conditions,
groupby => groupby,
having => having,
order => order,
null_sort => null_sort,
limit => limit,
offset => offset));
end query_select;
----------------------
-- prepare_select --
----------------------
function prepare_select (driver : SQLite_Driver;
distinct : Boolean := False;
tables : String;
columns : String;
conditions : String := blankstring;
groupby : String := blankstring;
having : String := blankstring;
order : String := blankstring;
null_sort : Null_Priority := native;
limit : Trax_ID := 0;
offset : Trax_ID := 0)
return ASS.SQLite_statement is
begin
return driver.private_statement
(prepared => True,
sql => driver.sql_assemble (distinct => distinct,
tables => tables,
columns => columns,
conditions => conditions,
groupby => groupby,
having => having,
order => order,
null_sort => null_sort,
limit => limit,
offset => offset));
end prepare_select;
------------------------------------------------------------------------
-- PRIVATE ROUTINES NOT COVERED BY INTERFACES --
------------------------------------------------------------------------
------------------
-- initialize --
------------------
overriding
procedure initialize (Object : in out SQLite_Driver)
is
begin
Object.connection := Object.local_connection'Unchecked_Access;
Object.dialect := driver_sqlite;
end initialize;
-----------------------
-- private_connect --
-----------------------
overriding
procedure private_connect (driver : out SQLite_Driver;
database : String;
username : String;
password : String;
hostname : String := blankstring;
socket : String := blankstring;
port : Posix_Port := portless)
is
err1 : constant CT.Text :=
CT.SUS ("ACK! Reconnection attempted on active connection");
nom : constant CT.Text :=
CT.SUS ("Connection to " & database & " database succeeded.");
begin
if driver.connection_active then
driver.log_problem (category => execution,
message => err1);
return;
end if;
driver.connection.connect (database => database,
username => username,
password => password,
socket => socket,
hostname => hostname,
port => port);
driver.connection_active := driver.connection.all.connected;
driver.log_nominal (category => connecting, message => nom);
exception
when Error : others =>
driver.log_problem
(category => connecting,
break => True,
message => CT.SUS (ACS.EX.Exception_Message (X => Error)));
end private_connect;
-------------------------
-- private_statement --
-------------------------
function private_statement (driver : SQLite_Driver;
sql : String;
prepared : Boolean)
return ASS.SQLite_statement
is
stype : AID.ASB.Stmt_Type := AID.ASB.direct_statement;
logcat : Log_Category := execution;
err1 : constant CT.Text :=
CT.SUS ("ACK! Query attempted on inactive connection");
duplicate : aliased String := sql;
begin
if prepared then
stype := AID.ASB.prepared_statement;
logcat := statement_preparation;
end if;
if driver.connection_active then
declare
statement : ASS.SQLite_statement
(type_of_statement => stype,
log_handler => logger'Access,
sqlite_conn => ACS.SQLite_Connection_Access
(driver.connection),
initial_sql => duplicate'Unchecked_Access,
con_error_mode => driver.trait_error_mode,
con_case_mode => driver.trait_column_case,
con_max_blob => driver.trait_max_blob_size);
begin
if not prepared then
if statement.successful then
driver.log_nominal
(category => logcat,
message => CT.SUS ("query succeeded," &
statement.rows_returned'Img & " rows returned"));
else
driver.log_nominal (category => execution,
message => CT.SUS ("Query failed!"));
end if;
end if;
return statement;
exception
when RES : others =>
-- Fatal attempt to prepare a statement
-- Logged already by stmt initialization
-- Should be internally marked as unsuccessful
return statement;
end;
else
-- Fatal attempt to query an unconnected database
driver.log_problem (category => logcat,
message => err1,
break => True);
end if;
-- We never get here, the driver.log_problem throws exception first
raise ACS.STMT_NOT_VALID
with "failed to return SQLite statement";
end private_statement;
------------------------
-- query_drop_table --
------------------------
overriding
procedure query_drop_table (driver : SQLite_Driver;
tables : String;
when_exists : Boolean := False;
cascade : Boolean := False)
is
sql : CT.Text;
AR : Affected_Rows;
begin
if CT.contains (tables, ",") then
driver.log_problem
(category => execution,
message => CT.SUS ("Multiple tables detected -- SQLite" &
" can only drop one table at a time : " & tables));
return;
end if;
case when_exists is
when True => sql := CT.SUS ("DROP TABLE IF EXISTS " & tables);
when False => sql := CT.SUS ("DROP TABLE " & tables);
end case;
if cascade then
driver.log_nominal
(category => note,
message => CT.SUS ("Requested CASCADE has no effect on SQLite"));
end if;
AR := driver.execute (sql => CT.USS (sql));
exception
when ACS.QUERY_FAIL =>
driver.log_problem (category => execution,
message => sql,
pull_codes => True);
end query_drop_table;
-------------------------
-- query_clear_table --
-------------------------
overriding
procedure query_clear_table (driver : SQLite_Driver;
table : String)
is
-- SQLite has no "truncate" commands
sql : constant String := "DELETE FROM " & table;
AR : Affected_Rows;
begin
AR := driver.execute (sql => sql);
exception
when ACS.QUERY_FAIL =>
driver.log_problem (category => execution,
message => CT.SUS (sql),
pull_codes => True);
end query_clear_table;
--------------------
-- sql_assemble --
--------------------
function sql_assemble (driver : SQLite_Driver;
distinct : Boolean := False;
tables : String;
columns : String;
conditions : String := blankstring;
groupby : String := blankstring;
having : String := blankstring;
order : String := blankstring;
null_sort : Null_Priority := native;
limit : Trax_ID := 0;
offset : Trax_ID := 0) return String
is
vanilla : String := assembly_common_select
(distinct, tables, columns, conditions, groupby, having, order);
begin
if null_sort /= native then
driver.log_nominal
(category => execution,
message => CT.SUS ("Note that NULLS FIRST/LAST is not " &
"supported by SQLite so the null_sort setting is ignored"));
end if;
if limit > 0 then
if offset > 0 then
return vanilla & " LIMIT" & limit'Img & " OFFSET" & offset'Img;
else
return vanilla & " LIMIT" & limit'Img;
end if;
end if;
return vanilla;
end sql_assemble;
-----------------------------
-- call_stored_procedure --
-----------------------------
function call_stored_procedure (driver : SQLite_Driver;
stored_procedure : String;
proc_arguments : String)
return ASS.SQLite_statement is
begin
raise ACS.UNSUPPORTED_BY_SQLITE
with "SQLite does not have the capability of stored procedures";
return driver.query ("this never runs.");
end call_stored_procedure;
end AdaBase.Driver.Base.SQLite;
|
with Numerics, Numerics.Sparse_Matrices, Ada.Text_IO;
use Numerics, Numerics.Sparse_Matrices, Ada.Text_IO;
with Ada.Numerics.Generic_Real_Arrays;
procedure Sparse_Test is
use Real_IO, Int_IO;
package RA is new Ada.Numerics.Generic_Real_Arrays (Real); use RA;
-- U : RA.Real_Matrix := (1 => (1 => 1.0),
-- 2 => (1 => 2.0),
-- 3 => (1 => 0.0),
-- 4 => (1 => 4.0),
-- 5 => (1 => 0.0),
-- 6 => (1 => -3.2));
-- V : RA.Real_Matrix := (1 => (6.0, 0.0, 7.0, 1.0, 8.0, 4.7));
X : Sparse_Vector := Sparse ((1.0, 2.0));
Y : Sparse_Vector := Sparse ((6.0, 0.0));
A : Sparse_Matrix;
B : Sparse_Matrix;
C : Sparse_Matrix;
-- D : RA.Real_Matrix := U * V;
-- E : RA.Real_Matrix := Transpose (D);
-- F : RA.Real_Matrix (E'Range (1), E'Range (2));
begin
A := X * Y; Print (A);
B := X * X; Print (B);
Print (A - B);
Print (B - A);
-- for I in 1 .. 10_000 loop
-- -- C := A * B;
-- F := D * E;
-- end loop;
end Sparse_Test;
|
pragma License (Unrestricted);
package Ada.Numerics is
pragma Pure;
Argument_Error : exception;
Pi : constant :=
3.14159_26535_89793_23846_26433_83279_50288_41971_69399_37511;
["03C0"] : constant := Pi;
e : constant :=
2.71828_18284_59045_23536_02874_71352_66249_77572_47093_69996;
end Ada.Numerics;
|
-- Project: MART - Modular Airborne Real-Time Testbed
-- System: Emergency Recovery System
-- Authors: Markus Neumair (Original C-Code)
-- Emanuel Regnath (emanuel.regnath@tum.de) (Ada Port)
--
-- Module Description:
-- Driver for the Barometer MS5611-01BA03
private package MS5611.Register with SPARK_Mode is
type Command_Type is mod 2**8;
-- Constants
TEMP_HIGH : constant := 20.0;
TEMP_LOW : constant := -15.0;
-- SPI Address of chip
BAROMETER_ADR : constant := 16#77#; -- I2C-Address of the barometer
-- Commands
CMD_RESET : constant Command_Type := 16#1E#; -- ADC reset command
CMD_ADC_READ : constant Command_Type := 16#00#; -- ADC read command
CMD_D1_CONV_256 : constant Command_Type := 16#40#; -- Pressure Conversion commands
CMD_D1_CONV_512 : constant Command_Type := 16#42#;
CMD_D1_CONV_1024 : constant Command_Type := 16#44#;
CMD_D1_CONV_2048 : constant Command_Type := 16#46#;
CMD_D1_CONV_4096 : constant Command_Type := 16#48#;
CMD_D2_CONV_256 : constant Command_Type := 16#50#; -- Temperature Conversion commands
CMD_D2_CONV_512 : constant Command_Type := 16#52#;
CMD_D2_CONV_1024 : constant Command_Type := 16#54#;
CMD_D2_CONV_2048 : constant Command_Type := 16#56#;
CMD_D2_CONV_4096 : constant Command_Type := 16#58#;
CMD_READ_C1 : constant Command_Type := 16#A2#; -- C1 read command
CMD_READ_C2 : constant Command_Type := 16#A4#; -- C2
CMD_READ_C3 : constant Command_Type := 16#A6#; -- C3
CMD_READ_C4 : constant Command_Type := 16#A8#; -- C4
CMD_READ_C5 : constant Command_Type := 16#AA#; -- C5
CMD_READ_C6 : constant Command_Type := 16#AC#; -- C6
CMD_READ_CRC : constant Command_Type := 16#AE#; -- CRC
end MS5611.Register;
|
with System.Address_To_Named_Access_Conversions;
with System.Standard_Allocators;
with System.System_Allocators;
package body System.Unbounded_Allocators is
use type Storage_Elements.Integer_Address;
use type Storage_Elements.Storage_Offset;
package HA_Conv is
new Address_To_Named_Access_Conversions (Header, Header_Access);
Header_Offset : constant Storage_Elements.Storage_Count :=
Storage_Elements.Storage_Offset (
(Header'Size / Standard'Storage_Unit
+ Storage_Elements.Integer_Address'(
Standard'Maximum_Alignment - 1))
and not (Standard'Maximum_Alignment - 1));
procedure Deallocate (X : not null Header_Access);
procedure Deallocate (X : not null Header_Access) is
begin
pragma Assert ((HA_Conv.To_Address (X.Previous) and 1) = 0);
X.Previous.Next := X.Next;
X.Next.Previous :=
HA_Conv.To_Pointer (
(HA_Conv.To_Address (X.Next.Previous) and 1)
or HA_Conv.To_Address (X.Previous));
System_Allocators.Free (HA_Conv.To_Address (X));
end Deallocate;
-- implementation
procedure Initialize (Object : in out Unbounded_Allocator) is
X : Address;
begin
X := System_Allocators.Allocate (Header'Size / Standard'Storage_Unit);
HA_Conv.To_Pointer (X).Previous := HA_Conv.To_Pointer (1 or X);
HA_Conv.To_Pointer (X).Next := HA_Conv.To_Pointer (X);
Object := Unbounded_Allocator (HA_Conv.To_Pointer (X));
end Initialize;
procedure Finalize (Object : in out Unbounded_Allocator) is
begin
while Object.Next /= Header_Access (Object) loop
Deallocate (Object.Next);
end loop;
System_Allocators.Free (HA_Conv.To_Address (Header_Access (Object)));
end Finalize;
procedure Allocate (
Allocator : Unbounded_Allocator;
Storage_Address : out Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count)
is
X : Address;
begin
X := System_Allocators.Allocate (
Header'Size / Standard'Storage_Unit + Size_In_Storage_Elements,
Alignment =>
Storage_Elements.Storage_Offset'Max (Header'Alignment, Alignment));
if X = Null_Address then
Standard_Allocators.Raise_Heap_Exhausted;
end if;
Storage_Address := X + Header_Offset;
HA_Conv.To_Pointer (X).Previous := Header_Access (Allocator);
HA_Conv.To_Pointer (X).Next := Allocator.Next;
HA_Conv.To_Pointer (X).Previous.Next := HA_Conv.To_Pointer (X);
HA_Conv.To_Pointer (X).Next.Previous :=
HA_Conv.To_Pointer (
(HA_Conv.To_Address (HA_Conv.To_Pointer (X).Next.Previous) and 1)
or X);
end Allocate;
procedure Deallocate (
Allocator : Unbounded_Allocator;
Storage_Address : Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count)
is
pragma Unreferenced (Allocator);
pragma Unreferenced (Size_In_Storage_Elements);
pragma Unreferenced (Alignment);
X : constant not null Header_Access :=
HA_Conv.To_Pointer (Storage_Address - Header_Offset);
begin
Deallocate (X);
end Deallocate;
function Allocator_Of (Storage_Address : Address)
return Unbounded_Allocator is
X : constant not null Header_Access :=
HA_Conv.To_Pointer (Storage_Address - Header_Offset);
I : not null Header_Access := X.Next;
begin
pragma Assert ((HA_Conv.To_Address (X.Previous) and 1) = 0);
loop
pragma Assert (I /= X);
if (HA_Conv.To_Address (I.Previous) and 1) /= 0 then
return Unbounded_Allocator (I);
end if;
I := I.Next;
end loop;
end Allocator_Of;
end System.Unbounded_Allocators;
|
-----------------------------------------------------------------------
-- awa-applications -- Ada Web Application
-- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017, 2018 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Serialize.IO;
with ASF.Applications.Main;
with ASF.Applications.Main.Configs;
with ADO.Sessions.Factory;
with AWA.Modules;
with AWA.Events;
with AWA.Events.Services;
with AWA.Audits.Services;
package AWA.Applications is
-- Directories where the configuration files are searched.
package P_Module_Dir is
new ASF.Applications.Main.Configs.Parameter ("app.modules.dir",
"#{fn:composePath(app_search_dirs,'config')}");
-- A list of configuration files separated by ';'. These files are searched in
-- 'app.modules.dir' and loaded in the order specified before the application modules.
package P_Config_File is
new ASF.Applications.Main.Configs.Parameter ("app.config", "awa.xml");
-- A list of configuration files separated by ';'. These files are searched in
-- 'app.modules.dir' and loaded in the order specified after all the application modules
-- are initialized.
package P_Plugin_Config_File is
new ASF.Applications.Main.Configs.Parameter ("app.config.plugins", "");
-- The database connection string to connect to the database.
package P_Database is
new ASF.Applications.Main.Configs.Parameter ("database",
"mysql://localhost:3306/db");
-- The application contextPath configuration that gives the base URL of the application.
package P_Context_Path is
new ASF.Applications.Main.Configs.Parameter ("contextPath",
"");
-- Module manager
--
-- The <b>Module_Manager</b> represents the root of the logic manager
type Application is new ASF.Applications.Main.Application with private;
type Application_Access is access all Application'Class;
-- Initialize the application
overriding
procedure Initialize (App : in out Application;
Conf : in ASF.Applications.Config;
Factory : in out ASF.Applications.Main.Application_Factory'Class);
-- Initialize the application configuration properties. Properties defined in <b>Conf</b>
-- are expanded by using the EL expression resolver.
overriding
procedure Initialize_Config (App : in out Application;
Conf : in out ASF.Applications.Config);
-- Initialize the servlets provided by the application.
-- This procedure is called by <b>Initialize</b>.
-- It should register the application servlets.
overriding
procedure Initialize_Servlets (App : in out Application);
-- Initialize the filters provided by the application.
-- This procedure is called by <b>Initialize</b>.
-- It should register the application filters.
overriding
procedure Initialize_Filters (App : in out Application);
-- Initialize the ASF components provided by the application.
-- This procedure is called by <b>Initialize</b>.
-- It should register the component factories used by the application.
overriding
procedure Initialize_Components (App : in out Application);
-- Read the application configuration file <b>awa.xml</b>. This is called after the servlets
-- and filters have been registered in the application but before the module registration.
procedure Load_Configuration (App : in out Application;
Files : in String);
-- Initialize the AWA modules provided by the application.
-- This procedure is called by <b>Initialize</b>.
-- It should register the modules used by the application.
procedure Initialize_Modules (App : in out Application);
-- Start the application. This is called by the server container when the server is started.
overriding
procedure Start (App : in out Application);
-- Close the application.
overriding
procedure Close (App : in out Application);
-- Register the module in the application
procedure Register (App : in Application_Access;
Module : access AWA.Modules.Module'Class;
Name : in String;
URI : in String := "");
-- Get the database connection for reading
function Get_Session (App : Application)
return ADO.Sessions.Session;
-- Get the database connection for writing
function Get_Master_Session (App : Application)
return ADO.Sessions.Master_Session;
-- Register the module in the application
procedure Register (App : in out Application;
Module : in AWA.Modules.Module_Access;
Name : in String;
URI : in String := "");
-- Find the module with the given name
function Find_Module (App : in Application;
Name : in String) return AWA.Modules.Module_Access;
-- Send the event in the application event queues.
procedure Send_Event (App : in Application;
Event : in AWA.Events.Module_Event'Class);
-- Execute the <tt>Process</tt> procedure with the event manager used by the application.
procedure Do_Event_Manager (App : in out Application;
Process : access procedure
(Events : in out AWA.Events.Services.Event_Manager));
-- Get the current application from the servlet context or service context.
function Current return Application_Access;
private
-- Initialize the parser represented by <b>Parser</b> to recognize the configuration
-- that are specific to the plugins that have been registered so far.
procedure Initialize_Parser (App : in out Application'Class;
Parser : in out Util.Serialize.IO.Parser'Class);
type Application is new ASF.Applications.Main.Application with record
DB_Factory : ADO.Sessions.Factory.Session_Factory;
Modules : aliased AWA.Modules.Module_Registry;
Events : aliased AWA.Events.Services.Event_Manager;
Audits : aliased AWA.Audits.Services.Audit_Manager;
end record;
end AWA.Applications;
|
private with Ada.Finalization, fov_types_h;
package Libtcod.Maps is
Error : exception;
type X_Pos is new Interfaces.C.int range 0 .. Interfaces.C.int'Last;
type Y_Pos is new Interfaces.C.int range 0 .. Interfaces.C.int'Last;
type X_Diff is new Interfaces.C.int;
type Y_Diff is new Interfaces.C.Int;
procedure increment(x : in out X_Pos; d : X_Diff);
function "+"(x : X_Pos; d : X_Diff) return X_Pos;
function "-"(x : X_Pos; d : X_Pos) return X_Diff;
procedure increment(y : in out Y_Pos; d : Y_Diff);
function "+"(y : Y_Pos; d : Y_Diff) return Y_Pos;
function "-"(x : Y_Pos; d : Y_Pos) return Y_Diff;
type Radius is range 0 .. Integer'Last;
type Map is tagged limited private;
function make_map(w : Width; h : Height) return Map;
function get_width(m : Map) return Width with Inline;
function get_height(m : Map) return Height with Inline;
function get_cell_count(m : Map) return Natural with Inline;
procedure set_properties_all(m : in out Map; transparent, walkable : Boolean)
with Inline;
procedure set_properties(m : in out Map; x : X_Pos; y : Y_Pos;
transparent, walkable : Boolean) with Inline;
function is_transparent(m : Map; x : X_Pos; y : Y_Pos) return Boolean
with Inline;
function is_walkable(m : Map; x : X_Pos; y : Y_Pos) return Boolean
with Inline;
private
type Map is new Ada.Finalization.Limited_Controlled with record
data : access fov_types_h.TCOD_Map;
end record;
overriding procedure Finalize(m : in out Map);
end Libtcod.Maps;
|
-- Copyright (c) 2010 - 2018, Nordic Semiconductor ASA
--
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without modification,
-- are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
--
-- 2. Redistributions in binary form, except as embedded into a Nordic
-- Semiconductor ASA integrated circuit in a product or a software update for
-- such product, must reproduce the above copyright notice, this list of
-- conditions and the following disclaimer in the documentation and/or other
-- materials provided with the distribution.
--
-- 3. Neither the name of Nordic Semiconductor ASA nor the names of its
-- contributors may be used to endorse or promote products derived from this
-- software without specific prior written permission.
--
-- 4. This software, with or without modification, must only be used with a
-- Nordic Semiconductor ASA integrated circuit.
--
-- 5. Any software provided in binary form under this license must not be reverse
-- engineered, decompiled, modified and/or disassembled.
--
-- THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
-- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-- OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
-- This spec has been automatically generated from nrf52.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NRF_SVD.TIMER is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Description collection[0]: Capture Timer value to CC[0] register
-- Description collection[0]: Capture Timer value to CC[0] register
type TASKS_CAPTURE_Registers is array (0 .. 5) of HAL.UInt32;
-- Description collection[0]: Compare event on CC[0] match
-- Description collection[0]: Compare event on CC[0] match
type EVENTS_COMPARE_Registers is array (0 .. 5) of HAL.UInt32;
-- Shortcut between COMPARE[0] event and CLEAR task
type SHORTS_COMPARE0_CLEAR_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_COMPARE0_CLEAR_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between COMPARE[1] event and CLEAR task
type SHORTS_COMPARE1_CLEAR_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_COMPARE1_CLEAR_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between COMPARE[2] event and CLEAR task
type SHORTS_COMPARE2_CLEAR_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_COMPARE2_CLEAR_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between COMPARE[3] event and CLEAR task
type SHORTS_COMPARE3_CLEAR_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_COMPARE3_CLEAR_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between COMPARE[4] event and CLEAR task
type SHORTS_COMPARE4_CLEAR_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_COMPARE4_CLEAR_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between COMPARE[5] event and CLEAR task
type SHORTS_COMPARE5_CLEAR_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_COMPARE5_CLEAR_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between COMPARE[0] event and STOP task
type SHORTS_COMPARE0_STOP_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_COMPARE0_STOP_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between COMPARE[1] event and STOP task
type SHORTS_COMPARE1_STOP_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_COMPARE1_STOP_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between COMPARE[2] event and STOP task
type SHORTS_COMPARE2_STOP_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_COMPARE2_STOP_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between COMPARE[3] event and STOP task
type SHORTS_COMPARE3_STOP_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_COMPARE3_STOP_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between COMPARE[4] event and STOP task
type SHORTS_COMPARE4_STOP_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_COMPARE4_STOP_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between COMPARE[5] event and STOP task
type SHORTS_COMPARE5_STOP_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_COMPARE5_STOP_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut register
type SHORTS_Register is record
-- Shortcut between COMPARE[0] event and CLEAR task
COMPARE0_CLEAR : SHORTS_COMPARE0_CLEAR_Field := NRF_SVD.TIMER.Disabled;
-- Shortcut between COMPARE[1] event and CLEAR task
COMPARE1_CLEAR : SHORTS_COMPARE1_CLEAR_Field := NRF_SVD.TIMER.Disabled;
-- Shortcut between COMPARE[2] event and CLEAR task
COMPARE2_CLEAR : SHORTS_COMPARE2_CLEAR_Field := NRF_SVD.TIMER.Disabled;
-- Shortcut between COMPARE[3] event and CLEAR task
COMPARE3_CLEAR : SHORTS_COMPARE3_CLEAR_Field := NRF_SVD.TIMER.Disabled;
-- Shortcut between COMPARE[4] event and CLEAR task
COMPARE4_CLEAR : SHORTS_COMPARE4_CLEAR_Field := NRF_SVD.TIMER.Disabled;
-- Shortcut between COMPARE[5] event and CLEAR task
COMPARE5_CLEAR : SHORTS_COMPARE5_CLEAR_Field := NRF_SVD.TIMER.Disabled;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- Shortcut between COMPARE[0] event and STOP task
COMPARE0_STOP : SHORTS_COMPARE0_STOP_Field := NRF_SVD.TIMER.Disabled;
-- Shortcut between COMPARE[1] event and STOP task
COMPARE1_STOP : SHORTS_COMPARE1_STOP_Field := NRF_SVD.TIMER.Disabled;
-- Shortcut between COMPARE[2] event and STOP task
COMPARE2_STOP : SHORTS_COMPARE2_STOP_Field := NRF_SVD.TIMER.Disabled;
-- Shortcut between COMPARE[3] event and STOP task
COMPARE3_STOP : SHORTS_COMPARE3_STOP_Field := NRF_SVD.TIMER.Disabled;
-- Shortcut between COMPARE[4] event and STOP task
COMPARE4_STOP : SHORTS_COMPARE4_STOP_Field := NRF_SVD.TIMER.Disabled;
-- Shortcut between COMPARE[5] event and STOP task
COMPARE5_STOP : SHORTS_COMPARE5_STOP_Field := NRF_SVD.TIMER.Disabled;
-- unspecified
Reserved_14_31 : HAL.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SHORTS_Register use record
COMPARE0_CLEAR at 0 range 0 .. 0;
COMPARE1_CLEAR at 0 range 1 .. 1;
COMPARE2_CLEAR at 0 range 2 .. 2;
COMPARE3_CLEAR at 0 range 3 .. 3;
COMPARE4_CLEAR at 0 range 4 .. 4;
COMPARE5_CLEAR at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
COMPARE0_STOP at 0 range 8 .. 8;
COMPARE1_STOP at 0 range 9 .. 9;
COMPARE2_STOP at 0 range 10 .. 10;
COMPARE3_STOP at 0 range 11 .. 11;
COMPARE4_STOP at 0 range 12 .. 12;
COMPARE5_STOP at 0 range 13 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
-- Write '1' to Enable interrupt for COMPARE[0] event
type INTENSET_COMPARE0_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_COMPARE0_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for COMPARE[0] event
type INTENSET_COMPARE0_Field_1 is
(-- Reset value for the field
Intenset_Compare0_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_COMPARE0_Field_1 use
(Intenset_Compare0_Field_Reset => 0,
Set => 1);
-- INTENSET_COMPARE array
type INTENSET_COMPARE_Field_Array is array (0 .. 5)
of INTENSET_COMPARE0_Field_1
with Component_Size => 1, Size => 6;
-- Type definition for INTENSET_COMPARE
type INTENSET_COMPARE_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- COMPARE as a value
Val : HAL.UInt6;
when True =>
-- COMPARE as an array
Arr : INTENSET_COMPARE_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for INTENSET_COMPARE_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
-- Enable interrupt
type INTENSET_Register is record
-- unspecified
Reserved_0_15 : HAL.UInt16 := 16#0#;
-- Write '1' to Enable interrupt for COMPARE[0] event
COMPARE : INTENSET_COMPARE_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_22_31 : HAL.UInt10 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENSET_Register use record
Reserved_0_15 at 0 range 0 .. 15;
COMPARE at 0 range 16 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
-- Write '1' to Disable interrupt for COMPARE[0] event
type INTENCLR_COMPARE0_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_COMPARE0_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for COMPARE[0] event
type INTENCLR_COMPARE0_Field_1 is
(-- Reset value for the field
Intenclr_Compare0_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_COMPARE0_Field_1 use
(Intenclr_Compare0_Field_Reset => 0,
Clear => 1);
-- INTENCLR_COMPARE array
type INTENCLR_COMPARE_Field_Array is array (0 .. 5)
of INTENCLR_COMPARE0_Field_1
with Component_Size => 1, Size => 6;
-- Type definition for INTENCLR_COMPARE
type INTENCLR_COMPARE_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- COMPARE as a value
Val : HAL.UInt6;
when True =>
-- COMPARE as an array
Arr : INTENCLR_COMPARE_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for INTENCLR_COMPARE_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
-- Disable interrupt
type INTENCLR_Register is record
-- unspecified
Reserved_0_15 : HAL.UInt16 := 16#0#;
-- Write '1' to Disable interrupt for COMPARE[0] event
COMPARE : INTENCLR_COMPARE_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_22_31 : HAL.UInt10 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENCLR_Register use record
Reserved_0_15 at 0 range 0 .. 15;
COMPARE at 0 range 16 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
-- Timer mode
type MODE_MODE_Field is
(-- Select Timer mode
Timer,
-- Deprecated enumerator - Select Counter mode
Counter,
-- Select Low Power Counter mode
Lowpowercounter)
with Size => 2;
for MODE_MODE_Field use
(Timer => 0,
Counter => 1,
Lowpowercounter => 2);
-- Timer mode selection
type MODE_Register is record
-- Timer mode
MODE : MODE_MODE_Field := NRF_SVD.TIMER.Timer;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for MODE_Register use record
MODE at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- Timer bit width
type BITMODE_BITMODE_Field is
(-- 16 bit timer bit width
Val_16Bit,
-- 8 bit timer bit width
Val_08Bit,
-- 24 bit timer bit width
Val_24Bit,
-- 32 bit timer bit width
Val_32Bit)
with Size => 2;
for BITMODE_BITMODE_Field use
(Val_16Bit => 0,
Val_08Bit => 1,
Val_24Bit => 2,
Val_32Bit => 3);
-- Configure the number of bits used by the TIMER
type BITMODE_Register is record
-- Timer bit width
BITMODE : BITMODE_BITMODE_Field := NRF_SVD.TIMER.Val_16Bit;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for BITMODE_Register use record
BITMODE at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
subtype PRESCALER_PRESCALER_Field is HAL.UInt4;
-- Timer prescaler register
type PRESCALER_Register is record
-- Prescaler value
PRESCALER : PRESCALER_PRESCALER_Field := 16#4#;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for PRESCALER_Register use record
PRESCALER at 0 range 0 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- Description collection[0]: Capture/Compare register 0
-- Description collection[0]: Capture/Compare register 0
type CC_Registers is array (0 .. 5) of HAL.UInt32;
-----------------
-- Peripherals --
-----------------
-- Timer/Counter 0
type TIMER_Peripheral is record
-- Start Timer
TASKS_START : aliased HAL.UInt32;
-- Stop Timer
TASKS_STOP : aliased HAL.UInt32;
-- Increment Timer (Counter mode only)
TASKS_COUNT : aliased HAL.UInt32;
-- Clear time
TASKS_CLEAR : aliased HAL.UInt32;
-- Deprecated register - Shut down timer
TASKS_SHUTDOWN : aliased HAL.UInt32;
-- Description collection[0]: Capture Timer value to CC[0] register
TASKS_CAPTURE : aliased TASKS_CAPTURE_Registers;
-- Description collection[0]: Compare event on CC[0] match
EVENTS_COMPARE : aliased EVENTS_COMPARE_Registers;
-- Shortcut register
SHORTS : aliased SHORTS_Register;
-- Enable interrupt
INTENSET : aliased INTENSET_Register;
-- Disable interrupt
INTENCLR : aliased INTENCLR_Register;
-- Timer mode selection
MODE : aliased MODE_Register;
-- Configure the number of bits used by the TIMER
BITMODE : aliased BITMODE_Register;
-- Timer prescaler register
PRESCALER : aliased PRESCALER_Register;
-- Description collection[0]: Capture/Compare register 0
CC : aliased CC_Registers;
end record
with Volatile;
for TIMER_Peripheral use record
TASKS_START at 16#0# range 0 .. 31;
TASKS_STOP at 16#4# range 0 .. 31;
TASKS_COUNT at 16#8# range 0 .. 31;
TASKS_CLEAR at 16#C# range 0 .. 31;
TASKS_SHUTDOWN at 16#10# range 0 .. 31;
TASKS_CAPTURE at 16#40# range 0 .. 191;
EVENTS_COMPARE at 16#140# range 0 .. 191;
SHORTS at 16#200# range 0 .. 31;
INTENSET at 16#304# range 0 .. 31;
INTENCLR at 16#308# range 0 .. 31;
MODE at 16#504# range 0 .. 31;
BITMODE at 16#508# range 0 .. 31;
PRESCALER at 16#510# range 0 .. 31;
CC at 16#540# range 0 .. 191;
end record;
-- Timer/Counter 0
TIMER0_Periph : aliased TIMER_Peripheral
with Import, Address => TIMER0_Base;
-- Timer/Counter 1
TIMER1_Periph : aliased TIMER_Peripheral
with Import, Address => TIMER1_Base;
-- Timer/Counter 2
TIMER2_Periph : aliased TIMER_Peripheral
with Import, Address => TIMER2_Base;
-- Timer/Counter 3
TIMER3_Periph : aliased TIMER_Peripheral
with Import, Address => TIMER3_Base;
-- Timer/Counter 4
TIMER4_Periph : aliased TIMER_Peripheral
with Import, Address => TIMER4_Base;
end NRF_SVD.TIMER;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- A D A . R E A L _ T I M E --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2014, 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. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This is the Ravenscar version of this package for generic bare board
-- targets. Note that the operations here assume that Time is a 64-bit
-- unsigned integer and Time_Span is a 64-bit signed integer.
with System.Tasking;
with System.Task_Primitives.Operations;
with Ada.Unchecked_Conversion;
package body Ada.Real_Time is
pragma Suppress (Overflow_Check);
-- This package has careful manual overflow checks, and unsupresses them
-- where appropriate. This default enables compilation with checks enabled
-- on Ravenscar SFP, where 64-bit multiplication with overflow checking is
-- not available.
package OSI renames System.OS_Interface;
subtype LLI is Long_Long_Integer;
------------------------------------------------------------
-- Handling of Conversions Between Duration and Time_Span --
------------------------------------------------------------
-- For the To_Duration and To_Time_Span conversion functions, we use the
-- intermediate Integer representation of Duration (64-bit) to allow for
-- simple Integer operations instead of Float. We take advantage of the
-- fact that Duration is represented as an Integer with units of Small.
-- Within these conversions we perform the range checks required by
-- AI-00432 manually.
-- Note that in the past, within To_Duration and To_Time_Span, we were
-- first computing the conversion factor between Duration and Time_Span
-- (10 ** 9 / Clock_Frecuency) and then we multiplied or divided by it. The
-- advantage of this approach was that the operations were simple, and we
-- limited a lot the number of occurrences of overflows, but the accuracy
-- loss could be significant depending on the clock frequency. For example,
-- with a clock frequency of 600 MHz the factor was 1.66, which was rounded
-- to 1 (Integer), and hence with a 67% difference.
-- We tried also to have a better trade off (Contraint_Error being raised
-- when transforming very big values, but limiting a lot the loss of
-- accuracy) using Clock_Frequency in MHz instead of Hz. Therefore, we
-- multiplied first by 10 ** 3 (or Clock_Frequency / 10 ** 6 which is
-- typically smaller than 1000), and hence overflow could occur only with
-- really big values). The problem of this approach was that some processor
-- frequencies may not be expressed in multiples of MHz (for example,
-- 33.3333 MHz). The approach finally followed is to do the operations
-- "by hand" on the upper and the lower part of the 64-bit value. This is
-- slightly heavier, but we can preserve the best accuracy and the lowest
-- occurrence of overflows.
-----------------------
-- Local definitions --
-----------------------
type Uint_64 is mod 2 ** 64;
-- Type used to represent intermediate results of arithmetic operations
Max_Pos_Time_Span : constant := Uint_64 (Time_Span_Last);
Max_Neg_Time_Span : constant := Uint_64 (2 ** 63);
-- Absolute value of Time_Span_Last and Time_Span_First. Used in overflow
-- checks. Note that we avoid using abs on Time_Span_First everywhere.
-----------------------
-- Local subprograms --
-----------------------
function To_Duration is
new Ada.Unchecked_Conversion (LLI, Duration);
function To_Integer is
new Ada.Unchecked_Conversion (Duration, LLI);
function Mul_Div (V : Uint_64; M : Natural; D : Natural) return Uint_64;
-- Compute V * M / D. Constraint_Error is raised in case of overflow,
-- results above (2 ** 63) - 1 are considered as overflow. Therefore,
-- the result can safely be converted to a signed 64-bit value.
---------
-- "*" --
---------
function "*" (Left : Time_Span; Right : Integer) return Time_Span is
Is_Negative : constant Boolean :=
(Left > 0 and then Right < 0) or else (Left < 0 and then Right > 0);
-- Sign of the result
Max_Value : constant Uint_64 :=
(if Is_Negative then Max_Neg_Time_Span else Max_Pos_Time_Span);
-- Maximum absolute value that can be returned by the multiplication
-- taking into account the sign of the operators.
Abs_Left : constant Uint_64 :=
(if Left = Time_Span_First then Max_Neg_Time_Span
else Uint_64 (abs (Left)));
-- Remove sign of left operator
Abs_Right : constant Uint_64 := Uint_64 (abs (LLI (Right)));
-- Remove sign of right operator
begin
-- Overflow check is performed by hand assuming that Time_Span is a
-- 64-bit signed integer. Otherwise these checks would need an
-- intermediate type with more than 64-bit. The sign of the operators
-- is removed to simplify the intermediate computation of the overflow
-- check.
if Abs_Right /= 0 and then Max_Value / Abs_Right < Abs_Left then
raise Constraint_Error;
else
return Left * Time_Span (Right);
end if;
end "*";
function "*" (Left : Integer; Right : Time_Span) return Time_Span is
begin
return Right * Left;
end "*";
---------
-- "+" --
---------
function "+" (Left : Time; Right : Time_Span) return Time is
begin
-- Overflow checks are be performed by hand assuming that Time and
-- Time_Span are 64-bit unsigned and signed integers respectively.
-- Otherwise these checks would need an intermediate type with more
-- than 64 bits.
if Right >= 0
and then Uint_64 (Time_Last) - Uint_64 (Left) >= Uint_64 (Right)
then
return Time (Uint_64 (Left) + Uint_64 (Right));
elsif Right = Time_Span'First and then Left >= Max_Neg_Time_Span then
return Time (Uint_64 (Left) - Max_Neg_Time_Span);
elsif Right < 0 and then Left >= Time (abs (Right)) then
return Time (Uint_64 (Left) - Uint_64 (abs (Right)));
else
raise Constraint_Error;
end if;
end "+";
function "+" (Left, Right : Time_Span) return Time_Span is
pragma Unsuppress (Overflow_Check);
begin
return Time_Span (LLI (Left) + LLI (Right));
end "+";
---------
-- "-" --
---------
function "-" (Left : Time; Right : Time_Span) return Time is
begin
-- Overflow checks must be performed by hand assuming that Time and
-- Time_Span are 64-bit unsigned and signed integers respectively.
-- Otherwise these checks would need an intermediate type with more
-- than 64-bit.
if Right >= 0 and then Left >= Time (Right) then
return Time (Uint_64 (Left) - Uint_64 (Right));
elsif Right = Time_Span'First
and then Uint_64 (Time_Last) - Uint_64 (Left) >= Max_Neg_Time_Span
then
return Left + Time (Max_Neg_Time_Span);
elsif Right < 0
and then Uint_64 (Time_Last) - Uint_64 (Left) >= Uint_64 (abs (Right))
then
return Left + Time (abs (Right));
else
raise Constraint_Error;
end if;
end "-";
function "-" (Left, Right : Time) return Time_Span is
begin
-- Overflow checks must be performed by hand assuming that Time and
-- Time_Span are 64-bit unsigned and signed integers respectively.
-- Otherwise these checks would need an intermediate type with more
-- than 64-bit.
if Left >= Right
and then Uint_64 (Left) - Uint_64 (Right) <= Uint_64 (Time_Span_Last)
then
return Time_Span (Uint_64 (Left) - Uint_64 (Right));
elsif Left < Right
and then Uint_64 (Right) - Uint_64 (Left) <= Max_Neg_Time_Span
then
return Time_Span (-(Uint_64 (Right) - Uint_64 (Left)));
else
raise Constraint_Error;
end if;
end "-";
function "-" (Left, Right : Time_Span) return Time_Span is
pragma Unsuppress (Overflow_Check);
begin
return Time_Span (LLI (Left) - LLI (Right));
end "-";
function "-" (Right : Time_Span) return Time_Span is
pragma Unsuppress (Overflow_Check);
begin
return Time_Span (-LLI (Right));
end "-";
---------
-- "/" --
---------
function "/" (Left, Right : Time_Span) return Integer is
pragma Unsuppress (Overflow_Check);
begin
return Integer (LLI (Left) / LLI (Right));
end "/";
function "/" (Left : Time_Span; Right : Integer) return Time_Span is
pragma Unsuppress (Overflow_Check);
begin
return Left / Time_Span (Right);
end "/";
-----------
-- Clock --
-----------
function Clock return Time is
begin
return Time (System.Task_Primitives.Operations.Monotonic_Clock);
end Clock;
------------------
-- Microseconds --
------------------
function Microseconds (US : Integer) return Time_Span is
begin
-- Overflow can't happen (Ticks_Per_Second is Natural)
return Time_Span
(LLI (US) * LLI (OSI.Ticks_Per_Second)) / Time_Span (10#1#E6);
end Microseconds;
------------------
-- Milliseconds --
------------------
function Milliseconds (MS : Integer) return Time_Span is
begin
-- Overflow can't happen (Ticks_Per_Second is Natural)
return Time_Span
(LLI (MS) * LLI (OSI.Ticks_Per_Second)) / Time_Span (10#1#E3);
end Milliseconds;
-------------
-- Minutes --
-------------
function Minutes (M : Integer) return Time_Span is
Min_M : constant LLI := LLI'First / LLI (OSI.Ticks_Per_Second);
Max_M : constant LLI := LLI'Last / LLI (OSI.Ticks_Per_Second);
-- Bounds for Sec_M. Note that we can't use unsupress overflow checks,
-- as this would require the use of arit64
Sec_M : constant LLI := LLI (M) * 60;
-- M converted to seconds
begin
if Sec_M < Min_M or else Sec_M > Max_M then
raise Constraint_Error;
else
return Time_Span (Sec_M * LLI (OSI.Ticks_Per_Second));
end if;
end Minutes;
-----------------
-- Nanoseconds --
-----------------
function Nanoseconds (NS : Integer) return Time_Span is
begin
-- Overflow can't happen (Ticks_Per_Second is Natural)
return Time_Span
(LLI (NS) * LLI (OSI.Ticks_Per_Second)) / Time_Span (10#1#E9);
end Nanoseconds;
-------------
-- Seconds --
-------------
function Seconds (S : Integer) return Time_Span is
begin
-- Overflow can't happen (Ticks_Per_Second is Natural)
return Time_Span (LLI (S) * LLI (OSI.Ticks_Per_Second));
end Seconds;
-----------
-- Split --
-----------
procedure Split (T : Time; SC : out Seconds_Count; TS : out Time_Span) is
Res : constant Time := Time (OSI.Ticks_Per_Second);
begin
SC := Seconds_Count (T / Res);
TS := T - Time (SC) * Res;
end Split;
-------------
-- Time_Of --
-------------
function Time_Of (SC : Seconds_Count; TS : Time_Span) return Time is
Res : constant Time := Time (OSI.Ticks_Per_Second);
begin
if Time_Last / Res < Time (SC) then
raise Constraint_Error;
else
return Time (SC) * Res + TS;
end if;
end Time_Of;
-------------
-- Mul_Div --
-------------
function Mul_Div (V : Uint_64; M : Natural; D : Natural) return Uint_64 is
-- Upper case letters represent one word (32-bit words in our case).
-- If we can compute, PQ = AB / D, then we can compute ABC / D using
-- the following method (pencil and paper algorithm):
-- MN := AB / D (first quotient)
-- R := AB - MN * D (remainder on one word, as R < D)
-- OP := RC / D (second quotient)
-- res := MN0 + OP
-- We check absence of overflow in the final result by checking that
-- M is 0, and that there is no carry when adding N0 and OP.
-- Initially, A = 0, BC = V
V_Hi : Uint_64 := V / 2 ** 32; -- AB
V_Lo : Uint_64 := V rem 2 ** 32; -- C
Result_Hi : Uint_64;
-- High part of the result
Result_Lo : Uint_64;
-- Low part of the result
Remainder : Uint_64;
-- Remainder of the first division (denoted R above)
begin
-- Multiply V by M
V_Hi := V_Hi * Uint_64 (M);
V_Lo := V_Lo * Uint_64 (M);
V_Hi := V_Hi + V_Lo / 2 ** 32;
V_Lo := V_Lo rem 2 ** 32;
-- First quotient
Result_Hi := V_Hi / Uint_64 (D);
if Result_Hi > (2 ** 31 - 1) then
-- The final result conversion would overflow: Result_Hi will be
-- the high 32 bit part of the result.
raise Constraint_Error;
end if;
Remainder := V_Hi - Result_Hi * Uint_64 (D);
Result_Hi := Result_Hi * 2 ** 32;
-- Second quotient. To improve rounding, D / 2 is added
Result_Lo :=
(V_Lo + Remainder * 2 ** 32 + Uint_64 (D / 2)) / Uint_64 (D);
if Result_Lo > (2 ** 63 - 1) - Result_Hi then
-- The final conversion for the result (just below) would overflow
raise Constraint_Error;
end if;
return Result_Hi + Result_Lo;
end Mul_Div;
-----------------
-- To_Duration --
-----------------
function To_Duration (TS : Time_Span) return Duration is
Duration_Units : constant Natural := Natural (1.0 / Duration'Small);
-- Number of units of Duration in one second. The result is correct
-- (not rounded) as Duration'Small is 10.0**(-9)
Result : LLI;
-- Contains the temporary result
Is_Negative : constant Boolean := TS < 0;
-- Remove the sign to simplify the intermediate computations
TPS : constant Natural := OSI.Ticks_Per_Second;
-- Capture ticks per second value
begin
-- See comment at the beginning of this file about this implementation
-- We need to accurately compute TS * Duration_Units / Ticks_Per_Second
-- TS being a 64-bit integer, both Duration_Units and Ticks_Per_Second
-- are 32-bit integers.
Result :=
(if TS = Time_Span'First
then LLI (Mul_Div (Max_Neg_Time_Span, Duration_Units, TPS))
else LLI (Mul_Div (Uint_64 (abs TS), Duration_Units, TPS)));
-- Handle the sign of the result
if Is_Negative then
Result := -Result;
end if;
return To_Duration (Result);
end To_Duration;
------------------
-- To_Time_Span --
------------------
function To_Time_Span (D : Duration) return Time_Span is
Duration_Units : constant Natural := Natural (1.0 / Duration'Small);
-- Number of units of Duration in one second
Result : LLI;
-- Contains the temporary results
Is_Negative : constant Boolean := D < 0.0;
-- Remove the sign to simplify the intermediate computations
begin
-- See comment at the beginning of this file about this implementation
Result := LLI
(Mul_Div (Uint_64 (abs To_Integer (D)),
OSI.Ticks_Per_Second,
Duration_Units));
-- Handle the sign of the result
if Is_Negative then
Result := -Result;
end if;
return Time_Span (Result);
end To_Time_Span;
begin
-- Ensure that the tasking run time is initialized when using clock and/or
-- delay operations. The initialization routine has the required machinery
-- to prevent multiple calls to Initialize.
System.Tasking.Initialize;
end Ada.Real_Time;
|
with Ada.Containers.Synchronized_Queue_Interfaces;
with Ada.Containers.Unbounded_Priority_Queues;
with Ada.Strings.Unbounded;
procedure Priority_Queues is
use Ada.Containers;
use Ada.Strings.Unbounded;
type Queue_Element is record
Priority : Natural;
Content : Unbounded_String;
end record;
function Get_Priority (Element : Queue_Element) return Natural is
begin
return Element.Priority;
end Get_Priority;
function Before (Left, Right : Natural) return Boolean is
begin
return Left > Right;
end Before;
package String_Queues is new Synchronized_Queue_Interfaces
(Element_Type => Queue_Element);
package String_Priority_Queues is new Unbounded_Priority_Queues
(Queue_Interfaces => String_Queues,
Queue_Priority => Natural);
My_Queue : String_Priority_Queues.Queue;
begin
My_Queue.Enqueue (New_Item => (Priority => 3, Content => To_Unbounded_String ("Clear drains")));
My_Queue.Enqueue (New_Item => (Priority => 4, Content => To_Unbounded_String ("Feed cat")));
My_Queue.Enqueue (New_Item => (Priority => 5, Content => To_Unbounded_String ("Make tea")));
My_Queue.Enqueue (New_Item => (Priority => 1, Content => To_Unbounded_String ("Solve RC tasks")));
My_Queue.Enqueue (New_Item => (Priority => 2, Content => To_Unbounded_String ("Tax return")));
declare
Element : Queue_Element;
begin
while My_Queue.Current_Use > 0 loop
My_Queue.Dequeue (Element => Element);
Ada.Text_IO.Put_Line (Natural'Image (Element.Priority) & " => " & To_String (Element.Content));
end loop;
end;
end Priority_Queues;
|
package Variant_Record is
type Record_1 (Discriminant_1 : Boolean) is record
case Discriminant_1 is
when True =>
Component_2 : Integer;
when False =>
Component_3 : Float;
end case;
end record;
type Record_With_Others (Discriminant_1 : Boolean) is record
case Discriminant_1 is
when True =>
Component_2 : Integer;
when others =>
Component_3 : Float;
end case;
end record;
type Record_With_Default_Discriminant
(Discriminant_1 : Boolean := True)
is record
case Discriminant_1 is
when True =>
Component_2 : Integer;
when False =>
Component_3 : Float;
end case;
end record;
type Record_With_Two_Discriminants
(Discriminant_1 : Boolean;
Discriminant_2 : Boolean)
is record
case Discriminant_1 is
when True =>
Component_2 : Integer;
when False =>
Component_3 : Float;
end case;
end record;
type Record_With_Non_Variant (Discriminant_1 : Boolean) is record
Component_1 : Natural;
case Discriminant_1 is
when True =>
Component_2 : Integer;
when False =>
Component_3 : Float;
end case;
end record;
type Record_With_Multiple_Variant_Components (Discriminant_1 : Boolean) is record
case Discriminant_1 is
when True =>
Component_2 : Integer;
Component_21 : Integer;
when False =>
Component_3 : Float;
Component_31 : Float;
end case;
end record;
end Variant_Record;
|
-------------------------------------------------------------------------------
-- --
-- D D S . R E Q U E S T _ R E P L Y . R E P L Y _ G E N E R I C --
-- --
-- B o d y --
-- --
-------------------------------------------------------------------------------
package body Dds.Request_Reply.Reply_Generic is
------------
-- Create --
------------
function Create
(Participant : DDS.DomainParticipant.Ref_Access;
Service_Name : DDS.String;
Datawriter_Qos : DDS.DataWriterQoS := DDS.Publisher.DATAWRITER_QOS_DEFAULT;
Datareader_Qos : DDS.DataReaderQoS := DDS.Subscriber.DATAREADER_QOS_DEFAULT;
Listener : ReplierListener_Access := null)
return Ref_Access
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Create unimplemented");
raise Program_Error with "Unimplemented function Create";
return Create (Participant => Participant, Service_Name => Service_Name,
Datawriter_Qos => Datawriter_Qos, Datareader_Qos => Datareader_Qos,
Listener => Listener);
end Create;
------------
-- Create --
------------
function Create
(Participant : DDS.DomainParticipant.Ref_Access;
Service_Name : Standard.String;
Datawriter_Qos : DDS.DataWriterQoS := DDS.Publisher.DATAWRITER_QOS_DEFAULT;
Datareader_Qos : DDS.DataReaderQoS := DDS.Subscriber.DATAREADER_QOS_DEFAULT;
Listener : ReplierListener_Access := null)
return Ref_Access
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Create unimplemented");
raise Program_Error with "Unimplemented function Create";
return Create (Participant => Participant, Service_Name => Service_Name,
Datawriter_Qos => Datawriter_Qos, Datareader_Qos => Datareader_Qos,
Listener => Listener);
end Create;
------------
-- Create --
------------
function Create
(Participant : DDS.DomainParticipant.Ref_Access;
Service_Name : DDS.String;
Datawriter_Qos : DDS.String;
Datareader_Qos : DDS.String;
Listener : ReplierListener_Access := null)
return Ref_Access
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Create unimplemented");
raise Program_Error with "Unimplemented function Create";
return Create (Participant => Participant, Service_Name => Service_Name,
Datawriter_Qos => Datawriter_Qos, Datareader_Qos => Datareader_Qos,
Listener => Listener);
end Create;
------------
-- Create --
------------
function Create
(Participant : DDS.DomainParticipant.Ref_Access;
Service_Name : DDS.String;
Datawriter_Qos : Standard.String;
Datareader_Qos : Standard.String;
Listener : ReplierListener_Access := null)
return Ref_Access
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Create unimplemented");
raise Program_Error with "Unimplemented function Create";
return Create (Participant => Participant, Service_Name => Service_Name,
Datawriter_Qos => Datawriter_Qos, Datareader_Qos => Datareader_Qos,
Listener => Listener);
end Create;
------------
-- Create --
------------
function Create
(Participant : DDS.DomainParticipant.Ref_Access;
Service_Name : DDS.String;
Request_Topic_Name : DDS.String;
Reply_Topic_Name : DDS.String;
Publisher : DDS.Publisher.Ref_Access;
Subscriber : DDS.Subscriber.Ref_Access;
Listener : ReplierListener_Access := null)
return Ref_Access
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Create unimplemented");
raise Program_Error with "Unimplemented function Create";
return Create (Participant => Participant, Service_Name => Service_Name,
Request_Topic_Name => Request_Topic_Name,
Reply_Topic_Name => Reply_Topic_Name, Publisher => Publisher,
Subscriber => Subscriber, Listener => Listener);
end Create;
------------
-- Create --
------------
function Create
(Participant : DDS.DomainParticipant.Ref_Access;
Service_Name : DDS.String;
Request_Topic_Name : DDS.String;
Reply_Topic_Name : DDS.String;
Qos_Library_Name : DDS.String;
Qos_Profile_Name : DDS.String;
Publisher : DDS.Publisher.Ref_Access;
Subscriber : DDS.Subscriber.Ref_Access;
Listener : ReplierListener_access := null)
return Ref_Access
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Create unimplemented");
raise Program_Error with "Unimplemented function Create";
return Create (Participant => Participant, Service_Name => Service_Name,
Request_Topic_Name => Request_Topic_Name,
Reply_Topic_Name => Reply_Topic_Name,
Qos_Library_Name => Qos_Library_Name,
Qos_Profile_Name => Qos_Profile_Name, Publisher => Publisher,
Subscriber => Subscriber, Listener => Listener);
end Create;
------------
-- Create --
------------
function Create
(Participant : DDS.DomainParticipant.Ref_Access;
Service_Name : DDS.String;
Request_Topic_Name : DDS.String;
Reply_Topic_Name : DDS.String;
Qos_Library_Name : Standard.String;
Qos_Profile_Name : Standard.String;
Publisher : DDS.Publisher.Ref_Access;
Subscriber : DDS.Subscriber.Ref_Access;
Listener : ReplierListener_access := null)
return Ref_Access
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Create unimplemented");
raise Program_Error with "Unimplemented function Create";
return Create (Participant => Participant, Service_Name => Service_Name,
Request_Topic_Name => Request_Topic_Name,
Reply_Topic_Name => Reply_Topic_Name,
Qos_Library_Name => Qos_Library_Name,
Qos_Profile_Name => Qos_Profile_Name, Publisher => Publisher,
Subscriber => Subscriber, Listener => Listener);
end Create;
------------
-- Create --
------------
function Create return Ref_Access is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Create unimplemented");
raise Program_Error with "Unimplemented function Create";
return Create;
end Create;
------------------
-- Take_Request --
------------------
function Take_Request
(Self : not null access Ref;
Requests : aliased Request_DataReaders.Treats.Data_Type;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence)
return DDS.ReturnCode_T
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Take_Request unimplemented");
raise Program_Error with "Unimplemented function Take_Request";
return Take_Request (Self => Self, Requests => Requests,
Sample_Info => Sample_Info);
end Take_Request;
------------------
-- Take_Request --
------------------
function Take_Request
(Self : not null access Ref)
return Request_DataReaders.Container'Class
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Take_Request unimplemented");
raise Program_Error with "Unimplemented function Take_Request";
return Take_Request (Self => Self);
end Take_Request;
-------------------
-- Take_Requests --
-------------------
function Take_Requests
(Self : not null access Ref;
Max_Request_Count : DDS.Long)
return Request_DataReaders.Container'Class
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Take_Requests unimplemented");
raise Program_Error with "Unimplemented function Take_Requests";
return Take_Requests (Self => Self,
Max_Request_Count => Max_Request_Count);
end Take_Requests;
------------------
-- Read_Request --
------------------
function Read_Request
(Self : not null access Ref;
Requests : aliased Request_DataReaders.Treats.Data_Type;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence)
return DDS.ReturnCode_T
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Read_Request unimplemented");
raise Program_Error with "Unimplemented function Read_Request";
return Read_Request (Self => Self, Requests => Requests,
Sample_Info => Sample_Info);
end Read_Request;
-------------------
-- Read_Requests --
-------------------
function Read_Requests
(Self : not null access Ref;
Requests : not null Request_DataReaders.Treats.Data_Sequences.Sequence_Access;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Max_Request_Count : DDS.Long)
return DDS.ReturnCode_T
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Read_Requests unimplemented");
raise Program_Error with "Unimplemented function Read_Requests";
return Read_Requests (Self => Self, Requests => Requests,
Sample_Info => Sample_Info, Max_Request_Count => Max_Request_Count);
end Read_Requests;
-------------------
-- Read_Requests --
-------------------
function Read_Requests
(Self : not null access Ref;
Max_Request_Count : DDS.Long := DDS.Long'Last)
return Request_DataReaders.Container'Class
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Read_Requests unimplemented");
raise Program_Error with "Unimplemented function Read_Requests";
return Read_Requests (Self => Self,
Max_Request_Count => Max_Request_Count);
end Read_Requests;
---------------------
-- Receive_Request --
---------------------
function Receive_Request
(Self : not null access Ref;
Request : access Request_DataReaders.Treats.Data_Type;
Info_Seq : not null access DDS.SampleInfo_Seq.Sequence;
Timeout : DDS.Duration_T)
return DDS.ReturnCode_T
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Receive_Request unimplemented");
raise Program_Error with "Unimplemented function Receive_Request";
return Receive_Request (Self => Self, Request => Request,
Info_Seq => Info_Seq, Timeout => Timeout);
end Receive_Request;
----------------------
-- Receive_Requests --
----------------------
function Receive_Requests
(Self : not null access Ref;
Requests : not null Request_DataReaders.Treats.Data_Sequences.Sequence_Access;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Min_Request_Count : Request_DataReaders.Treats.Index_Type;
Max_Request_Count : Request_DataReaders.Treats.Index_Type;
Timeout : DDS.Duration_T)
return DDS.ReturnCode_T
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Receive_Requests unimplemented");
raise Program_Error with "Unimplemented function Receive_Requests";
return Receive_Requests (Self => Self, Requests => Requests,
Sample_Info => Sample_Info, Min_Request_Count => Min_Request_Count,
Max_Request_Count => Max_Request_Count, Timeout => Timeout);
end Receive_Requests;
----------------------
-- Receive_Requests --
----------------------
function Receive_Requests
(Self : not null access Ref;
Min_Request_Count : Request_DataReaders.Treats.Index_Type;
Max_Request_Count : Request_DataReaders.Treats.Index_Type;
Timeout : DDS.Duration_T)
return Request_DataReaders.Container'Class
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Receive_Requests unimplemented");
raise Program_Error with "Unimplemented function Receive_Requests";
return Receive_Requests (Self => Self,
Min_Request_Count => Min_Request_Count,
Max_Request_Count => Max_Request_Count, Timeout => Timeout);
end Receive_Requests;
----------------
-- Send_Reply --
----------------
procedure Send_Reply
(Self : not null access Ref;
Reply : access Reply_DataWriters.Treats.Data_Type;
Related_Request_Info : DDS.SampleIdentity_T)
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Send_Reply unimplemented");
raise Program_Error with "Unimplemented procedure Send_Reply";
end Send_Reply;
----------------
-- Send_Reply --
----------------
procedure Send_Reply
(Self : not null access Ref;
Reply : access Reply_DataWriters.Treats.Data_Type;
Related_Request_Info : DDS.SampleInfo)
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Send_Reply unimplemented");
raise Program_Error with "Unimplemented procedure Send_Reply";
end Send_Reply;
----------------
-- Send_Reply --
----------------
procedure Send_Reply
(Self : not null access Ref;
Reply : Reply_DataWriters.Treats.Data_Type;
Related_Request_Info : DDS.SampleIdentity_T)
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Send_Reply unimplemented");
raise Program_Error with "Unimplemented procedure Send_Reply";
end Send_Reply;
----------------
-- Send_Reply --
----------------
procedure Send_Reply
(Self : not null access Ref;
Reply : Reply_DataWriters.Treats.Data_Type;
Related_Request_Info : DDS.SampleInfo)
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Send_Reply unimplemented");
raise Program_Error with "Unimplemented procedure Send_Reply";
end Send_Reply;
----------------
-- Send_Reply --
----------------
procedure Send_Reply
(Self : not null access Ref;
Reply : Reply_DataWriters.Treats.Data_Array;
Related_Request_Info : DDS.SampleIdentity_T)
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Send_Reply unimplemented");
raise Program_Error with "Unimplemented procedure Send_Reply";
end Send_Reply;
----------------
-- Send_Reply --
----------------
procedure Send_Reply
(Self : not null access Ref;
Reply : Reply_DataWriters.Treats.Data_Array;
Related_Request_Info : DDS.SampleInfo)
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Send_Reply unimplemented");
raise Program_Error with "Unimplemented procedure Send_Reply";
end Send_Reply;
-----------------
-- Return_Loan --
-----------------
procedure Return_Loan
(Self : not null access Ref;
Requests : not null Reply_DataWriters.Treats.Data_Sequences.Sequence_Access;
Sample_Info : DDS.SampleInfo_Seq.Sequence_Access)
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Return_Loan unimplemented");
raise Program_Error with "Unimplemented procedure Return_Loan";
end Return_Loan;
----------------------------
-- Get_Request_DataReader --
----------------------------
function Get_Request_DataReader
(Self : not null access Ref)
return Request_DataReaders.Ref_Access
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Get_Request_DataReader unimplemented");
raise Program_Error with "Unimplemented function Get_Request_DataReader";
return Get_Request_DataReader (Self => Self);
end Get_Request_DataReader;
--------------------------
-- Get_Reply_DataWriter --
--------------------------
function Get_Reply_DataWriter
(Self : not null access Ref)
return Reply_DataWriters.Ref_Access
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Get_Reply_DataWriter unimplemented");
raise Program_Error with "Unimplemented function Get_Reply_DataWriter";
return Get_Reply_DataWriter (Self => Self);
end Get_Reply_DataWriter;
end Dds.Request_Reply.Reply_Generic;
|
-------------------------------------------------------------------------------
-- Copyright (c) 2016 Daniel King
--
-- Permission is hereby granted, free of charge, to any person obtaining a
-- copy of this software and associated documentation files (the "Software"),
-- to deal in the Software without restriction, including without limitation
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons to whom the
-- Software is furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-- DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
with DW1000.Types; use DW1000.Types;
with DW1000.Register_Types; use DW1000.Register_Types;
package DW1000.Constants
with SPARK_Mode => On
is
----------------------------------------------------------------------------
-- OTP memory word addresses
OTP_ADDR_EUID : constant OTP_ADDR_Field := 16#00#;
OTP_ADDR_LDOTUNE_CAL : constant OTP_ADDR_Field := 16#04#;
OTP_ADDR_CHIP_ID : constant OTP_ADDR_Field := 16#06#;
OTP_ADDR_LOT_ID : constant OTP_ADDR_Field := 16#07#;
OTP_ADDR_CH1_TX_POWER_PRF_16 : constant OTP_ADDR_Field := 16#10#;
OTP_ADDR_CH1_TX_POWER_PRF_64 : constant OTP_ADDR_Field := 16#11#;
OTP_ADDR_CH2_TX_POWER_PRF_16 : constant OTP_ADDR_Field := 16#12#;
OTP_ADDR_CH2_TX_POWER_PRF_64 : constant OTP_ADDR_Field := 16#13#;
OTP_ADDR_CH3_TX_POWER_PRF_16 : constant OTP_ADDR_Field := 16#14#;
OTP_ADDR_CH3_TX_POWER_PRF_64 : constant OTP_ADDR_Field := 16#15#;
OTP_ADDR_CH4_TX_POWER_PRF_16 : constant OTP_ADDR_Field := 16#16#;
OTP_ADDR_CH4_TX_POWER_PRF_64 : constant OTP_ADDR_Field := 16#17#;
OTP_ADDR_CH5_TX_POWER_PRF_16 : constant OTP_ADDR_Field := 16#18#;
OTP_ADDR_CH5_TX_POWER_PRF_64 : constant OTP_ADDR_Field := 16#19#;
OTP_ADDR_CH7_TX_POWER_PRF_16 : constant OTP_ADDR_Field := 16#1A#;
OTP_ADDR_CH7_TX_POWER_PRF_64 : constant OTP_ADDR_Field := 16#1B#;
OTP_ADDR_ANTENNA_DELAY : constant OTP_ADDR_Field := 16#1C#;
OTP_ADDR_XTAL_TRIM : constant OTP_ADDR_Field := 16#E0#;
----------------------------------------------------------------------------
-- Buffer lengths
TX_BUFFER_Length : constant := 1024;
RX_BUFFER_Length : constant := 1024;
end DW1000.Constants;
|
-----------------------------------------------------------------------
-- pq -- Postgresql libpq thin binding
-- Copyright (C) 2018 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Interfaces.C.Strings;
with System;
package PQ is
pragma Linker_Options ("-lpq");
subtype chars_ptr is Interfaces.C.Strings.chars_ptr;
type PGconn_Access is new System.Address;
Null_PGconn : constant PGconn_Access := PGconn_Access (System.Null_Address);
type PGresult_Access is new System.Address;
Null_PGresult : constant PGresult_Access := PGresult_Access (System.Null_Address);
type ConnStatusType is
(
CONNECTION_OK,
CONNECTION_BAD,
-- Non-blocking mode only below here
-- The existence of these should never be relied upon - they should only
-- be used for user feedback or similar purposes.
-- Waiting for connection to be made.
CONNECTION_STARTED,
-- Connection OK; waiting to send.
CONNECTION_MADE,
-- Waiting for a response from the postmaster.
CONNECTION_AWAITING_RESPONSE,
-- Received authentication; waiting for backend startup.
CONNECTION_AUTH_OK,
-- Negotiating environment.
CONNECTION_SETENV,
-- Negotiating SSL.
CONNECTION_SSL_STARTUP,
-- Internal state: connect() needed
CONNECTION_NEEDED
);
type ExecStatusType is
(
-- empty query string was executed
PGRES_EMPTY_QUERY,
-- a query command that doesn't return anything was executed properly by the backend
PGRES_COMMAND_OK,
-- a query command that returns tuples was executed properly by the backend, PGresult
-- contains the result tuples
PGRES_TUPLES_OK,
-- Copy Out data transfer in progress
PGRES_COPY_OUT,
-- Copy In data transfer in progress
PGRES_COPY_IN,
-- an unexpected response was recv'd from the backend
PGRES_BAD_RESPONSE,
-- notice or warning message
PGRES_NONFATAL_ERROR,
-- query failed
PGRES_FATAL_ERROR,
-- Copy In/Out data transfer in progress
PGRES_COPY_BOTH,
-- single tuple from larger resultset
PGRES_SINGLE_TUPLE
);
function PQconnectdb (Conninfo : in chars_ptr) return PGconn_Access
with Import => True, Convention => C, Link_Name => "PQconnectdb";
function PQstatus (Conn : in PGconn_Access) return ConnStatusType
with Import => True, Convention => C, Link_Name => "PQstatus";
function PQerrorMessage (Conn : in PGconn_Access) return chars_ptr
with Import => True, Convention => C, Link_Name => "PQerrorMessage";
procedure PQfinish (Conn : PGconn_Access)
with Import => True, Convention => C, Link_Name => "PQfinish";
function PQexec (Conn : PGconn_Access;
SQL : Interfaces.C.Strings.chars_ptr) return PGresult_Access
with Import => True, Convention => C, Link_Name => "PQexec";
procedure PQclear (Result : in PGresult_Access)
with Import => True, Convention => C, Link_Name => "PQclear";
function PQresultStatus (Result : in PGresult_Access) return ExecStatusType
with Import => True, Convention => C, Link_Name => "PQresultStatus";
function PQresultErrorMessage (Result : in PGresult_Access) return chars_ptr
with Import => True, Convention => C, Link_Name => "PQresultErrorMessage";
function PQcmdTuples (Result : in PGresult_Access) return chars_ptr
with Import => True, Convention => C, Link_Name => "PQcmdTuples";
function PQntuples (Result : in PGresult_Access) return Interfaces.C.int
with Import => True, Convention => C, Link_Name => "PQntuples";
function PQnfields (Result : in PGresult_Access) return Interfaces.C.int
with Import => True, Convention => C, Link_Name => "PQnfields";
function PQfname (Result : in PGresult_Access;
Column_Number : in Interfaces.C.int) return chars_ptr
with Import => True, Convention => C, Link_Name => "PQfname";
function PQfsize (Result : in PGresult_Access;
Column_Number : in Interfaces.C.int) return Interfaces.C.int
with Import => True, Convention => C, Link_Name => "PQfsize";
function PQgetvalue (Result : in PGresult_Access;
Row_Number : in Interfaces.C.int;
Column_Number : in Interfaces.C.int) return chars_ptr
with Import => True, Convention => C, Link_Name => "PQgetvalue";
function PQgetisnull (Result : in PGresult_Access;
Row_Number : in Interfaces.C.int;
Column_Number : in Interfaces.C.int) return Interfaces.C.int
with Import => True, Convention => C, Link_Name => "PQgetisnull";
function PQgetlength (Result : in PGresult_Access;
Row_Number : in Interfaces.C.int;
Column_Number : in Interfaces.C.int) return Interfaces.C.int
with Import => True, Convention => C, Link_Name => "PQgetlength";
end PQ;
|
package body STM32GD.GPIO.Pin is
procedure Init is
begin
null;
end Init;
procedure Set_Mode (Mode : Pin_IO_Modes) is
begin
null;
end Set_Mode;
procedure Set_Type (Pin_Type : Pin_Output_Types) is
begin
null;
end Set_Type;
function Get_Pull_Resistor return Internal_Pin_Resistors is
begin
return Pull_Down;
end Get_Pull_Resistor;
procedure Set_Pull_Resistor (Pull : Internal_Pin_Resistors) is
begin
null;
end Set_Pull_Resistor;
function Is_Set return Boolean is
begin
return False;
end Is_Set;
procedure Set is
begin
null;
end Set;
procedure Clear is
begin
null;
end Clear;
procedure Toggle is
begin
null;
end Toggle;
procedure Configure_Alternate_Function (AF : GPIO_Alternate_Function) is
begin
null;
end Configure_Alternate_Function;
procedure Connect_External_Interrupt is
begin
null;
end Connect_External_Interrupt;
end STM32GD.GPIO.Pin;
|
------------------------------------------------------------------------------
-- names.ads
--
-- This package defines a collection of enumerated types that name some of the
-- objects in the simulation: namely the philosophers, chopsticks, waiters,
-- and cooks.
--
-- Note that we enforce the rule that there have to be the same number of
-- chopsticks as philosophers.
--
-- Note also that names are not given to the host, order bin, heat lamp, or
-- reporter since these are essentially unique objects.
------------------------------------------------------------------------------
package Names is
type Philosopher_Name is (Russell, Church, Empedocles, Rand, Kant);
type Chopstick_Name is range 0..Philosopher_Name'Pos(Philosopher_Name'Last);
type Waiter_Name is (Tweedledee, Tweedledum);
type Cook_Name is (Moe, Larry, Curly);
end Names;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- P A R . C H 9 --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
pragma Style_Checks (All_Checks);
-- Turn off subprogram body ordering check. Subprograms are in order by RM
-- section rather than alphabetical.
separate (Par)
package body Ch9 is
-- Local subprograms, used only in this chapter
function P_Accept_Alternative return Node_Id;
function P_Delay_Alternative return Node_Id;
function P_Delay_Relative_Statement return Node_Id;
function P_Delay_Until_Statement return Node_Id;
function P_Entry_Barrier return Node_Id;
function P_Entry_Body_Formal_Part return Node_Id;
function P_Entry_Declaration return Node_Id;
function P_Entry_Index_Specification return Node_Id;
function P_Protected_Definition return Node_Id;
function P_Protected_Operation_Declaration_Opt return Node_Id;
function P_Protected_Operation_Items return List_Id;
function P_Task_Items return List_Id;
function P_Task_Definition return Node_Id;
-----------------------------
-- 9.1 Task (also 10.1.3) --
-----------------------------
-- TASK_TYPE_DECLARATION ::=
-- task type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART]
-- [ASPECT_SPECIFICATIONS]
-- [is [new INTERFACE_LIST with] TASK_DEFINITION];
-- SINGLE_TASK_DECLARATION ::=
-- task DEFINING_IDENTIFIER
-- [ASPECT_SPECIFICATIONS]
-- [is [new INTERFACE_LIST with] TASK_DEFINITION];
-- TASK_BODY ::=
-- task body DEFINING_IDENTIFIER [ASPECT_SPECIFICATIONS] is
-- DECLARATIVE_PART
-- begin
-- HANDLED_SEQUENCE_OF_STATEMENTS
-- end [task_IDENTIFIER]
-- TASK_BODY_STUB ::=
-- task body DEFINING_IDENTIFIER is separate
-- [ASPECT_SPECIFICATIONS];
-- This routine scans out a task declaration, task body, or task stub
-- The caller has checked that the initial token is TASK and scanned
-- past it, so that Token is set to the token after TASK
-- Error recovery: cannot raise Error_Resync
function P_Task return Node_Id is
Aspect_Sloc : Source_Ptr := No_Location;
Name_Node : Node_Id;
Task_Node : Node_Id;
Task_Sloc : Source_Ptr;
Dummy_Node : constant Node_Id := New_Node (N_Task_Body, Token_Ptr);
-- Placeholder node used to hold legal or prematurely declared aspect
-- specifications. Depending on the context, the aspect specifications
-- may be moved to a new node.
begin
Push_Scope_Stack;
Scopes (Scope.Last).Etyp := E_Name;
Scopes (Scope.Last).Ecol := Start_Column;
Scopes (Scope.Last).Sloc := Token_Ptr;
Scopes (Scope.Last).Lreq := False;
Task_Sloc := Prev_Token_Ptr;
if Token = Tok_Body then
Scan; -- past BODY
Name_Node := P_Defining_Identifier (C_Is);
Scopes (Scope.Last).Labl := Name_Node;
Current_Node := Name_Node;
if Token = Tok_Left_Paren then
Error_Msg_SC ("discriminant part not allowed in task body");
Discard_Junk_List (P_Known_Discriminant_Part_Opt);
end if;
if Aspect_Specifications_Present then
Aspect_Sloc := Token_Ptr;
P_Aspect_Specifications (Dummy_Node, Semicolon => False);
end if;
TF_Is;
-- Task stub
if Token = Tok_Separate then
Scan; -- past SEPARATE
Task_Node := New_Node (N_Task_Body_Stub, Task_Sloc);
Set_Defining_Identifier (Task_Node, Name_Node);
if Has_Aspects (Dummy_Node) then
Error_Msg
("aspect specifications must come after SEPARATE",
Aspect_Sloc);
end if;
P_Aspect_Specifications (Task_Node, Semicolon => False);
TF_Semicolon;
Pop_Scope_Stack; -- remove unused entry
-- Task body
else
Task_Node := New_Node (N_Task_Body, Task_Sloc);
Set_Defining_Identifier (Task_Node, Name_Node);
-- Move the aspect specifications to the body node
if Has_Aspects (Dummy_Node) then
Move_Aspects (From => Dummy_Node, To => Task_Node);
end if;
Parse_Decls_Begin_End (Task_Node);
-- The statement list of a task body needs to include at least a
-- null statement, so if a parsing error produces an empty list,
-- patch it now.
if No (First (Statements
(Handled_Statement_Sequence (Task_Node))))
then
Set_Statements (Handled_Statement_Sequence (Task_Node),
New_List (Make_Null_Statement (Token_Ptr)));
end if;
end if;
return Task_Node;
-- Otherwise we must have a task declaration
else
if Token = Tok_Type then
Scan; -- past TYPE
Task_Node := New_Node (N_Task_Type_Declaration, Task_Sloc);
Name_Node := P_Defining_Identifier;
Set_Defining_Identifier (Task_Node, Name_Node);
Scopes (Scope.Last).Labl := Name_Node;
Current_Node := Name_Node;
Set_Discriminant_Specifications
(Task_Node, P_Known_Discriminant_Part_Opt);
else
Task_Node := New_Node (N_Single_Task_Declaration, Task_Sloc);
Name_Node := P_Defining_Identifier (C_Is);
Set_Defining_Identifier (Task_Node, Name_Node);
Scopes (Scope.Last).Labl := Name_Node;
Current_Node := Name_Node;
if Token = Tok_Left_Paren then
Error_Msg_SC ("discriminant part not allowed for single task");
Discard_Junk_List (P_Known_Discriminant_Part_Opt);
end if;
end if;
-- Scan aspect specifications, don't eat the semicolon, since it
-- might not be there if we have an IS.
P_Aspect_Specifications (Task_Node, Semicolon => False);
-- Parse optional task definition. Note that P_Task_Definition scans
-- out the semicolon and possible aspect specifications as well as
-- the task definition itself.
if Token = Tok_Semicolon then
-- A little check, if the next token after semicolon is Entry,
-- then surely the semicolon should really be IS
Scan; -- past semicolon
if Token = Tok_Entry then
Error_Msg_SP -- CODEFIX
("|"";"" should be IS");
Set_Task_Definition (Task_Node, P_Task_Definition);
else
Pop_Scope_Stack; -- Remove unused entry
end if;
-- Here we have a task definition
else
TF_Is; -- must have IS if no semicolon
-- Ada 2005 (AI-345)
if Token = Tok_New then
Scan; -- past NEW
if Ada_Version < Ada_2005 then
Error_Msg_SP ("task interface is an Ada 2005 extension");
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
end if;
Set_Interface_List (Task_Node, New_List);
loop
Append (P_Qualified_Simple_Name, Interface_List (Task_Node));
exit when Token /= Tok_And;
Scan; -- past AND
end loop;
if Token /= Tok_With then
Error_Msg_SC -- CODEFIX
("WITH expected");
end if;
Scan; -- past WITH
if Token = Tok_Private then
Error_Msg_SP -- CODEFIX
("PRIVATE not allowed in task type declaration");
end if;
end if;
Set_Task_Definition (Task_Node, P_Task_Definition);
end if;
return Task_Node;
end if;
end P_Task;
--------------------------------
-- 9.1 Task Type Declaration --
--------------------------------
-- Parsed by P_Task (9.1)
----------------------------------
-- 9.1 Single Task Declaration --
----------------------------------
-- Parsed by P_Task (9.1)
--------------------------
-- 9.1 Task Definition --
--------------------------
-- TASK_DEFINITION ::=
-- {TASK_ITEM}
-- [private
-- {TASK_ITEM}]
-- end [task_IDENTIFIER];
-- The caller has already made the scope stack entry
-- Note: there is a small deviation from official syntax here in that we
-- regard the semicolon after end as part of the Task_Definition, and in
-- the official syntax, it's part of the enclosing declaration. The reason
-- for this deviation is that otherwise the end processing would have to
-- be special cased, which would be a nuisance.
-- Error recovery: cannot raise Error_Resync
function P_Task_Definition return Node_Id is
Def_Node : Node_Id;
begin
Def_Node := New_Node (N_Task_Definition, Token_Ptr);
Set_Visible_Declarations (Def_Node, P_Task_Items);
if Token = Tok_Private then
Scan; -- past PRIVATE
Set_Private_Declarations (Def_Node, P_Task_Items);
-- Deal gracefully with multiple PRIVATE parts
while Token = Tok_Private loop
Error_Msg_SC ("only one private part allowed per task");
Scan; -- past PRIVATE
Append_List (P_Task_Items, Private_Declarations (Def_Node));
end loop;
end if;
End_Statements (Def_Node);
return Def_Node;
end P_Task_Definition;
--------------------
-- 9.1 Task Item --
--------------------
-- TASK_ITEM ::= ENTRY_DECLARATION | REPRESENTATION_CLAUSE
-- This subprogram scans a (possibly empty) list of task items and pragmas
-- Error recovery: cannot raise Error_Resync
-- Note: a pragma can also be returned in this position
function P_Task_Items return List_Id is
Items : List_Id;
Item_Node : Node_Id;
Decl_Sloc : Source_Ptr;
begin
-- Get rid of active SIS entry from outer scope. This means we will
-- miss some nested cases, but it doesn't seem worth the effort. See
-- discussion in Par for further details
SIS_Entry_Active := False;
-- Loop to scan out task items
Items := New_List;
Decl_Loop : loop
Decl_Sloc := Token_Ptr;
if Token = Tok_Pragma then
P_Pragmas_Opt (Items);
-- Ada 2005 (AI-397): Reserved words NOT and OVERRIDING may begin an
-- entry declaration.
elsif Token = Tok_Entry
or else Token = Tok_Not
or else Token = Tok_Overriding
then
Append (P_Entry_Declaration, Items);
elsif Token = Tok_For then
-- Representation clause in task declaration. The only rep clause
-- which is legal in a protected declaration is an address clause,
-- so that is what we try to scan out.
Item_Node := P_Representation_Clause;
if Nkind (Item_Node) = N_At_Clause then
Append (Item_Node, Items);
elsif Nkind (Item_Node) = N_Attribute_Definition_Clause
and then Chars (Item_Node) = Name_Address
then
Append (Item_Node, Items);
else
Error_Msg
("the only representation clause " &
"allowed here is an address clause!", Decl_Sloc);
end if;
elsif Token = Tok_Identifier
or else Token in Token_Class_Declk
then
Error_Msg_SC ("illegal declaration in task definition");
Resync_Past_Semicolon;
else
exit Decl_Loop;
end if;
end loop Decl_Loop;
return Items;
end P_Task_Items;
--------------------
-- 9.1 Task Body --
--------------------
-- Parsed by P_Task (9.1)
----------------------------------
-- 9.4 Protected (also 10.1.3) --
----------------------------------
-- PROTECTED_TYPE_DECLARATION ::=
-- protected type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART]
-- [ASPECT_SPECIFICATIONS]
-- is [new INTERFACE_LIST with] PROTECTED_DEFINITION;
-- SINGLE_PROTECTED_DECLARATION ::=
-- protected DEFINING_IDENTIFIER
-- [ASPECT_SPECIFICATIONS]
-- is [new INTERFACE_LIST with] PROTECTED_DEFINITION;
-- PROTECTED_BODY ::=
-- protected body DEFINING_IDENTIFIER
-- [ASPECT_SPECIFICATIONS]
-- is
-- {PROTECTED_OPERATION_ITEM}
-- end [protected_IDENTIFIER];
-- PROTECTED_BODY_STUB ::=
-- protected body DEFINING_IDENTIFIER is separate
-- [ASPECT_SPECIFICATIONS];
-- This routine scans out a protected declaration, protected body
-- or a protected stub.
-- The caller has checked that the initial token is PROTECTED and
-- scanned past it, so Token is set to the following token.
-- Error recovery: cannot raise Error_Resync
function P_Protected return Node_Id is
Aspect_Sloc : Source_Ptr := No_Location;
Name_Node : Node_Id;
Protected_Node : Node_Id;
Protected_Sloc : Source_Ptr;
Scan_State : Saved_Scan_State;
Dummy_Node : constant Node_Id := New_Node (N_Protected_Body, Token_Ptr);
-- Placeholder node used to hold legal or prematurely declared aspect
-- specifications. Depending on the context, the aspect specifications
-- may be moved to a new node.
begin
Push_Scope_Stack;
Scopes (Scope.Last).Etyp := E_Name;
Scopes (Scope.Last).Ecol := Start_Column;
Scopes (Scope.Last).Lreq := False;
Protected_Sloc := Prev_Token_Ptr;
if Token = Tok_Body then
Scan; -- past BODY
Name_Node := P_Defining_Identifier (C_Is);
Scopes (Scope.Last).Labl := Name_Node;
Current_Node := Name_Node;
if Token = Tok_Left_Paren then
Error_Msg_SC ("discriminant part not allowed in protected body");
Discard_Junk_List (P_Known_Discriminant_Part_Opt);
end if;
if Aspect_Specifications_Present then
Aspect_Sloc := Token_Ptr;
P_Aspect_Specifications (Dummy_Node, Semicolon => False);
end if;
TF_Is;
-- Protected stub
if Token = Tok_Separate then
Scan; -- past SEPARATE
Protected_Node := New_Node (N_Protected_Body_Stub, Protected_Sloc);
Set_Defining_Identifier (Protected_Node, Name_Node);
if Has_Aspects (Dummy_Node) then
Error_Msg
("aspect specifications must come after SEPARATE",
Aspect_Sloc);
end if;
P_Aspect_Specifications (Protected_Node, Semicolon => False);
TF_Semicolon;
Pop_Scope_Stack; -- remove unused entry
-- Protected body
else
Protected_Node := New_Node (N_Protected_Body, Protected_Sloc);
Set_Defining_Identifier (Protected_Node, Name_Node);
Move_Aspects (From => Dummy_Node, To => Protected_Node);
Set_Declarations (Protected_Node, P_Protected_Operation_Items);
End_Statements (Protected_Node);
end if;
return Protected_Node;
-- Otherwise we must have a protected declaration
else
if Token = Tok_Type then
Scan; -- past TYPE
Protected_Node :=
New_Node (N_Protected_Type_Declaration, Protected_Sloc);
Name_Node := P_Defining_Identifier (C_Is);
Set_Defining_Identifier (Protected_Node, Name_Node);
Scopes (Scope.Last).Labl := Name_Node;
Current_Node := Name_Node;
Set_Discriminant_Specifications
(Protected_Node, P_Known_Discriminant_Part_Opt);
else
Protected_Node :=
New_Node (N_Single_Protected_Declaration, Protected_Sloc);
Name_Node := P_Defining_Identifier (C_Is);
Set_Defining_Identifier (Protected_Node, Name_Node);
if Token = Tok_Left_Paren then
Error_Msg_SC
("discriminant part not allowed for single protected");
Discard_Junk_List (P_Known_Discriminant_Part_Opt);
end if;
Scopes (Scope.Last).Labl := Name_Node;
Current_Node := Name_Node;
end if;
P_Aspect_Specifications (Protected_Node, Semicolon => False);
-- Check for semicolon not followed by IS, this is something like
-- protected type r;
-- where we want
-- protected type r IS END;
if Token = Tok_Semicolon then
Save_Scan_State (Scan_State); -- at semicolon
Scan; -- past semicolon
if Token /= Tok_Is then
Restore_Scan_State (Scan_State);
Error_Msg_SC -- CODEFIX
("missing IS");
Set_Protected_Definition (Protected_Node,
Make_Protected_Definition (Token_Ptr,
Visible_Declarations => Empty_List,
End_Label => Empty));
SIS_Entry_Active := False;
End_Statements
(Protected_Definition (Protected_Node), Protected_Node);
return Protected_Node;
end if;
Error_Msg_SP -- CODEFIX
("|extra ""("" ignored");
end if;
T_Is;
-- Ada 2005 (AI-345)
if Token = Tok_New then
Scan; -- past NEW
if Ada_Version < Ada_2005 then
Error_Msg_SP ("protected interface is an Ada 2005 extension");
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
end if;
Set_Interface_List (Protected_Node, New_List);
loop
Append (P_Qualified_Simple_Name,
Interface_List (Protected_Node));
exit when Token /= Tok_And;
Scan; -- past AND
end loop;
if Token /= Tok_With then
Error_Msg_SC -- CODEFIX
("WITH expected");
end if;
Scan; -- past WITH
end if;
Set_Protected_Definition (Protected_Node, P_Protected_Definition);
return Protected_Node;
end if;
end P_Protected;
-------------------------------------
-- 9.4 Protected Type Declaration --
-------------------------------------
-- Parsed by P_Protected (9.4)
---------------------------------------
-- 9.4 Single Protected Declaration --
---------------------------------------
-- Parsed by P_Protected (9.4)
-------------------------------
-- 9.4 Protected Definition --
-------------------------------
-- PROTECTED_DEFINITION ::=
-- {PROTECTED_OPERATION_DECLARATION}
-- [private
-- {PROTECTED_ELEMENT_DECLARATION}]
-- end [protected_IDENTIFIER]
-- PROTECTED_ELEMENT_DECLARATION ::=
-- PROTECTED_OPERATION_DECLARATION
-- | COMPONENT_DECLARATION
-- The caller has already established the scope stack entry
-- Error recovery: cannot raise Error_Resync
function P_Protected_Definition return Node_Id is
Def_Node : Node_Id;
Item_Node : Node_Id;
Priv_Decls : List_Id;
Vis_Decls : List_Id;
begin
Def_Node := New_Node (N_Protected_Definition, Token_Ptr);
-- Get rid of active SIS entry from outer scope. This means we will
-- miss some nested cases, but it doesn't seem worth the effort. See
-- discussion in Par for further details
SIS_Entry_Active := False;
-- Loop to scan visible declarations (protected operation declarations)
Vis_Decls := New_List;
Set_Visible_Declarations (Def_Node, Vis_Decls);
-- Flag and discard all pragmas which cannot appear in the protected
-- definition. Note that certain pragmas are still allowed as long as
-- they apply to entries, entry families, or protected subprograms.
P_Pragmas_Opt (Vis_Decls);
loop
Item_Node := P_Protected_Operation_Declaration_Opt;
if Present (Item_Node) then
Append (Item_Node, Vis_Decls);
end if;
P_Pragmas_Opt (Vis_Decls);
exit when No (Item_Node);
end loop;
-- Deal with PRIVATE part (including graceful handling of multiple
-- PRIVATE parts).
Private_Loop : while Token = Tok_Private loop
Priv_Decls := Private_Declarations (Def_Node);
if Present (Priv_Decls) then
Error_Msg_SC ("duplicate private part");
else
Priv_Decls := New_List;
Set_Private_Declarations (Def_Node, Priv_Decls);
end if;
Scan; -- past PRIVATE
-- Flag and discard all pragmas which cannot appear in the protected
-- definition. Note that certain pragmas are still allowed as long as
-- they apply to entries, entry families, or protected subprograms.
P_Pragmas_Opt (Priv_Decls);
Declaration_Loop : loop
if Token = Tok_Identifier then
P_Component_Items (Priv_Decls);
P_Pragmas_Opt (Priv_Decls);
else
Item_Node := P_Protected_Operation_Declaration_Opt;
if Present (Item_Node) then
Append (Item_Node, Priv_Decls);
end if;
P_Pragmas_Opt (Priv_Decls);
exit Declaration_Loop when No (Item_Node);
end if;
end loop Declaration_Loop;
end loop Private_Loop;
End_Statements (Def_Node);
return Def_Node;
end P_Protected_Definition;
------------------------------------------
-- 9.4 Protected Operation Declaration --
------------------------------------------
-- PROTECTED_OPERATION_DECLARATION ::=
-- SUBPROGRAM_DECLARATION
-- | ENTRY_DECLARATION
-- | REPRESENTATION_CLAUSE
-- Error recovery: cannot raise Error_Resync
-- Note: a pragma can also be returned in this position
-- We are not currently permitting representation clauses to appear as
-- protected operation declarations, do we have to rethink this???
function P_Protected_Operation_Declaration_Opt return Node_Id is
L : List_Id;
P : Source_Ptr;
function P_Entry_Or_Subprogram_With_Indicator return Node_Id;
-- Ada 2005 (AI-397): Parse an entry or a subprogram with an overriding
-- indicator. The caller has checked that the initial token is NOT or
-- OVERRIDING.
------------------------------------------
-- P_Entry_Or_Subprogram_With_Indicator --
------------------------------------------
function P_Entry_Or_Subprogram_With_Indicator return Node_Id is
Decl : Node_Id := Error;
Is_Overriding : Boolean := False;
Not_Overriding : Boolean := False;
begin
if Token = Tok_Not then
Scan; -- past NOT
if Token = Tok_Overriding then
Scan; -- past OVERRIDING
Not_Overriding := True;
else
Error_Msg_SC -- CODEFIX
("OVERRIDING expected!");
end if;
else
Scan; -- past OVERRIDING
Is_Overriding := True;
end if;
if Is_Overriding or else Not_Overriding then
if Ada_Version < Ada_2005 then
Error_Msg_SP ("overriding indicator is an Ada 2005 extension");
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
elsif Token = Tok_Entry then
Decl := P_Entry_Declaration;
Set_Must_Override (Decl, Is_Overriding);
Set_Must_Not_Override (Decl, Not_Overriding);
elsif Token = Tok_Function or else Token = Tok_Procedure then
Decl := P_Subprogram (Pf_Decl_Pexp);
Set_Must_Override (Specification (Decl), Is_Overriding);
Set_Must_Not_Override (Specification (Decl), Not_Overriding);
else
Error_Msg_SC -- CODEFIX
("ENTRY, FUNCTION or PROCEDURE expected!");
end if;
end if;
return Decl;
end P_Entry_Or_Subprogram_With_Indicator;
Result : Node_Id := Empty;
-- Start of processing for P_Protected_Operation_Declaration_Opt
begin
-- This loop runs more than once only when a junk declaration is skipped
loop
case Token is
when Tok_Pragma =>
Result := P_Pragma;
exit;
when Tok_Not
| Tok_Overriding
=>
Result := P_Entry_Or_Subprogram_With_Indicator;
exit;
when Tok_Entry =>
Result := P_Entry_Declaration;
exit;
when Tok_Function
| Tok_Procedure
=>
Result := P_Subprogram (Pf_Decl_Pexp);
exit;
when Tok_Identifier =>
L := New_List;
P := Token_Ptr;
Skip_Declaration (L);
if Nkind (First (L)) = N_Object_Declaration then
Error_Msg
("component must be declared in private part of " &
"protected type", P);
else
Error_Msg
("illegal declaration in protected definition", P);
end if;
-- Continue looping
when Tok_For =>
Error_Msg_SC
("representation clause not allowed in protected definition");
Resync_Past_Semicolon;
-- Continue looping
when others =>
if Token in Token_Class_Declk then
Error_Msg_SC ("illegal declaration in protected definition");
Resync_Past_Semicolon;
-- Return now to avoid cascaded messages if next declaration
-- is a valid component declaration.
Result := Error;
end if;
exit;
end case;
end loop;
if Nkind (Result) = N_Subprogram_Declaration
and then Nkind (Specification (Result)) =
N_Procedure_Specification
and then Null_Present (Specification (Result))
then
Error_Msg_N
("protected operation cannot be a null procedure",
Null_Statement (Specification (Result)));
end if;
return Result;
end P_Protected_Operation_Declaration_Opt;
-----------------------------------
-- 9.4 Protected Operation Item --
-----------------------------------
-- PROTECTED_OPERATION_ITEM ::=
-- SUBPROGRAM_DECLARATION
-- | SUBPROGRAM_BODY
-- | ENTRY_BODY
-- | REPRESENTATION_CLAUSE
-- This procedure parses and returns a list of protected operation items
-- We are not currently permitting representation clauses to appear
-- as protected operation items, do we have to rethink this???
function P_Protected_Operation_Items return List_Id is
Item_List : List_Id;
begin
Item_List := New_List;
loop
if Token = Tok_Entry or else Bad_Spelling_Of (Tok_Entry) then
Append (P_Entry_Body, Item_List);
-- If the operation starts with procedure, function, or an overriding
-- indicator ("overriding" or "not overriding"), parse a subprogram.
elsif Token = Tok_Function or else Bad_Spelling_Of (Tok_Function)
or else
Token = Tok_Procedure or else Bad_Spelling_Of (Tok_Procedure)
or else
Token = Tok_Overriding or else Bad_Spelling_Of (Tok_Overriding)
or else
Token = Tok_Not or else Bad_Spelling_Of (Tok_Not)
then
Append (P_Subprogram (Pf_Decl_Pbod_Pexp), Item_List);
elsif Token = Tok_Pragma or else Bad_Spelling_Of (Tok_Pragma) then
P_Pragmas_Opt (Item_List);
elsif Token = Tok_Private or else Bad_Spelling_Of (Tok_Private) then
Error_Msg_SC ("PRIVATE not allowed in protected body");
Scan; -- past PRIVATE
elsif Token = Tok_Identifier then
Error_Msg_SC ("all components must be declared in spec!");
Resync_Past_Semicolon;
elsif Token in Token_Class_Declk then
Error_Msg_SC ("this declaration not allowed in protected body");
Resync_Past_Semicolon;
else
exit;
end if;
end loop;
return Item_List;
end P_Protected_Operation_Items;
------------------------------
-- 9.5.2 Entry Declaration --
------------------------------
-- ENTRY_DECLARATION ::=
-- [OVERRIDING_INDICATOR]
-- entry DEFINING_IDENTIFIER
-- [(DISCRETE_SUBTYPE_DEFINITION)] PARAMETER_PROFILE
-- [ASPECT_SPECIFICATIONS];
-- The caller has checked that the initial token is ENTRY, NOT or
-- OVERRIDING.
-- Error recovery: cannot raise Error_Resync
function P_Entry_Declaration return Node_Id is
Decl_Node : Node_Id;
Scan_State : Saved_Scan_State;
-- Flags for optional overriding indication. Two flags are needed,
-- to distinguish positive and negative overriding indicators from
-- the absence of any indicator.
Is_Overriding : Boolean := False;
Not_Overriding : Boolean := False;
begin
-- Ada 2005 (AI-397): Scan leading overriding indicator
if Token = Tok_Not then
Scan; -- past NOT
if Token = Tok_Overriding then
Scan; -- part OVERRIDING
Not_Overriding := True;
else
Error_Msg_SC -- CODEFIX
("OVERRIDING expected!");
end if;
elsif Token = Tok_Overriding then
Scan; -- part OVERRIDING
Is_Overriding := True;
end if;
if Is_Overriding or else Not_Overriding then
if Ada_Version < Ada_2005 then
Error_Msg_SP ("overriding indicator is an Ada 2005 extension");
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
elsif Token /= Tok_Entry then
Error_Msg_SC -- CODEFIX
("ENTRY expected!");
end if;
end if;
Decl_Node := New_Node (N_Entry_Declaration, Token_Ptr);
Scan; -- past ENTRY
Set_Defining_Identifier
(Decl_Node, P_Defining_Identifier (C_Left_Paren_Semicolon));
-- If left paren, could be (Discrete_Subtype_Definition) or Formal_Part
if Token = Tok_Left_Paren then
Scan; -- past (
-- If identifier after left paren, could still be either
if Token = Tok_Identifier then
Save_Scan_State (Scan_State); -- at Id
Scan; -- past Id
-- If comma or colon after Id, must be Formal_Part
if Token = Tok_Comma or else Token = Tok_Colon then
Restore_Scan_State (Scan_State); -- to Id
Set_Parameter_Specifications (Decl_Node, P_Formal_Part);
-- Else if Id without comma or colon, must be discrete subtype
-- defn
else
Restore_Scan_State (Scan_State); -- to Id
Set_Discrete_Subtype_Definition
(Decl_Node, P_Discrete_Subtype_Definition);
T_Right_Paren;
Set_Parameter_Specifications (Decl_Node, P_Parameter_Profile);
end if;
-- If no Id, must be discrete subtype definition
else
Set_Discrete_Subtype_Definition
(Decl_Node, P_Discrete_Subtype_Definition);
T_Right_Paren;
Set_Parameter_Specifications (Decl_Node, P_Parameter_Profile);
end if;
end if;
if Is_Overriding then
Set_Must_Override (Decl_Node);
elsif Not_Overriding then
Set_Must_Not_Override (Decl_Node);
end if;
-- Error recovery check for illegal return
if Token = Tok_Return then
Error_Msg_SC ("entry cannot have return value!");
Scan;
Discard_Junk_Node (P_Subtype_Indication);
end if;
-- Error recovery check for improper use of entry barrier in spec
if Token = Tok_When then
Error_Msg_SC ("barrier not allowed here (belongs in body)");
Scan; -- past WHEN;
Discard_Junk_Node (P_Expression_No_Right_Paren);
end if;
P_Aspect_Specifications (Decl_Node);
return Decl_Node;
exception
when Error_Resync =>
Resync_Past_Semicolon;
return Error;
end P_Entry_Declaration;
-----------------------------
-- 9.5.2 Accept Statement --
-----------------------------
-- ACCEPT_STATEMENT ::=
-- accept entry_DIRECT_NAME
-- [(ENTRY_INDEX)] PARAMETER_PROFILE [do
-- HANDLED_SEQUENCE_OF_STATEMENTS
-- end [entry_IDENTIFIER]];
-- The caller has checked that the initial token is ACCEPT
-- Error recovery: cannot raise Error_Resync. If an error occurs, the
-- scan is resynchronized past the next semicolon and control returns.
function P_Accept_Statement return Node_Id is
Scan_State : Saved_Scan_State;
Accept_Node : Node_Id;
Hand_Seq : Node_Id;
begin
Push_Scope_Stack;
Scopes (Scope.Last).Sloc := Token_Ptr;
Scopes (Scope.Last).Ecol := Start_Column;
Accept_Node := New_Node (N_Accept_Statement, Token_Ptr);
Scan; -- past ACCEPT
Scopes (Scope.Last).Labl := Token_Node;
Current_Node := Token_Node;
Set_Entry_Direct_Name (Accept_Node, P_Identifier (C_Do));
-- Left paren could be (Entry_Index) or Formal_Part, determine which
if Token = Tok_Left_Paren then
Save_Scan_State (Scan_State); -- at left paren
Scan; -- past left paren
-- If first token after left paren not identifier, then Entry_Index
if Token /= Tok_Identifier then
Set_Entry_Index (Accept_Node, P_Expression);
T_Right_Paren;
Set_Parameter_Specifications (Accept_Node, P_Parameter_Profile);
-- First token after left paren is identifier, could be either case
else -- Token = Tok_Identifier
Scan; -- past identifier
-- If identifier followed by comma or colon, must be Formal_Part
if Token = Tok_Comma or else Token = Tok_Colon then
Restore_Scan_State (Scan_State); -- to left paren
Set_Parameter_Specifications (Accept_Node, P_Parameter_Profile);
-- If identifier not followed by comma/colon, must be entry index
else
Restore_Scan_State (Scan_State); -- to left paren
Scan; -- past left paren (again)
Set_Entry_Index (Accept_Node, P_Expression);
T_Right_Paren;
Set_Parameter_Specifications (Accept_Node, P_Parameter_Profile);
end if;
end if;
end if;
-- Scan out DO if present
if Token = Tok_Do then
Scopes (Scope.Last).Etyp := E_Name;
Scopes (Scope.Last).Lreq := False;
Scan; -- past DO
Hand_Seq := P_Handled_Sequence_Of_Statements;
Set_Handled_Statement_Sequence (Accept_Node, Hand_Seq);
End_Statements (Handled_Statement_Sequence (Accept_Node));
-- Exception handlers not allowed in Ada 95 node
if Present (Exception_Handlers (Hand_Seq)) then
if Ada_Version = Ada_83 then
Error_Msg_N
("(Ada 83) exception handlers in accept not allowed",
First_Non_Pragma (Exception_Handlers (Hand_Seq)));
end if;
end if;
else
Pop_Scope_Stack; -- discard unused entry
TF_Semicolon;
end if;
return Accept_Node;
-- If error, resynchronize past semicolon
exception
when Error_Resync =>
Resync_Past_Semicolon;
Pop_Scope_Stack; -- discard unused entry
return Error;
end P_Accept_Statement;
------------------------
-- 9.5.2 Entry Index --
------------------------
-- Parsed by P_Expression (4.4)
--------------------------
-- 9.5.2 Entry Barrier --
--------------------------
-- ENTRY_BARRIER ::= when CONDITION
-- Error_Recovery: cannot raise Error_Resync
function P_Entry_Barrier return Node_Id is
Bnode : Node_Id;
begin
if Token = Tok_When then
Scan; -- past WHEN;
Bnode := P_Expression_No_Right_Paren;
if Token = Tok_Colon_Equal then
Error_Msg_SC -- CODEFIX
("|"":="" should be ""=""");
Scan;
Bnode := P_Expression_No_Right_Paren;
end if;
else
T_When; -- to give error message
Bnode := Error;
end if;
return Bnode;
end P_Entry_Barrier;
-----------------------
-- 9.5.2 Entry Body --
-----------------------
-- ENTRY_BODY ::=
-- entry DEFINING_IDENTIFIER ENTRY_BODY_FORMAL_PART
-- [ASPECT_SPECIFICATIONS] ENTRY_BARRIER
-- is
-- DECLARATIVE_PART
-- begin
-- HANDLED_SEQUENCE_OF_STATEMENTS
-- end [entry_IDENTIFIER];
-- The caller has checked that the initial token is ENTRY
-- Error_Recovery: cannot raise Error_Resync
function P_Entry_Body return Node_Id is
Dummy_Node : Node_Id;
Entry_Node : Node_Id;
Formal_Part_Node : Node_Id;
Name_Node : Node_Id;
begin
Push_Scope_Stack;
Entry_Node := New_Node (N_Entry_Body, Token_Ptr);
Scan; -- past ENTRY
Scopes (Scope.Last).Ecol := Start_Column;
Scopes (Scope.Last).Lreq := False;
Scopes (Scope.Last).Etyp := E_Name;
Scopes (Scope.Last).Sloc := Token_Ptr;
Name_Node := P_Defining_Identifier;
Set_Defining_Identifier (Entry_Node, Name_Node);
Scopes (Scope.Last).Labl := Name_Node;
Current_Node := Name_Node;
Formal_Part_Node := P_Entry_Body_Formal_Part;
Set_Entry_Body_Formal_Part (Entry_Node, Formal_Part_Node);
-- Ada 2012 (AI12-0169): Aspect specifications may appear on an entry
-- body immediately after the formal part. Do not parse the aspect
-- specifications directly because the "when" of the entry barrier may
-- be interpreted as a misused "with".
if Token = Tok_With then
P_Aspect_Specifications (Entry_Node, Semicolon => False);
end if;
Set_Condition (Formal_Part_Node, P_Entry_Barrier);
-- Detect an illegal placement of aspect specifications following the
-- entry barrier.
-- entry E ... when Barrier with Aspect is
if Token = Tok_With then
Error_Msg_SC ("aspect specifications must come before entry barrier");
-- Consume the illegal aspects to allow for parsing to continue
Dummy_Node := New_Node (N_Entry_Body, Sloc (Entry_Node));
P_Aspect_Specifications (Dummy_Node, Semicolon => False);
end if;
TF_Is;
Parse_Decls_Begin_End (Entry_Node);
return Entry_Node;
end P_Entry_Body;
-----------------------------------
-- 9.5.2 Entry Body Formal Part --
-----------------------------------
-- ENTRY_BODY_FORMAL_PART ::=
-- [(ENTRY_INDEX_SPECIFICATION)] [PARAMETER_PART]
-- Error_Recovery: cannot raise Error_Resync
function P_Entry_Body_Formal_Part return Node_Id is
Fpart_Node : Node_Id;
Scan_State : Saved_Scan_State;
begin
Fpart_Node := New_Node (N_Entry_Body_Formal_Part, Token_Ptr);
-- See if entry index specification present, and if so parse it
if Token = Tok_Left_Paren then
Save_Scan_State (Scan_State); -- at left paren
Scan; -- past left paren
if Token = Tok_For then
Set_Entry_Index_Specification
(Fpart_Node, P_Entry_Index_Specification);
T_Right_Paren;
else
Restore_Scan_State (Scan_State); -- to left paren
end if;
-- Check for (common?) case of left paren omitted before FOR. This
-- is a tricky case, because the corresponding missing left paren
-- can cause real havoc if a formal part is present which gets
-- treated as part of the discrete subtype definition of the
-- entry index specification, so just give error and resynchronize
elsif Token = Tok_For then
T_Left_Paren; -- to give error message
Resync_To_When;
end if;
Set_Parameter_Specifications (Fpart_Node, P_Parameter_Profile);
return Fpart_Node;
end P_Entry_Body_Formal_Part;
--------------------------------------
-- 9.5.2 Entry Index Specification --
--------------------------------------
-- ENTRY_INDEX_SPECIFICATION ::=
-- for DEFINING_IDENTIFIER in DISCRETE_SUBTYPE_DEFINITION
-- Error recovery: can raise Error_Resync
function P_Entry_Index_Specification return Node_Id is
Iterator_Node : Node_Id;
begin
Iterator_Node := New_Node (N_Entry_Index_Specification, Token_Ptr);
T_For; -- past FOR
Set_Defining_Identifier (Iterator_Node, P_Defining_Identifier (C_In));
T_In;
Set_Discrete_Subtype_Definition
(Iterator_Node, P_Discrete_Subtype_Definition);
return Iterator_Node;
end P_Entry_Index_Specification;
---------------------------------
-- 9.5.3 Entry Call Statement --
---------------------------------
-- Parsed by P_Name (4.1). Within a select, an entry call is parsed
-- by P_Select_Statement (9.7)
------------------------------
-- 9.5.4 Requeue Statement --
------------------------------
-- REQUEUE_STATEMENT ::= requeue entry_NAME [with abort];
-- The caller has checked that the initial token is requeue
-- Error recovery: can raise Error_Resync
function P_Requeue_Statement return Node_Id is
Requeue_Node : Node_Id;
begin
Requeue_Node := New_Node (N_Requeue_Statement, Token_Ptr);
Scan; -- past REQUEUE
Set_Name (Requeue_Node, P_Name);
if Token = Tok_With then
Scan; -- past WITH
T_Abort;
Set_Abort_Present (Requeue_Node, True);
end if;
TF_Semicolon;
return Requeue_Node;
end P_Requeue_Statement;
--------------------------
-- 9.6 Delay Statement --
--------------------------
-- DELAY_STATEMENT ::=
-- DELAY_UNTIL_STATEMENT
-- | DELAY_RELATIVE_STATEMENT
-- The caller has checked that the initial token is DELAY
-- Error recovery: cannot raise Error_Resync
function P_Delay_Statement return Node_Id is
begin
Scan; -- past DELAY
-- The following check for delay until misused in Ada 83 doesn't catch
-- all cases, but it's good enough to catch most of them.
if Token_Name = Name_Until then
Check_95_Keyword (Tok_Until, Tok_Left_Paren);
Check_95_Keyword (Tok_Until, Tok_Identifier);
end if;
if Token = Tok_Until then
return P_Delay_Until_Statement;
else
return P_Delay_Relative_Statement;
end if;
end P_Delay_Statement;
--------------------------------
-- 9.6 Delay Until Statement --
--------------------------------
-- DELAY_UNTIL_STATEMENT ::= delay until delay_EXPRESSION;
-- The caller has checked that the initial token is DELAY, scanned it
-- out and checked that the current token is UNTIL
-- Error recovery: cannot raise Error_Resync
function P_Delay_Until_Statement return Node_Id is
Delay_Node : Node_Id;
begin
Delay_Node := New_Node (N_Delay_Until_Statement, Prev_Token_Ptr);
Scan; -- past UNTIL
Set_Expression (Delay_Node, P_Expression_No_Right_Paren);
TF_Semicolon;
return Delay_Node;
end P_Delay_Until_Statement;
-----------------------------------
-- 9.6 Delay Relative Statement --
-----------------------------------
-- DELAY_RELATIVE_STATEMENT ::= delay delay_EXPRESSION;
-- The caller has checked that the initial token is DELAY, scanned it
-- out and determined that the current token is not UNTIL
-- Error recovery: cannot raise Error_Resync
function P_Delay_Relative_Statement return Node_Id is
Delay_Node : Node_Id;
begin
Delay_Node := New_Node (N_Delay_Relative_Statement, Prev_Token_Ptr);
Set_Expression (Delay_Node, P_Expression_No_Right_Paren);
Check_Simple_Expression_In_Ada_83 (Expression (Delay_Node));
TF_Semicolon;
return Delay_Node;
end P_Delay_Relative_Statement;
---------------------------
-- 9.7 Select Statement --
---------------------------
-- SELECT_STATEMENT ::=
-- SELECTIVE_ACCEPT
-- | TIMED_ENTRY_CALL
-- | CONDITIONAL_ENTRY_CALL
-- | ASYNCHRONOUS_SELECT
-- SELECTIVE_ACCEPT ::=
-- select
-- [GUARD]
-- SELECT_ALTERNATIVE
-- {or
-- [GUARD]
-- SELECT_ALTERNATIVE
-- [else
-- SEQUENCE_OF_STATEMENTS]
-- end select;
-- GUARD ::= when CONDITION =>
-- Note: the guard preceding a select alternative is included as part
-- of the node generated for a selective accept alternative.
-- SELECT_ALTERNATIVE ::=
-- ACCEPT_ALTERNATIVE
-- | DELAY_ALTERNATIVE
-- | TERMINATE_ALTERNATIVE
-- TIMED_ENTRY_CALL ::=
-- select
-- ENTRY_CALL_ALTERNATIVE
-- or
-- DELAY_ALTERNATIVE
-- end select;
-- CONDITIONAL_ENTRY_CALL ::=
-- select
-- ENTRY_CALL_ALTERNATIVE
-- else
-- SEQUENCE_OF_STATEMENTS
-- end select;
-- ENTRY_CALL_ALTERNATIVE ::=
-- ENTRY_CALL_STATEMENT [SEQUENCE_OF_STATEMENTS]
-- ASYNCHRONOUS_SELECT ::=
-- select
-- TRIGGERING_ALTERNATIVE
-- then abort
-- ABORTABLE_PART
-- end select;
-- TRIGGERING_ALTERNATIVE ::=
-- TRIGGERING_STATEMENT [SEQUENCE_OF_STATEMENTS]
-- TRIGGERING_STATEMENT ::= ENTRY_CALL_STATEMENT | DELAY_STATEMENT
-- The caller has checked that the initial token is SELECT
-- Error recovery: can raise Error_Resync
function P_Select_Statement return Node_Id is
Select_Node : Node_Id;
Select_Sloc : Source_Ptr;
Stmnt_Sloc : Source_Ptr;
Ecall_Node : Node_Id;
Alternative : Node_Id;
Select_Pragmas : List_Id;
Alt_Pragmas : List_Id;
Statement_List : List_Id;
Alt_List : List_Id;
Cond_Expr : Node_Id;
Delay_Stmnt : Node_Id;
begin
Push_Scope_Stack;
Scopes (Scope.Last).Etyp := E_Select;
Scopes (Scope.Last).Ecol := Start_Column;
Scopes (Scope.Last).Sloc := Token_Ptr;
Scopes (Scope.Last).Labl := Error;
Select_Sloc := Token_Ptr;
Scan; -- past SELECT
Stmnt_Sloc := Token_Ptr;
Select_Pragmas := P_Pragmas_Opt;
-- If first token after select is designator, then we have an entry
-- call, which must be the start of a conditional entry call, timed
-- entry call or asynchronous select
if Token in Token_Class_Desig then
-- Scan entry call statement
begin
Ecall_Node := P_Name;
-- ?? The following two clauses exactly parallel code in ch5
-- and should be combined sometime
if Nkind (Ecall_Node) = N_Indexed_Component then
declare
Prefix_Node : constant Node_Id := Prefix (Ecall_Node);
Exprs_Node : constant List_Id := Expressions (Ecall_Node);
begin
Change_Node (Ecall_Node, N_Procedure_Call_Statement);
Set_Name (Ecall_Node, Prefix_Node);
Set_Parameter_Associations (Ecall_Node, Exprs_Node);
end;
elsif Nkind (Ecall_Node) = N_Function_Call then
declare
Fname_Node : constant Node_Id := Name (Ecall_Node);
Params_List : constant List_Id :=
Parameter_Associations (Ecall_Node);
begin
Change_Node (Ecall_Node, N_Procedure_Call_Statement);
Set_Name (Ecall_Node, Fname_Node);
Set_Parameter_Associations (Ecall_Node, Params_List);
end;
elsif Nkind (Ecall_Node) = N_Identifier
or else Nkind (Ecall_Node) = N_Selected_Component
then
-- Case of a call to a parameterless entry
declare
C_Node : constant Node_Id :=
New_Node (N_Procedure_Call_Statement, Stmnt_Sloc);
begin
Set_Name (C_Node, Ecall_Node);
Set_Parameter_Associations (C_Node, No_List);
Ecall_Node := C_Node;
end;
end if;
TF_Semicolon;
exception
when Error_Resync =>
Resync_Past_Semicolon;
return Error;
end;
Statement_List := P_Sequence_Of_Statements (SS_Eltm_Ortm_Tatm);
-- OR follows, we have a timed entry call
if Token = Tok_Or then
Scan; -- past OR
Alt_Pragmas := P_Pragmas_Opt;
Select_Node := New_Node (N_Timed_Entry_Call, Select_Sloc);
Set_Entry_Call_Alternative (Select_Node,
Make_Entry_Call_Alternative (Stmnt_Sloc,
Entry_Call_Statement => Ecall_Node,
Pragmas_Before => Select_Pragmas,
Statements => Statement_List));
-- Only possibility is delay alternative. If we have anything
-- else, give message, and treat as conditional entry call.
if Token /= Tok_Delay then
Error_Msg_SC
("only allowed alternative in timed entry call is delay!");
Discard_Junk_List (P_Sequence_Of_Statements (SS_Sreq));
Set_Delay_Alternative (Select_Node, Error);
else
Set_Delay_Alternative (Select_Node, P_Delay_Alternative);
Set_Pragmas_Before
(Delay_Alternative (Select_Node), Alt_Pragmas);
end if;
-- ELSE follows, we have a conditional entry call
elsif Token = Tok_Else then
Scan; -- past ELSE
Select_Node := New_Node (N_Conditional_Entry_Call, Select_Sloc);
Set_Entry_Call_Alternative (Select_Node,
Make_Entry_Call_Alternative (Stmnt_Sloc,
Entry_Call_Statement => Ecall_Node,
Pragmas_Before => Select_Pragmas,
Statements => Statement_List));
Set_Else_Statements
(Select_Node, P_Sequence_Of_Statements (SS_Sreq));
-- Only remaining case is THEN ABORT (asynchronous select)
elsif Token = Tok_Abort then
Select_Node :=
Make_Asynchronous_Select (Select_Sloc,
Triggering_Alternative =>
Make_Triggering_Alternative (Stmnt_Sloc,
Triggering_Statement => Ecall_Node,
Pragmas_Before => Select_Pragmas,
Statements => Statement_List),
Abortable_Part => P_Abortable_Part);
-- Else error
else
if Ada_Version = Ada_83 then
Error_Msg_BC ("OR or ELSE expected");
else
Error_Msg_BC ("OR or ELSE or THEN ABORT expected");
end if;
Select_Node := Error;
end if;
End_Statements;
-- Here we have a selective accept or an asynchronous select (first
-- token after SELECT is other than a designator token).
else
-- If we have delay with no guard, could be asynchronous select
if Token = Tok_Delay then
Delay_Stmnt := P_Delay_Statement;
Statement_List := P_Sequence_Of_Statements (SS_Eltm_Ortm_Tatm);
-- Asynchronous select
if Token = Tok_Abort then
Select_Node :=
Make_Asynchronous_Select (Select_Sloc,
Triggering_Alternative =>
Make_Triggering_Alternative (Stmnt_Sloc,
Triggering_Statement => Delay_Stmnt,
Pragmas_Before => Select_Pragmas,
Statements => Statement_List),
Abortable_Part => P_Abortable_Part);
End_Statements;
return Select_Node;
-- Delay which was not an asynchronous select. Must be a selective
-- accept, and since at least one accept statement is required,
-- we must have at least one OR phrase present.
else
Alt_List := New_List (
Make_Delay_Alternative (Stmnt_Sloc,
Delay_Statement => Delay_Stmnt,
Pragmas_Before => Select_Pragmas,
Statements => Statement_List));
T_Or;
Alt_Pragmas := P_Pragmas_Opt;
end if;
-- If not a delay statement, then must be another possibility for
-- a selective accept alternative, or perhaps a guard is present
else
Alt_List := New_List;
Alt_Pragmas := Select_Pragmas;
end if;
Select_Node := New_Node (N_Selective_Accept, Select_Sloc);
Set_Select_Alternatives (Select_Node, Alt_List);
-- Scan out selective accept alternatives. On entry to this loop,
-- we are just past a SELECT or OR token, and any pragmas that
-- immediately follow the SELECT or OR are in Alt_Pragmas.
loop
if Token = Tok_When then
if Present (Alt_Pragmas) then
Error_Msg_SC ("pragmas may not precede guard");
end if;
Scan; -- past WHEN
Cond_Expr := P_Expression_No_Right_Paren;
T_Arrow;
Alt_Pragmas := P_Pragmas_Opt;
else
Cond_Expr := Empty;
end if;
if Token = Tok_Accept then
Alternative := P_Accept_Alternative;
-- Check for junk attempt at asynchronous select using
-- an Accept alternative as the triggering statement
if Token = Tok_Abort
and then Is_Empty_List (Alt_List)
and then No (Cond_Expr)
then
Error_Msg
("triggering statement must be entry call or delay",
Sloc (Alternative));
Scan; -- past junk ABORT
Discard_Junk_List (P_Sequence_Of_Statements (SS_Sreq));
End_Statements;
return Error;
end if;
elsif Token = Tok_Delay then
Alternative := P_Delay_Alternative;
elsif Token = Tok_Terminate then
Alternative := P_Terminate_Alternative;
else
Error_Msg_SC
("select alternative (ACCEPT, ABORT, DELAY) expected");
Alternative := Error;
if Token = Tok_Semicolon then
Scan; -- past junk semicolon
end if;
end if;
-- THEN ABORT at this stage is just junk
if Token = Tok_Abort then
Error_Msg_SP ("misplaced `THEN ABORT`");
Scan; -- past junk ABORT
Discard_Junk_List (P_Sequence_Of_Statements (SS_Sreq));
End_Statements;
return Error;
else
if Alternative /= Error then
Set_Condition (Alternative, Cond_Expr);
Set_Pragmas_Before (Alternative, Alt_Pragmas);
Append (Alternative, Alt_List);
end if;
exit when Token /= Tok_Or;
end if;
T_Or;
Alt_Pragmas := P_Pragmas_Opt;
end loop;
if Token = Tok_Else then
Scan; -- past ELSE
Set_Else_Statements
(Select_Node, P_Sequence_Of_Statements (SS_Ortm_Sreq));
if Token = Tok_Or then
Error_Msg_SC ("select alternative cannot follow else part!");
end if;
end if;
End_Statements;
end if;
return Select_Node;
end P_Select_Statement;
-----------------------------
-- 9.7.1 Selective Accept --
-----------------------------
-- Parsed by P_Select_Statement (9.7)
------------------
-- 9.7.1 Guard --
------------------
-- Parsed by P_Select_Statement (9.7)
-------------------------------
-- 9.7.1 Select Alternative --
-------------------------------
-- SELECT_ALTERNATIVE ::=
-- ACCEPT_ALTERNATIVE
-- | DELAY_ALTERNATIVE
-- | TERMINATE_ALTERNATIVE
-- Note: the guard preceding a select alternative is included as part
-- of the node generated for a selective accept alternative.
-- Error recovery: cannot raise Error_Resync
-------------------------------
-- 9.7.1 Accept Alternative --
-------------------------------
-- ACCEPT_ALTERNATIVE ::=
-- ACCEPT_STATEMENT [SEQUENCE_OF_STATEMENTS]
-- Error_Recovery: Cannot raise Error_Resync
-- Note: the caller is responsible for setting the Pragmas_Before
-- field of the returned N_Terminate_Alternative node.
function P_Accept_Alternative return Node_Id is
Accept_Alt_Node : Node_Id;
begin
Accept_Alt_Node := New_Node (N_Accept_Alternative, Token_Ptr);
Set_Accept_Statement (Accept_Alt_Node, P_Accept_Statement);
-- Note: the reason that we accept THEN ABORT as a terminator for
-- the sequence of statements is for error recovery which allows
-- for misuse of an accept statement as a triggering statement.
Set_Statements
(Accept_Alt_Node, P_Sequence_Of_Statements (SS_Eltm_Ortm_Tatm));
return Accept_Alt_Node;
end P_Accept_Alternative;
------------------------------
-- 9.7.1 Delay Alternative --
------------------------------
-- DELAY_ALTERNATIVE ::=
-- DELAY_STATEMENT [SEQUENCE_OF_STATEMENTS]
-- Error_Recovery: Cannot raise Error_Resync
-- Note: the caller is responsible for setting the Pragmas_Before
-- field of the returned N_Terminate_Alternative node.
function P_Delay_Alternative return Node_Id is
Delay_Alt_Node : Node_Id;
begin
Delay_Alt_Node := New_Node (N_Delay_Alternative, Token_Ptr);
Set_Delay_Statement (Delay_Alt_Node, P_Delay_Statement);
-- Note: the reason that we accept THEN ABORT as a terminator for
-- the sequence of statements is for error recovery which allows
-- for misuse of an accept statement as a triggering statement.
Set_Statements
(Delay_Alt_Node, P_Sequence_Of_Statements (SS_Eltm_Ortm_Tatm));
return Delay_Alt_Node;
end P_Delay_Alternative;
----------------------------------
-- 9.7.1 Terminate Alternative --
----------------------------------
-- TERMINATE_ALTERNATIVE ::= terminate;
-- Error_Recovery: Cannot raise Error_Resync
-- Note: the caller is responsible for setting the Pragmas_Before
-- field of the returned N_Terminate_Alternative node.
function P_Terminate_Alternative return Node_Id is
Terminate_Alt_Node : Node_Id;
begin
Terminate_Alt_Node := New_Node (N_Terminate_Alternative, Token_Ptr);
Scan; -- past TERMINATE
TF_Semicolon;
-- For all other select alternatives, the sequence of statements
-- after the alternative statement will swallow up any pragmas
-- coming in this position. But the terminate alternative has no
-- sequence of statements, so the pragmas here must be treated
-- specially.
Set_Pragmas_After (Terminate_Alt_Node, P_Pragmas_Opt);
return Terminate_Alt_Node;
end P_Terminate_Alternative;
-----------------------------
-- 9.7.2 Timed Entry Call --
-----------------------------
-- Parsed by P_Select_Statement (9.7)
-----------------------------------
-- 9.7.2 Entry Call Alternative --
-----------------------------------
-- Parsed by P_Select_Statement (9.7)
-----------------------------------
-- 9.7.3 Conditional Entry Call --
-----------------------------------
-- Parsed by P_Select_Statement (9.7)
--------------------------------
-- 9.7.4 Asynchronous Select --
--------------------------------
-- Parsed by P_Select_Statement (9.7)
-----------------------------------
-- 9.7.4 Triggering Alternative --
-----------------------------------
-- Parsed by P_Select_Statement (9.7)
---------------------------------
-- 9.7.4 Triggering Statement --
---------------------------------
-- Parsed by P_Select_Statement (9.7)
---------------------------
-- 9.7.4 Abortable Part --
---------------------------
-- ABORTABLE_PART ::= SEQUENCE_OF_STATEMENTS
-- The caller has verified that THEN ABORT is present, and Token is
-- pointing to the ABORT on entry (or if not, then we have an error)
-- Error recovery: cannot raise Error_Resync
function P_Abortable_Part return Node_Id is
Abortable_Part_Node : Node_Id;
begin
Abortable_Part_Node := New_Node (N_Abortable_Part, Token_Ptr);
T_Abort; -- scan past ABORT
if Ada_Version = Ada_83 then
Error_Msg_SP ("(Ada 83) asynchronous select not allowed!");
end if;
Set_Statements (Abortable_Part_Node, P_Sequence_Of_Statements (SS_Sreq));
return Abortable_Part_Node;
end P_Abortable_Part;
--------------------------
-- 9.8 Abort Statement --
--------------------------
-- ABORT_STATEMENT ::= abort task_NAME {, task_NAME};
-- The caller has checked that the initial token is ABORT
-- Error recovery: cannot raise Error_Resync
function P_Abort_Statement return Node_Id is
Abort_Node : Node_Id;
begin
Abort_Node := New_Node (N_Abort_Statement, Token_Ptr);
Scan; -- past ABORT
Set_Names (Abort_Node, New_List);
loop
Append (P_Name, Names (Abort_Node));
exit when Token /= Tok_Comma;
Scan; -- past comma
end loop;
TF_Semicolon;
return Abort_Node;
end P_Abort_Statement;
end Ch9;
|
with Ada.Text_IO;
procedure Foo is
begin
Ada.Text_IO.Put_Line("Bar");
end Foo;
|
-- ___ _ ___ _ _ --
-- / __| |/ (_) | | Common SKilL implementation --
-- \__ \ ' <| | | |__ skills vector container implementation --
-- |___/_|\_\_|_|____| by: Dennis Przytarski, Timm Felden --
-- --
pragma Ada_2012;
with Ada.Unchecked_Deallocation;
package body Skill.Containers.Maps is
procedure Advance (This : access Iterator_T) is
begin
HS.Next (This.Cursor);
end Advance;
procedure Free (This : access Iterator_T) is
type T is access all Iterator_T;
X : T := T (This);
procedure Delete is new Ada.Unchecked_Deallocation (Iterator_T, T);
begin
Delete (X);
end Free;
procedure Update
(This : access Map_T;
K : Skill.Types.Box;
V : Skill.Types.Box)
is
begin
HS.Include (This.This, CastK (K), CastV (V));
end Update;
procedure Remove (This : access Map_T; K : Skill.Types.Box) is
begin
HS.Exclude (This.This, CastK (K));
end Remove;
function Make return Ref is
begin
return new Map_T'(This => HS.Empty_Map);
end Make;
end Skill.Containers.Maps;
|
limited with Limited_With3_Pkg3;
package Limited_With3_Pkg2 is
type T is tagged null record;
procedure Proc (X : Limited_With3_Pkg3.TT; Y : T);
end Limited_With3_Pkg2;
|
-- Minimum package providing support for Unit testing
package Test_Assertions is
Test_Assertion_Error : exception;
procedure Assert_True (Value : Boolean);
-- Raises Assertion_Error when Value is False
procedure Assert_False (Value : Boolean);
-- Raises Assertion_Error when Value is True
procedure Assert_True (Value : Boolean; Message : String);
-- Outputs Message and displays OK when Value is True.
procedure Assert_False (Value : Boolean; Message : String);
-- Outputs Message and displays OK when Value is False.
end Test_Assertions;
|
-----------------------------------------------------------------------
-- mat-callbacks - Callbacks for Gtk
-- Copyright (C) 2014 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Glib.Main;
with Gtk.Main;
with Gtk.Widget;
with Gtk.Label;
with Util.Log.Loggers;
with MAT.Commands;
package body MAT.Callbacks is
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("MAT.Callbacks");
type Info is record
Builder : access Gtkada.Builder.Gtkada_Builder_Record'Class;
end record;
package Timer_Callback is
new Glib.Main.Generic_Sources (MAT.Targets.Gtkmat.Target_Type_Access);
Timer : Glib.Main.G_Source_Id;
MemTotal : Natural := 1;
Target : MAT.Targets.Gtkmat.Target_Type_Access;
function Refresh_Timeout (Target : in MAT.Targets.Gtkmat.Target_Type_Access) return Boolean is
begin
Target.Refresh_Process;
return True;
end Refresh_Timeout;
-- ------------------------------
-- Initialize and register the callbacks.
-- ------------------------------
procedure Initialize (Target : in MAT.Targets.Gtkmat.Target_Type_Access;
Builder : in Gtkada.Builder.Gtkada_Builder) is
begin
MAT.Callbacks.Target := Target;
Builder.Register_Handler (Handler_Name => "quit",
Handler => MAT.Callbacks.On_Menu_Quit'Access);
Builder.Register_Handler (Handler_Name => "about",
Handler => MAT.Callbacks.On_Menu_About'Access);
Builder.Register_Handler (Handler_Name => "close-about",
Handler => MAT.Callbacks.On_Close_About'Access);
Builder.Register_Handler (Handler_Name => "cmd-sizes",
Handler => MAT.Callbacks.On_Btn_Sizes'Access);
Builder.Register_Handler (Handler_Name => "cmd-threads",
Handler => MAT.Callbacks.On_Btn_Threads'Access);
Timer := Timer_Callback.Timeout_Add (1000, Refresh_Timeout'Access, Target);
end Initialize;
-- ------------------------------
-- Callback executed when the "quit" action is executed from the menu.
-- ------------------------------
procedure On_Menu_Quit (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class) is
begin
Gtk.Main.Main_Quit;
end On_Menu_Quit;
-- ------------------------------
-- Callback executed when the "about" action is executed from the menu.
-- ------------------------------
procedure On_Menu_About (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class) is
About : constant Gtk.Widget.Gtk_Widget :=
Gtk.Widget.Gtk_Widget (Object.Get_Object ("about"));
begin
About.Show;
end On_Menu_About;
-- ------------------------------
-- Callback executed when the "close-about" action is executed from the about box.
-- ------------------------------
procedure On_Close_About (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class) is
About : constant Gtk.Widget.Gtk_Widget :=
Gtk.Widget.Gtk_Widget (Object.Get_Object ("about"));
begin
About.Hide;
end On_Close_About;
-- ------------------------------
-- Callback executed when the "cmd-sizes" action is executed from the "Sizes" action.
-- ------------------------------
procedure On_Btn_Sizes (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class) is
pragma Unreferenced (Object);
begin
MAT.Commands.Sizes_Command (Target.all, "");
end On_Btn_Sizes;
-- ------------------------------
-- Callback executed when the "cmd-threads" action is executed from the "Threads" action.
-- ------------------------------
procedure On_Btn_Threads (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class) is
pragma Unreferenced (Object);
begin
MAT.Commands.Threads_Command (Target.all, "");
end On_Btn_Threads;
end MAT.Callbacks;
|
with Discr16_Pkg; use Discr16_Pkg;
package Discr16_Cont is
type ES6a is new ET3a range E2..E4;
end;
|
function System.Tasking.Async_Delays.Enqueue_Calendar (
T : Ada.Calendar.Time;
D : not null access Delay_Block)
return Boolean is
begin
raise Program_Error; -- unimplemented
return Enqueue_Calendar (T, D);
end System.Tasking.Async_Delays.Enqueue_Calendar;
|
with Main;
-- the entry point after POR
procedure boot is
-- pragma Priority (MAIN_TASK_PRIORITY);
-- Self_Test_Passed : Boolean;
begin
Main.Initialize;
Main.Run_Loop;
end boot;
|
-- Copyright 2014-2019 Simon Symeonidis (psyomn), Patrick Kelly (entomy)
--
-- 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; use Ada.Strings.Unbounded;
package Agen is
type Parameter is private;
type Parameter_Array is array(Positive range <>) of Parameter;
function Try_Parse(Candidate : String; Result : out Parameter) return Boolean;
------------
-- Create --
------------
procedure Create_Project(Name : String);
procedure Create_GPR(Name : String);
procedure Create_Program(Name : String);
-----------
-- Print --
-----------
procedure Print_Comment(Message : String);
procedure Print_Description_Comment(Message : String);
procedure Print_Exception_Comment(Name : String; Message : String);
procedure Print_Field_Comment(Name : String; Message : String);
procedure Print_Param_Comment(Name : String; Message : String);
procedure Print_Return_Comment(Message : String);
procedure Print_Summary_Comment(Message : String);
procedure Print_Value_Comment(Name : String; Message : String);
procedure Print_Procedure(Name : String);
procedure Print_Procedure(Name : String; Stub_Comments : Boolean);
procedure Print_Procedure(Name : String; Param : Parameter);
procedure Print_Procedure(Name : String; Param : Parameter; Stub_Comments : Boolean);
procedure Print_Procedure(Name : String; Params : Parameter_Array);
procedure Print_Procedure(Name : String; Params : Parameter_Array; Stub_Comments : Boolean);
procedure Print_Function(Form : Parameter);
procedure Print_Function(Form : Parameter; Stub_Comments : Boolean);
procedure Print_Function(Name : String; Returns : String);
procedure Print_Function(Name : String; Returns : String; Stub_Comments : Boolean);
procedure Print_Function(Form : Parameter; Param : Parameter);
procedure Print_Function(Form : Parameter; Param : Parameter; Stub_Comments : Boolean);
procedure Print_Function(Name : String; Returns : String; Param : Parameter);
procedure Print_Function(Name : String; Returns : String; Param : Parameter; Stub_Comments : Boolean);
procedure Print_Function(Form : Parameter; Params : Parameter_Array);
procedure Print_Function(Form : Parameter; Params : Parameter_Array; Stub_Comments : Boolean);
procedure Print_Function(Name : String; Returns : String; Params : Parameter_Array);
procedure Print_Function(Name : String; Returns : String; Params : Parameter_Array; Stub_Comments : Boolean);
private
type Parameter is record
Name : Unbounded_String;
Of_Type : Unbounded_String;
end record;
end Agen;
|
------------------------------------------------------------------------------
-- --
-- GNAT EXAMPLE --
-- --
-- Copyright (C) 2013, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Interfaces; use Interfaces;
with Commands; use Commands;
with Console; use Console;
with Dumps; use Dumps;
with System.Machine_Code; use System.Machine_Code;
with System; use System;
pragma Warnings (Off);
with System.Machine_Reset;
pragma Warnings (On);
with Term; use Term;
package body Ppc6xx is
type Core_Type is (Core_Unknown, Core_E300);
Core : Core_Type := Core_Unknown;
function Field (V : Unsigned_32; F, L : Natural) return Unsigned_32 is
begin
return Shift_Right (V, 63 - L)
and Shift_Right (16#ffff_ffff#, 32 - (L - F + 1));
end Field;
procedure Put_Bit (V : Unsigned_32; F : Natural; Name : Character) is
begin
if Field (V, F, F) = 1 then
Put (Name);
else
Put ('-');
end if;
end Put_Bit;
pragma Unreferenced (Put_Bit);
procedure Disp_Msr is
begin
Put_Register ("MSR", Get_Msr,
"13,pow,1,ile,ee,pr,fp,me,fe0,se,be," &
"fe1,1,ip,ir,dr,2,ri,le");
New_Line;
end Disp_Msr;
procedure Proc_Cr is
Pvr : constant Unsigned_32 := Get_Pvr;
begin
Put ("PVR: " & Image8 (Pvr));
Put (" ");
case Shift_Right (Pvr, 16) is
when 16#8083# => Put ("e300c1");
when 16#8084# => Put ("e300c2");
when 16#8085# => Put ("e300c3");
when others => Put ("unknown");
end case;
New_Line;
Disp_Msr;
Put ("HID0: " & Image8 (Get_Hid0));
case Core is
when Core_E300 =>
Put_Register_Desc
(Get_Hid0,
"emcp,ecpe,eba,ebd,sbclk,1,eclk,par,doze,nap,sleep,dpm,2,nhr," &
"ice,dce,ilock,dlock,icfi,dcfi,2,ifem,2,fbiob,abe,2,noopti");
when others =>
null;
end case;
New_Line;
Put_Line ("HID1: " & Image8 (Get_Hid1));
if Core = Core_E300 then
Put_Register
("HID2",
Get_Hid2,
"4,let,ifeb,1,mesi,ifec,ebqs,ebpx,2,hbe,2," &
"iwlck:3,icwp,4,dwlck:3,5");
end if;
end Proc_Cr;
procedure Proc_Timer is
begin
Put_Line ("TBU: " & Image8 (Get_Tbu) & " TBL: " & Image8 (Get_Tbl));
Put_Line ("DEC: " & Image8 (Get_Dec));
end Proc_Timer;
procedure Show_Bat (L, U : Unsigned_32; Name : String) is
Bl : constant Unsigned_32 := U and BL_256MB;
begin
Put (Name);
Put ("l: " & Image8 (L));
Put (" u: " & Image8 (U));
Put (" len: ");
case Bl is
when BL_128KB => Put ("128KB");
when BL_256KB => Put ("256KB");
when BL_512KB => Put ("512KB");
when BL_1MB => Put (" 1MB");
when BL_2MB => Put (" 2MB");
when BL_4MB => Put (" 4MB");
when BL_8MB => Put (" 8MB");
when BL_16MB => Put (" 16MB");
when BL_32MB => Put (" 32MB");
when BL_64MB => Put (" 64MB");
when BL_128MB => Put ("128MB");
when BL_256MB => Put ("256MB");
when others => Put (" ???");
end case;
Put (" mode:");
Put_Bit ((U and Vs_Mask) /= 0, 'S');
Put_Bit ((U and Vp_Mask) /= 0, 'U');
Put (", cache:");
Put_Bit ((L and WIMG_W) /= 0, 'W');
Put_Bit ((L and WIMG_I) /= 0, 'I');
Put_Bit ((L and WIMG_M) /= 0, 'M');
Put_Bit ((L and WIMG_G) /= 0, 'G');
Put (" prot:");
case L and Pp_Mask is
when Pp_No => Put ("--");
when Pp_RW => Put ("RW");
when others => Put ("RO");
end case;
New_Line;
end Show_Bat;
procedure Proc_Bat is
begin
Show_Bat (Get_Dbat0l, Get_Dbat0u, "dbat0");
Show_Bat (Get_Dbat1l, Get_Dbat1u, "dbat1");
Show_Bat (Get_Dbat2l, Get_Dbat2u, "dbat2");
Show_Bat (Get_Dbat3l, Get_Dbat3u, "dbat3");
if Core = Core_E300 then
Show_Bat (Get_Dbat4l, Get_Dbat4u, "dbat4");
Show_Bat (Get_Dbat5l, Get_Dbat5u, "dbat5");
Show_Bat (Get_Dbat6l, Get_Dbat6u, "dbat6");
Show_Bat (Get_Dbat7l, Get_Dbat7u, "dbat7");
end if;
New_Line;
Show_Bat (Get_Ibat0l, Get_Ibat0u, "ibat0");
Show_Bat (Get_Ibat1l, Get_Ibat1u, "ibat1");
Show_Bat (Get_Ibat2l, Get_Ibat2u, "ibat2");
Show_Bat (Get_Ibat3l, Get_Ibat3u, "ibat3");
if Core = Core_E300 then
Show_Bat (Get_Ibat4l, Get_Ibat4u, "ibat4");
Show_Bat (Get_Ibat5l, Get_Ibat5u, "ibat5");
Show_Bat (Get_Ibat6l, Get_Ibat6u, "ibat6");
Show_Bat (Get_Ibat7l, Get_Ibat7u, "ibat7");
end if;
end Proc_Bat;
-- Set the sc vector.
procedure Set_Excp_Vector (Addr : Address) is
Vector : Unsigned_32;
for Vector'Address use Addr;
Fault_Entry : Unsigned_32;
pragma Import (C, Fault_Entry, "fault_entry");
begin
Vector := Fault_Entry;
Asm ("dcbst 0,%0; icbi 0,%0",
Inputs => System.Address'Asm_Input ("r", Addr),
Volatile => True);
end Set_Excp_Vector;
procedure Fault_Handler (Ip : Unsigned_32; Msr : Unsigned_32);
pragma Export (C, Fault_Handler);
procedure Fault_Handler (Ip : Unsigned_32; Msr : Unsigned_32) is
begin
New_Line;
Put_Line ("Fault handler");
Put ("IP: ");
Put (Image8 (Ip));
Put (" MSR: ");
Put (Image8 (Msr));
New_Line;
Disp_Msr;
New_Line;
System.Machine_Reset.Stop;
end Fault_Handler;
procedure Proc_Fault is
begin
Next_Word;
if Line (Pos .. End_Pos) = "install" then
Set_Excp_Vector (System'To_Address (16#0100#)); -- Reset
Set_Excp_Vector (System'To_Address (16#0200#)); -- Machine check
Set_Excp_Vector (System'To_Address (16#0300#)); -- DSI
Set_Excp_Vector (System'To_Address (16#0400#)); -- ISI
Set_Excp_Vector (System'To_Address (16#0500#)); -- External Interrupt
Set_Excp_Vector (System'To_Address (16#0600#)); -- Alignment
Set_Excp_Vector (System'To_Address (16#0700#)); -- Program
Set_Excp_Vector (System'To_Address (16#0800#)); -- FP unavailable
Set_Excp_Vector (System'To_Address (16#0900#)); -- Decr
Set_Excp_Vector (System'To_Address (16#0c00#)); -- System call
Set_Excp_Vector (System'To_Address (16#1000#)); -- itlb
Set_Excp_Vector (System'To_Address (16#1100#)); -- dtlb load
Set_Excp_Vector (System'To_Address (16#1200#)); -- dtlb write
Set_Excp_Vector (System'To_Address (16#1300#)); -- iabr
elsif Line (Pos .. End_Pos) = "sc" then
Asm ("sc", Volatile => True);
else
Put_Line ("unknown fault command");
end if;
end Proc_Fault;
Commands : aliased Command_List :=
(4,
((new String'("cr - Display some config registers"),
Proc_Cr'Access),
(new String'("timer - Display time registers"),
Proc_Timer'Access),
(new String'("bat - Display BAT registers"),
Proc_Bat'Access),
(new String'("fault install|sc - Fault handling"),
Proc_Fault'Access)),
null);
begin
Register_Commands (Commands'Access);
-- Find core type
case Shift_Right (Get_Pvr, 16) is
when 16#8083# .. 16#8085# => Core := Core_E300;
when others => null;
end case;
end Ppc6xx;
|
------------------------------------------------------------------------------
-- G E L A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
-- Purpose:
with Asis.Errors;
with Asis.Exceptions;
with Asis.Implementation;
package body Asis is
procedure Raise_Inappropriate_Element
(The_Context : Context;
Raiser : Wide_String);
function Get_Context (Item : in Element_Node'Class) return Context;
---------
-- "<" --
---------
function "<" (Left, Right : Text_Position) return Boolean is
begin
return Left.Line < Right.Line or else
(Left.Line = Right.Line and then Left.Column < Right.Column);
end "<";
--------------
-- Assigned --
--------------
function Assigned (Item : in Element) return Boolean is
type Element_Node_Ptr is access all Element_Node'Class;
begin
return Element_Node_Ptr (Item) /= null;
end Assigned;
--------------
-- Assigned --
--------------
function Assigned (Item : in Context) return Boolean is
type Context_Node_Ptr is access all Context_Node'Class;
begin
return Context_Node_Ptr (Item) /= null;
end Assigned;
--------------
-- Assigned --
--------------
function Assigned (Item : in Compilation_Unit) return Boolean is
type Comp_Unit_Node_Ptr is access all Compilation_Unit_Node'Class;
begin
return Comp_Unit_Node_Ptr (Item) /= null;
end Assigned;
-------------------
-- Check_Context --
-------------------
procedure Check_Context (The_Context : Asis.Context) is
begin
if not Assigned (The_Context)
or else not Is_Open (The_Context.all)
then
Implementation.Set_Status
(Errors.Value_Error, "Null or unopen context");
raise Exceptions.ASIS_Inappropriate_Context;
end if;
end Check_Context;
-----------------------
-- Check_Nil_Element --
-----------------------
procedure Check_Nil_Element
(Element : Asis.Element;
Raiser : Wide_String := "")
is
begin
if not Assigned (Element) then
Raise_Inappropriate_Element (Raiser);
end if;
end Check_Nil_Element;
--------------------
-- Check_Nil_Unit --
--------------------
procedure Check_Nil_Unit
(Unit : Asis.Compilation_Unit;
Raiser : Wide_String := "")
is
begin
if not Assigned (Unit) then
Implementation.Set_Status
(Errors.Value_Error, "Null compilation unit " & Raiser);
raise Exceptions.ASIS_Inappropriate_Compilation_Unit;
end if;
end Check_Nil_Unit;
--------------
-- Children --
--------------
function Children (Item : access Element_Node) return Traverse_List is
begin
return (1 .. 0 => (False, null));
end Children;
-----------
-- Clone --
-----------
function Clone
(Object : Cloner;
Item : Element;
Parent : Element) return Element
is
begin
return Copy (Source => Item, Cloner => Object, Parent => Parent);
end Clone;
----------
-- Copy --
----------
procedure Copy
(Source : in Element;
Target : access Element_Node;
Cloner : in Cloner_Class;
Parent : in Element) is
begin
null;
end Copy;
----------
-- Copy --
----------
function Copy
(Cloner : in Cloner_Class;
Source : in Element;
Parent : in Element) return Element
is
Result : Element := Nil_Element;
begin
if Assigned (Source) then
Result := Clone (Cloner, Source, Parent);
if Assigned (Result) then
Copy (Source, Result, Cloner, Parent);
end if;
end if;
return Result;
end Copy;
---------------
-- Deep_Copy --
---------------
function Deep_Copy
(Cloner : in Cloner_Class;
Source : in Element;
Parent : in Element) return Element
is
Result : Element;
The_Context : constant Context := Get_Context (Parent.all);
begin
Set_Check_Appropriate (The_Context.all, False);
Result := Copy (Cloner, Source, Parent);
Set_Check_Appropriate (The_Context.all, True);
return Result;
end Deep_Copy;
-----------------
-- Get_Context --
-----------------
function Get_Context (Item : in Element_Node'Class) return Context is
begin
return Enclosing_Context (Enclosing_Compilation_Unit (Item).all);
end Get_Context;
------------------
-- Get_Equality --
------------------
generic
type Element is private;
package Generic_Get_Equality is
function Is_Equal (Left, Right : Element) return Boolean
renames "=";
end Generic_Get_Equality;
package Get_Equality is new Generic_Get_Equality (Element);
--------------
-- Is_Equal --
--------------
function Is_Equal (Left, Right : Element) return Boolean is
begin
return Get_Equality.Is_Equal (Left, Right);
end Is_Equal;
-------------
-- Is_List --
-------------
function Is_List (Item : Element_Node) return Boolean is
begin
return False;
end Is_List;
--------------------
-- To_Wide_String --
--------------------
function To_Wide_String (Item : Text_Position) return Wide_String is
Line_Image : constant Wide_String := Natural'Wide_Image (Item.Line);
Column_Image : constant Wide_String := Natural'Wide_Image (Item.Column);
begin
return Line_Image (2 .. Line_Image'Last) & ":" &
Column_Image (2 .. Column_Image'Last);
end To_Wide_String;
---------------------------------
-- Raise_Inappropriate_Element --
---------------------------------
procedure Raise_Inappropriate_Element (Raiser : Wide_String := "") is
Text : constant Wide_String := "Inappropriate element";
begin
if Raiser /= "" then
Implementation.Set_Status
(Errors.Value_Error, Text & " in " & Raiser);
else
Implementation.Set_Status
(Errors.Value_Error, Text);
end if;
raise Exceptions.ASIS_Inappropriate_Element;
end Raise_Inappropriate_Element;
---------------------------------
-- Raise_Inappropriate_Element --
---------------------------------
procedure Raise_Inappropriate_Element
(The_Context : Context;
Raiser : Wide_String)
is
begin
if Check_Appropriate (The_Context.all) then
Raise_Inappropriate_Element (Raiser);
end if;
end Raise_Inappropriate_Element;
----------------------
-- Set_Next_Element --
----------------------
procedure Set_Next_Element
(Item : in out Element_Node;
Next : in Element)
is
begin
Raise_Inappropriate_Element ("Set_Next_Element");
end Set_Next_Element;
---------------------
-- Without_Pragmas --
---------------------
function Without_Pragmas (List : Element_List) return Element_List is
Result : Element_List (List'Range);
Index : List_Index := Result'First;
begin
for I in List'Range loop
if Element_Kind (List (I).all) /= A_Pragma then
Result (Index) := List (I);
Index := Index + 1;
end if;
end loop;
return Result (Result'First .. Index - 1);
end Without_Pragmas;
function Aborted_Tasks
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Aborted_Tasks");
return Nil_Element_List;
end Aborted_Tasks;
function Accept_Body_Exception_Handlers
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Accept_Body_Exception_Handlers");
return Nil_Element_List;
end Accept_Body_Exception_Handlers;
function Accept_Body_Statements
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Accept_Body_Statements");
return Nil_Element_List;
end Accept_Body_Statements;
function Accept_Entry_Direct_Name
(Element : Element_Node) return Asis.Name
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Accept_Entry_Direct_Name");
return Nil_Element;
end Accept_Entry_Direct_Name;
function Accept_Entry_Index
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Accept_Entry_Index");
return Nil_Element;
end Accept_Entry_Index;
function Accept_Parameters
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Accept_Parameters");
return Nil_Element_List;
end Accept_Parameters;
function Access_To_Function_Result_Subtype
(Element : Element_Node) return Asis.Definition
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Access_To_Function_Result_Subtype");
return Nil_Element;
end Access_To_Function_Result_Subtype;
function Get_Access_To_Object_Definition
(Element : Element_Node) return Asis.Subtype_Indication
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Get_Access_To_Object_Definition");
return Nil_Element;
end Get_Access_To_Object_Definition;
function Access_To_Subprogram_Parameter_Profile
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Access_To_Subprogram_Parameter_Profile");
return Nil_Element_List;
end Access_To_Subprogram_Parameter_Profile;
function Access_Type_Kind
(Element : Element_Node) return Asis.Access_Type_Kinds
is
begin
return Not_An_Access_Type_Definition;
end Access_Type_Kind;
function Actual_Parameter
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Actual_Parameter");
return Nil_Element;
end Actual_Parameter;
function Allocator_Qualified_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Allocator_Qualified_Expression");
return Nil_Element;
end Allocator_Qualified_Expression;
function Allocator_Subtype_Indication
(Element : Element_Node) return Asis.Subtype_Indication
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Allocator_Subtype_Indication");
return Nil_Element;
end Allocator_Subtype_Indication;
function Ancestor_Subtype_Indication
(Element : Element_Node) return Asis.Subtype_Indication
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Ancestor_Subtype_Indication");
return Nil_Element;
end Ancestor_Subtype_Indication;
function Anonymous_Access_To_Object_Subtype_Mark
(Element : Element_Node) return Asis.Name
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Anonymous_Access_To_Object_Subtype_Mark");
return Nil_Element;
end Anonymous_Access_To_Object_Subtype_Mark;
function Array_Component_Associations
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Array_Component_Associations");
return Nil_Element_List;
end Array_Component_Associations;
function Array_Component_Choices
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Array_Component_Choices");
return Nil_Element_List;
end Array_Component_Choices;
function Array_Component_Definition
(Element : Element_Node) return Asis.Component_Definition
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Array_Component_Definition");
return Nil_Element;
end Array_Component_Definition;
function Assignment_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Assignment_Expression");
return Nil_Element;
end Assignment_Expression;
function Assignment_Variable_Name
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Assignment_Variable_Name");
return Nil_Element;
end Assignment_Variable_Name;
function Attribute_Designator_Expressions
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Attribute_Designator_Expressions");
return Nil_Element_List;
end Attribute_Designator_Expressions;
function Attribute_Designator_Identifier
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Attribute_Designator_Identifier");
return Nil_Element;
end Attribute_Designator_Identifier;
function Attribute_Kind
(Element : Element_Node) return Asis.Attribute_Kinds
is
begin
return Not_An_Attribute;
end Attribute_Kind;
function Block_Declarative_Items
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Block_Declarative_Items");
return Nil_Element_List;
end Block_Declarative_Items;
function Block_Exception_Handlers
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Block_Exception_Handlers");
return Nil_Element_List;
end Block_Exception_Handlers;
function Block_Statements
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Block_Statements");
return Nil_Element_List;
end Block_Statements;
function Body_Declarative_Items
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Body_Declarative_Items");
return Nil_Element_List;
end Body_Declarative_Items;
function Body_Exception_Handlers
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Body_Exception_Handlers");
return Nil_Element_List;
end Body_Exception_Handlers;
function Body_Statements
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Body_Statements");
return Nil_Element_List;
end Body_Statements;
function Call_Statement_Parameters
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Call_Statement_Parameters");
return Nil_Element_List;
end Call_Statement_Parameters;
function Called_Name
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Called_Name");
return Nil_Element;
end Called_Name;
function Case_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Case_Expression");
return Nil_Element;
end Case_Expression;
function Case_Statement_Alternative_Choices
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Case_Statement_Alternative_Choices");
return Nil_Element_List;
end Case_Statement_Alternative_Choices;
function Choice_Parameter_Specification
(Element : Element_Node) return Asis.Element
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Choice_Parameter_Specification");
return Nil_Element;
end Choice_Parameter_Specification;
function Clause_Names
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Clause_Names");
return Nil_Element_List;
end Clause_Names;
function Component_Clause_Position
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Component_Clause_Position");
return Nil_Element;
end Component_Clause_Position;
function Component_Clause_Range
(Element : Element_Node) return Asis.Discrete_Range
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Component_Clause_Range");
return Nil_Element;
end Component_Clause_Range;
function Component_Clauses
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Component_Clauses");
return Nil_Element_List;
end Component_Clauses;
function Component_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Component_Expression");
return Nil_Element;
end Component_Expression;
function Component_Subtype_Indication
(Element : Element_Node) return Asis.Subtype_Indication
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Component_Subtype_Indication");
return Nil_Element;
end Component_Subtype_Indication;
function Condition_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Condition_Expression");
return Nil_Element;
end Condition_Expression;
function Converted_Or_Qualified_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Converted_Or_Qualified_Expression");
return Nil_Element;
end Converted_Or_Qualified_Expression;
function Converted_Or_Qualified_Subtype_Mark
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Converted_Or_Qualified_Subtype_Mark");
return Nil_Element;
end Converted_Or_Qualified_Subtype_Mark;
function Corresponding_Base_Entity
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Base_Entity");
return Nil_Element;
end Corresponding_Base_Entity;
function Corresponding_Body
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Body");
return Nil_Element;
end Corresponding_Body;
function Corresponding_Body_Stub
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Body_Stub");
return Nil_Element;
end Corresponding_Body_Stub;
function Corresponding_Called_Entity
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Called_Entity");
return Nil_Element;
end Corresponding_Called_Entity;
function Corresponding_Called_Function
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Called_Function");
return Nil_Element;
end Corresponding_Called_Function;
function Corresponding_Constant_Declaration
(Element : Element_Node) return Asis.Element
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Constant_Declaration");
return Nil_Element;
end Corresponding_Constant_Declaration;
function Corresponding_Declaration
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Declaration");
return Nil_Element;
end Corresponding_Declaration;
function Corresponding_Destination_Statement
(Element : Element_Node) return Asis.Statement
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Destination_Statement");
return Nil_Element;
end Corresponding_Destination_Statement;
function Corresponding_Entry
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Entry");
return Nil_Element;
end Corresponding_Entry;
function Corresponding_Equality_Operator
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Equality_Operator");
return Nil_Element;
end Corresponding_Equality_Operator;
function Corresponding_Expression_Type
(Element : Element_Node) return Asis.Element
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Expression_Type");
return Nil_Element;
end Corresponding_Expression_Type;
function Corresponding_First_Subtype
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_First_Subtype");
return Nil_Element;
end Corresponding_First_Subtype;
function Corresponding_Generic_Element
(Element : Element_Node) return Asis.Defining_Name
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Generic_Element");
return Nil_Element;
end Corresponding_Generic_Element;
function Corresponding_Last_Constraint
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Last_Constraint");
return Nil_Element;
end Corresponding_Last_Constraint;
function Corresponding_Last_Subtype
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Last_Subtype");
return Nil_Element;
end Corresponding_Last_Subtype;
function Corresponding_Loop_Exited
(Element : Element_Node) return Asis.Statement
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Loop_Exited");
return Nil_Element;
end Corresponding_Loop_Exited;
function Corresponding_Name_Declaration
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Name_Declaration");
return Nil_Element;
end Corresponding_Name_Declaration;
function Corresponding_Name_Definition_List
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Name_Definition_List");
return Nil_Element_List;
end Corresponding_Name_Definition_List;
function Corresponding_Parent_Subtype
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Parent_Subtype");
return Nil_Element;
end Corresponding_Parent_Subtype;
function Corresponding_Pragmas
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Pragmas");
return Nil_Element_List;
end Corresponding_Pragmas;
function Corresponding_Representation_Clauses
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Representation_Clauses");
return Nil_Element_List;
end Corresponding_Representation_Clauses;
function Corresponding_Root_Type
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Root_Type");
return Nil_Element;
end Corresponding_Root_Type;
function Corresponding_Subprogram_Derivation
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Subprogram_Derivation");
return Nil_Element;
end Corresponding_Subprogram_Derivation;
function Corresponding_Subunit
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Subunit");
return Nil_Element;
end Corresponding_Subunit;
function Corresponding_Type
(Element : Element_Node) return Asis.Type_Definition
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Type");
return Nil_Element;
end Corresponding_Type;
function Corresponding_Type_Declaration
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Type_Declaration");
return Nil_Element;
end Corresponding_Type_Declaration;
function Corresponding_Type_Operators
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Type_Operators");
return Nil_Element_List;
end Corresponding_Type_Operators;
function Corresponding_Type_Structure
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Corresponding_Type_Structure");
return Nil_Element;
end Corresponding_Type_Structure;
function Declaration_Origin
(Element : Element_Node) return Asis.Declaration_Origins
is
begin
return Not_A_Declaration_Origin;
end Declaration_Origin;
function Default_Kind
(Element : Element_Node) return Asis.Subprogram_Default_Kinds
is
begin
return Not_A_Default;
end Default_Kind;
function Defining_Name_Image
(Element : Element_Node) return Wide_String
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Defining_Name_Image");
return "";
end Defining_Name_Image;
function Defining_Prefix
(Element : Element_Node) return Asis.Name
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Defining_Prefix");
return Nil_Element;
end Defining_Prefix;
function Defining_Selector
(Element : Element_Node) return Asis.Defining_Name
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Defining_Selector");
return Nil_Element;
end Defining_Selector;
function Delay_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Delay_Expression");
return Nil_Element;
end Delay_Expression;
function Delta_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Delta_Expression");
return Nil_Element;
end Delta_Expression;
function Digits_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Digits_Expression");
return Nil_Element;
end Digits_Expression;
function Discrete_Ranges
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Discrete_Ranges");
return Nil_Element_List;
end Discrete_Ranges;
function Discrete_Subtype_Definitions
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Discrete_Subtype_Definitions");
return Nil_Element_List;
end Discrete_Subtype_Definitions;
function Discriminant_Associations
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Discriminant_Associations");
return Nil_Element_List;
end Discriminant_Associations;
function Discriminant_Direct_Name
(Element : Element_Node) return Asis.Name
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Discriminant_Direct_Name");
return Nil_Element;
end Discriminant_Direct_Name;
function Discriminant_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Discriminant_Expression");
return Nil_Element;
end Discriminant_Expression;
function Discriminant_Part
(Element : Element_Node) return Asis.Definition
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Discriminant_Part");
return Nil_Element;
end Discriminant_Part;
function Discriminant_Selector_Name
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Discriminant_Selector_Name");
return Nil_Element;
end Discriminant_Selector_Name;
function Discriminant_Selector_Names
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Discriminant_Selector_Names");
return Nil_Element_List;
end Discriminant_Selector_Names;
function Discriminants
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Discriminants");
return Nil_Element_List;
end Discriminants;
function Enclosing_Compilation_Unit
(Element : Element_Node) return Asis.Compilation_Unit
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Enclosing_Compilation_Unit");
return Nil_Compilation_Unit;
end Enclosing_Compilation_Unit;
function Enclosing_Element
(Element : Element_Node) return Asis.Element
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Enclosing_Element");
return Nil_Element;
end Enclosing_Element;
function End_Position
(Element : Element_Node) return Asis.Text_Position
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "End_Position");
return Nil_Text_Position;
end End_Position;
function Entry_Barrier
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Entry_Barrier");
return Nil_Element;
end Entry_Barrier;
function Entry_Family_Definition
(Element : Element_Node) return Asis.Discrete_Subtype_Definition
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Entry_Family_Definition");
return Nil_Element;
end Entry_Family_Definition;
function Entry_Index_Specification
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Entry_Index_Specification");
return Nil_Element;
end Entry_Index_Specification;
function Enumeration_Literal_Declarations
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Enumeration_Literal_Declarations");
return Nil_Element_List;
end Enumeration_Literal_Declarations;
function Exception_Choices
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Exception_Choices");
return Nil_Element_List;
end Exception_Choices;
function Exception_Handlers
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Exception_Handlers");
return Nil_Element_List;
end Exception_Handlers;
function Exit_Condition
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Exit_Condition");
return Nil_Element;
end Exit_Condition;
function Exit_Loop_Name
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Exit_Loop_Name");
return Nil_Element;
end Exit_Loop_Name;
function Expression_Parenthesized
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Expression_Parenthesized");
return Nil_Element;
end Expression_Parenthesized;
function Extended_Return_Exception_Handlers
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Extended_Return_Exception_Handlers");
return Nil_Element_List;
end Extended_Return_Exception_Handlers;
function Extended_Return_Statements
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Extended_Return_Statements");
return Nil_Element_List;
end Extended_Return_Statements;
function Extension_Aggregate_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Extension_Aggregate_Expression");
return Nil_Element;
end Extension_Aggregate_Expression;
function Formal_Parameter
(Element : Element_Node) return Asis.Identifier
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Formal_Parameter");
return Nil_Element;
end Formal_Parameter;
function Formal_Subprogram_Default
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Formal_Subprogram_Default");
return Nil_Element;
end Formal_Subprogram_Default;
function Function_Call_Parameters
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Function_Call_Parameters");
return Nil_Element_List;
end Function_Call_Parameters;
function Generic_Actual_Part
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Generic_Actual_Part");
return Nil_Element_List;
end Generic_Actual_Part;
function Generic_Formal_Part
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Generic_Formal_Part");
return Nil_Element_List;
end Generic_Formal_Part;
function Generic_Unit_Name
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Generic_Unit_Name");
return Nil_Element;
end Generic_Unit_Name;
function Goto_Label
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Goto_Label");
return Nil_Element;
end Goto_Label;
function Guard
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Guard");
return Nil_Element;
end Guard;
function Handler_Statements
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Handler_Statements");
return Nil_Element_List;
end Handler_Statements;
function Has_Abstract
(Element : Element_Node) return Boolean
is
begin
return False;
end Has_Abstract;
function Has_Limited
(Element : Element_Node) return Boolean
is
begin
return False;
end Has_Limited;
function Has_Null_Exclusion
(Element : Element_Node) return Boolean
is
begin
return False;
end Has_Null_Exclusion;
function Has_Private
(Element : Element_Node) return Boolean
is
begin
return False;
end Has_Private;
function Has_Protected
(Element : Element_Node) return Boolean
is
begin
return False;
end Has_Protected;
function Has_Synchronized
(Element : Element_Node) return Boolean
is
begin
return False;
end Has_Synchronized;
function Has_Tagged
(Element : Element_Node) return Boolean
is
begin
return False;
end Has_Tagged;
function Has_Task
(Element : Element_Node) return Boolean
is
begin
return False;
end Has_Task;
function Hash
(Element : Element_Node) return Asis.ASIS_Integer
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Hash");
return 0;
end Hash;
function Implicit_Components
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Implicit_Components");
return Nil_Element_List;
end Implicit_Components;
function Implicit_Inherited_Declarations
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Implicit_Inherited_Declarations");
return Nil_Element_List;
end Implicit_Inherited_Declarations;
function Implicit_Inherited_Subprograms
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Implicit_Inherited_Subprograms");
return Nil_Element_List;
end Implicit_Inherited_Subprograms;
function Index_Expressions
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Index_Expressions");
return Nil_Element_List;
end Index_Expressions;
function Index_Subtype_Definitions
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Index_Subtype_Definitions");
return Nil_Element_List;
end Index_Subtype_Definitions;
function Initialization_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Initialization_Expression");
return Nil_Element;
end Initialization_Expression;
function Integer_Constraint
(Element : Element_Node) return Asis.Range_Constraint
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Integer_Constraint");
return Nil_Element;
end Integer_Constraint;
function Interface_Kind
(Element : Element_Node) return Asis.Interface_Kinds
is
begin
return Not_An_Interface;
end Interface_Kind;
function Is_Call_On_Dispatching_Operation
(Element : Element_Node) return Boolean
is
begin
return False;
end Is_Call_On_Dispatching_Operation;
function Is_Declare_Block
(Element : Element_Node) return Boolean
is
begin
return False;
end Is_Declare_Block;
function Is_Defaulted_Association
(Element : Element_Node) return Boolean
is
begin
return False;
end Is_Defaulted_Association;
function Is_Dispatching_Call
(Element : Element_Node) return Boolean
is
begin
return False;
end Is_Dispatching_Call;
function Is_Dispatching_Operation
(Element : Element_Node) return Boolean
is
begin
return False;
end Is_Dispatching_Operation;
function Is_Name_Repeated
(Element : Element_Node) return Boolean
is
begin
return False;
end Is_Name_Repeated;
function Is_Normalized
(Element : Element_Node) return Boolean
is
begin
return False;
end Is_Normalized;
function Is_Null_Procedure
(Element : Element_Node) return Boolean
is
begin
return False;
end Is_Null_Procedure;
function Is_Part_Of_Implicit
(Element : Element_Node) return Boolean
is
begin
return False;
end Is_Part_Of_Implicit;
function Is_Part_Of_Inherited
(Element : Element_Node) return Boolean
is
begin
return False;
end Is_Part_Of_Inherited;
function Is_Part_Of_Instance
(Element : Element_Node) return Boolean
is
begin
return False;
end Is_Part_Of_Instance;
function Is_Prefix_Call
(Element : Element_Node) return Boolean
is
begin
return False;
end Is_Prefix_Call;
function Is_Private_Present
(Element : Element_Node) return Boolean
is
begin
return False;
end Is_Private_Present;
function Is_Task_Definition_Present
(Element : Element_Node) return Boolean
is
begin
return False;
end Is_Task_Definition_Present;
function Label_Names
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Label_Names");
return Nil_Element_List;
end Label_Names;
function Loop_Parameter_Specification
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Loop_Parameter_Specification");
return Nil_Element;
end Loop_Parameter_Specification;
function Loop_Statements
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Loop_Statements");
return Nil_Element_List;
end Loop_Statements;
function Lower_Bound
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Lower_Bound");
return Nil_Element;
end Lower_Bound;
function Membership_Test_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Membership_Test_Expression");
return Nil_Element;
end Membership_Test_Expression;
function Membership_Test_Range
(Element : Element_Node) return Asis.Range_Constraint
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Membership_Test_Range");
return Nil_Element;
end Membership_Test_Range;
function Membership_Test_Subtype_Mark
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Membership_Test_Subtype_Mark");
return Nil_Element;
end Membership_Test_Subtype_Mark;
function Mod_Clause_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Mod_Clause_Expression");
return Nil_Element;
end Mod_Clause_Expression;
function Mod_Static_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Mod_Static_Expression");
return Nil_Element;
end Mod_Static_Expression;
function Mode_Kind
(Element : Element_Node) return Asis.Mode_Kinds
is
begin
return Not_A_Mode;
end Mode_Kind;
function Name_Image
(Element : Element_Node) return Wide_String
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Name_Image");
return "";
end Name_Image;
function Names
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Names");
return Nil_Element_List;
end Names;
function Next_Element
(Element : Element_Node) return Asis.Element
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Next_Element");
return Nil_Element;
end Next_Element;
function Normalized_Call_Statement_Parameters
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Normalized_Call_Statement_Parameters");
return Nil_Element_List;
end Normalized_Call_Statement_Parameters;
function Normalized_Discriminant_Associations
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Normalized_Discriminant_Associations");
return Nil_Element_List;
end Normalized_Discriminant_Associations;
function Normalized_Function_Call_Parameters
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Normalized_Function_Call_Parameters");
return Nil_Element_List;
end Normalized_Function_Call_Parameters;
function Normalized_Generic_Actual_Part
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Normalized_Generic_Actual_Part");
return Nil_Element_List;
end Normalized_Generic_Actual_Part;
function Normalized_Record_Component_Associations
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Normalized_Record_Component_Associations");
return Nil_Element_List;
end Normalized_Record_Component_Associations;
function Object_Declaration_Subtype
(Element : Element_Node) return Asis.Definition
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Object_Declaration_Subtype");
return Nil_Element;
end Object_Declaration_Subtype;
function Operator_Kind
(Element : Element_Node) return Asis.Operator_Kinds
is
begin
return Not_An_Operator;
end Operator_Kind;
function Overriding_Indicator_Kind
(Element : Element_Node) return Asis.Overriding_Indicator_Kinds
is
begin
return Not_An_Overriding_Indicator;
end Overriding_Indicator_Kind;
function Parameter_Profile
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Parameter_Profile");
return Nil_Element_List;
end Parameter_Profile;
function Parent_Subtype_Indication
(Element : Element_Node) return Asis.Subtype_Indication
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Parent_Subtype_Indication");
return Nil_Element;
end Parent_Subtype_Indication;
function Position_Number_Image
(Element : Element_Node) return Wide_String
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Position_Number_Image");
return "";
end Position_Number_Image;
function Pragma_Argument_Associations
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Pragma_Argument_Associations");
return Nil_Element_List;
end Pragma_Argument_Associations;
function Pragma_Kind
(Element : Element_Node) return Asis.Pragma_Kinds
is
begin
return Not_A_Pragma;
end Pragma_Kind;
function Pragma_Name_Image
(Element : Element_Node) return Wide_String
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Pragma_Name_Image");
return "";
end Pragma_Name_Image;
function Pragmas
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Pragmas");
return Nil_Element_List;
end Pragmas;
function Prefix
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Prefix");
return Nil_Element;
end Prefix;
function Private_Part_Declarative_Items
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Private_Part_Declarative_Items");
return Nil_Element_List;
end Private_Part_Declarative_Items;
function Private_Part_Items
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Private_Part_Items");
return Nil_Element_List;
end Private_Part_Items;
function Profile
(Element : Element_Node) return Asis.Element
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Profile");
return Nil_Element;
end Profile;
function Progenitor_List
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Progenitor_List");
return Nil_Element_List;
end Progenitor_List;
function Protected_Operation_Items
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Protected_Operation_Items");
return Nil_Element_List;
end Protected_Operation_Items;
function Qualified_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Qualified_Expression");
return Nil_Element;
end Qualified_Expression;
function Raise_Statement_Message
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Raise_Statement_Message");
return Nil_Element;
end Raise_Statement_Message;
function Raised_Exception
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Raised_Exception");
return Nil_Element;
end Raised_Exception;
function Range_Attribute
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Range_Attribute");
return Nil_Element;
end Range_Attribute;
function Raw_Image
(Element : Element_Node) return Gela_String
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Raw_Image");
return Raw_Image (Element);
end Raw_Image;
function Real_Range_Constraint
(Element : Element_Node) return Asis.Range_Constraint
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Real_Range_Constraint");
return Nil_Element;
end Real_Range_Constraint;
function Record_Component_Associations
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Record_Component_Associations");
return Nil_Element_List;
end Record_Component_Associations;
function Record_Component_Choice
(Element : Element_Node) return Asis.Defining_Name
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Record_Component_Choice");
return Nil_Element;
end Record_Component_Choice;
function Record_Component_Choices
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Record_Component_Choices");
return Nil_Element_List;
end Record_Component_Choices;
function Record_Components
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Record_Components");
return Nil_Element_List;
end Record_Components;
function Get_Record_Definition
(Element : Element_Node) return Asis.Definition
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Get_Record_Definition");
return Nil_Element;
end Get_Record_Definition;
function References
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "References");
return Nil_Element_List;
end References;
function Renamed_Entity
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Renamed_Entity");
return Nil_Element;
end Renamed_Entity;
function Representation_Clause_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Representation_Clause_Expression");
return Nil_Element;
end Representation_Clause_Expression;
function Representation_Clause_Name
(Element : Element_Node) return Asis.Name
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Representation_Clause_Name");
return Nil_Element;
end Representation_Clause_Name;
function Representation_Value_Image
(Element : Element_Node) return Wide_String
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Representation_Value_Image");
return "";
end Representation_Value_Image;
function Requeue_Entry_Name
(Element : Element_Node) return Asis.Name
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Requeue_Entry_Name");
return Nil_Element;
end Requeue_Entry_Name;
function Result_Subtype
(Element : Element_Node) return Asis.Definition
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Result_Subtype");
return Nil_Element;
end Result_Subtype;
function Return_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Return_Expression");
return Nil_Element;
end Return_Expression;
function Return_Object_Specification
(Element : Element_Node) return Asis.Declaration
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Return_Object_Specification");
return Nil_Element;
end Return_Object_Specification;
function Root_Type_Kind
(Element : Element_Node) return Asis.Root_Type_Kinds
is
begin
return Not_A_Root_Type_Definition;
end Root_Type_Kind;
function Selector
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Selector");
return Nil_Element;
end Selector;
function Sequence_Of_Statements
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Sequence_Of_Statements");
return Nil_Element_List;
end Sequence_Of_Statements;
function Short_Circuit_Operation_Left_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Short_Circuit_Operation_Left_Expression");
return Nil_Element;
end Short_Circuit_Operation_Left_Expression;
function Short_Circuit_Operation_Right_Expression
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Short_Circuit_Operation_Right_Expression");
return Nil_Element;
end Short_Circuit_Operation_Right_Expression;
function Slice_Range
(Element : Element_Node) return Asis.Discrete_Range
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Slice_Range");
return Nil_Element;
end Slice_Range;
function Specification_Subtype_Definition
(Element : Element_Node) return Asis.Discrete_Subtype_Definition
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Specification_Subtype_Definition");
return Nil_Element;
end Specification_Subtype_Definition;
function Start_Position
(Element : Element_Node) return Asis.Text_Position
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Start_Position");
return Nil_Text_Position;
end Start_Position;
function Statement_Identifier
(Element : Element_Node) return Asis.Defining_Name
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Statement_Identifier");
return Nil_Element;
end Statement_Identifier;
function Statement_Paths
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Statement_Paths");
return Nil_Element_List;
end Statement_Paths;
function Subtype_Constraint
(Element : Element_Node) return Asis.Constraint
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Subtype_Constraint");
return Nil_Element;
end Subtype_Constraint;
function Get_Subtype_Mark
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Get_Subtype_Mark");
return Nil_Element;
end Get_Subtype_Mark;
function Trait_Kind
(Element : Element_Node) return Asis.Trait_Kinds
is
begin
return Not_A_Trait;
end Trait_Kind;
function Type_Declaration_View
(Element : Element_Node) return Asis.Definition
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Type_Declaration_View");
return Nil_Element;
end Type_Declaration_View;
function Upper_Bound
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Upper_Bound");
return Nil_Element;
end Upper_Bound;
function Value_Image
(Element : Element_Node) return Wide_String
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Value_Image");
return "";
end Value_Image;
function Variant_Choices
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Variant_Choices");
return Nil_Element_List;
end Variant_Choices;
function Variants
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Variants");
return Nil_Element_List;
end Variants;
function Visible_Part_Declarative_Items
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Visible_Part_Declarative_Items");
return Nil_Element_List;
end Visible_Part_Declarative_Items;
function Visible_Part_Items
(Element : Element_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "Visible_Part_Items");
return Nil_Element_List;
end Visible_Part_Items;
function While_Condition
(Element : Element_Node) return Asis.Expression
is
begin
Raise_Inappropriate_Element
(Get_Context (Element), "While_Condition");
return Nil_Element;
end While_Condition;
function Access_Definition_Kind (Element : Element_Node)
return Asis.Access_Definition_Kinds is
begin
return Not_An_Access_Definition;
end Access_Definition_Kind;
function Association_Kind (Element : Element_Node)
return Asis.Association_Kinds is
begin
return Not_An_Association;
end Association_Kind;
function Clause_Kind (Element : Element_Node)
return Asis.Clause_Kinds is
begin
return Not_A_Clause;
end Clause_Kind;
function Constraint_Kind (Element : Element_Node)
return Asis.Constraint_Kinds is
begin
return Not_A_Constraint;
end Constraint_Kind;
function Declaration_Kind (Element : Element_Node)
return Asis.Declaration_Kinds is
begin
return Not_A_Declaration;
end Declaration_Kind;
function Defining_Name_Kind (Element : Element_Node)
return Asis.Defining_Name_Kinds is
begin
return Not_A_Defining_Name;
end Defining_Name_Kind;
function Definition_Kind (Element : Element_Node)
return Asis.Definition_Kinds is
begin
return Not_A_Definition;
end Definition_Kind;
function Discrete_Range_Kind (Element : Element_Node)
return Asis.Discrete_Range_Kinds is
begin
return Not_A_Discrete_Range;
end Discrete_Range_Kind;
function Element_Kind (Element : Element_Node)
return Asis.Element_Kinds is
begin
return Not_An_Element;
end Element_Kind;
function Expression_Kind (Element : Element_Node)
return Asis.Expression_Kinds is
begin
return Not_An_Expression;
end Expression_Kind;
function Formal_Type_Definition_Kind (Element : Element_Node)
return Asis.Formal_Type_Kinds is
begin
return Not_A_Formal_Type_Definition;
end Formal_Type_Definition_Kind;
function Path_Kind (Element : Element_Node)
return Asis.Path_Kinds is
begin
return Not_A_Path;
end Path_Kind;
function Representation_Clause_Kind (Element : Element_Node)
return Asis.Representation_Clause_Kinds is
begin
return Not_A_Representation_Clause;
end Representation_Clause_Kind;
function Statement_Kind (Element : Element_Node)
return Asis.Statement_Kinds is
begin
return Not_A_Statement;
end Statement_Kind;
function Type_Definition_Kind (Element : Element_Node)
return Asis.Type_Kinds is
begin
return Not_A_Type_Definition;
end Type_Definition_Kind;
end Asis;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, Maxim Reznik
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the Maxim Reznik, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
|
with Ada.Containers.Ordered_Maps;
with Memory;
package Intcode is
use type Memory.Address;
use type Memory.Value;
package Aux_Memory is new Ada.Containers.Ordered_Maps(
Key_Type => Memory.Address, Element_Type => Memory.Value);
type Maybe_Memory_Value(Present: Boolean := False) is
record
case Present is
when False => null;
when True => Value: Memory.Value;
end case;
end record;
type Port_Status is (Empty, Full, Closed);
protected type Port is
entry Put(I: in Memory.Value);
entry Get(X: out Maybe_Memory_Value);
entry Close;
private
Status: Port_Status := Empty;
Value: Memory.Value := 0;
end Port;
type Machine(Hi_Mem: Memory.Address) is record
Mem: Memory.Block(0 .. Hi_Mem);
Aux_Mem: Aux_Memory.Map;
Input, Output: access Port;
end record;
task type Executor(AM: not null access Machine);
end Intcode;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . S Y N C H R O N O U S _ T A S K _ C O N T R O L --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2016, 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. --
-- --
------------------------------------------------------------------------------
-- This is the generic bare board version of this package
with System.Tasking;
with Ada.Task_Identification;
package Ada.Synchronous_Task_Control with
SPARK_Mode
is
pragma Preelaborate;
-- In accordance with Ada 2005 AI-362
type Suspension_Object is limited private;
-- There was a 'Default_Initial_Condition' but it is removed as it resulted
-- in an undefined symbol.
procedure Set_True (S : in out Suspension_Object) with
Global => null,
Depends => (S => null,
null => S);
procedure Set_False (S : in out Suspension_Object) with
Global => null,
Depends => (S => null,
null => S);
function Current_State (S : Suspension_Object) return Boolean with
Volatile_Function,
Global => Ada.Task_Identification.Tasking_State;
procedure Suspend_Until_True (S : in out Suspension_Object) with
Global => null,
Depends => (S => null,
null => S);
private
pragma SPARK_Mode (Off);
-- Using a protected object may seem overkill, but assuming the
-- appropriate restrictions (such as those imposed by the Ravenscar
-- profile) protected operations are very efficient. Moreover, this
-- allows for a generic implementation that is not dependent on the
-- underlying operating system.
protected type Suspension_Object is
entry Wait;
procedure Set_False;
procedure Set_True;
function Get_Open return Boolean;
pragma Interrupt_Priority;
private
Open : Boolean := False;
-- Status
end Suspension_Object;
end Ada.Synchronous_Task_Control;
|
package body ACO.Utils.Generic_Alarms is
function Get_Next_Up
(This : Alarm_Manager;
T_Now : Ada.Real_Time.Time)
return Alarm_Access
is
use type Ada.Real_Time.Time;
begin
if not This.Alarm_List.Is_Empty then
declare
Next : constant Alarm_Data := This.Alarm_List.First;
begin
if Next.Alarm_Ref /= No_Alarm and then
Next.Signal_Time <= T_Now
then
return Next.Alarm_Ref;
end if;
end;
end if;
return No_Alarm;
end Get_Next_Up;
procedure Process
(This : in out Alarm_Manager;
T_Now : in Ada.Real_Time.Time)
is
Next : Alarm_Access := This.Get_Next_Up (T_Now);
begin
while Next /= No_Alarm loop
This.Cancel (Next);
Next.Signal (T_Now);
Next := This.Get_Next_Up (T_Now);
end loop;
end Process;
procedure Set
(This : in out Alarm_Manager;
Alarm : in Alarm_Access;
Signal_Time : in Ada.Real_Time.Time)
is
begin
This.Alarm_List.Append ((Alarm, Signal_Time));
end Set;
function Is_Pending
(This : in out Alarm_Manager;
Alarm : in Alarm_Access)
return Boolean
is
begin
return This.Alarm_List.Location
((Alarm_Ref => Alarm,
Signal_Time => Ada.Real_Time.Time_Last)) /= Collection_Pack.No_Index;
end Is_Pending;
procedure Cancel
(This : in out Alarm_Manager;
Alarm : in Alarm_Access)
is
I : constant Natural := This.Alarm_List.Location
((Alarm_Ref => Alarm,
Signal_Time => Ada.Real_Time.Time_Last));
begin
if I /= Collection_Pack.No_Index then
This.Alarm_List.Remove (I);
end if;
end Cancel;
function "<" (Left, Right : Alarm_Data) return Boolean
is
use Ada.Real_Time;
begin
return Left.Signal_Time < Right.Signal_Time;
end "<";
function "=" (Left, Right : Alarm_Data) return Boolean
is
begin
return Left.Alarm_Ref = Right.Alarm_Ref;
end "=";
end ACO.Utils.Generic_Alarms;
|
-- --
-- Copyright (c) 2015, John Leimon --
-- --
-- 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 Interfaces.C; use Interfaces.C;
with stdint_h; use stdint_h;
with stddef_h; use stddef_h;
with Interfaces.C.Strings;
package SPI is
type Mode_Type is new uint32_t;
Mode_Loop : constant Mode_Type := 16#0000_0020#;
Mode_CPHA : constant Mode_Type := 16#0000_0001#;
Mode_CPOL : constant Mode_Type := 16#0000_0002#;
Mode_LSB_First : constant Mode_Type := 16#0000_0008#;
Mode_CS_High : constant Mode_Type := 16#0000_0004#;
Mode_No_CS : constant Mode_Type := 16#0000_0040#;
Mode_3Wire : constant Mode_Type := 16#0000_0010#;
Mode_Ready : constant Mode_Type := 16#0000_0080#;
Mode_TX_Dual : constant Mode_Type := 16#0000_0100#;
Mode_TX_Quad : constant Mode_Type := 16#0000_0200#;
Mode_RX_Dual : constant Mode_Type := 16#0000_0400#;
Mode_RX_Quad : constant Mode_Type := 16#0000_0800#;
Error_Mode : exception;
Error_Bits : exception;
Error_Freq : exception;
Error_Device : exception;
Error_Xfer : exception;
Error_Unknown : exception;
type SPI_Device is record
fd : aliased int; -- ../include/spi_driver.h:32
clk_freq : aliased uint32_t; -- ../include/spi_driver.h:33
mode : aliased uint32_t; -- ../include/spi_driver.h:34
c_delay : aliased uint16_t; -- ../include/spi_driver.h:35
bits : aliased uint8_t; -- ../include/spi_driver.h:36
end record;
pragma Convention (C_Pass_By_Copy, SPI_Device); -- ../include/spi_driver.h:31
procedure Open(device : access SPI_Device;
device_path : Interfaces.C.Strings.chars_ptr;
mode : Mode_Type;
bits : uint8_t;
freq : uint32_t);
procedure Transfer(device : access SPI_Device;
transmit_buffer : access uint8_t;
receive_buffer : access uint8_t;
c_delay : uint16_t;
length : stddef_h.size_t);
procedure Close(device : access SPI_Device);
private
-- @brief Initialize and configure a SPI device.
-- @param[in,out] spi Address of a SPI device structure.
-- @param[in] dev Full path to SPI device.
-- @param[in] mode SPI_MODE_LOOP Loopback
-- SPI_MODE_CPHA Clock Phase
-- SPI_MODE_CPOL Clock Polarity
-- SPI_MODE_LSB_FIRST Least Significant Bit First
-- SPI_MODE_CS_HIGH Chip Select Active High
-- SPI_MODE_NO_CS No Chip Select
-- SPI_MODE_3WIRE SI/SO Signals Shared
-- SPI_MODE_READY Slave may pull down to pause
-- SPI_MODE_TX_DUAL Dual transfer
-- SPI_MODE_TX_QUAD Quad transfer
-- @param[in] bits Number of bits in a transfer
-- @param[in] freq Clock frequency (Hz)
-- @return SPI_SUCCESS SPI device opened successfully
-- @return SPI_ERROR_MODE Error: Cannot set mode
-- @return SPI_ERROR_BITS Error: Cannot set bits
-- @return SPI_ERROR_FREQ Error: Cannot set frequency
-- @return SPI_ERROR_DEV Error: Cannot open device
--
function c_open
(device : access SPI_Device;
device_path : Interfaces.C.Strings.chars_ptr;
mode : uint32_t;
bits : uint8_t;
freq : uint32_t) return int; -- ../include/pi-spi_driver.h:85
pragma Import (CPP, c_open, "_Z15spi_driver_openP6spidevPcjhj");
-- @brief Send and receive some data.
-- @param[in,out] spi Address of a SPI device structure.
-- @param[in] transmit_buffer Address of the first byte to transmit
-- @param[out] receive_buffer Address to write data read in from SPI
-- @param[in] delay Delay in us before the transmission
-- @param[in] length Number of bytes to read/write
-- @return SPI_SUCCESS Operation completed successfully
-- @return SPI_ERROR_XFER Error: Could not send data
--
function c_transfer
(device : access SPI_Device;
transmit_buffer : access uint8_t;
receive_buffer : access uint8_t;
c_delay : uint16_t;
length : stddef_h.size_t) return int; -- ../include/spi_driver.h:101
pragma Import (CPP, c_transfer, "_Z19spi_driver_transferP6spidevPhS1_tj");
-- @brief Close SPI device.
-- @param[in,out] spi Address of a SPI device structure.
--
procedure c_close (device : access SPI_Device); -- ../include/spi_driver.h:111
pragma Import (CPP, c_close, "_Z16spi_driver_closeP6spidev");
end SPI;
|
with Ada.Text_IO; use Ada.Text_IO;
with Input; use Input;
procedure Day10 is
procedure Print_Grid
(Points : Point_Array;
Min_X, Max_X, Min_Y, Max_Y : Integer)
is
Grid : array
(Integer range Min_X .. Max_X,
Integer range Min_Y .. Max_Y) of Character :=
(others => (others => '.'));
begin
for I in Points'Range loop
Grid (Points (I).X, Points (I).Y) := '#';
end loop;
for Y in Min_Y .. Max_Y loop
for X in Min_X .. Max_X loop
Put ("" & Grid (X, Y));
end loop;
Put_Line ("");
end loop;
end Print_Grid;
Seconds : Natural := 0;
begin
-- Assumption: The points are converging until the message appears
-- and then diverge again. Meaning the diameter on the Y-axis should
-- increase for the first time directly after the message is shown.
Infinite_Loop :
loop
declare
Min_X : Integer := Integer'Last;
Max_X : Integer := Integer'First;
Min_Y_Before : Integer := Integer'Last;
Max_Y_Before : Integer := Integer'First;
Min_Y_After : Integer := Integer'Last;
Max_Y_After : Integer := Integer'First;
begin
for I in Points'Range loop
Min_X := Integer'Min (Min_X, Points (I).X);
Max_X := Integer'Max (Max_X, Points (I).X);
Min_Y_Before := Integer'Min (Min_Y_Before, Points (I).Y);
Max_Y_Before := Integer'Max (Max_Y_Before, Points (I).Y);
Points (I) := Points (I) + Velocities (I);
Min_Y_After := Integer'Min (Min_Y_After, Points (I).Y);
Max_Y_After := Integer'Max (Max_Y_After, Points (I).Y);
end loop;
if abs (Max_Y_After - Min_Y_After) > abs (Max_Y_Before - Min_Y_Before)
then
-- Roll-back the last step
for I in Points'Range loop
Points (I) := Points (I) - Velocities (I);
end loop;
-- Print the result
Put_Line ("Part 1:");
Print_Grid (Points, Min_X, Max_X, Min_Y_Before, Max_Y_Before);
Put_Line ("Part 2 =" & Natural'Image (Seconds));
exit Infinite_Loop;
end if;
Seconds := Seconds + 1;
end;
end loop Infinite_Loop;
end Day10;
|
with System.Storage_Elements;
package body TLSF.Block.Operations_Old with SPARK_Mode is
package SSE renames System.Storage_Elements;
function Get_System_Address(Base : System.Address;
Addr : Address)
return System.Address
with SPARK_Mode => Off
is
use type SSE.Integer_Address;
Base_Int : constant SSE.Integer_Address := SSE.To_Integer(Base);
Addr_Int : constant SSE.Integer_Address :=
Base_Int + SSE.Integer_Address(Addr);
Final_Addr : constant System.Address := SSE.To_Address(Addr_Int);
begin
return Final_Addr;
end Get_System_Address;
---------------------------------
-- Physical presence of blocks --
---------------------------------
function Get_Block_At_Address(Base : System.Address;
Addr : Aligned_Address)
return Block_Header
with SPARK_Mode => Off
is
Block : Block_Header
with Import, Address => Get_System_Address(Base, Addr);
begin
return Block;
end Get_Block_At_Address;
procedure Real_Set_Block_At_Address(Base : System.Address;
Addr : Aligned_Address;
Header : Block_Header)
with Pre => Addr /= Address_Null;
procedure Real_Set_Block_At_Address(Base : System.Address;
Addr : Aligned_Address;
Header : Block_Header)
with SPARK_Mode => Off
is
Block : Block_Header
with Import, Address => Get_System_Address(Base, Addr);
begin
Block := Header;
end Real_Set_Block_At_Address;
procedure Set_Block_At_Address(Base : System.Address;
Addr : Aligned_Address;
Header : Block_Header)
is
begin
Real_Set_Block_At_Address(Base, Addr, Header);
Proof.Put_Block_At_Address(Addr, Header);
end Set_Block_At_Address;
procedure Remove_Block_At_Address(Base : System.Address;
Addr : Aligned_Address)
is
pragma Unreferenced(Base);
begin
Proof.Remove_Block_At_Address(Addr);
-- read deletion is not performed - it is useless, may be only for security
-- reasons
end Remove_Block_At_Address;
procedure Test is
B : Block_Header;
C : Block_Header := Block_Header'(Status => Occupied,
Prev_Block_Address => Address_Null,
Prev_Block_Status => Absent,
Next_Block_Status => Free,
Size => 1);
A : System.Address := SSE.To_Address(0);
begin
Set_Block_At_Address(A, 0, C);
pragma Assert(Proof.Block_Present_At_Address(0));
pragma Assert(Proof.Block_At_Address(0) = C);
end Test;
---------------------------
-- Work with Free Blocks --
---------------------------
procedure Unlink_From_Free_List (Base : System.Address;
Address : Aligned_Address;
Block : in out Block_Header;
Free_List : in out Free_Blocks_List)
is
Prev_Address : constant Aligned_Address := Block.Free_List.Prev_Address;
Next_Address : constant Aligned_Address := Block.Free_List.Next_Address;
begin
pragma Assert(Proof.Block_Present_At_Address(Address));
Remove_Block_At_Address(Base, Address);
Proof.Remove_Block_From_Free_List_For_Size(Block.Size, Address);
if Is_Block_Last_In_Free_List(Block) then
Block.Free_List := Empty_Free_List;
Free_List := Empty_Free_List;
else
declare
Prev_Block : Block_Header := Get_Block_At_Address(Base, Prev_Address);
Next_Block : Block_Header := Get_Block_At_Address(Base, Next_Address);
begin
Remove_Block_At_Address(Base, Prev_Address);
Remove_Block_At_Address(Base, Next_Address);
Prev_Block.Free_List.Next_Address := Next_Address;
Next_Block.Free_List.Prev_Address := Prev_Address;
Set_Block_At_Address(Base, Prev_Address, Prev_Block);
Set_Block_At_Address(Base, Next_Address, Next_Block);
end;
end if;
Set_Block_At_Address(Base, Address, Block);
end Unlink_From_Free_List;
end TLSF.Block.Operations_Old;
|
PACKAGE Salas IS
TYPE Sala IS PRIVATE;
--Constructor para crear la sala e inicializarla
FUNCTION Crear_Sala (
Nombre_Sala : String;
Numero_Filas : Positive;
Numero_Localidades_Fila : Positive)
RETURN Sala;
--Devuelve el nombre de la sala
FUNCTION Nombre_Sala (
S : Sala)
RETURN String;
--Devuelve el aforo maximo de la sala
FUNCTION Aforo_Sala (
S : Sala)
RETURN Positive;
--Devuelve el numero de plazas libres en la sala
FUNCTION Plazas_Libres (
S : Sala)
RETURN Natural;
--Imprime por pantalla el identificador de la pelicula
FUNCTION La_Pelicula (
S : IN Sala)
RETURN String;
--Modificar el identificador de la sala pasada por parametro
PROCEDURE Modificar_Pelicula (
S : IN OUT Sala;
Nombre : String);
--Procedimiento que vende localidades contiguas
PROCEDURE Vender_Localidades_Contiguas (
S : IN OUT Sala;
Numero_Entradas : Positive);
--Funcion auxiliar para normalizar strings
FUNCTION Normalizar_String (
S : Sala;
Rango_Maximo : Positive)
RETURN String;
--Procedimiento para mostrar el mapa de la sala
PROCEDURE Mostrar_Sala (
S : Sala);
--Sobrecarga del operador ":=" para copiar objetos
PROCEDURE Copiar_Sala (
S : IN OUT Sala;
S_A_Copiar : IN Sala);
PRIVATE
RANGO_MATRIZ : CONSTANT := 25;
RANGO_LOCALIDADES : CONSTANT := 25;
TYPE Matriz IS ARRAY (1 .. RANGO_MATRIZ, 1 .. RANGO_MATRIZ) OF Boolean;
TYPE Sala IS
RECORD
Nombre_Sala : String (1 .. 7);
Identificador_Peli : String (1 .. 10);
Localidades_Libres : Natural;
Numero_Filas,
Numero_Localidades_Fila : Positive RANGE 1 .. RANGO_LOCALIDADES;
Array_Localidades : Matriz;
END RECORD;
END Salas;
|
--PRÁCTICA 3: CÉSAR BORAO MORATINOS (Chat_Messages.adb)
with Ada.Text_IO;
with Lower_Layer_UDP;
with Ada.Strings.Unbounded;
package body Chat_Messages is
package ATI renames Ada.Text_IO;
use Ada.Strings.Unbounded;
procedure Init_Message (Server_EP: LLU.End_Point_Type;
Client_EP_Receive: LLU.End_Point_Type;
Client_EP_Handler: LLU.End_Point_Type;
Nick: ASU.Unbounded_String;
O_Buffer: Access LLU.Buffer_Type) is
begin
Message_Type'Output(O_Buffer, Init);
LLU.End_Point_Type'Output(O_Buffer, Client_EP_Receive);
LLU.End_Point_Type'Output(O_Buffer, Client_EP_Handler);
ASU.Unbounded_String'Output(O_Buffer, Nick);
LLU.Send(Server_EP, O_Buffer);
LLU.Reset(O_Buffer.all);
end Init_Message;
procedure Welcome_Message (Client_EP_Handler: LLU.End_Point_Type;
Accepted: Boolean;
O_Buffer: Access LLU.Buffer_Type) is
begin
Message_Type'Output(O_Buffer, Welcome);
Boolean'Output(O_Buffer, Accepted);
LLU.Send (Client_EP_Handler, O_Buffer);
LLU.Reset (O_Buffer.all);
end Welcome_Message;
procedure Server_Message (Client_EP_Handler: LLU.End_Point_Type;
Nick: ASU.Unbounded_String;
Comment: ASU.Unbounded_String;
O_Buffer: Access LLU.Buffer_Type) is
begin
Message_Type'Output (O_Buffer,Server);
ASU.Unbounded_String'Output (O_Buffer,Nick);
ASU.Unbounded_String'Output (O_Buffer,Comment);
LLU.Send(Client_EP_Handler, O_Buffer);
LLU.Reset (O_Buffer.all);
end Server_Message;
procedure Writer_Message (Server_EP: LLU.End_Point_Type;
Client_EP_Handler: LLU.End_Point_Type;
Nick: ASU.Unbounded_String;
Comment: ASU.Unbounded_String;
O_Buffer: Access LLU.Buffer_Type) is
begin
Message_Type'Output(O_Buffer, Writer);
LLU.End_Point_Type'Output(O_Buffer, Client_EP_Handler);
ASU.Unbounded_String'Output(O_Buffer, Nick);
ASU.Unbounded_String'Output(O_Buffer, Comment);
LLU.Send(Server_EP, O_Buffer);
LLU.Reset(O_Buffer.all);
end Writer_Message;
procedure Logout_Message (Server_EP: LLU.End_Point_Type;
Client_EP_Handler: LLU.End_Point_Type;
Nick: ASU.Unbounded_String;
O_Buffer: Access LLU.Buffer_Type) is
begin
Message_Type'Output(O_Buffer, Logout);
LLU.End_Point_Type'Output(O_Buffer, Client_EP_Handler);
ASU.Unbounded_String'Output(O_Buffer, Nick);
LLU.Send(Server_EP, O_Buffer);
LLU.Reset(O_Buffer.all);
end Logout_Message;
end Chat_Messages;
|
pragma License (Unrestricted);
-- runtime unit specialized for Windows
with C.winnt;
package System.Stack is
pragma Preelaborate;
procedure Get (
TEB : C.winnt.struct_TEB_ptr := C.winnt.NtCurrentTeb;
Top, Bottom : out Address);
end System.Stack;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E R R O U T C --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-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. 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. --
-- --
------------------------------------------------------------------------------
-- Warning: Error messages can be generated during Gigi processing by direct
-- calls to error message routines, so it is essential that the processing
-- in this body be consistent with the requirements for the Gigi processing
-- environment, and that in particular, no disallowed table expansion is
-- allowed to occur.
with Atree; use Atree;
with Casing; use Casing;
with Csets; use Csets;
with Debug; use Debug;
with Err_Vars; use Err_Vars;
with Namet; use Namet;
with Opt; use Opt;
with Output; use Output;
with Sinput; use Sinput;
with Snames; use Snames;
with Stringt; use Stringt;
with Targparm; use Targparm;
with Uintp; use Uintp;
with Widechar; use Widechar;
package body Erroutc is
-----------------------
-- Local Subprograms --
-----------------------
function Matches (S : String; P : String) return Boolean;
-- Returns true if the String S patches the pattern P, which can contain
-- wild card chars (*). The entire pattern must match the entire string.
-- Case is ignored in the comparison (so X matches x).
---------------
-- Add_Class --
---------------
procedure Add_Class is
begin
if Class_Flag then
Class_Flag := False;
Set_Msg_Char (''');
Get_Name_String (Name_Class);
Set_Casing (Identifier_Casing (Flag_Source), Mixed_Case);
Set_Msg_Name_Buffer;
end if;
end Add_Class;
----------------------
-- Buffer_Ends_With --
----------------------
function Buffer_Ends_With (C : Character) return Boolean is
begin
return Msglen > 0 and then Msg_Buffer (Msglen) = C;
end Buffer_Ends_With;
function Buffer_Ends_With (S : String) return Boolean is
Len : constant Natural := S'Length;
begin
return Msglen > Len
and then Msg_Buffer (Msglen - Len) = ' '
and then Msg_Buffer (Msglen - Len + 1 .. Msglen) = S;
end Buffer_Ends_With;
-------------------
-- Buffer_Remove --
-------------------
procedure Buffer_Remove (C : Character) is
begin
if Buffer_Ends_With (C) then
Msglen := Msglen - 1;
end if;
end Buffer_Remove;
procedure Buffer_Remove (S : String) is
begin
if Buffer_Ends_With (S) then
Msglen := Msglen - S'Length;
end if;
end Buffer_Remove;
-----------------------------
-- Check_Duplicate_Message --
-----------------------------
procedure Check_Duplicate_Message (M1, M2 : Error_Msg_Id) is
L1, L2 : Error_Msg_Id;
N1, N2 : Error_Msg_Id;
procedure Delete_Msg (Delete, Keep : Error_Msg_Id);
-- Called to delete message Delete, keeping message Keep. Marks msg
-- Delete and all its continuations with deleted flag set to True.
-- Also makes sure that for the error messages that are retained the
-- preferred message is the one retained (we prefer the shorter one in
-- the case where one has an Instance tag). Note that we always know
-- that Keep has at least as many continuations as Delete (since we
-- always delete the shorter sequence).
----------------
-- Delete_Msg --
----------------
procedure Delete_Msg (Delete, Keep : Error_Msg_Id) is
D, K : Error_Msg_Id;
begin
D := Delete;
K := Keep;
loop
Errors.Table (D).Deleted := True;
-- Adjust error message count
if Errors.Table (D).Warn or else Errors.Table (D).Style then
Warnings_Detected := Warnings_Detected - 1;
if Errors.Table (D).Info then
Info_Messages := Info_Messages - 1;
end if;
-- Note: we do not need to decrement Warnings_Treated_As_Errors
-- because this only gets incremented if we actually output the
-- message, which we won't do if we are deleting it here!
elsif Errors.Table (D).Check then
Check_Messages := Check_Messages - 1;
else
Total_Errors_Detected := Total_Errors_Detected - 1;
if Errors.Table (D).Serious then
Serious_Errors_Detected := Serious_Errors_Detected - 1;
end if;
end if;
-- Substitute shorter of the two error messages
if Errors.Table (K).Text'Length > Errors.Table (D).Text'Length then
Errors.Table (K).Text := Errors.Table (D).Text;
end if;
D := Errors.Table (D).Next;
K := Errors.Table (K).Next;
if D = No_Error_Msg or else not Errors.Table (D).Msg_Cont then
return;
end if;
end loop;
end Delete_Msg;
-- Start of processing for Check_Duplicate_Message
begin
-- Both messages must be non-continuation messages and not deleted
if Errors.Table (M1).Msg_Cont
or else Errors.Table (M2).Msg_Cont
or else Errors.Table (M1).Deleted
or else Errors.Table (M2).Deleted
then
return;
end if;
-- Definitely not equal if message text does not match
if not Same_Error (M1, M2) then
return;
end if;
-- Same text. See if all continuations are also identical
L1 := M1;
L2 := M2;
loop
N1 := Errors.Table (L1).Next;
N2 := Errors.Table (L2).Next;
-- If M1 continuations have run out, we delete M1, either the
-- messages have the same number of continuations, or M2 has
-- more and we prefer the one with more anyway.
if N1 = No_Error_Msg or else not Errors.Table (N1).Msg_Cont then
Delete_Msg (M1, M2);
return;
-- If M2 continuations have run out, we delete M2
elsif N2 = No_Error_Msg or else not Errors.Table (N2).Msg_Cont then
Delete_Msg (M2, M1);
return;
-- Otherwise see if continuations are the same, if not, keep both
-- sequences, a curious case, but better to keep everything.
elsif not Same_Error (N1, N2) then
return;
-- If continuations are the same, continue scan
else
L1 := N1;
L2 := N2;
end if;
end loop;
end Check_Duplicate_Message;
------------------------
-- Compilation_Errors --
------------------------
function Compilation_Errors return Boolean is
begin
return Total_Errors_Detected /= 0
or else (Warnings_Detected - Info_Messages /= 0
and then Warning_Mode = Treat_As_Error)
or else Warnings_Treated_As_Errors /= 0;
end Compilation_Errors;
------------------
-- Debug_Output --
------------------
procedure Debug_Output (N : Node_Id) is
begin
if Debug_Flag_1 then
Write_Str ("*** following error message posted on node id = #");
Write_Int (Int (N));
Write_Str (" ***");
Write_Eol;
end if;
end Debug_Output;
----------
-- dmsg --
----------
procedure dmsg (Id : Error_Msg_Id) is
E : Error_Msg_Object renames Errors.Table (Id);
begin
w ("Dumping error message, Id = ", Int (Id));
w (" Text = ", E.Text.all);
w (" Next = ", Int (E.Next));
w (" Prev = ", Int (E.Prev));
w (" Sfile = ", Int (E.Sfile));
Write_Str
(" Sptr = ");
Write_Location (E.Sptr);
Write_Eol;
Write_Str
(" Optr = ");
Write_Location (E.Optr);
Write_Eol;
w (" Line = ", Int (E.Line));
w (" Col = ", Int (E.Col));
w (" Warn = ", E.Warn);
w (" Warn_Err = ", E.Warn_Err);
w (" Warn_Chr = '" & E.Warn_Chr & ''');
w (" Style = ", E.Style);
w (" Serious = ", E.Serious);
w (" Uncond = ", E.Uncond);
w (" Msg_Cont = ", E.Msg_Cont);
w (" Deleted = ", E.Deleted);
Write_Eol;
end dmsg;
------------------
-- Get_Location --
------------------
function Get_Location (E : Error_Msg_Id) return Source_Ptr is
begin
return Errors.Table (E).Sptr;
end Get_Location;
----------------
-- Get_Msg_Id --
----------------
function Get_Msg_Id return Error_Msg_Id is
begin
return Cur_Msg;
end Get_Msg_Id;
---------------------
-- Get_Warning_Tag --
---------------------
function Get_Warning_Tag (Id : Error_Msg_Id) return String is
Warn : constant Boolean := Errors.Table (Id).Warn;
Warn_Chr : constant Character := Errors.Table (Id).Warn_Chr;
begin
if Warn and then Warn_Chr /= ' ' then
if Warn_Chr = '?' then
return "[enabled by default]";
elsif Warn_Chr = '*' then
return "[restriction warning]";
elsif Warn_Chr = '$' then
return "[-gnatel]";
elsif Warn_Chr in 'a' .. 'z' then
return "[-gnatw" & Warn_Chr & ']';
else pragma Assert (Warn_Chr in 'A' .. 'Z');
return "[-gnatw." & Fold_Lower (Warn_Chr) & ']';
end if;
else
return "";
end if;
end Get_Warning_Tag;
-------------
-- Matches --
-------------
function Matches (S : String; P : String) return Boolean is
Slast : constant Natural := S'Last;
PLast : constant Natural := P'Last;
SPtr : Natural := S'First;
PPtr : Natural := P'First;
begin
-- Loop advancing through characters of string and pattern
SPtr := S'First;
PPtr := P'First;
loop
-- Return True if pattern is a single asterisk
if PPtr = PLast and then P (PPtr) = '*' then
return True;
-- Return True if both pattern and string exhausted
elsif PPtr > PLast and then SPtr > Slast then
return True;
-- Return False, if one exhausted and not the other
elsif PPtr > PLast or else SPtr > Slast then
return False;
-- Case where pattern starts with asterisk
elsif P (PPtr) = '*' then
-- Try all possible starting positions in S for match with the
-- remaining characters of the pattern. This is the recursive
-- call that implements the scanner backup.
for J in SPtr .. Slast loop
if Matches (S (J .. Slast), P (PPtr + 1 .. PLast)) then
return True;
end if;
end loop;
return False;
-- Dealt with end of string and *, advance if we have a match
elsif Fold_Lower (S (SPtr)) = Fold_Lower (P (PPtr)) then
SPtr := SPtr + 1;
PPtr := PPtr + 1;
-- If first characters do not match, that's decisive
else
return False;
end if;
end loop;
end Matches;
-----------------------
-- Output_Error_Msgs --
-----------------------
procedure Output_Error_Msgs (E : in out Error_Msg_Id) is
P : Source_Ptr;
T : Error_Msg_Id;
S : Error_Msg_Id;
Flag_Num : Pos;
Mult_Flags : Boolean := False;
begin
S := E;
-- Skip deleted messages at start
if Errors.Table (S).Deleted then
Set_Next_Non_Deleted_Msg (S);
end if;
-- Figure out if we will place more than one error flag on this line
T := S;
while T /= No_Error_Msg
and then Errors.Table (T).Line = Errors.Table (E).Line
and then Errors.Table (T).Sfile = Errors.Table (E).Sfile
loop
if Errors.Table (T).Sptr > Errors.Table (E).Sptr then
Mult_Flags := True;
end if;
Set_Next_Non_Deleted_Msg (T);
end loop;
-- Output the error flags. The circuit here makes sure that the tab
-- characters in the original line are properly accounted for. The
-- eight blanks at the start are to match the line number.
if not Debug_Flag_2 then
Write_Str (" ");
P := Line_Start (Errors.Table (E).Sptr);
Flag_Num := 1;
-- Loop through error messages for this line to place flags
T := S;
while T /= No_Error_Msg
and then Errors.Table (T).Line = Errors.Table (E).Line
and then Errors.Table (T).Sfile = Errors.Table (E).Sfile
loop
declare
Src : Source_Buffer_Ptr
renames Source_Text (Errors.Table (T).Sfile);
begin
-- Loop to output blanks till current flag position
while P < Errors.Table (T).Sptr loop
-- Horizontal tab case, just echo the tab
if Src (P) = ASCII.HT then
Write_Char (ASCII.HT);
P := P + 1;
-- Deal with wide character case, but don't include brackets
-- notation in this circuit, since we know that this will
-- display unencoded (no one encodes brackets notation).
elsif Src (P) /= '['
and then Is_Start_Of_Wide_Char (Src, P)
then
Skip_Wide (Src, P);
Write_Char (' ');
-- Normal non-wide character case (or bracket)
else
P := P + 1;
Write_Char (' ');
end if;
end loop;
-- Output flag (unless already output, this happens if more
-- than one error message occurs at the same flag position).
if P = Errors.Table (T).Sptr then
if (Flag_Num = 1 and then not Mult_Flags)
or else Flag_Num > 9
then
Write_Char ('|');
else
Write_Char
(Character'Val (Character'Pos ('0') + Flag_Num));
end if;
-- Skip past the corresponding source text character
-- Horizontal tab case, we output a flag at the tab position
-- so now we output a tab to match up with the text.
if Src (P) = ASCII.HT then
Write_Char (ASCII.HT);
P := P + 1;
-- Skip wide character other than left bracket
elsif Src (P) /= '['
and then Is_Start_Of_Wide_Char (Src, P)
then
Skip_Wide (Src, P);
-- Skip normal non-wide character case (or bracket)
else
P := P + 1;
end if;
end if;
end;
Set_Next_Non_Deleted_Msg (T);
Flag_Num := Flag_Num + 1;
end loop;
Write_Eol;
end if;
-- Now output the error messages
T := S;
while T /= No_Error_Msg
and then Errors.Table (T).Line = Errors.Table (E).Line
and then Errors.Table (T).Sfile = Errors.Table (E).Sfile
loop
Write_Str (" >>> ");
Output_Msg_Text (T);
if Debug_Flag_2 then
while Column < 74 loop
Write_Char (' ');
end loop;
Write_Str (" <<<");
end if;
Write_Eol;
Set_Next_Non_Deleted_Msg (T);
end loop;
E := T;
end Output_Error_Msgs;
------------------------
-- Output_Line_Number --
------------------------
procedure Output_Line_Number (L : Logical_Line_Number) is
D : Int; -- next digit
C : Character; -- next character
Z : Boolean; -- flag for zero suppress
N, M : Int; -- temporaries
begin
if L = No_Line_Number then
Write_Str (" ");
else
Z := False;
N := Int (L);
M := 100_000;
while M /= 0 loop
D := Int (N / M);
N := N rem M;
M := M / 10;
if D = 0 then
if Z then
C := '0';
else
C := ' ';
end if;
else
Z := True;
C := Character'Val (D + 48);
end if;
Write_Char (C);
end loop;
Write_Str (". ");
end if;
end Output_Line_Number;
---------------------
-- Output_Msg_Text --
---------------------
procedure Output_Msg_Text (E : Error_Msg_Id) is
Offs : constant Nat := Column - 1;
-- Offset to start of message, used for continuations
Max : Integer;
-- Maximum characters to output on next line
Length : Nat;
-- Maximum total length of lines
Text : constant String_Ptr := Errors.Table (E).Text;
Ptr : Natural;
Split : Natural;
Start : Natural;
begin
declare
Tag : constant String := Get_Warning_Tag (E);
Txt : String_Ptr;
Len : Natural;
begin
-- Postfix warning tag to message if needed
if Tag /= "" and then Warning_Doc_Switch then
Txt := new String'(Text.all & ' ' & Tag);
else
Txt := Text;
end if;
-- Deal with warning case
if Errors.Table (E).Warn then
-- For info messages, prefix message with "info: "
if Errors.Table (E).Info then
Txt := new String'("info: " & Txt.all);
-- Warning treated as error
elsif Errors.Table (E).Warn_Err then
-- We prefix with "error:" rather than warning: and postfix
-- [warning-as-error] at the end.
Warnings_Treated_As_Errors := Warnings_Treated_As_Errors + 1;
Txt := new String'("error: " & Txt.all & " [warning-as-error]");
-- Normal case, prefix with "warning: "
else
Txt := new String'("warning: " & Txt.all);
end if;
-- No prefix needed for style message, "(style)" is there already
elsif Errors.Table (E).Style then
null;
-- No prefix needed for check message, severity is there already
elsif Errors.Table (E).Check then
null;
-- All other cases, add "error: " if unique error tag set
elsif Opt.Unique_Error_Tag then
Txt := new String'("error: " & Txt.all);
end if;
-- Set error message line length and length of message
if Error_Msg_Line_Length = 0 then
Length := Nat'Last;
else
Length := Error_Msg_Line_Length;
end if;
Max := Integer (Length - Column + 1);
Len := Txt'Length;
-- Here we have to split the message up into multiple lines
Ptr := 1;
loop
-- Make sure we do not have ludicrously small line
Max := Integer'Max (Max, 20);
-- If remaining text fits, output it respecting LF and we are done
if Len - Ptr < Max then
for J in Ptr .. Len loop
if Txt (J) = ASCII.LF then
Write_Eol;
Write_Spaces (Offs);
else
Write_Char (Txt (J));
end if;
end loop;
return;
-- Line does not fit
else
Start := Ptr;
-- First scan forward looking for a hard end of line
for Scan in Ptr .. Ptr + Max - 1 loop
if Txt (Scan) = ASCII.LF then
Split := Scan - 1;
Ptr := Scan + 1;
goto Continue;
end if;
end loop;
-- Otherwise scan backwards looking for a space
for Scan in reverse Ptr .. Ptr + Max - 1 loop
if Txt (Scan) = ' ' then
Split := Scan - 1;
Ptr := Scan + 1;
goto Continue;
end if;
end loop;
-- If we fall through, no space, so split line arbitrarily
Split := Ptr + Max - 1;
Ptr := Split + 1;
end if;
<<Continue>>
if Start <= Split then
Write_Line (Txt (Start .. Split));
Write_Spaces (Offs);
end if;
Max := Integer (Length - Column + 1);
end loop;
end;
end Output_Msg_Text;
---------------------
-- Prescan_Message --
---------------------
procedure Prescan_Message (Msg : String) is
J : Natural;
begin
-- Nothing to do for continuation line
if Msg (Msg'First) = '\' then
return;
end if;
-- Set initial values of globals (may be changed during scan)
Is_Serious_Error := True;
Is_Unconditional_Msg := False;
Is_Warning_Msg := False;
Has_Double_Exclam := False;
-- Check style message
Is_Style_Msg :=
Msg'Length > 7 and then Msg (Msg'First .. Msg'First + 6) = "(style)";
-- Check info message
Is_Info_Msg :=
Msg'Length > 6 and then Msg (Msg'First .. Msg'First + 5) = "info: ";
-- Check check message
Is_Check_Msg :=
(Msg'Length > 8 and then Msg (Msg'First .. Msg'First + 7) = "medium: ")
or else
(Msg'Length > 6 and then Msg (Msg'First .. Msg'First + 5) = "high: ")
or else
(Msg'Length > 5 and then Msg (Msg'First .. Msg'First + 4) = "low: ");
-- Loop through message looking for relevant insertion sequences
J := Msg'First;
while J <= Msg'Last loop
-- If we have a quote, don't look at following character
if Msg (J) = ''' then
J := J + 2;
-- Warning message (? or < insertion sequence)
elsif Msg (J) = '?' or else Msg (J) = '<' then
Is_Warning_Msg := Msg (J) = '?' or else Error_Msg_Warn;
Warning_Msg_Char := ' ';
J := J + 1;
if Is_Warning_Msg then
declare
C : constant Character := Msg (J - 1);
begin
if J <= Msg'Last then
if Msg (J) = C then
Warning_Msg_Char := '?';
J := J + 1;
elsif J < Msg'Last and then Msg (J + 1) = C
and then (Msg (J) in 'a' .. 'z' or else
Msg (J) in 'A' .. 'Z' or else
Msg (J) = '*' or else
Msg (J) = '$')
then
Warning_Msg_Char := Msg (J);
J := J + 2;
end if;
end if;
end;
end if;
-- Bomb if untagged warning message. This code can be uncommented
-- for debugging when looking for untagged warning messages.
-- if Is_Warning_Msg and then Warning_Msg_Char = ' ' then
-- raise Program_Error;
-- end if;
-- Unconditional message (! insertion)
elsif Msg (J) = '!' then
Is_Unconditional_Msg := True;
J := J + 1;
if J <= Msg'Last and then Msg (J) = '!' then
Has_Double_Exclam := True;
J := J + 1;
end if;
-- Non-serious error (| insertion)
elsif Msg (J) = '|' then
Is_Serious_Error := False;
J := J + 1;
else
J := J + 1;
end if;
end loop;
if Is_Warning_Msg or Is_Style_Msg or Is_Check_Msg then
Is_Serious_Error := False;
end if;
end Prescan_Message;
--------------------
-- Purge_Messages --
--------------------
procedure Purge_Messages (From : Source_Ptr; To : Source_Ptr) is
E : Error_Msg_Id;
function To_Be_Purged (E : Error_Msg_Id) return Boolean;
-- Returns True for a message that is to be purged. Also adjusts
-- error counts appropriately.
------------------
-- To_Be_Purged --
------------------
function To_Be_Purged (E : Error_Msg_Id) return Boolean is
begin
if E /= No_Error_Msg
and then Errors.Table (E).Sptr > From
and then Errors.Table (E).Sptr < To
then
if Errors.Table (E).Warn or else Errors.Table (E).Style then
Warnings_Detected := Warnings_Detected - 1;
else
Total_Errors_Detected := Total_Errors_Detected - 1;
if Errors.Table (E).Serious then
Serious_Errors_Detected := Serious_Errors_Detected - 1;
end if;
end if;
return True;
else
return False;
end if;
end To_Be_Purged;
-- Start of processing for Purge_Messages
begin
while To_Be_Purged (First_Error_Msg) loop
First_Error_Msg := Errors.Table (First_Error_Msg).Next;
end loop;
E := First_Error_Msg;
while E /= No_Error_Msg loop
while To_Be_Purged (Errors.Table (E).Next) loop
Errors.Table (E).Next :=
Errors.Table (Errors.Table (E).Next).Next;
end loop;
E := Errors.Table (E).Next;
end loop;
end Purge_Messages;
----------------
-- Same_Error --
----------------
function Same_Error (M1, M2 : Error_Msg_Id) return Boolean is
Msg1 : constant String_Ptr := Errors.Table (M1).Text;
Msg2 : constant String_Ptr := Errors.Table (M2).Text;
Msg2_Len : constant Integer := Msg2'Length;
Msg1_Len : constant Integer := Msg1'Length;
begin
return
Msg1.all = Msg2.all
or else
(Msg1_Len - 10 > Msg2_Len
and then
Msg2.all = Msg1.all (1 .. Msg2_Len)
and then
Msg1 (Msg2_Len + 1 .. Msg2_Len + 10) = ", instance")
or else
(Msg2_Len - 10 > Msg1_Len
and then
Msg1.all = Msg2.all (1 .. Msg1_Len)
and then
Msg2 (Msg1_Len + 1 .. Msg1_Len + 10) = ", instance");
end Same_Error;
-------------------
-- Set_Msg_Blank --
-------------------
procedure Set_Msg_Blank is
begin
if Msglen > 0
and then Msg_Buffer (Msglen) /= ' '
and then Msg_Buffer (Msglen) /= '('
and then Msg_Buffer (Msglen) /= '-'
and then not Manual_Quote_Mode
then
Set_Msg_Char (' ');
end if;
end Set_Msg_Blank;
-------------------------------
-- Set_Msg_Blank_Conditional --
-------------------------------
procedure Set_Msg_Blank_Conditional is
begin
if Msglen > 0
and then Msg_Buffer (Msglen) /= ' '
and then Msg_Buffer (Msglen) /= '('
and then Msg_Buffer (Msglen) /= '"'
and then not Manual_Quote_Mode
then
Set_Msg_Char (' ');
end if;
end Set_Msg_Blank_Conditional;
------------------
-- Set_Msg_Char --
------------------
procedure Set_Msg_Char (C : Character) is
begin
-- The check for message buffer overflow is needed to deal with cases
-- where insertions get too long (in particular a child unit name can
-- be very long).
if Msglen < Max_Msg_Length then
Msglen := Msglen + 1;
Msg_Buffer (Msglen) := C;
end if;
end Set_Msg_Char;
---------------------------------
-- Set_Msg_Insertion_File_Name --
---------------------------------
procedure Set_Msg_Insertion_File_Name is
begin
if Error_Msg_File_1 = No_File then
null;
elsif Error_Msg_File_1 = Error_File_Name then
Set_Msg_Blank;
Set_Msg_Str ("<error>");
else
Set_Msg_Blank;
Get_Name_String (Error_Msg_File_1);
Set_Msg_Quote;
Set_Msg_Name_Buffer;
Set_Msg_Quote;
end if;
-- The following assignments ensure that the second and third {
-- insertion characters will correspond to the Error_Msg_File_2 and
-- Error_Msg_File_3 values and We suppress possible validity checks in
-- case operating in -gnatVa mode, and Error_Msg_File_2 or
-- Error_Msg_File_3 is not needed and has not been set.
declare
pragma Suppress (Range_Check);
begin
Error_Msg_File_1 := Error_Msg_File_2;
Error_Msg_File_2 := Error_Msg_File_3;
end;
end Set_Msg_Insertion_File_Name;
-----------------------------------
-- Set_Msg_Insertion_Line_Number --
-----------------------------------
procedure Set_Msg_Insertion_Line_Number (Loc, Flag : Source_Ptr) is
Sindex_Loc : Source_File_Index;
Sindex_Flag : Source_File_Index;
procedure Set_At;
-- Outputs "at " unless last characters in buffer are " from ". Certain
-- messages read better with from than at.
------------
-- Set_At --
------------
procedure Set_At is
begin
if Msglen < 6
or else Msg_Buffer (Msglen - 5 .. Msglen) /= " from "
then
Set_Msg_Str ("at ");
end if;
end Set_At;
-- Start of processing for Set_Msg_Insertion_Line_Number
begin
Set_Msg_Blank;
if Loc = No_Location then
Set_At;
Set_Msg_Str ("unknown location");
elsif Loc = System_Location then
Set_Msg_Str ("in package System");
Set_Msg_Insertion_Run_Time_Name;
elsif Loc = Standard_Location then
Set_Msg_Str ("in package Standard");
elsif Loc = Standard_ASCII_Location then
Set_Msg_Str ("in package Standard.ASCII");
else
-- Add "at file-name:" if reference is to other than the source
-- file in which the error message is placed. Note that we check
-- full file names, rather than just the source indexes, to
-- deal with generic instantiations from the current file.
Sindex_Loc := Get_Source_File_Index (Loc);
Sindex_Flag := Get_Source_File_Index (Flag);
if Full_File_Name (Sindex_Loc) /= Full_File_Name (Sindex_Flag) then
Set_At;
Get_Name_String
(Reference_Name (Get_Source_File_Index (Loc)));
Set_Msg_Name_Buffer;
Set_Msg_Char (':');
-- If in current file, add text "at line "
else
Set_At;
Set_Msg_Str ("line ");
end if;
-- Output line number for reference
Set_Msg_Int (Int (Get_Logical_Line_Number (Loc)));
-- Deal with the instantiation case. We may have a reference to,
-- e.g. a type, that is declared within a generic template, and
-- what we are really referring to is the occurrence in an instance.
-- In this case, the line number of the instantiation is also of
-- interest, and we add a notation:
-- , instance at xxx
-- where xxx is a line number output using this same routine (and
-- the recursion can go further if the instantiation is itself in
-- a generic template).
-- The flag location passed to us in this situation is indeed the
-- line number within the template, but as described in Sinput.L
-- (file sinput-l.ads, section "Handling Generic Instantiations")
-- we can retrieve the location of the instantiation itself from
-- this flag location value.
-- Note: this processing is suppressed if Suppress_Instance_Location
-- is set True. This is used to prevent redundant annotations of the
-- location of the instantiation in the case where we are placing
-- the messages on the instantiation in any case.
if Instantiation (Sindex_Loc) /= No_Location
and then not Suppress_Instance_Location
then
Set_Msg_Str (", instance ");
Set_Msg_Insertion_Line_Number (Instantiation (Sindex_Loc), Flag);
end if;
end if;
end Set_Msg_Insertion_Line_Number;
----------------------------
-- Set_Msg_Insertion_Name --
----------------------------
procedure Set_Msg_Insertion_Name is
begin
if Error_Msg_Name_1 = No_Name then
null;
elsif Error_Msg_Name_1 = Error_Name then
Set_Msg_Blank;
Set_Msg_Str ("<error>");
else
Set_Msg_Blank_Conditional;
Get_Unqualified_Decoded_Name_String (Error_Msg_Name_1);
-- Remove %s or %b at end. These come from unit names. If the
-- caller wanted the (unit) or (body), then they would have used
-- the $ insertion character. Certainly no error message should
-- ever have %b or %s explicitly occurring.
if Name_Len > 2
and then Name_Buffer (Name_Len - 1) = '%'
and then (Name_Buffer (Name_Len) = 'b'
or else
Name_Buffer (Name_Len) = 's')
then
Name_Len := Name_Len - 2;
end if;
-- Remove upper case letter at end, again, we should not be getting
-- such names, and what we hope is that the remainder makes sense.
if Name_Len > 1 and then Name_Buffer (Name_Len) in 'A' .. 'Z' then
Name_Len := Name_Len - 1;
end if;
-- If operator name or character literal name, just print it as is
-- Also print as is if it ends in a right paren (case of x'val(nnn))
if Name_Buffer (1) = '"'
or else Name_Buffer (1) = '''
or else Name_Buffer (Name_Len) = ')'
then
Set_Msg_Name_Buffer;
-- Else output with surrounding quotes in proper casing mode
else
Set_Casing (Identifier_Casing (Flag_Source), Mixed_Case);
Set_Msg_Quote;
Set_Msg_Name_Buffer;
Set_Msg_Quote;
end if;
end if;
-- The following assignments ensure that the second and third percent
-- insertion characters will correspond to the Error_Msg_Name_2 and
-- Error_Msg_Name_3 as required. We suppress possible validity checks in
-- case operating in -gnatVa mode, and Error_Msg_Name_1/2 is not needed
-- and has not been set.
declare
pragma Suppress (Range_Check);
begin
Error_Msg_Name_1 := Error_Msg_Name_2;
Error_Msg_Name_2 := Error_Msg_Name_3;
end;
end Set_Msg_Insertion_Name;
------------------------------------
-- Set_Msg_Insertion_Name_Literal --
------------------------------------
procedure Set_Msg_Insertion_Name_Literal is
begin
if Error_Msg_Name_1 = No_Name then
null;
elsif Error_Msg_Name_1 = Error_Name then
Set_Msg_Blank;
Set_Msg_Str ("<error>");
else
Set_Msg_Blank;
Get_Name_String (Error_Msg_Name_1);
Set_Msg_Quote;
Set_Msg_Name_Buffer;
Set_Msg_Quote;
end if;
-- The following assignments ensure that the second and third % or %%
-- insertion characters will correspond to the Error_Msg_Name_2 and
-- Error_Msg_Name_3 values and We suppress possible validity checks in
-- case operating in -gnatVa mode, and Error_Msg_Name_2 or
-- Error_Msg_Name_3 is not needed and has not been set.
declare
pragma Suppress (Range_Check);
begin
Error_Msg_Name_1 := Error_Msg_Name_2;
Error_Msg_Name_2 := Error_Msg_Name_3;
end;
end Set_Msg_Insertion_Name_Literal;
-------------------------------------
-- Set_Msg_Insertion_Reserved_Name --
-------------------------------------
procedure Set_Msg_Insertion_Reserved_Name is
begin
Set_Msg_Blank_Conditional;
Get_Name_String (Error_Msg_Name_1);
Set_Msg_Quote;
Set_Casing (Keyword_Casing (Flag_Source), All_Lower_Case);
Set_Msg_Name_Buffer;
Set_Msg_Quote;
end Set_Msg_Insertion_Reserved_Name;
-------------------------------------
-- Set_Msg_Insertion_Reserved_Word --
-------------------------------------
procedure Set_Msg_Insertion_Reserved_Word
(Text : String;
J : in out Integer)
is
begin
Set_Msg_Blank_Conditional;
Name_Len := 0;
while J <= Text'Last and then Text (J) in 'A' .. 'Z' loop
Add_Char_To_Name_Buffer (Text (J));
J := J + 1;
end loop;
-- Here is where we make the special exception for RM
if Name_Len = 2 and then Name_Buffer (1 .. 2) = "RM" then
Set_Msg_Name_Buffer;
-- We make a similar exception for SPARK
elsif Name_Len = 5 and then Name_Buffer (1 .. 5) = "SPARK" then
Set_Msg_Name_Buffer;
-- Neither RM nor SPARK: case appropriately and add surrounding quotes
else
Set_Casing (Keyword_Casing (Flag_Source), All_Lower_Case);
Set_Msg_Quote;
Set_Msg_Name_Buffer;
Set_Msg_Quote;
end if;
end Set_Msg_Insertion_Reserved_Word;
-------------------------------------
-- Set_Msg_Insertion_Run_Time_Name --
-------------------------------------
procedure Set_Msg_Insertion_Run_Time_Name is
begin
if Targparm.Run_Time_Name_On_Target /= No_Name then
Set_Msg_Blank_Conditional;
Set_Msg_Char ('(');
Get_Name_String (Targparm.Run_Time_Name_On_Target);
Set_Casing (Mixed_Case);
Set_Msg_Str (Name_Buffer (1 .. Name_Len));
Set_Msg_Char (')');
end if;
end Set_Msg_Insertion_Run_Time_Name;
----------------------------
-- Set_Msg_Insertion_Uint --
----------------------------
procedure Set_Msg_Insertion_Uint is
begin
Set_Msg_Blank;
UI_Image (Error_Msg_Uint_1);
for J in 1 .. UI_Image_Length loop
Set_Msg_Char (UI_Image_Buffer (J));
end loop;
-- The following assignment ensures that a second caret insertion
-- character will correspond to the Error_Msg_Uint_2 parameter. We
-- suppress possible validity checks in case operating in -gnatVa mode,
-- and Error_Msg_Uint_2 is not needed and has not been set.
declare
pragma Suppress (Range_Check);
begin
Error_Msg_Uint_1 := Error_Msg_Uint_2;
end;
end Set_Msg_Insertion_Uint;
-----------------
-- Set_Msg_Int --
-----------------
procedure Set_Msg_Int (Line : Int) is
begin
if Line > 9 then
Set_Msg_Int (Line / 10);
end if;
Set_Msg_Char (Character'Val (Character'Pos ('0') + (Line rem 10)));
end Set_Msg_Int;
-------------------------
-- Set_Msg_Name_Buffer --
-------------------------
procedure Set_Msg_Name_Buffer is
begin
Set_Msg_Str (Name_Buffer (1 .. Name_Len));
end Set_Msg_Name_Buffer;
-------------------
-- Set_Msg_Quote --
-------------------
procedure Set_Msg_Quote is
begin
if not Manual_Quote_Mode then
Set_Msg_Char ('"');
end if;
end Set_Msg_Quote;
-----------------
-- Set_Msg_Str --
-----------------
procedure Set_Msg_Str (Text : String) is
begin
-- Do replacement for special x'Class aspect names
if Text = "_Pre" then
Set_Msg_Str ("Pre'Class");
elsif Text = "_Post" then
Set_Msg_Str ("Post'Class");
elsif Text = "_Type_Invariant" then
Set_Msg_Str ("Type_Invariant'Class");
elsif Text = "_pre" then
Set_Msg_Str ("pre'class");
elsif Text = "_post" then
Set_Msg_Str ("post'class");
elsif Text = "_type_invariant" then
Set_Msg_Str ("type_invariant'class");
elsif Text = "_PRE" then
Set_Msg_Str ("PRE'CLASS");
elsif Text = "_POST" then
Set_Msg_Str ("POST'CLASS");
elsif Text = "_TYPE_INVARIANT" then
Set_Msg_Str ("TYPE_INVARIANT'CLASS");
-- Normal case with no replacement
else
for J in Text'Range loop
Set_Msg_Char (Text (J));
end loop;
end if;
end Set_Msg_Str;
------------------------------
-- Set_Next_Non_Deleted_Msg --
------------------------------
procedure Set_Next_Non_Deleted_Msg (E : in out Error_Msg_Id) is
begin
if E = No_Error_Msg then
return;
else
loop
E := Errors.Table (E).Next;
exit when E = No_Error_Msg or else not Errors.Table (E).Deleted;
end loop;
end if;
end Set_Next_Non_Deleted_Msg;
------------------------------
-- Set_Specific_Warning_Off --
------------------------------
procedure Set_Specific_Warning_Off
(Loc : Source_Ptr;
Msg : String;
Reason : String_Id;
Config : Boolean;
Used : Boolean := False)
is
begin
Specific_Warnings.Append
((Start => Loc,
Msg => new String'(Msg),
Stop => Source_Last (Current_Source_File),
Reason => Reason,
Open => True,
Used => Used,
Config => Config));
end Set_Specific_Warning_Off;
-----------------------------
-- Set_Specific_Warning_On --
-----------------------------
procedure Set_Specific_Warning_On
(Loc : Source_Ptr;
Msg : String;
Err : out Boolean)
is
begin
for J in 1 .. Specific_Warnings.Last loop
declare
SWE : Specific_Warning_Entry renames Specific_Warnings.Table (J);
begin
if Msg = SWE.Msg.all
and then Loc > SWE.Start
and then SWE.Open
and then Get_Source_File_Index (SWE.Start) =
Get_Source_File_Index (Loc)
then
SWE.Stop := Loc;
SWE.Open := False;
Err := False;
-- If a config pragma is specifically cancelled, consider
-- that it is no longer active as a configuration pragma.
SWE.Config := False;
return;
end if;
end;
end loop;
Err := True;
end Set_Specific_Warning_On;
---------------------------
-- Set_Warnings_Mode_Off --
---------------------------
procedure Set_Warnings_Mode_Off (Loc : Source_Ptr; Reason : String_Id) is
begin
-- Don't bother with entries from instantiation copies, since we will
-- already have a copy in the template, which is what matters.
if Instantiation (Get_Source_File_Index (Loc)) /= No_Location then
return;
end if;
-- If all warnings are suppressed by command line switch, this can
-- be ignored, unless we are in GNATprove_Mode which requires pragma
-- Warnings to be stored for the formal verification backend.
if Warning_Mode = Suppress
and then not GNATprove_Mode
then
return;
end if;
-- If last entry in table already covers us, this is a redundant pragma
-- Warnings (Off) and can be ignored.
if Warnings.Last >= Warnings.First
and then Warnings.Table (Warnings.Last).Start <= Loc
and then Loc <= Warnings.Table (Warnings.Last).Stop
then
return;
end if;
-- If none of those special conditions holds, establish a new entry,
-- extending from the location of the pragma to the end of the current
-- source file. This ending point will be adjusted by a subsequent
-- corresponding pragma Warnings (On).
Warnings.Append
((Start => Loc,
Stop => Source_Last (Current_Source_File),
Reason => Reason));
end Set_Warnings_Mode_Off;
--------------------------
-- Set_Warnings_Mode_On --
--------------------------
procedure Set_Warnings_Mode_On (Loc : Source_Ptr) is
begin
-- Don't bother with entries from instantiation copies, since we will
-- already have a copy in the template, which is what matters.
if Instantiation (Get_Source_File_Index (Loc)) /= No_Location then
return;
end if;
-- If all warnings are suppressed by command line switch, this can
-- be ignored, unless we are in GNATprove_Mode which requires pragma
-- Warnings to be stored for the formal verification backend.
if Warning_Mode = Suppress
and then not GNATprove_Mode
then
return;
end if;
-- If the last entry in the warnings table covers this pragma, then
-- we adjust the end point appropriately.
if Warnings.Last >= Warnings.First
and then Warnings.Table (Warnings.Last).Start <= Loc
and then Loc <= Warnings.Table (Warnings.Last).Stop
then
Warnings.Table (Warnings.Last).Stop := Loc;
end if;
end Set_Warnings_Mode_On;
--------------------------------
-- Validate_Specific_Warnings --
--------------------------------
procedure Validate_Specific_Warnings (Eproc : Error_Msg_Proc) is
begin
if not Warn_On_Warnings_Off then
return;
end if;
for J in Specific_Warnings.First .. Specific_Warnings.Last loop
declare
SWE : Specific_Warning_Entry renames Specific_Warnings.Table (J);
begin
if not SWE.Config then
-- Warn for unmatched Warnings (Off, ...)
if SWE.Open then
Eproc.all
("?W?pragma Warnings Off with no matching Warnings On",
SWE.Start);
-- Warn for ineffective Warnings (Off, ..)
elsif not SWE.Used
-- Do not issue this warning for -Wxxx messages since the
-- back-end doesn't report the information. Note that there
-- is always an asterisk at the start of every message.
and then not
(SWE.Msg'Length > 3 and then SWE.Msg (2 .. 3) = "-W")
then
Eproc.all
("?W?no warning suppressed by this pragma", SWE.Start);
end if;
end if;
end;
end loop;
end Validate_Specific_Warnings;
-------------------------------------
-- Warning_Specifically_Suppressed --
-------------------------------------
function Warning_Specifically_Suppressed
(Loc : Source_Ptr;
Msg : String_Ptr;
Tag : String := "") return String_Id
is
begin
-- Loop through specific warning suppression entries
for J in Specific_Warnings.First .. Specific_Warnings.Last loop
declare
SWE : Specific_Warning_Entry renames Specific_Warnings.Table (J);
begin
-- Pragma applies if it is a configuration pragma, or if the
-- location is in range of a specific non-configuration pragma.
if SWE.Config
or else (SWE.Start <= Loc and then Loc <= SWE.Stop)
then
if Matches (Msg.all, SWE.Msg.all)
or else Matches (Tag, SWE.Msg.all)
then
SWE.Used := True;
return SWE.Reason;
end if;
end if;
end;
end loop;
return No_String;
end Warning_Specifically_Suppressed;
------------------------------
-- Warning_Treated_As_Error --
------------------------------
function Warning_Treated_As_Error (Msg : String) return Boolean is
begin
for J in 1 .. Warnings_As_Errors_Count loop
if Matches (Msg, Warnings_As_Errors (J).all) then
return True;
end if;
end loop;
return False;
end Warning_Treated_As_Error;
-------------------------
-- Warnings_Suppressed --
-------------------------
function Warnings_Suppressed (Loc : Source_Ptr) return String_Id is
begin
-- Loop through table of ON/OFF warnings
for J in Warnings.First .. Warnings.Last loop
if Warnings.Table (J).Start <= Loc
and then Loc <= Warnings.Table (J).Stop
then
return Warnings.Table (J).Reason;
end if;
end loop;
if Warning_Mode = Suppress then
return Null_String_Id;
else
return No_String;
end if;
end Warnings_Suppressed;
end Erroutc;
|
-----------------------------------------------------------------------
-- awa-settings -- Settings module
-- Copyright (C) 2013 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Util.Strings;
with AWA.Settings.Modules;
package body AWA.Settings is
-- ------------------------------
-- Get the user setting identified by the given name.
-- If the user does not have such setting, return the default value.
-- ------------------------------
function Get_User_Setting (Name : in String;
Default : in String) return String is
Mgr : constant AWA.Settings.Modules.Setting_Manager_Access := AWA.Settings.Modules.Current;
Value : Ada.Strings.Unbounded.Unbounded_String;
begin
Mgr.Get (Name, Default, Value);
return Ada.Strings.Unbounded.To_String (Value);
end Get_User_Setting;
-- ------------------------------
-- Get the user setting identified by the given name.
-- If the user does not have such setting, return the default value.
-- ------------------------------
function Get_User_Setting (Name : in String;
Default : in Integer) return Integer is
Mgr : constant AWA.Settings.Modules.Setting_Manager_Access := AWA.Settings.Modules.Current;
Value : Ada.Strings.Unbounded.Unbounded_String;
begin
Mgr.Get (Name, Integer'Image (Default), Value);
return Integer'Value (Ada.Strings.Unbounded.To_String (Value));
end Get_User_Setting;
-- ------------------------------
-- Set the user setting identified by the given name. If the user
-- does not have such setting, it is created and set to the given value.
-- Otherwise, the user setting is updated to hold the new value.
-- ------------------------------
procedure Set_User_Setting (Name : in String;
Value : in String) is
Mgr : constant AWA.Settings.Modules.Setting_Manager_Access := AWA.Settings.Modules.Current;
begin
Mgr.Set (Name, Value);
end Set_User_Setting;
-- ------------------------------
-- Set the user setting identified by the given name. If the user
-- does not have such setting, it is created and set to the given value.
-- Otherwise, the user setting is updated to hold the new value.
-- ------------------------------
procedure Set_User_Setting (Name : in String;
Value : in Integer) is
Mgr : constant AWA.Settings.Modules.Setting_Manager_Access := AWA.Settings.Modules.Current;
begin
Mgr.Set (Name, Util.Strings.Image (Value));
end Set_User_Setting;
end AWA.Settings;
|
-------------------------------------------------------------------------------
-- This file is part of libsparkcrypto.
--
-- Copyright (C) 2012, Stefan Berghofer
-- Copyright (C) 2012, secunet Security Networks AG
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
--
-- * Neither the name of the author nor the names of its contributors may be
-- used to endorse or promote products derived from this software without
-- specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
-- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with LSC.Internal.Types;
with LSC.Internal.Bignum;
with LSC.Internal.EC;
with LSC.Internal.Math_Int;
use type LSC.Internal.Math_Int.Math_Int;
use type LSC.Internal.Types.Word32;
package LSC.Internal.EC_Signature
is
pragma Pure;
type Signature_Type is (ECDSA, ECGDSA);
procedure Sign
(Sign1 : out Bignum.Big_Int;
Sign1_First : in Natural;
Sign1_Last : in Natural;
Sign2 : out Bignum.Big_Int;
Sign2_First : in Natural;
Hash : in Bignum.Big_Int;
Hash_First : in Natural;
Rand : in Bignum.Big_Int;
Rand_First : in Natural;
T : in Signature_Type;
Priv : in Bignum.Big_Int;
Priv_First : in Natural;
BX : in Bignum.Big_Int;
BX_First : in Natural;
BY : in Bignum.Big_Int;
BY_First : in Natural;
A : in Bignum.Big_Int;
A_First : in Natural;
M : in Bignum.Big_Int;
M_First : in Natural;
M_Inv : in Types.Word32;
RM : in Bignum.Big_Int;
RM_First : in Natural;
N : in Bignum.Big_Int;
N_First : in Natural;
N_Inv : in Types.Word32;
RN : in Bignum.Big_Int;
RN_First : in Natural;
Success : out Boolean)
with
Depends =>
(Sign1 =>+
(Sign1_First, Sign1_Last, Rand, Rand_First,
BX, BX_First, BY, BY_First, A, A_First,
M, M_First, M_Inv, RM, RM_First,
N, N_First, N_Inv, RN, RN_First),
(Sign2, Success) =>
(Sign1, Sign1_First, Sign1_Last, Sign2, Sign2_First,
Hash, Hash_First, Rand, Rand_First,
T, Priv, Priv_First, BX, BX_First, BY, BY_First, A, A_First,
M, M_First, M_Inv, RM, RM_First,
N, N_First, N_Inv, RN, RN_First)),
Pre =>
Sign1_First in Sign1'Range and then
Sign1_Last in Sign1'Range and then
Sign1_First < Sign1_Last and then
Sign1_Last - Sign1_First < EC.Max_Coord_Length and then
Sign2_First in Sign2'Range and then
Sign2_First + (Sign1_Last - Sign1_First) in Sign2'Range and then
Hash_First in Hash'Range and then
Hash_First + (Sign1_Last - Sign1_First) in Hash'Range and then
Rand_First in Rand'Range and then
Rand_First + (Sign1_Last - Sign1_First) in Rand'Range and then
Priv_First in Priv'Range and then
Priv_First + (Sign1_Last - Sign1_First) in Priv'Range and then
BX_First in BX'Range and then
BX_First + (Sign1_Last - Sign1_First) in BX'Range and then
BY_First in BY'Range and then
BY_First + (Sign1_Last - Sign1_First) in BY'Range and then
A_First in A'Range and then
A_First + (Sign1_Last - Sign1_First) in A'Range and then
M_First in M'Range and then
M_First + (Sign1_Last - Sign1_First) in M'Range and then
RM_First in RM'Range and then
RM_First + (Sign1_Last - Sign1_First) in RM'Range and then
N_First in N'Range and then
N_First + (Sign1_Last - Sign1_First) in N'Range and then
RN_First in RN'Range and then
RN_First + (Sign1_Last - Sign1_First) in RN'Range and then
Bignum.Num_Of_Big_Int (BX, BX_First, Sign1_Last - Sign1_First + 1) <
Bignum.Num_Of_Big_Int (M, M_First, Sign1_Last - Sign1_First + 1) and then
Bignum.Num_Of_Big_Int (BY, BY_First, Sign1_Last - Sign1_First + 1) <
Bignum.Num_Of_Big_Int (M, M_First, Sign1_Last - Sign1_First + 1) and then
Bignum.Num_Of_Big_Int (A, A_First, Sign1_Last - Sign1_First + 1) <
Bignum.Num_Of_Big_Int (M, M_First, Sign1_Last - Sign1_First + 1) and then
Math_Int.From_Word32 (1) <
Bignum.Num_Of_Big_Int (M, M_First, Sign1_Last - Sign1_First + 1) and then
1 + M_Inv * M (M_First) = 0 and then
Math_Int.From_Word32 (1) <
Bignum.Num_Of_Big_Int (N, N_First, Sign1_Last - Sign1_First + 1) and then
1 + N_Inv * N (N_First) = 0 and then
Bignum.Num_Of_Big_Int (RM, RM_First, Sign1_Last - Sign1_First + 1) =
Bignum.Base ** (Math_Int.From_Integer (2) *
Math_Int.From_Integer (Sign1_Last - Sign1_First + 1)) mod
Bignum.Num_Of_Big_Int (M, M_First, Sign1_Last - Sign1_First + 1) and then
Bignum.Num_Of_Big_Int (RN, RN_First, Sign1_Last - Sign1_First + 1) =
Bignum.Base ** (Math_Int.From_Integer (2) *
Math_Int.From_Integer (Sign1_Last - Sign1_First + 1)) mod
Bignum.Num_Of_Big_Int (N, N_First, Sign1_Last - Sign1_First + 1),
Post =>
(if Success then
(Math_Int.From_Word32 (0) < Bignum.Num_Of_Big_Int
(Sign1, Sign1_First, Sign1_Last - Sign1_First + 1) and
Bignum.Num_Of_Big_Int
(Sign1, Sign1_First, Sign1_Last - Sign1_First + 1) <
Bignum.Num_Of_Big_Int (N, N_First, Sign1_Last - Sign1_First + 1) and
Math_Int.From_Word32 (0) < Bignum.Num_Of_Big_Int
(Sign2, Sign2_First, Sign1_Last - Sign1_First + 1) and
Bignum.Num_Of_Big_Int
(Sign2, Sign2_First, Sign1_Last - Sign1_First + 1) <
Bignum.Num_Of_Big_Int (N, N_First, Sign1_Last - Sign1_First + 1)));
function Verify
(Sign1 : Bignum.Big_Int;
Sign1_First : Natural;
Sign1_Last : Natural;
Sign2 : Bignum.Big_Int;
Sign2_First : Natural;
Hash : Bignum.Big_Int;
Hash_First : Natural;
T : Signature_Type;
PubX : Bignum.Big_Int;
PubX_First : Natural;
PubY : Bignum.Big_Int;
PubY_First : Natural;
BX : Bignum.Big_Int;
BX_First : Natural;
BY : Bignum.Big_Int;
BY_First : Natural;
A : Bignum.Big_Int;
A_First : Natural;
M : Bignum.Big_Int;
M_First : Natural;
M_Inv : Types.Word32;
RM : Bignum.Big_Int;
RM_First : Natural;
N : Bignum.Big_Int;
N_First : Natural;
N_Inv : Types.Word32;
RN : Bignum.Big_Int;
RN_First : Natural)
return Boolean
with
Pre =>
Sign1_First in Sign1'Range and then
Sign1_Last in Sign1'Range and then
Sign1_First < Sign1_Last and then
Sign1_Last - Sign1_First < EC.Max_Coord_Length and then
Sign2_First in Sign2'Range and then
Sign2_First + (Sign1_Last - Sign1_First) in Sign2'Range and then
Hash_First in Hash'Range and then
Hash_First + (Sign1_Last - Sign1_First) in Hash'Range and then
PubX_First in PubX'Range and then
PubX_First + (Sign1_Last - Sign1_First) in PubX'Range and then
PubY_First in PubY'Range and then
PubY_First + (Sign1_Last - Sign1_First) in PubY'Range and then
BX_First in BX'Range and then
BX_First + (Sign1_Last - Sign1_First) in BX'Range and then
BY_First in BY'Range and then
BY_First + (Sign1_Last - Sign1_First) in BY'Range and then
A_First in A'Range and then
A_First + (Sign1_Last - Sign1_First) in A'Range and then
M_First in M'Range and then
M_First + (Sign1_Last - Sign1_First) in M'Range and then
RM_First in RM'Range and then
RM_First + (Sign1_Last - Sign1_First) in RM'Range and then
N_First in N'Range and then
N_First + (Sign1_Last - Sign1_First) in N'Range and then
RN_First in RN'Range and then
RN_First + (Sign1_Last - Sign1_First) in RN'Range and then
Bignum.Num_Of_Big_Int (PubX, PubX_First, Sign1_Last - Sign1_First + 1) <
Bignum.Num_Of_Big_Int (M, M_First, Sign1_Last - Sign1_First + 1) and then
Bignum.Num_Of_Big_Int (PubY, PubY_First, Sign1_Last - Sign1_First + 1) <
Bignum.Num_Of_Big_Int (M, M_First, Sign1_Last - Sign1_First + 1) and then
Bignum.Num_Of_Big_Int (BX, BX_First, Sign1_Last - Sign1_First + 1) <
Bignum.Num_Of_Big_Int (M, M_First, Sign1_Last - Sign1_First + 1) and then
Bignum.Num_Of_Big_Int (BY, BY_First, Sign1_Last - Sign1_First + 1) <
Bignum.Num_Of_Big_Int (M, M_First, Sign1_Last - Sign1_First + 1) and then
Bignum.Num_Of_Big_Int (A, A_First, Sign1_Last - Sign1_First + 1) <
Bignum.Num_Of_Big_Int (M, M_First, Sign1_Last - Sign1_First + 1) and then
Math_Int.From_Word32 (1) <
Bignum.Num_Of_Big_Int (M, M_First, Sign1_Last - Sign1_First + 1) and then
1 + M_Inv * M (M_First) = 0 and then
Math_Int.From_Word32 (1) <
Bignum.Num_Of_Big_Int (N, N_First, Sign1_Last - Sign1_First + 1) and then
1 + N_Inv * N (N_First) = 0 and then
Bignum.Num_Of_Big_Int (RM, RM_First, Sign1_Last - Sign1_First + 1) =
Bignum.Base ** (Math_Int.From_Integer (2) *
Math_Int.From_Integer (Sign1_Last - Sign1_First + 1)) mod
Bignum.Num_Of_Big_Int (M, M_First, Sign1_Last - Sign1_First + 1) and then
Bignum.Num_Of_Big_Int (RN, RN_First, Sign1_Last - Sign1_First + 1) =
Bignum.Base ** (Math_Int.From_Integer (2) *
Math_Int.From_Integer (Sign1_Last - Sign1_First + 1)) mod
Bignum.Num_Of_Big_Int (N, N_First, Sign1_Last - Sign1_First + 1);
end LSC.Internal.EC_Signature;
|
-----------------------------------------------------------------------
-- asf-beans-mappers -- Read XML managed bean declaratiosn
-- Copyright (C) 2010, 2011, 2017, 2019 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body ASF.Beans.Mappers is
Empty : constant Util.Beans.Objects.Object := Util.Beans.Objects.To_Object (String '(""));
Empty_Params : ASF.Beans.Parameter_Bean_Ref.Ref;
-- ------------------------------
-- Set the field identified by <b>Field</b> with the <b>Value</b>.
-- ------------------------------
procedure Set_Member (MBean : in out Managed_Bean;
Field : in Managed_Bean_Fields;
Value : in Util.Beans.Objects.Object) is
begin
case Field is
when FIELD_NAME =>
MBean.Name := Value;
when FIELD_CLASS =>
MBean.Class := Value;
when FIELD_SCOPE =>
declare
Scope : constant String := Util.Beans.Objects.To_String (Value);
begin
if Scope = "request" then
MBean.Scope := REQUEST_SCOPE;
elsif Scope = "session" then
MBean.Scope := SESSION_SCOPE;
elsif Scope = "application" then
MBean.Scope := APPLICATION_SCOPE;
else
raise Util.Serialize.Mappers.Field_Error with "Invalid scope: " & Scope;
end if;
end;
when FIELD_PROPERTY_NAME =>
MBean.Prop_Name := Value;
when FIELD_PROPERTY_VALUE =>
MBean.Prop_Value := Value;
when FIELD_PROPERTY_CLASS =>
null;
when FIELD_PROPERTY =>
-- Create the parameter list only the first time a property is seen.
if MBean.Params.Is_Null then
MBean.Params := ASF.Beans.Parameter_Bean_Ref.Create (new ASF.Beans.Parameter_Bean);
end if;
-- Add the parameter. The property value is parsed as an EL expression.
EL.Beans.Add_Parameter (MBean.Params.Value.Params,
Util.Beans.Objects.To_String (MBean.Prop_Name),
Util.Beans.Objects.To_String (MBean.Prop_Value),
MBean.Context.all);
MBean.Prop_Name := Empty;
MBean.Prop_Value := Empty;
when FIELD_MANAGED_BEAN =>
declare
Name : constant String := Util.Beans.Objects.To_String (MBean.Name);
Class : constant String := Util.Beans.Objects.To_String (MBean.Class);
begin
Register (Factory => MBean.Factory.all,
Name => Name,
Class => Class,
Params => MBean.Params,
Scope => MBean.Scope);
end;
MBean.Name := Empty;
MBean.Class := Empty;
MBean.Scope := REQUEST_SCOPE;
MBean.Params := Empty_Params;
end case;
end Set_Member;
MBean_Mapping : aliased Config_Mapper.Mapper;
-- ------------------------------
-- Setup the XML parser to read the managed bean definitions.
-- ------------------------------
package body Reader_Config is
begin
Mapper.Add_Mapping ("faces-config", MBean_Mapping'Access);
Mapper.Add_Mapping ("module", MBean_Mapping'Access);
Mapper.Add_Mapping ("web-app", MBean_Mapping'Access);
Config.Factory := Factory;
Config.Context := Context;
Config_Mapper.Set_Context (Mapper, Config'Unchecked_Access);
end Reader_Config;
begin
-- <managed-bean> mapping
MBean_Mapping.Add_Mapping ("managed-bean", FIELD_MANAGED_BEAN);
MBean_Mapping.Add_Mapping ("managed-bean/managed-bean-name", FIELD_NAME);
MBean_Mapping.Add_Mapping ("managed-bean/managed-bean-class", FIELD_CLASS);
MBean_Mapping.Add_Mapping ("managed-bean/managed-bean-scope", FIELD_SCOPE);
MBean_Mapping.Add_Mapping ("managed-bean/managed-property/property-name", FIELD_PROPERTY_NAME);
MBean_Mapping.Add_Mapping ("managed-bean/managed-property/value", FIELD_PROPERTY_VALUE);
MBean_Mapping.Add_Mapping ("managed-bean/managed-property/property-class",
FIELD_PROPERTY_CLASS);
MBean_Mapping.Add_Mapping ("managed-bean/managed-property", FIELD_PROPERTY);
end ASF.Beans.Mappers;
|
with AUnit.Reporter.Text;
with AUnit.Run;
with PBKDF2.Tests;
procedure PBKDF2_Tests is
procedure Runner is new AUnit.Run.Test_Runner (PBKDF2.Tests.Suite);
Reporter : AUnit.Reporter.Text.Text_Reporter;
begin
Reporter.Set_Use_ANSI_Colors (True);
Runner (Reporter);
end PBKDF2_Tests;
|
-----------------------------------------------------------------------
-- servlet-core-configs -- Read servlet configuration files
-- Copyright (C) 2018 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Servlet.Core.Mappers;
with Util.Serialize.IO.XML;
with Util.Serialize.Mappers;
with EL.Contexts.Default;
package body Servlet.Core.Configs is
-- ------------------------------
-- Read the configuration file associated with the servlet container.
-- ------------------------------
procedure Read_Configuration (App : in out Servlet_Registry'Class;
File : in String) is
Reader : Util.Serialize.IO.XML.Parser;
Mapper : Util.Serialize.Mappers.Processing;
Context : aliased EL.Contexts.Default.Default_Context;
-- Setup the <b>Reader</b> to parse and build the configuration for managed beans,
-- navigation rules, servlet rules. Each package instantiation creates a local variable
-- used while parsing the XML file.
package Config is
new Mappers.Reader_Config (Mapper, App'Unchecked_Access, Context'Unchecked_Access);
pragma Warnings (Off, Config);
begin
-- Read the configuration file and record managed beans, navigation rules.
Reader.Parse (File, Mapper);
end Read_Configuration;
end Servlet.Core.Configs;
|
with ada.text_io, ada.integer_text_io;
use ada.text_io, ada.integer_text_io;
with ada.text_io, ada.integer_text_io;
use ada.text_io, ada.integer_text_io;
with multiplosdetres;
procedure prueba_multiplosdetres is
n1, n2, resultado :integer:=0;
begin
-- caso de prueba 1:
n1:=5;
n2:=15;
put("El resultado deberia de ser 6 9 12 15 y la suma 42:");
new_line;
put("Y tu programa dice que:");
multiplosdetres(n1, n2, resultado);
put(resultado);
new_line;
-- caso de prueba 2:
n1:=3;
n2:=3;
put("El resultado deberia de ser 3 y la suma 3:");
new_line;
put("Y tu programa dice que:");
multiplosdetres(n1, n2, resultado);
put(resultado);
new_line;
-- caso de prueba 3:
n1:=2;
n2:=10;
put("El resultado deberia de ser 3 6 9 y la suma 18:");
new_line;
put("Y tu programa dice que:");
multiplosdetres(n1, n2, resultado);
put(resultado);
new_line;
-- caso de prueba 4:
n1:=-6;
n2:=6;
put("El resultado deberia de ser -6 -3 0 3 6 y la suma 0:");
new_line;
put("Y tu programa dice que:");
multiplosdetres(n1, n2, resultado);
put(resultado);
new_line;
end prueba_multiplosdetres;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Read_And_Write_File_Line_By_Line is
Input, Output : File_Type;
begin
Open (File => Input,
Mode => In_File,
Name => "input.txt");
Create (File => Output,
Mode => Out_File,
Name => "output.txt");
loop
declare
Line : String := Get_Line (Input);
begin
-- You can process the contents of Line here.
Put_Line (Output, Line);
end;
end loop;
Close (Input);
Close (Output);
exception
when End_Error =>
if Is_Open(Input) then
Close (Input);
end if;
if Is_Open(Output) then
Close (Output);
end if;
end Read_And_Write_File_Line_By_Line;
|
with Ada.Exceptions.Finally;
with Ada.Unchecked_Deallocation;
package body Ada.Command_Line.Generic_Parsing is
pragma Check_Policy (Trace => Ignore);
procedure Retain (Context : not null Argument_Context_Access);
procedure Retain (Context : not null Argument_Context_Access) is
begin
Context.Reference_Count := Context.Reference_Count + 1;
end Retain;
procedure Release (Context : in out Argument_Context_Access);
procedure Release (Context : in out Argument_Context_Access) is
procedure Free is
new Unchecked_Deallocation (String, String_Access);
procedure Free is
new Unchecked_Deallocation (
Argument_Parsing.Argument_Iterator,
Argument_Iterator_Access);
procedure Free is
new Unchecked_Deallocation (
Argument_Context,
Argument_Context_Access);
begin
Context.Reference_Count := Context.Reference_Count - 1;
if Context.Reference_Count <= 0 then
pragma Check (Trace, Debug.Put ("deallocate"));
Free (Context.Argument);
Free (Context.Argument_Iterator);
Free (Context);
end if;
end Release;
function Make_Cursor (
Index : Input_Cursor;
State : Argument_Parsing.State_Type)
return Cursor;
function Make_Cursor (
Index : Input_Cursor;
State : Argument_Parsing.State_Type)
return Cursor
is
Next_Index : Input_Cursor := Index;
Next_State : Argument_Parsing.State_Type := State;
begin
while Has_Element (Next_Index) loop
pragma Check (Trace, Debug.Put ("allocate"));
declare
package Holder is
new Exceptions.Finally.Scoped_Holder (
Argument_Context_Access,
Release);
Context : aliased Argument_Context_Access;
Subindex : Argument_Parsing.Cursor;
begin
Holder.Assign (Context);
Context := new Argument_Context'(
Reference_Count => 1,
Index => Next_Index,
Next_Index => Next_Index,
Argument => <>,
Argument_Iterator => <>);
Context.Argument := new String'(Argument (Next_Index));
Context.Argument_Iterator :=
new Argument_Parsing.Argument_Iterator'(
Argument_Parsing.Iterate (Context.Argument.all, Next_State));
Subindex := Argument_Parsing.First (Context.Argument_Iterator.all);
if Argument_Parsing.Has_Element (Subindex) then
return Create (Context, Subindex);
end if;
Next_Index :=
Input_Iterator_Interfaces.Next (Input_Iterator, Next_Index);
Next_State :=
Argument_Parsing.State (Context.Argument_Iterator.all);
end;
end loop;
return Create (null, Argument_Parsing.No_Element);
end Make_Cursor;
-- implementation
function Has_Element (Position : Cursor) return Boolean is
NC_Position : Non_Controlled_Cursor
renames Controlled.Reference (Position).all;
Context : constant Argument_Context_Access :=
NC_Position.Argument_Context;
begin
if Context = null then
return False;
else
return Has_Element (Context.Index);
end if;
end Has_Element;
function Iterate (Posixly_Correct : Boolean := False)
return Iterator_Interfaces.Forward_Iterator'Class is
begin
return Iterator'(
State => (Posixly_Correct => Posixly_Correct, others => <>));
end Iterate;
function Argument (Position : Cursor) return String is
NC_Position : Non_Controlled_Cursor
renames Controlled.Reference (Position).all;
begin
return NC_Position.Argument_Context.Argument.all;
end Argument;
function Is_Option (
Position : Cursor;
Name : Character;
Option : Option_Character := ' ')
return Boolean
is
NC_Position : Non_Controlled_Cursor
renames Controlled.Reference (Position).all;
begin
return Argument_Parsing.Is_Option (
NC_Position.Argument_Context.Argument.all,
NC_Position.Subindex,
Name,
Argument_Parsing.Option_Character'Enum_Val (
Option_Character'Enum_Rep (Option)));
end Is_Option;
function Is_Option (
Position : Cursor;
Long_Name : String;
Option : Option_Character := ' ')
return Boolean
is
NC_Position : Non_Controlled_Cursor
renames Controlled.Reference (Position).all;
begin
return Argument_Parsing.Is_Option (
NC_Position.Argument_Context.Argument.all,
NC_Position.Subindex,
Long_Name,
Argument_Parsing.Option_Character'Enum_Val (
Option_Character'Enum_Rep (Option)));
end Is_Option;
function Is_Option (
Position : Cursor;
Name : Character;
Long_Name : String;
Option : Option_Character := ' ')
return Boolean
is
NC_Position : Non_Controlled_Cursor
renames Controlled.Reference (Position).all;
begin
return Argument_Parsing.Is_Option (
NC_Position.Argument_Context.Argument.all,
NC_Position.Subindex,
Name,
Long_Name,
Argument_Parsing.Option_Character'Enum_Val (
Option_Character'Enum_Rep (Option)));
end Is_Option;
function Is_Unknown_Option (Position : Cursor) return Boolean is
NC_Position : Non_Controlled_Cursor
renames Controlled.Reference (Position).all;
begin
return Argument_Parsing.Is_Unknown_Option (
NC_Position.Argument_Context.Argument.all,
NC_Position.Subindex);
end Is_Unknown_Option;
function Name (Position : Cursor) return String is
NC_Position : Non_Controlled_Cursor
renames Controlled.Reference (Position).all;
begin
return Argument_Parsing.Name (
NC_Position.Argument_Context.Argument.all,
NC_Position.Subindex);
end Name;
function Short_Name (Position : Cursor) return Character is
NC_Position : Non_Controlled_Cursor
renames Controlled.Reference (Position).all;
begin
return Argument_Parsing.Short_Name (
NC_Position.Argument_Context.Argument.all,
NC_Position.Subindex);
end Short_Name;
function Long_Name (Position : Cursor) return String is
NC_Position : Non_Controlled_Cursor
renames Controlled.Reference (Position).all;
begin
return Argument_Parsing.Long_Name (
NC_Position.Argument_Context.Argument.all,
NC_Position.Subindex);
end Long_Name;
function Value (Position : Cursor) return String is
NC_Position : Non_Controlled_Cursor
renames Controlled.Reference (Position).all;
Context : constant not null Argument_Context_Access :=
NC_Position.Argument_Context;
begin
case Argument_Parsing.Has_Value (
Context.Argument.all,
NC_Position.Subindex)
is
when Argument_Parsing.None | Argument_Parsing.Same =>
return Argument_Parsing.Value (
Context.Argument.all,
NC_Position.Subindex);
when Argument_Parsing.Next =>
if Context.Next_Index /= Context.Index then
return Argument (Context.Next_Index);
else
declare
Next_Index : constant Input_Cursor :=
Input_Iterator_Interfaces.Next (
Input_Iterator,
Context.Index);
begin
if Has_Element (Next_Index) then
Context.Next_Index := Next_Index;
return Argument (Next_Index);
else
return "";
end if;
end;
end if;
end case;
end Value;
overriding function First (Object : Iterator) return Cursor is
Index : constant Input_Cursor :=
Input_Iterator_Interfaces.First (Input_Iterator);
begin
return Make_Cursor (Index => Index, State => Object.State);
end First;
overriding function Next (Object : Iterator; Position : Cursor)
return Cursor
is
pragma Unreferenced (Object);
NC_Position : Non_Controlled_Cursor
renames Controlled.Reference (Position).all;
Context : constant not null Argument_Context_Access :=
NC_Position.Argument_Context;
Subindex : constant Argument_Parsing.Cursor :=
Argument_Parsing.Next (
Context.Argument_Iterator.all,
NC_Position.Subindex);
begin
if Argument_Parsing.Has_Element (Subindex) then
return Create (Context, Subindex);
else
declare
Index : constant Input_Cursor :=
Input_Iterator_Interfaces.Next (
Input_Iterator,
Context.Next_Index);
begin
return Make_Cursor (
Index => Index,
State =>
Argument_Parsing.State (Context.Argument_Iterator.all));
end;
end if;
end Next;
package body Controlled is
function Create (
Argument_Context : Argument_Context_Access;
Subindex : Argument_Parsing.Cursor)
return Cursor is
begin
if Argument_Context /= null then
Retain (Argument_Context);
end if;
return (Finalization.Controlled with (Argument_Context, Subindex));
end Create;
function Reference (Position : Generic_Parsing.Cursor)
return not null access Non_Controlled_Cursor is
begin
return Cursor (Position).Data'Unrestricted_Access;
end Reference;
overriding procedure Adjust (Object : in out Cursor) is
begin
if Object.Data.Argument_Context /= null then
Retain (Object.Data.Argument_Context);
end if;
end Adjust;
overriding procedure Finalize (Object : in out Cursor) is
begin
if Object.Data.Argument_Context /= null then
Release (Object.Data.Argument_Context);
end if;
end Finalize;
end Controlled;
end Ada.Command_Line.Generic_Parsing;
|
with Ada.Text_IO;
procedure Best_Shuffle is
function Best_Shuffle(S: String) return String is
T: String(S'Range) := S;
Tmp: Character;
begin
for I in S'Range loop
for J in S'Range loop
if I /= J and S(I) /= T(J) and S(J) /= T(I) then
Tmp := T(I);
T(I) := T(J);
T(J) := Tmp;
end if;
end loop;
end loop;
return T;
end Best_Shuffle;
Stop : Boolean := False;
begin -- main procedure
while not Stop loop
declare
Original: String := Ada.Text_IO.Get_Line;
Shuffle: String := Best_Shuffle(Original);
Score: Natural := 0;
begin
for I in Original'Range loop
if Original(I) = Shuffle(I) then
Score := Score + 1;
end if;
end loop;
Ada.Text_Io.Put_Line(Original & ", " & Shuffle & ", (" &
Natural'Image(Score) & " )");
if Original = "" then
Stop := True;
end if;
end;
end loop;
end Best_Shuffle;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Adventofcode.Day_12.Main is
begin
Put_Line ("Day-12");
end Adventofcode.Day_12.Main;
|
with ada.unchecked_Deallocation,
ada.Containers.generic_array_Sort;
package body impact.d2.Broadphase
is
use type int32;
procedure free is new ada.Unchecked_Deallocation (int32_array, int32_array_view);
procedure free is new ada.Unchecked_Deallocation (b2Pairs, b2Pairs_view);
function to_b2BroadPhase return b2BroadPhase
is
Self : b2BroadPhase;
begin
Self.m_proxyCount := 0;
Self.m_pairCapacity := 16;
Self.m_pairCount := 0;
Self.m_pairBuffer := new b2Pairs (1 .. Self.m_pairCapacity);
Self.m_moveCapacity := 16;
Self.m_moveCount := 0;
Self.m_moveBuffer := new int32_array (1 .. Self.m_moveCapacity);
return Self;
end to_b2BroadPhase;
procedure destruct (Self : in out b2BroadPhase)
is
begin
free (Self.m_moveBuffer);
free (Self.m_pairBuffer);
end destruct;
function CreateProxy (Self : access b2BroadPhase; aabb : in collision.b2AABB;
userData : access Any'Class) return int32
is
proxyId : constant int32 := Self.m_tree.createProxy (aabb, userData);
begin
Self.m_proxyCount := Self.m_proxyCount + 1;
Self.BufferMove (proxyId);
return proxyId;
end CreateProxy;
procedure DestroyProxy (Self : in out b2BroadPhase; proxyId : in int32)
is
begin
Self.UnBufferMove (proxyId);
Self.m_proxyCount := Self.m_proxyCount - 1;
Self.m_tree.destroyProxy (proxyId);
end DestroyProxy;
procedure MoveProxy (Self : in out b2BroadPhase; proxyId : in int32;
aabb : in collision.b2AABB;
displacement : in b2Vec2)
is
buffer : constant Boolean := Self.m_tree.moveProxy (proxyId, aabb, displacement);
begin
if buffer then
Self.BufferMove (proxyId);
end if;
end MoveProxy;
function GetFatAABB (Self : in b2BroadPhase; proxyId : in int32) return collision.b2AABB
is
begin
return Self.m_tree.getFatAABB (proxyId);
end GetFatAABB;
function GetUserData (Self : in b2BroadPhase; proxyId : in int32) return access Any'Class
is
begin
return Self.m_tree.getUserData (proxyId);
end GetUserData;
function TestOverlap (Self : in b2BroadPhase; proxyIdA, proxyIdB : in int32) return Boolean
is
aabbA : constant collision.b2AABB := Self.m_tree.getFatAABB (proxyIdA);
aabbB : constant collision.b2AABB := Self.m_tree.getFatAABB (proxyIdB);
begin
return collision.b2TestOverlap (aabbA, aabbB);
end TestOverlap;
function GetProxyCount (Self : in b2BroadPhase) return int32
is
begin
return Self.m_proxyCount;
end GetProxyCount;
function ComputeHeight (Self : in b2BroadPhase) return int32
is
begin
return Self.m_tree.getHeight;
-- return Self.m_tree.ComputeHeight;
end ComputeHeight;
procedure BufferMove (Self : in out b2BroadPhase; proxyId : in int32)
is
oldBuffer : int32_array_view;
begin
if Self.m_moveCount = Self.m_moveCapacity then
oldBuffer := Self.m_moveBuffer;
Self.m_moveCapacity := Self.m_moveCapacity * 2;
Self.m_moveBuffer := new int32_array (1 .. Self.m_moveCapacity);
Self.m_moveBuffer (oldBuffer'Range) := oldBuffer.all;
free (oldBuffer);
end if;
Self.m_moveCount := Self.m_moveCount + 1;
Self.m_moveBuffer (Self.m_moveCount) := proxyId;
end BufferMove;
procedure unBufferMove (Self : in out b2BroadPhase; proxyId : in int32)
is
begin
for i in 1 .. Self.m_moveCount loop
if Self.m_moveBuffer (i) = proxyId then
Self.m_moveBuffer (i) := e_nullProxy;
return;
end if;
end loop;
end unBufferMove;
-- This is called from b2DynamicTree::Query when we are gathering pairs.
--
function QueryCallback (Self : access b2BroadPhase; proxyId : in int32) return Boolean
is
oldBuffer : b2Pairs_view;
begin
-- A proxy cannot form a pair with itself.
if proxyId = Self.m_queryProxyId then
return True;
end if;
-- Grow the pair buffer as needed.
if Self.m_pairCount = Self.m_pairCapacity then
oldBuffer := Self.m_pairBuffer;
Self.m_pairCapacity := Self.m_pairCapacity * 2;
Self.m_pairBuffer := new b2Pairs (1 .. Self.m_pairCapacity);
Self.m_pairBuffer (oldBuffer'Range) := oldBuffer.all;
free (oldBuffer);
end if;
Self.m_pairCount := Self.m_pairCount + 1;
Self.m_pairBuffer (Self.m_pairCount).proxyIdA := int32'Min (proxyId, Self.m_queryProxyId);
Self.m_pairBuffer (Self.m_pairCount).proxyIdB := int32'Max (proxyId, Self.m_queryProxyId);
return True;
end QueryCallback;
-- This is used to sort pairs.
--
function b2PairLessThan (pair1, pair2 : in b2Pair) return Boolean
is
begin
if pair1.proxyIdA < pair2.proxyIdA then
return True;
end if;
if pair1.proxyIdA = pair2.proxyIdA then
return pair1.proxyIdB < pair2.proxyIdB;
end if;
return False;
end b2PairLessThan;
procedure UpdatePairs (Self : in out b2BroadPhase; the_Callback : access callback_t)
is
userDataA,
userDataB : access Any'Class;
procedure sort is new ada.Containers.Generic_Array_Sort (int32, b2Pair,
b2Pairs,
b2PairLessThan);
i : int32;
begin
-- Reset pair buffer
Self.m_pairCount := 0;
-- Perform tree queries for all moving proxies.
for i in 1 .. Self.m_moveCount loop
Self.m_queryProxyId := Self.m_moveBuffer (i);
if Self.m_queryProxyId /= e_nullProxy then
declare
-- We have to query the tree with the fat AABB so that
-- we don't fail to create a pair that may touch later.
fatAABB : collision.b2AABB renames Self.m_tree.GetFatAABB (Self.m_queryProxyId);
procedure Query is new dynamic_tree.Query (b2BroadPhase, QueryCallback);
begin
-- Query tree, create pairs and add them pair buffer.
Query (Self.m_tree, Self'Access, fatAABB);
end;
end if;
end loop;
-- Reset move buffer
Self.m_moveCount := 0;
-- Sort the pair buffer to expose duplicates.
sort (Self.m_pairBuffer (1 .. Self.m_pairCount));
-- Send the pairs back to the client.
i := 1;
while i <= Self.m_pairCount loop
declare
primaryPair : constant access b2Pair := Self.m_pairBuffer (i)'Access;
pair : access b2Pair;
begin
userDataA := Self.m_tree.GetUserData (primaryPair.proxyIdA);
userDataB := Self.m_tree.GetUserData (primaryPair.proxyIdB);
addPair (the_Callback, userDataA, userDataB);
i := i + 1;
-- Skip any duplicate pairs.
while i <= Self.m_pairCount loop
pair := Self.m_pairBuffer (i)'Access;
exit when pair.proxyIdA /= primaryPair.proxyIdA or else pair.proxyIdB /= primaryPair.proxyIdB;
i := i + 1;
end loop;
end;
end loop;
-- Try to keep the tree balanced.
-- Self.m_tree.Rebalance (4);
end UpdatePairs;
procedure Query (Self : in b2BroadPhase; the_Callback : access callback_t;
aabb : in collision.b2AABB)
is
procedure Query is new dynamic_tree.Query (callback_t, QueryCallback);
begin
Query (Self.m_tree, the_Callback, aabb);
end Query;
procedure RayCast (Self : in b2BroadPhase; the_Callback : access callback_t;
input : in collision.b2RayCastInput)
is
procedure RayCast is new dynamic_tree.Raycast (callback_t, RayCastCallback);
begin
RayCast (Self.m_tree, the_Callback, input);
end RayCast;
function GetTreeHeight (Self : in b2BroadPhase) return int32
is
begin
return Self.m_tree.getHeight;
end GetTreeHeight;
function GetTreeBalance (Self : in b2BroadPhase) return int32
is
begin
return Self.m_tree.GetMaxBalance;
end GetTreeBalance;
function GetTreeQuality (Self : in b2BroadPhase) return float32
is
begin
return Self.m_tree.GetAreaRatio;
end GetTreeQuality;
end impact.d2.Broadphase;
|
-- specification of the package -
-- read this to get an overview of the package;
-- see bubble.adb for the implementation
package Bubble is
-- state shared by all tasks (ie threads)
protected State is
-- a setter for a, b, c, d
procedure Set_All(a, b, c, d : Integer);
-- get a, b, c, d but only when a <= b <= c <= d
-- block when they are not sorted
entry Wait_Until_Sorted(a, b, c, d : out Integer);
-- entries for detecting when neighbouring numbers
-- are not in order and swapping them:
entry BubbleAB;
entry BubbleBC;
entry BubbleCD;
private
procedure Print_State;
a, b, c, d : Integer := 0;
end State;
-- tasks for swapping neighbours in State:
task BubbleAB;
task BubbleBC;
task BubbleCD;
end Bubble;
|
--- kernel/src/gtkada-search_entry.ads.orig 2021-06-15 05:19:41 UTC
+++ kernel/src/gtkada-search_entry.ads
@@ -35,7 +35,7 @@ package Gtkada.Search_Entry is
function Get_Icon_Position
(Self : access Gtkada_Search_Entry_Record'Class;
- Event : Gdk_Event_Button) return Gtk_Entry_Icon_Position;
+ Event : Gdk_Event) return Gtk_Entry_Icon_Position;
-- Returns the icon which was clicked on.
-- For some reason, gtk+ always seems to return the primary icon otherwise.
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <denkpadje@gmail.com>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Unchecked_Conversion;
package body Orka.Base64 is
type Input_Value is mod 2**6
with Size => 6;
type Output_Value is mod 2**8
with Size => 8;
type Input_Group is record
V1, V2, V3, V4 : Input_Value;
end record;
type Output_Group is record
B1, B2, B3 : Output_Value;
end record;
for Input_Group use record
V4 at 0 range 0 .. 5;
V3 at 0 range 6 .. 11;
V2 at 0 range 12 .. 17;
V1 at 0 range 18 .. 23;
end record;
for Output_Group use record
B3 at 0 range 0 .. 7;
B2 at 0 range 8 .. 15;
B1 at 0 range 16 .. 23;
end record;
Alphabet : constant array (Character) of Input_Value :=
('A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'E' => 4, 'F' => 5,
'G' => 6, 'H' => 7, 'I' => 8, 'J' => 9, 'K' => 10, 'L' => 11,
'M' => 12, 'N' => 13, 'O' => 14, 'P' => 15, 'Q' => 16, 'R' => 17,
'S' => 18, 'T' => 19, 'U' => 20, 'V' => 21, 'W' => 22, 'X' => 23,
'Y' => 24, 'Z' => 25, 'a' => 26, 'b' => 27, 'c' => 28, 'd' => 29,
'e' => 30, 'f' => 31, 'g' => 32, 'h' => 33, 'i' => 34, 'j' => 35,
'k' => 36, 'l' => 37, 'm' => 38, 'n' => 39, 'o' => 40, 'p' => 41,
'q' => 42, 'r' => 43, 's' => 44, 't' => 45, 'u' => 46, 'v' => 47,
'w' => 48, 'x' => 49, 'y' => 50, 'z' => 51, '0' => 52, '1' => 53,
'2' => 54, '3' => 55, '4' => 56, '5' => 57, '6' => 58, '7' => 59,
'8' => 60, '9' => 61, '+' => 62, '/' => 63, others => 0);
function Convert_Group is new Ada.Unchecked_Conversion
(Source => Input_Group, Target => Output_Group);
function Decode (Input : String) return Stream_Element_Array is
G1 : Input_Group;
G2 : Output_Group;
Groups : constant Positive := Input'Length / 4;
Bytes : Positive := Groups * 3;
begin
if Input'Length mod 4 /= 0 then
raise Encoding_Error with "Length not a multiple of 4";
end if;
if (for some C of Input =>
C not in 'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '+' | '/' | '=')
then
raise Encoding_Error with "Illegal character";
end if;
declare
Output : Stream_Element_Array (1 .. Stream_Element_Offset (Bytes));
begin
for Index in 0 .. Groups - 1 loop
G1.V1 := Alphabet (Input (Input'First + Index * 4 + 0));
G1.V2 := Alphabet (Input (Input'First + Index * 4 + 1));
G1.V3 := Alphabet (Input (Input'First + Index * 4 + 2));
G1.V4 := Alphabet (Input (Input'First + Index * 4 + 3));
G2 := Convert_Group (G1);
Output (Stream_Element_Offset (Index) * 3 + 1) := Stream_Element (G2.B1);
Output (Stream_Element_Offset (Index) * 3 + 2) := Stream_Element (G2.B2);
Output (Stream_Element_Offset (Index) * 3 + 3) := Stream_Element (G2.B3);
end loop;
if Input (Input'Last - 1 .. Input'Last) = "==" then
Bytes := Bytes - 2;
elsif Input (Input'Last) = '=' then
Bytes := Bytes - 1;
end if;
return Output (1 .. Stream_Element_Offset (Bytes));
end;
end Decode;
end Orka.Base64;
|
with raylib;
package Surface is
type Actor is interface;
procedure Setup (ctxt : in out Actor) is abstract;
procedure Update (ctxt : in out Actor ; dt : Float) is abstract;
type Reference is access Actor'class;
type Actor_Stack is array (Positive range <>) of Reference;
type Instance is new Actor with record
Tab : Actor_Stack (1 .. 50);
end record;
procedure Setup (ctxt : in out Instance) is null;
procedure Update (ctxt : in out Instance ; dt : Float) is null;
end Surface;
|
with Ada.Unchecked_Conversion;
with System.Tasks;
package body Ada.Task_Termination is
use type Task_Identification.Task_Id;
function To_Private is
new Unchecked_Conversion (
Task_Identification.Task_Id,
System.Tasks.Task_Id);
function To_Private is
new Unchecked_Conversion (
Termination_Handler,
System.Tasks.Termination_Handler);
function To_Public is
new Unchecked_Conversion (
System.Tasks.Termination_Handler,
Termination_Handler);
-- implementation
procedure Set_Dependents_Fallback_Handler (Handler : Termination_Handler) is
begin
System.Tasks.Set_Dependents_Fallback_Handler (
System.Tasks.Current_Task_Id,
To_Private (Handler));
end Set_Dependents_Fallback_Handler;
function Current_Task_Fallback_Handler return Termination_Handler is
begin
return To_Public (
System.Tasks.Dependents_Fallback_Handler (
System.Tasks.Current_Task_Id));
end Current_Task_Fallback_Handler;
procedure Set_Specific_Handler (
T : Task_Identification.Task_Id;
Handler : Termination_Handler)
is
pragma Check (Pre,
Check =>
T /= Task_Identification.Null_Task_Id
or else raise Program_Error); -- RM C.7.3(15/2)
begin
System.Tasks.Set_Specific_Handler (To_Private (T), To_Private (Handler));
end Set_Specific_Handler;
function Specific_Handler (T : Task_Identification.Task_Id)
return Termination_Handler
is
pragma Check (Pre,
Check =>
T /= Task_Identification.Null_Task_Id
or else raise Program_Error); -- RM C.7.3(15/2)
begin
return To_Public (System.Tasks.Specific_Handler (To_Private (T)));
end Specific_Handler;
end Ada.Task_Termination;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.