content stringlengths 23 1.05M |
|---|
with pointer_variable_bounds_q; use pointer_variable_bounds_q;
package pointer_variable_bounds is
type HALF_INTEGER is range -32768 .. 32767;
subtype HALF_NATURAL is HALF_INTEGER range 0 .. 32767;
MAX_COMPS : constant HALF_NATURAL := HALF_NATURAL(A_MAX_COMPS);
subtype COMP_POINTER_TYPE is HALF_NATURAL range 0 .. MAX_COMPS;
subtype BUNDLE_POINTER_TYPE is HALF_NATURAL range 0 .. 1;
subtype C_POINTER_TYPE is HALF_NATURAL range 0 .. 1;
procedure BUNDLE_DAT(BP : in BUNDLE_POINTER_TYPE);
procedure SEQUENCE_DAT(BP : in BUNDLE_POINTER_TYPE);
end pointer_variable_bounds;
|
with Ada.Containers.Ordered_Maps; use Ada.Containers;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Input12; use Input12;
procedure Day12 is
package String_Maps is new Ordered_Maps
(Key_Type => String_Pattern,
Element_Type => Character);
type Integer_64 is range -(2**63) .. +(2**63 - 1);
Lookup_Table : String_Maps.Map;
function Generation_Sum
(Initial_State : String;
Num_Gens : Integer_64) return Integer_64
is
Diff_Count : Natural := 0;
Old_Sum : Integer_64 := 0;
Old_Diff : Integer_64 := 0;
Zero_Index : Positive := Initial_State'First + 5;
Current_State : Unbounded_String :=
To_Unbounded_String ("....." & Initial_State & ".....");
begin
for Gen in 1 .. Num_Gens loop
declare
Old_State : constant String := To_String (Current_State);
New_State : String := Old_State;
Sum : Integer_64 := 0;
begin
for I in Old_State'First + 2 .. Old_State'Last - 2 loop
declare
Pattern : constant String := Old_State (I - 2 .. I + 2);
begin
New_State (I) := Lookup_Table.Element (Pattern);
if New_State (I) = '#' then
Sum := Sum + Integer_64 (I - Zero_Index);
end if;
end;
end loop;
if Old_Diff = (Sum - Old_Sum) then
Diff_Count := Diff_Count + 1;
else
Diff_Count := 0;
end if;
if Diff_Count > 10 then
return Sum + ((Num_Gens - Gen) * (Sum - Old_Sum));
end if;
Old_Diff := Sum - Old_Sum;
Old_Sum := Sum;
Current_State := To_Unbounded_String (New_State);
if New_State (1 .. 5) /= "....." then
Current_State := "....." & Current_State;
Zero_Index := Zero_Index + 5;
end if;
if New_State (New_State'Last - 4 .. New_State'Last) /= "....." then
Append (Current_State, ".....");
end if;
end;
end loop;
return Old_Sum;
end Generation_Sum;
begin
for I in Inputs'Range loop
Lookup_Table.Insert (Inputs (I).Pattern, Inputs (I).Plant);
end loop;
Put_Line
("Part 1 =" & Integer_64'Image (Generation_Sum (Initial_State, 20)));
Put_Line
("Part 2 =" &
Integer_64'Image (Generation_Sum (Initial_State, 50000000000)));
end Day12;
|
generic
type Element is private;
package Liste_Generique is
type Liste is limited private; -- une liste est initialement vide
-- vide L et libere la memoire correspondante
procedure Vider(L : in out Liste);
-- insere E en tete de L
procedure Insertion_Tete(L : in out Liste ; E : Element);
-- insere E en queue de L
procedure Insertion_Queue(L : in out Liste ; E : Element);
-- appelle Traiter sur chaque element de L, dans l'ordre
generic
with procedure Traiter(E : in out Element);
procedure Parcourir(L : Liste);
-- si L = [E1 ; E2 ; ... ; En-1 ; En]
-- appelle Traiter sur chaque couple (Ei, Ei+1) pour 0 < i < n
generic
with procedure Traiter(E1, E2 : in Element);
procedure Parcourir_Par_Couples(L : Liste);
--fusionne L2 a la fin de L1; en sortie L2 est vide
procedure Fusion(L1 : in out Liste ; L2 : in out Liste);
-- nombre d'éléments de L
function Taille(L : Liste) return Natural;
-- requiert Taille(L) /= 0
function Tete(L : Liste) return Element;
-- requiert Taille(L) /= 0
function Queue(L : Liste) return Element;
private
type Cellule;
type Pointeur is access Cellule;
type Cellule is record
Contenu : Element;
Suivant : Pointeur;
end record;
type Liste is record
Debut, Fin : Pointeur := null;
Taille : Natural := 0;
end record;
end;
|
-- Test LU decomposition on a
-- real valued square matrix.
with Cholesky_LU;
With Text_IO; use Text_IO;
procedure cholesky_demo_1 is
type Real is digits 15;
type Index is range 0..2**7-1;
Starting_Index : constant Index := Index'First + 0;
Max_Index : Index := Index'Last - 0;
package lu is new Cholesky_LU (Real, Index, Matrix);
use lu;
package rio is new Float_IO(Real);
use rio;
package iio is new Integer_IO(Integer);
use iio;
type Matrix is array(Index, Index) of Real;
-- Row major form is appropriate for Matrix * Row_VectorVector
-- operations, which dominate the algorithm in procedure Solve.
Zero_Vector : constant Row_Vector := (others => 0.0);
C, C_Inverse : Matrix := (others => (others => 0.0));
IO_Max_Index : Integer := 4;
Sum, Max_Error, Del, Error_Off_Diag, Error_Diag : Real;
type Matrix_Id is (Easy_Matrix, Small_Diagonal, Upper_Ones,
Lower_Ones, Moler, Hilbert);
--Desired_Matrix : Matrix_Id := Easy_Matrix;
Desired_Matrix : Matrix_Id := Small_Diagonal;
--Desired_Matrix : Matrix_Id := Upper_Ones;
--Desired_Matrix : Matrix_Id := Lower_Ones;
--Desired_Matrix : Matrix_Id := Moler;
--Desired_Matrix : Matrix_Id := Hilbert;
type Real_Extended is digits 15;
--type Real_Extended is digits 18; -- 18 on intel
e_Sum : Real_Extended;
-----------
-- Pause --
-----------
procedure Pause (s1,s2,s3,s4,s5,s6,s7,s8 : string := "") is
Continue : Character := ' ';
begin
new_line;
if S1 /= "" then put_line (S1); end if;
if S2 /= "" then put_line (S2); end if;
if S3 /= "" then put_line (S3); end if;
if S4 /= "" then put_line (S4); end if;
if S5 /= "" then put_line (S5); end if;
if S6 /= "" then put_line (S6); end if;
if S7 /= "" then put_line (S7); end if;
if S8 /= "" then put_line (S8); end if;
new_line;
begin
put ("Enter a character to continue: ");
get_immediate (Continue);
new_line;
exception
when others => null;
end;
end pause;
------------
-- Invert --
------------
-- Get Inverse of the Matrix:
procedure Invert
(M : in Matrix;
M_Inv : out Matrix;
Max_Index : in Index;
Starting_Index : in Index;
Max_Error : out Real)
is
Solution_Vector : Row_Vector;
Unit_Vector : Row_Vector := (others => 0.0);
Error : Col_Vector := (others => 0.0);
M_LU : Matrix := M;
Diag_Inverse : Row_Vector;
begin
Max_Error := 0.0;
LU_decompose
(M_LU,
Diag_Inverse,
Max_Index,
Starting_Index);
for I in Starting_Index..Max_Index loop
if I > Starting_Index then
Unit_Vector(I-1) := 0.0;
end if;
Unit_Vector(I) := 1.0;
Solve
(Solution_Vector,
Unit_Vector,
M_LU,
Diag_Inverse,
Max_Index,
Starting_Index);
-- Solve M*Solution_Vector = Unit_Vector (for Solution_Vector).
Error := Unit_Vector - Product (M, Solution_Vector, Max_Index, Starting_Index);
for I in Starting_Index..Max_Index loop
if Abs(Error(I)) > Max_Error then
Max_Error := Abs(Error(I));
end if;
end loop;
-- Solution vector is the I-th column of M_Inverse:
for J in Starting_Index..Max_Index loop
M_Inv (J, I) := Solution_Vector(J);
end loop;
end loop;
end Invert;
begin
put("Maximum matrix size is "&
Integer'Image (Zero_Vector'length-(Integer(Starting_Index)-Integer(Index'First))));
new_Line;
put("Input Size Of Matrix To Invert (enter an Integer)"); new_Line;
get(IO_Max_Index);
Max_Index := Starting_Index + Index (IO_Max_Index-1);
C := (others => (others => 0.0));
case Desired_Matrix is
when Easy_Matrix =>
for I in Index loop
C(I, I) := 1.010101010101;
end loop;
for BottomDiagonal in Starting_Index+1..Index'Last loop
for Row in BottomDiagonal..Index'Last loop
C(Row, Row-BottomDiagonal+Starting_Index)
:= 0.013 * Real(Row) / Real(Index'Last)
+ 0.10101010101 / Real(BottomDiagonal);
end loop;
end loop;
for Row in Starting_Index+1..Index'Last loop
for Col in Starting_Index..Row-1 loop
C(Col, Row) := C(Row, Col) + 0.333;
end loop;
end loop;
when Small_Diagonal =>
for I in Index loop
C(I, I) := 2.0;
end loop;
for BottomDiagonal in Starting_Index+1..Index'Last loop
for Row in BottomDiagonal..Index'Last loop
C(Row, Row-BottomDiagonal+Starting_Index)
:= 0.013 * Real(Row) / Real(Index'Last)
+ 1.0 / Real(BottomDiagonal);
end loop;
end loop;
for Row in Starting_Index+1..Index'Last loop
for Col in Starting_Index..Row-1 loop
C(Col, Row) := C(Row, Col) + 0.333; -- this is tough on it.
end loop;
end loop;
when Upper_Ones =>
C := (others => (others => 0.0));
for Row in Starting_Index .. Index'Last loop
for Col in Row .. Index'Last loop
C(Row, Col) := 1.0;
end loop;
end loop;
when Lower_Ones =>
C := (others => (others => 0.0));
for Row in Starting_Index .. Index'Last loop
for Col in Row .. Index'Last loop
C(Col, Row) := 1.0;
end loop;
end loop;
when Moler =>
C := (others => (others => 0.0));
for Row in Starting_Index .. Index'Last loop
for Col in Starting_Index .. Index'Last loop
C(Row, Col) := Real(Index'Min(Col,Row)) - Real(Starting_Index) - 1.0;
end loop;
end loop;
for Col in Starting_Index .. Index'Last loop
C(Col, Col) := Real(Col) - Real(Starting_Index) + 1.0;
end loop;
when Hilbert =>
-- Construct Hilbert's matrix Plus epsilon:
C := (others => (others => 0.0));
for Row in Starting_Index .. Index'Last loop
for Col in Starting_Index .. Index'Last loop
C(Row, Col) :=
1.0 / (Real(Row) + Real(Col) - 2.0*Real(Starting_Index) + 1.0);
end loop;
end loop;
end case;
-- symmetrize C for Cholesky:
declare Val : Real;
begin
for Row in Index loop
if Row < Index'Last then
for Col in Row+1 .. Index'Last loop
Val := 0.5 * (C(Col, Row) + C(Row, Col));
C(Col, Row) := Val;
C(Row, Col) := Val;
end loop;
end if;
end loop;
end;
-- Construct inverse of C:
Invert (C, C_Inverse, Max_Index, Starting_Index, Max_Error);
new_line;
put("We just took the matrices inverse. Error estimate follows.");
new_line;
put ("Max Error according to Residual function is: "); put (Max_Error);
new_line;
-- Multiply Original C and C_Inverse as test. Get Max error:
Error_Off_Diag := 0.0;
Error_Diag := 0.0;
for I in Starting_Index..Max_Index loop
for J in Starting_Index..Max_Index loop
e_Sum := 0.0;
for K in Starting_Index..Max_Index loop
e_Sum := e_Sum + Real_Extended (C_Inverse(I, k)) * Real_Extended (C(k, J));
end loop;
Sum:= Real(e_Sum);
-- Product(I,J) := Sum;
-- The product should be the unit matrix. Calculate the error:
if I = J then
Del := Abs (Sum - 1.0);
if Del > Error_Diag then
Error_Diag := Del;
end if;
else
Del := Abs (Sum);
if Del > Error_Off_Diag then
Error_Off_Diag := Del;
end if;
end if;
end loop;
end loop;
pause
("We just took the product the original matrix with its inverse,",
"and then calculated the difference between this product and",
"the identity matrix. The difference is printed below. The difference",
"should be near 10**(-15) only if the matrix is well conditioned.");
new_line;
put("Max difference along diagonals of product: "); put(Error_Diag);
new_line;
put("Max difference along off-diagonals of product: "); put(Error_Off_Diag);
new_line;
-- Multiply Original C and C_Inverse as test. Get Max error:
Error_Off_Diag := 0.0;
Error_Diag := 0.0;
for I in Starting_Index..Max_Index loop
for J in Starting_Index..Max_Index loop
e_Sum := 0.0;
for K in Starting_Index..Max_Index loop
e_Sum := e_Sum + Real_Extended (C_Inverse(I, k)) * Real_Extended (C(k, J));
end loop;
Sum:= Real(e_Sum);
-- Product(I,J) := Sum;
-- The product should be the I matrix. Calculate the error:
if I = J then
Del := Abs (Sum - 1.0);
if Del > Error_Diag then
Error_Diag := Del;
end if;
else
Del := Abs (Sum);
if Del > Error_Off_Diag then
Error_Off_Diag := Del;
end if;
end if;
end loop;
end loop;
pause
("Just took the product of the inverse matrix with the original matrix,",
"and then calculated the difference between this product and",
"the identity matrix. The difference is printed below.",
"The product of the inverse matrix with the original matrix does not",
"equal the identity matrix unless the original matrix is well conditioned.");
new_line;
put("The difference along diagonals: "); put(Error_Diag);
new_line;
put("The difference along off-diagonals: "); put(Error_Off_Diag);
new_line;
end;
|
with Ada.Text_IO;
with Ada.Command_Line;
with Stemmer;
with Stemmer.Factory;
procedure Stemargs is
use Stemmer.Factory;
function Get_Language (Name : in String) return Language_Type;
function Get_Language (Name : in String) return Language_Type is
begin
return Language_Type'Value ("L_" & Name);
exception
when Constraint_Error =>
Ada.Text_IO.Put_Line ("Unsupported language: " & Ada.Command_Line.Argument (1));
return L_ENGLISH;
end Get_Language;
Count : constant Natural := Ada.Command_Line.Argument_Count;
begin
if Count <= 1 then
Ada.Text_IO.Put_Line ("Usage: stemargs language words...");
return;
end if;
declare
Lang : constant Language_Type := Get_Language (Ada.Command_Line.Argument (1));
begin
for I in 2 .. Count loop
Ada.Text_IO.Put_Line (Stem (Lang, Ada.Command_Line.Argument (I)));
end loop;
end;
end Stemargs;
|
with Ada.Text_IO;
with Ada.Integer_Text_IO;
package body Problem_31 is
package IO renames Ada.Text_IO;
package I_IO renames Ada.Integer_Text_IO;
Type Two_Pounds is new Integer range 0 .. 200;
type Coin is new Integer range 1 .. 7;
denominations : constant Array(Coin) of Two_Pounds := (200, 100, 50, 20, 10, 5, 2);
procedure Solve is
function Count_From(amount : Two_Pounds; index : coin) return Integer is
sum : Integer := 0;
begin
if amount = 0 then
return 1;
end if;
declare
max_usage : constant Two_Pounds := amount / denominations(index);
begin
for used in 0 .. max_usage loop
if index = Coin'Last then
-- remainder is all ones
sum := sum + 1;
else
sum := sum + Count_From(amount - used*denominations(index), index + 1);
end if;
end loop;
end;
return sum;
end Count_From;
begin
I_IO.Put(Count_From(Two_Pounds'Last, 1));
IO.New_Line;
end Solve;
end Problem_31;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2019 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 System;
with Ada.Streams;
with Ada.Unchecked_Conversion;
package body Inotify is
use type GNAT.OS_Lib.File_Descriptor;
overriding procedure Initialize (Object : in out Instance) is
function Inotify_Init return GNAT.OS_Lib.File_Descriptor
with Import, Convention => C, External_Name => "inotify_init";
begin
Object.Instance := Inotify_Init;
if Object.Instance = GNAT.OS_Lib.Invalid_FD then
raise Program_Error;
end if;
end Initialize;
overriding procedure Finalize (Object : in out Instance) is
Status : Boolean;
begin
if Object.Instance /= GNAT.OS_Lib.Invalid_FD then
GNAT.OS_Lib.Close (Object.Instance, Status);
Object.Instance := GNAT.OS_Lib.Invalid_FD;
if not Status then
raise Program_Error;
end if;
end if;
end Finalize;
function File_Descriptor (Object : Instance) return Integer is (Integer (Object.Instance));
use type Interfaces.C.int;
function Add_Watch
(Object : in out Instance;
Path : String;
Mask : Watch_Bits := All_Events) return Watch
is
function Inotify_Add_Watch
(Instance : GNAT.OS_Lib.File_Descriptor;
Path : Interfaces.C.char_array;
Mask : Interfaces.C.unsigned) return Interfaces.C.int
with Import, Convention => C, External_Name => "inotify_add_watch";
function Convert is new Ada.Unchecked_Conversion
(Source => Watch_Bits, Target => Interfaces.C.unsigned);
Result : constant Interfaces.C.int := Inotify_Add_Watch
(Object.Instance, Interfaces.C.To_C (Path), Convert (Mask));
begin
if Result = -1 then
raise Program_Error;
end if;
Object.Watches.Include (Result, Path);
return (Watch => Result);
end Add_Watch;
procedure Add_Watch
(Object : in out Instance;
Path : String;
Mask : Watch_Bits := All_Events)
is
Result : constant Watch := Instance'Class (Object).Add_Watch (Path, Mask);
begin
pragma Assert (Result.Watch /= -1);
end Add_Watch;
procedure Remove_Watch (Object : in out Instance; Subject : Watch) is
function Inotify_Remove_Watch
(Instance : GNAT.OS_Lib.File_Descriptor;
Watch : Interfaces.C.int) return Interfaces.C.int
with Import, Convention => C, External_Name => "inotify_rm_watch";
begin
-- Procedure Process_Events might read multiple events for a specific
-- watch and the callback for the first event may immediately try to
-- remove the watch
if Object.Defer_Remove then
if not Object.Pending_Removals.Contains (Subject) then
Object.Pending_Removals.Append (Subject);
end if;
return;
end if;
if Inotify_Remove_Watch (Object.Instance, Subject.Watch) = -1 then
raise Program_Error;
end if;
Object.Watches.Delete (Subject.Watch);
end Remove_Watch;
function Has_Watches (Object : in out Instance) return Boolean is
(not Object.Watches.Is_Empty);
function Name (Object : Instance; Subject : Watch) return String is
(Object.Watches.Element (Subject.Watch));
-----------------------------------------------------------------------------
type Inotify_Event is record
Watch : Interfaces.C.int; -- -1 if event queue has overflowed
Mask : Interfaces.C.unsigned;
Cookie : Interfaces.C.unsigned;
Length : Interfaces.C.unsigned;
end record
with Convention => C,
Alignment => 4;
type Event_Bits is record
Event : Event_Kind;
Queue_Overflowed : Boolean := False;
Ignored : Boolean := False;
Is_Directory : Boolean := False;
end record;
for Event_Bits use record
Event at 0 range 0 .. 13;
Queue_Overflowed at 0 range 14 .. 14;
Ignored at 0 range 15 .. 15;
Is_Directory at 0 range 30 .. 30;
end record;
for Event_Bits'Size use Interfaces.C.unsigned'Size;
for Event_Bits'Alignment use Interfaces.C.unsigned'Alignment;
procedure Process_Events
(Object : in out Instance;
Handle : not null access procedure
(Subject : Watch;
Event : Event_Kind;
Is_Directory : Boolean;
Name : String);
Move_Handle : not null access procedure
(Subject : Watch;
Is_Directory : Boolean;
From, To : String))
is
use Ada.Streams;
function Convert is new Ada.Unchecked_Conversion
(Source => Stream_Element_Array, Target => Inotify_Event);
function Convert is new Ada.Unchecked_Conversion
(Source => Interfaces.C.unsigned, Target => Event_Bits);
Event_In_Bytes : constant Stream_Element_Offset
:= Inotify_Event'Size / System.Storage_Unit;
Length : Stream_Element_Offset;
Buffer : Stream_Element_Array (1 .. 4096)
with Alignment => 4;
function Find_Move (Cookie : Interfaces.C.unsigned) return Move_Vectors.Cursor is
Cursor : Move_Vectors.Cursor := Move_Vectors.No_Element;
procedure Reverse_Iterate (Position : Move_Vectors.Cursor) is
use type Interfaces.C.unsigned;
begin
if Cookie = Object.Moves (Position).Key then
Cursor := Position;
end if;
end Reverse_Iterate;
begin
Object.Moves.Reverse_Iterate (Reverse_Iterate'Access);
return Cursor;
end Find_Move;
use type Ada.Containers.Count_Type;
begin
if Object.Watches.Is_Empty then
return;
end if;
Length := Stream_Element_Offset (GNAT.OS_Lib.Read
(Object.Instance, Buffer'Address, Buffer'Length));
if Length = -1 then
raise Read_Error;
end if;
if Length = 0 then
return;
end if;
declare
Index : Stream_Element_Offset := Buffer'First;
begin
Object.Defer_Remove := True;
while Index < Buffer'First + Length loop
declare
Event : constant Inotify_Event
:= Convert (Buffer (Index .. Index + Event_In_Bytes - 1));
Mask : constant Event_Bits := Convert (Event.Mask);
Name_Length : constant Stream_Element_Offset
:= Stream_Element_Offset (Event.Length);
begin
if Mask.Queue_Overflowed then
raise Queue_Overflow_Error;
end if;
pragma Assert (Event.Watch /= -1);
if Mask.Ignored then
Object.Watches.Exclude (Event.Watch);
else
declare
Directory : constant String := Object.Watches.Element (Event.Watch);
begin
if Name_Length > 0 then
declare
subtype Name_Array is Interfaces.C.char_array
(1 .. Interfaces.C.size_t (Event.Length));
subtype Name_Buffer is Stream_Element_Array
(1 .. Name_Length);
function Convert is new Ada.Unchecked_Conversion
(Source => Name_Buffer, Target => Name_Array);
Name_Index : constant Stream_Element_Offset
:= Index + Event_In_Bytes;
Name : constant String := Interfaces.C.To_Ada (Convert
(Buffer (Name_Index .. Name_Index + Name_Length - 1)));
begin
Handle
((Watch => Event.Watch), Mask.Event,
Mask.Is_Directory, Directory & "/" & Name);
case Mask.Event is
when Moved_From =>
if Object.Moves.Length = Object.Moves.Capacity then
Object.Moves.Delete_First;
end if;
Object.Moves.Append ((Event.Cookie,
(From => SU.To_Unbounded_String (Directory & "/" & Name),
To => <>)));
-- If inode is moved to outside watched directory,
-- then there will never be a Moved_To or Moved_Self
-- if instance is not recursive
when Moved_To =>
declare
Cursor : Move_Vectors.Cursor := Find_Move (Event.Cookie);
use type Move_Vectors.Cursor;
begin
if Cursor /= Move_Vectors.No_Element then
-- It's a rename
Move_Handle
(Subject => (Watch => Event.Watch),
Is_Directory => Mask.Is_Directory,
From => SU.To_String
(Object.Moves (Cursor).Value.From),
To => Directory & "/" & Name);
Object.Moves.Delete (Cursor);
else
Move_Handle
(Subject => (Watch => Event.Watch),
Is_Directory => Mask.Is_Directory,
From => "",
To => Directory & "/" & Name);
end if;
end;
when others =>
null;
end case;
end;
else
Handle
((Watch => Event.Watch), Mask.Event,
Mask.Is_Directory, Directory);
end if;
end;
end if;
Index := Index + Event_In_Bytes + Name_Length;
end;
end loop;
Object.Defer_Remove := False;
-- Remove pending removals of watches after having processed
-- all events
for Watch of Object.Pending_Removals loop
Object.Remove_Watch (Watch);
end loop;
Object.Pending_Removals.Clear;
end;
end Process_Events;
procedure Process_Events
(Object : in out Instance;
Handle : not null access procedure
(Subject : Watch;
Event : Event_Kind;
Is_Directory : Boolean;
Name : String))
is
procedure Move_Handle
(Subject : Watch;
Is_Directory : Boolean;
From, To : String) is null;
begin
Object.Process_Events (Handle, Move_Handle'Access);
end Process_Events;
end Inotify;
|
package openGL.Light.directional
--
-- Models a directional light.
--
is
type Item is new Light.item with private;
type Items is array (Positive range <>) of Item;
procedure inverse_view_Transform_is (Self : in out Item; Now : in Matrix_3x3);
procedure Color_is (Self : in out Item; Ambient,
Diffuse,
Specular : in light_Color);
function ambient_Color (Self : in Item) return Vector_4;
function diffuse_Color (Self : in Item) return Vector_4;
function specular_Color (Self : in Item) return Vector_4;
function Direction (Self : in Item) return Vector_3; -- Normalized light direction in eye space.
function halfplane_Vector (Self : in Item) return Vector_3; -- Normalized half-plane vector.
private
type Item is new Light.item with
record
Direction : Vector_3;
halfplane_Vector : Vector_3;
ambient_Color : Vector_4 := (0.0, 0.0, 0.0, 1.0); -- The GL defaults for all lights bar 'Light0'.
diffuse_Color : Vector_4 := (0.0, 0.0, 0.0, 1.0);
specular_Color : Vector_4 := (0.0, 0.0, 0.0, 1.0);
end record;
end openGL.Light.directional;
|
--------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. (gh+si_units@heisenbug.eu)
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
--------------------------------------------------------------------------------
pragma License (Unrestricted);
with Ada.IO_Exceptions;
with SI_Units.Float_IO;
package body SI_Units.Metric is
function Prefix (S : in Prefixes) return String is
(case S is
when yocto => "y",
when zepto => "z",
when atto => "a",
when femto => "f",
when pico => "p",
when nano => "n",
when micro => Micro_Sign,
when milli => "m",
when None => "",
when kilo => "k",
when Mega => "M",
when Giga => "G",
when Tera => "T",
when Peta => "P",
when Exa => "E",
when Zetta => "Z",
when Yotta => "Y") with
Inline => True;
function General_Image (Value : in Float_IO.General_Float;
Aft : in Ada.Text_IO.Field;
Unit : in String) return String;
-- The actual implementation of each of the Image subprograms.
--
-- Finds the best match for a value such that the value to be displayed will
-- be in the interval (0.0 .. 1000.0] with an appropriate prefix for the
-- unit name, i.e. a call to
--
-- General_Image (123_456_789.0, 3, "Hz");
--
-- will return the string
--
-- 123.457 MHz
function General_Image (Value : in Float_IO.General_Float;
Aft : in Ada.Text_IO.Field;
Unit : in String) return String
is
use type Float_IO.General_Float;
Temp : Float_IO.General_Float := abs Value;
-- Ignore sign for temporary value.
Scale : Prefixes := None;
begin
-- No prefix if no unit is given or value is exactly zero.
if Unit /= No_Unit and then Temp /= 0.0 then
-- We ignored the sign of the input value, so we only have to cope
-- with positive values here.
if Temp < 1.0 then
Handle_Small_Prefixes :
declare
-- Set threshold, if the value is less than that it will be
-- rounded down. Please note, that an Aft of 0 will be handled
-- like an Aft of 1 (as we always emit at least one digit after
-- the decimal point.
Threshold : constant Float_IO.General_Float
:= 1.0 - (0.1 ** (Ada.Text_IO.Field'Max (1, Aft))) / 2.0;
begin
Find_Best_Small_Prefix :
while Temp <= Threshold loop
exit Find_Best_Small_Prefix when Scale = Prefixes'First;
-- Value is too small to be optimally represented.
-- Down to next prefix.
Scale := Prefixes'Pred (Scale);
Temp := Temp * Magnitude;
end loop Find_Best_Small_Prefix;
-- Value is (still) too small to be properly represented, treat
-- as zero.
if Temp < 1.0 - Threshold then
Temp := 0.0;
Scale := None;
end if;
end Handle_Small_Prefixes;
else
Handle_Large_Prefixes :
declare
Threshold : constant Float_IO.General_Float :=
Magnitude - ((0.1 ** Aft) / 2.0);
-- If the value is greater than that it will be rounded up.
begin
Find_Best_Large_Prefix :
while Temp >= Threshold loop
exit Find_Best_Large_Prefix when Scale = Prefixes'Last;
-- Value is too large to be optimally represented.
-- Up to next prefix.
Scale := Prefixes'Succ (Scale);
Temp := Temp / Magnitude;
end loop Find_Best_Large_Prefix;
end Handle_Large_Prefixes;
end if;
end if;
-- Restore sign before converting into string.
if Value < 0.0 then
Temp := -Temp;
end if;
Convert_To_Postfixed_String :
declare
Result : String (1 .. 5 + Ada.Text_IO.Field'Max (1, Aft));
-- "-999.[...]";
begin
Try_Numeric_To_String_Conversion :
begin
Float_IO.General_Float_IO.Put (To => Result,
Item => Temp,
Aft => Aft,
Exp => 0);
exception
when Ada.IO_Exceptions.Layout_Error =>
-- Value was larger than 999 Yunits and didn't fit into the
-- string.
-- Reset Scale and return "<inf>"inity instead.
Scale := None;
Result (1 .. 4) := (if Temp < 0.0
then Minus_Sign
else Plus_Sign) & "inf";
Result (5 .. Result'Last) := (others => ' ');
end Try_Numeric_To_String_Conversion;
return Trim (Result &
(if Unit = No_Unit
then ""
else No_Break_Space & Prefix (Scale) & Unit));
end Convert_To_Postfixed_String;
end General_Image;
function Fixed_Image
(Value : in Item;
Aft : in Ada.Text_IO.Field := Default_Aft) return String is
(General_Image (Value => Float_IO.General_Float (Value),
Aft => Aft,
Unit => Unit));
function Float_Image
(Value : in Item;
Aft : in Ada.Text_IO.Field := Default_Aft) return String is
(General_Image (Value => Float_IO.General_Float (Value),
Aft => Aft,
Unit => Unit));
function Integer_Image
(Value : in Item;
Aft : in Ada.Text_IO.Field := Default_Aft) return String is
(General_Image (Value => Float_IO.General_Float (Value),
Aft => Aft,
Unit => Unit));
function Mod_Image
(Value : in Item;
Aft : in Ada.Text_IO.Field := Default_Aft) return String is
(General_Image (Value => Float_IO.General_Float (Value),
Aft => Aft,
Unit => Unit));
end SI_Units.Metric;
|
------------------------------------------------------------------------------
-- AGAR GUI LIBRARY --
-- A G A R . T E X T --
-- S p e c --
------------------------------------------------------------------------------
with Ada.Containers.Indefinite_Vectors;
with Interfaces; use Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
with Interfaces.C.Strings;
with Agar.Types; use Agar.Types;
with Agar.Object;
with Agar.Surface;
with System;
package Agar.Text is
package C renames Interfaces.C;
package CS renames Interfaces.C.Strings;
package SU renames Agar.Surface;
use type C.int;
use type C.unsigned;
TEXT_STATES_MAX : constant C.unsigned := $AG_TEXT_STATES_MAX;
FONT_BOLD : constant C.unsigned := 16#01#;
FONT_ITALIC : constant C.unsigned := 16#02#;
FONT_UNDERLINE : constant C.unsigned := 16#04#;
FONT_UPPERCASE : constant C.unsigned := 16#08#;
-----------------------------------
-- Horizontal Justification Mode --
-----------------------------------
type AG_Text_Justify is
(LEFT,
CENTER,
RIGHT);
for AG_Text_Justify use
(LEFT => 0,
CENTER => 1,
RIGHT => 2);
for AG_Text_Justify'Size use C.int'Size;
-----------------------------
-- Vertical Alignment Mode --
-----------------------------
type AG_Text_Valign is
(TOP,
MIDDLE,
BOTTOM);
for AG_Text_Valign use
(TOP => 0,
MIDDLE => 1,
BOTTOM => 2);
for AG_Text_Valign'Size use C.int'Size;
--------------------------------
-- Type of message to display --
--------------------------------
type AG_Text_Message_Title is
(ERROR, -- Error message alert
WARNING, -- Warning (ignorable)
INFO); -- Informational message (ignorable)
for AG_Text_Message_Title use
(ERROR => 0,
WARNING => 1,
INFO => 2);
for AG_Text_Message_Title'Size use C.int'Size;
------------------
-- Type of font --
------------------
type AG_Font_Type is
(VECTOR, -- Vector font engine (e.g., FreeType)
BITMAP, -- Bitmap font engine (builtin)
DUMMY); -- Null font engine
for AG_Font_Type use
(VECTOR => 0,
BITMAP => 1,
DUMMY => 2);
for AG_Font_Type'Size use C.int'Size;
-------------------------------------------
-- Type of data source to load font from --
-------------------------------------------
type AG_Font_Spec_Source is
(FONT_FILE, -- Load font from file
FONT_IN_MEMORY); -- Deserialize in-memory font data
for AG_Font_Spec_Source use
(FONT_FILE => 0,
FONT_IN_MEMORY => 1);
for AG_Font_Spec_Source'Size use C.int'Size;
----------------------------
-- Size of font in points --
----------------------------
#if HAVE_FLOAT
subtype AG_Font_Points is C.double;
#else
subtype AG_Font_Points is C.int;
#end if;
type Font_Points_Access is access all AG_Font_Points with Convention => C;
----------------------
-- Filename of font --
----------------------
type AG_Font_Source_Filename is array (1 .. $AG_FILENAME_MAX) of
aliased C.char with Convention => C;
-----------------------------
-- Agar font specification --
-----------------------------
type AG_Font_Spec
(Spec_Source : AG_Font_Spec_Source := FONT_FILE) is
record
Size : AG_Font_Points; -- Font size in points
Index : C.int; -- Font index (FC_INDEX)
Font_Type : AG_Font_Type; -- Font engine
Font_Source : AG_Font_Spec_Source; -- Source type
#if HAVE_FLOAT
Matrix_XX : C.double; -- 1 -- -- Transformation matrix
Matrix_XY : C.double; -- 0 --
Matrix_YX : C.double; -- 0 --
Matrix_YY : C.double; -- 1 --
#end if;
case Spec_Source is
when FONT_FILE =>
File_Source : AG_Font_Source_Filename; -- Font file name
when FONT_IN_MEMORY =>
Memory_Source : access Unsigned_8; -- Source memory region
Memory_Size : AG_Size; -- Size in bytes
end case;
end record
with Convention => C;
pragma Unchecked_Union (AG_Font_Spec);
type Font_Spec_Access is access all AG_Font_Spec with Convention => C;
------------------
-- An Agar Font --
------------------
type AG_Font;
type Font_Access is access all AG_Font with Convention => C;
subtype Font_not_null_Access is not null Font_Access;
type AG_Font_Entry is limited record
Next : Font_Access;
Prev : access Font_Access;
end record
with Convention => C;
type AG_Font_Bitmap_Spec is array (1 .. 32) of aliased C.char
with Convention => C;
type AG_Font is limited record
Super : aliased Agar.Object.Object; -- [Font]
Spec : aliased AG_Font_Spec; -- Font specification
Flags : C.unsigned; -- Options
Height : C.int; -- Height in pixels
Ascent : C.int; -- Ascent relative to baseline
Descent : C.int; -- Descent relative to baseline
Line_Skip : C.int; -- Multiline Y-increment
TTF : System.Address; -- TODO TTF interface
Bitmap_Spec : aliased AG_Font_Bitmap_Spec; -- Bitmap font spec
Bitmap_Glyphs : System.Address; -- TODO Bitmap glyph array
Bitmap_Glyph_Count : C.unsigned; -- Bitmap glyph count
Char_0, Char_1 : AG_Char; -- Bitmap font spec
Reference_Count : C.unsigned; -- Reference count for cache
Entry_in_Cache : AG_Font_Entry; -- Entry in cache
end record
with Convention => C;
----------------------------------
-- A rendered (in-memory) glyph --
----------------------------------
type AG_Glyph;
type Glyph_Access is access all AG_Glyph with Convention => C;
type AG_Glyph_Entry is limited record
Next : Glyph_Access;
end record
with Convention => C;
type AG_Glyph is limited record
Font : Font_not_null_Access; -- Back pointer to font
Color : SU.AG_Color; -- Base color
Char : AG_Char; -- Native character
Surface : SU.Surface_not_null_Access; -- Rendered surface
Advance : C.int; -- Advance in pixels
Texture : C.unsigned; -- Mapped texture (by driver)
Texcoords : SU.AG_Texcoord; -- Texture coordinates
Entry_in_Cache : AG_Glyph_Entry; -- Entry in cache
end record
with Convention => C;
---------------------------------------
-- Pushable/poppable state variables --
---------------------------------------
type AG_Text_State is record
Font : Font_not_null_Access; -- Font face
Color : SU.AG_Color; -- Foreground text color
Color_BG : SU.AG_Color; -- Background color
Justify : AG_Text_Justify; -- Justification mode
Valign : AG_Text_Valign; -- Vertical alignment
Tab_Wd : C.int; -- Width of tabs in pixels
end record
with Convention => C;
------------------------------------------
-- Statically-compiled font description --
------------------------------------------
type AG_Static_Font is array (1 .. $SIZEOF_AG_StaticFont)
of aliased Unsigned_8 with Convention => C;
for AG_Static_Font'Size use $SIZEOF_AG_StaticFont * System.Storage_Unit;
------------------------------
-- Measure of rendered text --
------------------------------
type AG_Text_Metrics is record
W, H : C.int; -- Dimensions in pixels
Line_Widths : access C.unsigned; -- Width of each line
Line_Count : C.unsigned; -- Total line count
end record
with Convention => C;
type Text_Metrics_Access is access all AG_Text_Metrics with Convention => C;
subtype Text_Metrics_not_null_Access is not null Text_Metrics_Access;
package Text_Line_Widths_Packages is new Ada.Containers.Indefinite_Vectors
(Index_Type => Positive,
Element_Type => Natural);
subtype Text_Line_Widths is Text_Line_Widths_Packages.Vector;
--------------------------
-- Internal glyph cache --
--------------------------
type AG_Glyph_Cache is array (1 .. $SIZEOF_AG_GlyphCache)
of aliased Unsigned_8 with Convention => C;
for AG_Glyph_Cache'Size use $SIZEOF_AG_GlyphCache * System.Storage_Unit;
--
-- Initialize the font engine.
--
function Init_Text_Subsystem return Boolean;
--
-- Release all resources allocated by the font engine.
--
procedure Destroy_Text_Subsystem;
--
-- Set the default Agar font (by access to a Font object).
--
procedure Set_Default_Font (Font : in Font_not_null_Access)
with Import, Convention => C, Link_Name => "AG_SetDefaultFont";
--
-- Set the default Agar font (by a font specification string).
--
-- Syntax: "(family):(size):(style)". Valid field separators include
-- `:', `,', `.' and `/'. This works with fontconfig if available.
-- Size is whole points (no fractional allowed with the default font).
-- Style may include `b' (bold), `i' (italic) and `U' (uppercase).
--
procedure Set_Default_Font (Spec : in String);
--
-- Load (or fetch from cache) a font.
--
function Fetch_Font
(Family : in String := "_agFontVera";
Size : in AG_Font_Points := AG_Font_Points(12);
Bold : in Boolean := False;
Italic : in Boolean := False;
Underlined : in Boolean := False;
Uppercase : in Boolean := False) return Font_Access;
--
-- Decrement the reference count of a font (and free unreferenced fonts).
--
procedure Unused_Font (Font : in Font_not_null_Access)
with Import, Convention => C, Link_Name => "AG_UnusedFont";
--
-- Push and pop the font engine rendering state.
--
procedure Push_Text_State
with Import, Convention => C, Link_Name => "AG_PushTextState";
procedure Pop_Text_State
with Import, Convention => C, Link_Name => "AG_PopTextState";
--
-- Set the current font to the specified family+size+style (or just size).
--
function Set_Font
(Family : in String;
Size : in AG_Font_Points := AG_Font_Points(12);
Bold : in Boolean := False;
Italic : in Boolean := False;
Underlined : in Boolean := False;
Uppercase : in Boolean := False) return Font_Access;
--
-- Set the current font to a given % of the current font size.
--
function Set_Font (Percent : in Natural) return Font_Access;
--
-- Return the expected size in pixels of rendered (UTF-8) text.
--
procedure Size_Text
(Text : in String;
W,H : out Natural);
procedure Size_Text
(Text : in String;
W,H : out Natural;
Line_Count : out Natural);
procedure Size_Text
(Text : in String;
W,H : out Natural;
Line_Count : out Natural;
Line_Widths : out Text_Line_Widths);
--
-- Display an informational message window (canned dialog).
--
procedure Message_Box
(Title : in AG_Text_Message_Title := INFO;
Text : in String);
#if AG_TIMERS
procedure Message_Box
(Title : in AG_Text_Message_Title := INFO;
Text : in String;
Time : in Natural := 2000);
#end if;
private
function AG_InitTextSubsystem return C.int
with Import, Convention => C, Link_Name => "AG_InitTextSubsystem";
procedure AG_DestroyTextSubsystem
with Import, Convention => C, Link_Name => "AG_DestroyTextSubsystem";
procedure AG_TextParseFontSpec
(Spec : in CS.chars_ptr)
with Import, Convention => C, Link_Name => "AG_TextParseFontSpec";
function AG_FetchFont
(Family : in CS.chars_ptr;
Size : in Font_Points_Access;
Flags : in C.unsigned) return Font_Access
with Import, Convention => C, Link_Name => "AG_FetchFont";
function AG_TextFontLookup
(Family : in CS.chars_ptr;
Size : in Font_Points_Access;
Flags : in C.unsigned) return Font_Access
with Import, Convention => C, Link_Name => "AG_TextFontLookup";
function AG_TextFontPct
(Percent : in C.int) return Font_Access
with Import, Convention => C, Link_Name => "AG_TextFontPct";
procedure AG_TextSize
(Text : in CS.chars_ptr;
W,H : access C.int)
with Import, Convention => C, Link_Name => "AG_TextSize";
type AG_TextSizeMulti_Line_Entry is array (C.unsigned range <>)
of aliased C.unsigned with Convention => C;
package Line_Width_Array is new Interfaces.C.Pointers
(Index => C.unsigned,
Element => C.unsigned,
Element_Array => AG_TextSizeMulti_Line_Entry,
Default_Terminator => 0);
procedure AG_TextSizeMulti
(Text : in CS.chars_ptr;
W,H : access C.int;
W_Lines : in Line_Width_Array.Pointer;
N_Lines : access C.unsigned)
with Import, Convention => C, Link_Name => "AG_TextSizeMulti";
procedure AG_TextMsgS
(Title : in AG_Text_Message_Title;
Text : in CS.chars_ptr)
with Import, Convention => C, Link_Name => "AG_TextMsgS";
#if AG_TIMERS
procedure AG_TextTmsgS
(Title : in AG_Text_Message_Title;
Time : in Unsigned_32;
Text : in CS.chars_ptr)
with Import, Convention => C, Link_Name => "AG_TextTmsgS";
#end if;
end Agar.Text;
|
pragma License (Unrestricted);
-- implementation unit required by compiler
package System.Mantissa is
pragma Pure;
-- required for Fixed'Mantissa, if its range is dynamic (s-mantis.ads)
function Mantissa_Value (First, Last : Integer) return Natural;
end System.Mantissa;
|
with Utils.Command_Lines; use Utils.Command_Lines;
with Utils.Command_Lines.Common; use Utils.Command_Lines.Common;
package JSON_Gen.Command_Lines is
package Freeze_Common is new Freeze_Descriptor (Common_Descriptor);
Descriptor : aliased Command_Line_Descriptor :=
Copy_Descriptor (Common_Descriptor);
pragma Warnings (Off);
use Common_Flag_Switches, Common_String_Switches,
Common_String_Seq_Switches, Common_Nat_Switches;
pragma Warnings (On);
package Json_Gen_Disable is new Disable_Switches
(Descriptor, (To_All (Rep_Clauses), To_All (Compute_Timing)));
type Json_Gen_Flags is
(Subunits,
Force,
Alphabetical_Order,
Comment_Header_Sample,
Comment_Header_Spec,
Ignored_Keep_Tree_File,
No_Exception,
No_Local_Header,
Ignored_Reuse_Tree_File,
Ignored_Overwrite_Tree_File);
-- Above "Ignored_" switches are legacy switches from the ASIS-based
-- version.
package Json_Gen_Flag_Switches is new Flag_Switches
(Descriptor,
Json_Gen_Flags);
package Json_Gen_Flag_Shorthands is new Json_Gen_Flag_Switches.Set_Shorthands
((Subunits => null,
Force => +"-f",
Alphabetical_Order => +"-gnatyo",
Comment_Header_Sample => +"-hg",
Comment_Header_Spec => +"-hs",
Ignored_Keep_Tree_File => +"-k",
No_Exception => null,
No_Local_Header => null,
Ignored_Reuse_Tree_File => +"-r",
Ignored_Overwrite_Tree_File => +"-t"));
type Json_Gen_Strings is
(Header_File,
Output);
package Json_Gen_String_Switches is new String_Switches
(Descriptor,
Json_Gen_Strings);
package Json_Gen_String_Syntax is new Json_Gen_String_Switches.Set_Syntax
((Header_File => '=',
Output => '='));
package Json_Gen_String_Shorthands is new Json_Gen_String_Switches
.Set_Shorthands
((Header_File => null,
Output => +"-o"));
-- ???Perhaps Max_Line_Length, Indentation should be moved to Common, and
-- gnatpp and gnatstub shorthands unified. Output is also shared between
-- gnatpp and gnatstub. Or perhaps gnatstub should import Pp.Command_Lines.
type Json_Gen_Nats is
(Max_Line_Length,
Indentation,
Update_Body); -- undocumented
-- Update_Body is intended mainly for use by GPS or other text editors
package Json_Gen_Nat_Switches is new Other_Switches
(Descriptor,
Json_Gen_Nats,
Natural,
Natural'Image,
Natural'Value);
package Json_Gen_Nat_Syntax is new Json_Gen_Nat_Switches.Set_Syntax
((Max_Line_Length => '!',
Indentation => '!',
Update_Body => '='));
No_Update_Body : constant Natural := 0;
package Json_Gen_Nat_Defaults is new Json_Gen_Nat_Switches.Set_Defaults
((Max_Line_Length => 79,
Indentation => 3,
Update_Body => No_Update_Body));
package Json_Gen_Nat_Shorthands is new Json_Gen_Nat_Switches.Set_Shorthands
((Max_Line_Length => +"-gnatyM",
Indentation => +"-gnaty",
Update_Body => null));
package Json_Gen_Nat_Shorthands_2 is new Json_Gen_Nat_Switches.Set_Shorthands
((Max_Line_Length => +"-l",
Indentation => +"-i",
Update_Body => null));
package Freeze is new Freeze_Descriptor (Descriptor);
pragma Warnings (Off);
use Json_Gen_Flag_Switches,
Json_Gen_String_Switches,
Json_Gen_Nat_Switches;
pragma Warnings (On);
subtype Cmd_Line is Utils.Command_Lines.Command_Line;
function Update_Body_Specified (Cmd : Cmd_Line) return Boolean is
(Arg (Cmd, Update_Body) /= No_Update_Body);
-- If --update-body was not specified on the command line, then it will be
-- equal to the default (No_Update_Body).
end JSON_Gen.Command_Lines;
|
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
with Apsepp.Test_Node_Class.Generic_Case_And_Suite_Run_Body;
package Apsepp.Test_Node_Class.Suite_Stub is
type Test_Suite_Stub is limited new Test_Node_Interfa with private
with Type_Invariant'Class =>
Test_Suite_Stub.Invariant_Class_Test_Suite_Stub;
not overriding
function Invariant_Class_Test_Suite_Stub
(Obj : Test_Suite_Stub) return Boolean
is (Test_Suite_Stub'Class (Obj).Routine_Count = 0
and then
Test_Suite_Stub'Class (Obj).Has_Early_Test);
overriding
procedure Run
(Obj : in out Test_Suite_Stub;
Outcome : out Test_Outcome;
Kind : Run_Kind := Assert_Cond_And_Run_Test);
overriding
function Child_Count (Obj : Test_Suite_Stub) return Test_Node_Count
is (0);
overriding
function Child (Obj : Test_Suite_Stub;
K : Test_Node_Index) return Test_Node_Access;
overriding
function Routine_Count (Obj : Test_Suite_Stub) return Test_Routine_Count
is (0);
overriding
function Routine (Obj : Test_Suite_Stub;
K : Test_Routine_Index) return Test_Routine
is (Null_Test_Routine'Access)
with Pre'Class => K <= Obj.Routine_Count;
overriding
function No_Subtasking (Obj : Test_Suite_Stub) return Boolean
is (False);
overriding
function Has_Early_Test (Obj : Test_Suite_Stub) return Boolean
is (True);
overriding
function Early_Run_Done (Obj : Test_Suite_Stub) return Boolean;
overriding
procedure Early_Run (Obj : in out Test_Suite_Stub);
procedure Run_Children (Obj : Test_Node_Interfa'Class;
Outcome : out Test_Outcome;
Kind : Run_Kind);
procedure Run_Body
is new Generic_Case_And_Suite_Run_Body (Work => Run_Children);
private
type Test_Suite_Stub is limited new Test_Node_Interfa with record
Early_Run_Done_Flag : Boolean := False;
end record;
end Apsepp.Test_Node_Class.Suite_Stub;
|
------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Child_Processes.Standard_IO;
procedure Child_Processes.Wait_And_Buffer
(Process : in out Child_Process'Class;
Poll_Rate: in Duration;
Timeout : in Duration;
Output : out Buffer_Type;
Error : out Buffer_Type;
Timed_Out: out Boolean;
Status : out Exit_Status)
is
use Standard_IO;
type IO_Stream_Access is access all Standard_IO_Stream'Class with
Storage_Size => 0;
STDOUT: constant IO_Stream_Access
:= IO_Stream_Access (Process.IO_Stream (Standard_Output));
STDERR: constant IO_Stream_Access
:= IO_Stream_Access (Process.IO_Stream (Standard_Error));
package Stream_Buffers is
type Stream_Buffer is new Root_Stream_Type with
record
Buffer: Stream_Element_Array (1 .. 512);
-- Note there is a GNAT bug here where if this array is any
-- larger than 512, To_String can't handle it.
Level : Stream_Element_Offset := 0;
end record;
-- To reduce the number of system calls
overriding
procedure Write (Stream: in out Stream_Buffer;
Item : in Stream_Element_Array)
is null;
overriding
procedure Read (Stream: in out Stream_Buffer;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset);
not overriding
function To_String (Stream: aliased in out Stream_Buffer)
return String;
end Stream_Buffers;
package body Stream_Buffers is
----------
-- Read --
----------
-- The purpose of Read is to use the Ada stream attributes for String
-- to voncert from out Stream_Element_Array to a String. Obviously this
-- call only happens here, so we are strict in what we expect for the
-- parameters -> that they exactly fit the size of the buffer
procedure Read (Stream: in out Stream_Buffer;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset)
is
Buffer_Slice: Stream_Element_Array
renames Stream.Buffer (Stream.Buffer'First .. Stream.Level);
begin
Item := Stream.Buffer (Stream.Buffer'First .. Stream.Level);
Last := Item'Last;
Stream.Level := 0;
end Read;
---------------
-- To_String --
---------------
function To_String (Stream: aliased in out Stream_Buffer)
return String
is
pragma Assert (Character'Stream_Size = Stream_Element'Size);
-- To be honest, we're pretty darn sure this is always going to be
-- one Character per Stream_Element, but this is good form.
begin
return S: String (1 .. Natural (Stream.Level)) do
String'Read (Stream'Access, S);
end return;
end To_String;
end Stream_Buffers;
use Stream_Buffers;
Out_Buffer: aliased Stream_Buffer;
Err_Buffer: aliased Stream_Buffer;
Start: Time;
Discard: Boolean;
procedure Drain_Streams is
begin
loop
STDOUT.Read_Immediate (Item => Out_Buffer.Buffer,
Last => Out_Buffer.Level);
STDERR.Read_Immediate (Item => Err_Buffer.Buffer,
Last => Err_Buffer.Level);
exit when Out_Buffer.Level = 0 and Err_Buffer.Level = 0;
if Out_Buffer.Level > 0 then
Append (Buffer => Output,
Item => Out_Buffer.To_String);
end if;
if Err_Buffer.Level > 0 then
Append (Buffer => Error,
Item => Err_Buffer.To_String);
end if;
end loop;
end Drain_Streams;
begin
Timed_Out := False;
Start := Clock;
Output := Empty_Buffer;
Error := Empty_Buffer;
loop
Drain_Streams;
if Process.Terminated then
-- Get the status
Process.Wait_Terminated (Timeout => 0.0,
Timed_Out => Discard,
Status => Status);
-- Drain one last time
Drain_Streams;
return;
end if;
delay Poll_Rate;
exit when Clock > Start + Timeout;
end loop;
Drain_Streams;
Timed_Out := True;
end Child_Processes.Wait_And_Buffer;
|
case Today is
when Monday =>
Compute_Starting_Balance;
when Friday =>
Compute_Ending_Balance;
when Tuesday .. Thursday =>
Accumulate_Sales;
-- ignore Saturday and Sunday
end case;
|
------------------------------------------------------------------------------
-- --
-- Internet Protocol Suite Package --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Calendar;
with Interfaces.C.Strings;
with INET.TLS;
with INET.Internal.OS_Constants; use INET.Internal.OS_Constants;
pragma External_With ("inet-internal-tls-sys.c");
use Interfaces.C;
package body INET.Internal.TLS is
TLS_Error : exception renames INET.TLS.TLS_Error;
TLS_Handshake_Failed: exception renames INET.TLS.TLS_Handshake_Failed;
---------------------
-- Raise_TLS_Error --
---------------------
function Context_Error_Message (Context: TLS_Context'Class) return String is
use Interfaces.C.Strings;
function tls_error (Context: in Context_Handle) return chars_ptr with
Import => True, Convention => C, External_Name => "tls_error";
-- <tls.h> tls_error(3). The returned string probably points to a buffer
-- in Context somewhere. In any case, it does not need to be freed by
-- the callee.
error_string: constant chars_ptr := tls_error (Context.Handle);
begin
return (if error_string /= Null_Ptr then
Value (error_string)
else
"[No error message available from libtls]");
end Context_Error_Message;
procedure Raise_TLS_Error (Context : in TLS_Context'Class;
Preamble: in String)
with No_Return is
begin
raise TLS_Error with Preamble & ": "
& Context_Error_Message (Context);
end Raise_TLS_Error;
--
-- libtls Imports
--
function tls_init return int with
Import => True, Convention => C, External_Name => "tls_init";
function tls_client return Context_Handle with
Import => True, Convention => C, External_Name => "tls_client";
function tls_server return Context_Handle with
Import => True, Convention => C, External_Name => "tls_server";
-- <tls.h> tls_client(3)
function tls_configure (ctx : Context_Handle;
config: INET_Extension_Handle)
return int
with Import => True, Convention => C, External_Name => "tls_configure";
function tls_close (ctx: in Context_Handle) return int with
Import => True, Convention => C, External_Name => "tls_close";
procedure tls_reset (ctx: in Context_Handle) with
Import => True, Convention => C, External_Name => "tls_reset";
procedure tls_free (ctx: in Context_Handle) with
Import => True, Convention => C, External_Name => "tls_free";
-- <tls.h> tls_read(3)
TLS_WANT_POLLIN: constant ssize_t with
Import => True, Convention => C,
External_Name => "__inet_internal_tls_sys_TLS_WANT_POLLIN";
TLS_WANT_POLLOUT: constant ssize_t with
Import => True, Convention => C,
External_Name => "__inet_internal_tls_sys_TLS_WANT_POLLOUT";
-- <tls.h> tls_read(3)
--
-- Common Facilities
--
-----------------------------
-- Cryptographic_Randomize --
-----------------------------
-- The actual facilities to do this is very platform-dependent. So the
-- actual platform-dependent part will be in the C part.
-- (Arbitrary Data) --------------------------------------------------
procedure Cryptographic_Randomize (Data : out Random_Data) is
procedure cryptorand_buffer (buf: out Random_Data;
len: in Interfaces.C.size_t)
with Import => True, Convention => C,
External_Name => "__inet_internal_tls_sys_cryptorand_buffer";
begin
if Data'Length = 0 then return; end if;
cryptorand_buffer (buf => Data, len => Data'Length);
end Cryptographic_Randomize;
-- (Unsigned 32) -----------------------------------------------------
procedure Cryptographic_Randomize (Value: out Interfaces.Unsigned_32) is
function cryptorand_uint32 return Interfaces.Unsigned_32 with
Import => True, Convention => C,
External_Name => "__inet_internal_tls_sys_cryptorand_uint32";
begin
Value := cryptorand_uint32;
end Cryptographic_Randomize;
--
-- TLS_Context
--
---------------
-- Available --
---------------
function Available (Context: TLS_Context) return Boolean is
(Context.Avail and then Context.Handle /= Null_Context_Handle);
--------------
-- Shutdown --
--------------
procedure Shutdown (Context: in out TLS_Context) is
Retval: int;
begin
if not Context.Available then
return;
end if;
Retval := tls_close (Context.Handle);
Context.Avail := False;
-- We might be tempted to say that the return value of close doesn't
-- matter, because what can we do about it? But this is TLS, and
-- security is important. We're explicit about every failure.
if Retval /= 0 then
Raise_TLS_Error (Context, "Failed to close TLS context");
end if;
end Shutdown;
---------------
-- Handshake --
---------------
procedure Handshake (Context: in out TLS_Context;
Socket : in UNIX_Sockets.UNIX_Socket;
Timeout: in Duration)
is
use Ada.Calendar;
function tls_handshake (ctx: Context_Handle) return int with
Import => True, Convention => C,
External_Name => "tls_handshake";
Mark : constant Time := Clock;
Check: Time;
Retval : ssize_t;
Discard: int;
begin
if not Context.Avail then
raise Program_Error with "Attempt to execute a TLS handshake on an "
& "inactive context";
end if;
loop
Retval := ssize_t (tls_handshake (Context.Handle));
if Retval in TLS_WANT_POLLIN | TLS_WANT_POLLOUT then
Check := Clock;
if Check >= Mark + Timeout then
Discard := tls_close (Context.Handle);
raise TLS_Handshake_Failed with "Handshake timed-out";
end if;
UNIX_Sockets.Wait
(Socket => Socket,
Direction => (if Retval = TLS_WANT_POLLIN then
UNIX_Sockets.Inbound
else
UNIX_Sockets.Outbound),
Timeout => (Mark + Timeout) - Check);
elsif Retval < 0 then
declare
Error: constant String := Context_Error_Message (Context);
begin
Discard := tls_close (Context.Handle);
raise TLS_Handshake_Failed with Error;
end;
else
-- All good
return;
end if;
end loop;
end Handshake;
--------------
-- Finalize --
--------------
procedure Finalize (Context: in out TLS_Context) is
Discard: int;
begin
if Context.Handle = Null_Context_Handle then return; end if;
Discard := tls_close (Context.Handle);
tls_free (Context.Handle);
end Finalize;
--
-- TLS_Listener_Context
--
---------------
-- Configure --
---------------
procedure Configure
(Context : in out TLS_Listener_Context;
Configuration: in INET.TLS.TLS_Server_Configuration'Class)
is
Retval : int;
Discard: int;
Config_Handle: INET_Extension_Handle;
begin
if Context.Available then
Discard := tls_close (Context.Handle);
tls_reset (Context.Handle);
elsif Context.Handle = Null_Context_Handle then
Context.Handle := tls_server;
if Context.Handle = Null_Context_Handle then
raise TLS_Error with "Unable to allocate new TLS server context" ;
end if;
end if;
Context.Avail := False;
Configuration.Get_External_Handle (Config_Handle);
Retval := tls_configure (ctx => Context.Handle,
config => Config_Handle);
if Retval /= 0 then
Raise_TLS_Error (Context, "Unable to configure TLS server context");
else
Context.Avail := True;
end if;
end Configure;
--
-- TLS_Stream_Context
--
---------------
-- Establish --
---------------
procedure Establish
(Context : in out TLS_Stream_Context;
Listener_Context: in TLS_Listener_Context'Class;
Socket : in UNIX_Sockets.UNIX_Socket;
Timeout : in Duration)
is
function tls_accept_socket (ctx : in Context_Handle;
cctx : out Context_Handle;
socket: in int)
return int
with Import => True, Convention => C,
External_Name => "tls_accept_socket";
s: constant int := UNIX_Sockets.TCP_Socket_Descriptor (Socket);
Retval, Discard: int;
begin
if Context.Available then
raise Program_Error with "Attempt to establish a TLS context "
& "on an active context.";
elsif not Listener_Context.Available then
raise Program_Error with "Attempt to establish a TLS context "
& "on an inactive listener context.";
end if;
-- No explicit check for the status of Socket because, tbh, that is
-- not something the user can mess up, so it would be a bug in the
-- INET subsystem, and would show up immediately.
-- In the case of an Establish on an Listener_Context, unfortunately we
-- cannot reuse an old context, since tls_accept_socket makes a new
-- context so we need to deallocate it now,
-- unconditionally. If the handle is null, this has no effect
-- (tls_free(3))
tls_free (Context.Handle);
Context.Handle := Null_Context_Handle;
-- tls_accept_socket(3) takes an established socket, not a listen
-- socket, so this is a socket that's been accepted already at the
-- TCP level
Retval := tls_accept_socket (ctx => Listener_Context.Handle,
cctx => Context.Handle,
socket => s);
if Retval /= 0 then
tls_free (Context.Handle);
Context.Handle := Null_Context_Handle;
Raise_TLS_Error (Context, "Failed to establish TLS context");
end if;
Context.Avail := True;
Context.Handshake (Socket, Timeout);
exception
when others =>
Discard := tls_close (Context.Handle);
Context.Avail := False;
raise;
end Establish;
----------------------------------------------------------------------
procedure Establish
(Context : in out TLS_Stream_Context;
Configuration: in INET.TLS.TLS_Client_Configuration'Class;
Socket : in UNIX_Sockets.UNIX_Socket;
Timeout : in Duration)
is begin
Context.Establish (Configuration => Configuration,
Server_Name => "",
Socket => Socket,
Timeout => Timeout);
end Establish;
----------------------------------------------------------------------
procedure Establish
(Context : in out TLS_Stream_Context;
Configuration: in INET.TLS.TLS_Client_Configuration'Class;
Server_Name : in String;
Socket : in UNIX_Sockets.UNIX_Socket;
Timeout : in Duration)
is
use Interfaces.C.Strings;
function tls_connect_socket (ctx : Context_Handle;
s : int;
servername: chars_ptr)
return int
with Import => True, Convention => C,
External_Name => "tls_connect_socket";
s: constant int := UNIX_Sockets.TCP_Socket_Descriptor (Socket);
servername: aliased char_array := To_C (Server_Name);
servername_ptr: constant chars_ptr
:= (if Server_Name'Length > 0 then
To_Chars_Ptr (servername'Unchecked_Access)
-- We promoise that tls_connect_socket will not pass
-- servername_ptr around all over the place after the call
else
Null_Ptr);
Config_Handle: INET_Extension_Handle;
Retval, Discard: int;
begin
if Context.Available then
raise Program_Error with "Attempt to establish a TLS context "
& "on an active context.";
end if;
Context.Avail := False; -- Should be redundant, but is safer
-- For outbound establishments, we have the opportunity to re-use the
-- context.
if Context.Handle /= Null_Context_Handle then
tls_reset (Context.Handle);
else
Context.Handle := tls_client;
if Context.Handle = Null_Context_Handle then
raise TLS_Error with "Failed to allocate TLS context";
end if;
end if;
-- Now we configure the session
Configuration.Get_External_Handle (Config_Handle);
Retval := tls_configure (ctx => Context.Handle,
config => Config_Handle);
if Retval /= 0 then
Raise_TLS_Error (Context, "TLS context configuration failed");
-- We don't need to do anything else here since Context.Available
-- will be false due to Context.Avail being false;
end if;
Retval := tls_connect_socket
(ctx => Context.Handle,
s => s,
servername => servername_ptr);
if Retval /= 0 then
Raise_TLS_Error (Context, "TLS socket-context association failed");
end if;
Context.Avail := True;
Context.Handshake (Socket, Timeout);
exception
when others =>
Discard := tls_close (Context.Handle);
Context.Avail := False;
raise;
end Establish;
------------------------
-- TLS_Send_Immediate --
------------------------
procedure TLS_Send_Immediate
(Context: in out TLS_Stream_Context;
Buffer : in Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset)
is
use Ada.Streams;
function tls_write (ctx: Context_Handle;
buf: Stream_Element_Array;
buflen: size_t)
return ssize_t
with Import => True, Convention => C, External_Name => "tls_write";
Retval: ssize_t;
begin
if not Context.Available then
raise Program_Error with
"Attempted TLS write via an inactive context";
elsif Buffer'Length < 1 then
Last := Buffer'First - 1;
return;
end if;
Retval := tls_write (ctx => Context.Handle,
buf => Buffer,
buflen => Buffer'Length);
if Retval > 0 then
Last := Buffer'First + Stream_Element_Offset (Retval) - 1;
elsif Retval = TLS_WANT_POLLOUT then
-- Outbound buffer is full
Last := Buffer'First - 1;
else
Raise_TLS_Error (Context, "TLS write failed");
end if;
end;
---------------------------
-- TLS_Receive_Immediate --
---------------------------
procedure TLS_Receive_Immediate
(Context: in out TLS_Stream_Context;
Buffer : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset)
is
use Ada.Streams;
function tls_read (ctx : Context_Handle;
buf : Stream_Element_Array;
buflen: size_t)
return ssize_t
with Import => True, Convention => C, External_Name => "tls_read";
Retval: ssize_t;
begin
if not Context.Available then
raise Program_Error with
"Attempted TLS write via an inactive context";
elsif Buffer'Length < 1 then
Last := Buffer'First - 1;
return;
end if;
Retval := tls_read (ctx => Context.Handle,
buf => Buffer,
buflen => Buffer'Length);
if Retval > 0 then
Last := Buffer'First + Stream_Element_Offset (Retval) - 1;
elsif Retval = TLS_WANT_POLLIN then
-- Nothing available in the (decrypted) buffer
Last := Buffer'First - 1;
else
Raise_TLS_Error (Context, "TLS read failed");
end if;
end TLS_Receive_Immediate;
begin
-- Initialize libtls
if tls_init /= 0 then
raise Program_Error with "Failed to initialize libtls";
end if;
end INET.Internal.TLS;
|
package body Semantica.Declsc3a is
-- Taula Procediments
procedure Nouproc
(Tp : in out T_Procs;
Idp : out Num_Proc) is
begin
Posa(Tp, Info_Proc_Nul, Idp);
end Nouproc;
function Consulta
(Tp : in T_Procs;
Idp : in Num_Proc) return Info_Proc is
begin
return Tp.Tp(Idp);
end Consulta;
-- Taula Variables
function Consulta
(Tv : in T_Vars;
Idv : in Num_Var) return Info_Var is
begin
return Tv.Tv(Idv);
end Consulta;
procedure Modif_Descripcio
(Tv : in out T_Vars;
Idv : in Num_Var;
Iv : in Info_Var) is
begin
Tv.Tv(Idv) := Iv;
end Modif_Descripcio;
procedure Novavar
(Tv : in out T_Vars;
Idpr : in Num_Proc;
Idv : out Num_Var) is
Ip : Info_Proc := Info_Proc_Nul;
Iv : Info_Var := Info_Var_Nul;
Numvar : Integer := Integer (Tv.Nv) + 1;
Nomvar : String := "_var" &
Integer'Image(Numvar);
Idn : Id_Nom;
begin
Nomvar(Nomvar'First + 4) := '_' ;
Posa_Id(Tn, Idn, Nomvar);
Ip:=Consulta(Tp, Idpr);
Iv:=(Id => Idn,
Np => Idpr,
Ocup => Integer'Size / 8,
Desp => 0,
Tsub => Tsent,
Param => False,
Const => False,
Valconst => 0);
Ip.Ocup_Var := Ip.Ocup_Var + Iv.Ocup;
Posa(Tv, Iv, Idv);
Modif_Descripcio(Tp, Idpr, Ip);
end Novavar;
procedure Novaconst
(Tv : in out T_Vars;
Vc : in Valor;
Tsub : in Tipussubjacent;
Idpr : in Num_Proc;
Idc : out Num_Var) is
Idn : Id_Nom;
E : Boolean;
Iv : Info_Var;
D : Descrip;
Ocup : Despl;
Nconst : Num_Var := Tv.Nv + 1;
Nomconst : String := "_cnt" & Nconst'img;
begin
Nomconst(Nomconst'First + 4) := '_';
if Tsub=Tsarr then
Ocup:=16*Integer'Size;
Nomconst(2..4):="str";
else
Ocup:=Integer'Size/8;
end if;
Posa_Id(Tn, Idn, Nomconst);
Iv:=(Id => Idn,
Np => Idpr,
Ocup => Integer'Size / 8,
Desp => 0,
Tsub => Tsub,
Param => False,
Const => True,
Valconst => Vc);
Posa(Tv, Iv, Idc);
D:=(Dconst,
Id_Nul,
Vc,
Nconst);
Posa(Ts, Idn, D, E);
end Novaconst;
function Nova_Etiq return Num_Etiq is
begin
Ne := Ne + 1;
return Ne;
end Nova_Etiq;
function Etiqueta
(Idpr : in num_Proc) return String is
Nomproc : String := Cons_Nom
(Tn, Consulta(Tp, Idpr).Idn);
begin
return "_" & Trim(Nomproc, Both);
end Etiqueta;
function Etiqueta
(N : in Integer) return String is
Text : String := "_etq" & Integer'Image (N);
begin
Text(Text'First+4):='_';
return Trim(Text, Both);
end Etiqueta;
function Etiqueta
(Ipr : in Info_Proc) return String is
begin
case Ipr.Tp is
when Intern =>
return "_etq_" & Trim(Ipr.Etiq'Img, Both);
when Extern =>
return "_" &
Trim(Cons_Nom(Tn, Ipr.Etiq_Extern), Both);
end case;
end Etiqueta;
--Fitxers
procedure Crea_Fitxer
(Nom_Fitxer : in String) is
begin
Create(F3as, Out_File, Nom_Fitxer&".c3as");
Create(F3at, Out_File, Nom_Fitxer&".c3at");
end Crea_Fitxer;
procedure Obrir_Fitxer
(Nom_Fitxer : in String) is
begin
Open(F3as, In_File, Nom_Fitxer&".c3as");
end Obrir_Fitxer;
procedure Tanca_Fitxer is
begin
Close(F3as);
end Tanca_Fitxer;
procedure Llegir_Fitxer
(Instruccio : out c3a) is
begin
Read(F3as, Instruccio);
end Llegir_Fitxer;
procedure Escriure_Fitxer
(Instruccio : in c3a) is
begin
-- Escriptura a arxiu binari
Write(F3as, Instruccio);
-- Escriptura a arxiu de text
Put(F3at, Instruccio.Instr'Img & Ascii.Ht);
if Instruccio.Instr <= Branc_Inc then
-- 1 operand
case Instruccio.Camp1.Tc is
when Proc =>
Put_Line(F3at, Instruccio.Camp1.Idp'Img);
when Var =>
Put_Line(F3at, Instruccio.Camp1.Idv'Img);
when Const =>
Put_Line(F3at, Instruccio.Camp1.Idc'Img);
when Etiq =>
Put_Line(F3at, Instruccio.Camp1.Ide'Img);
when others =>
null;
end case;
elsif Instruccio.Instr <= Paramc then
-- 2 operands
case Instruccio.Camp1.Tc is
when Proc =>
Put(F3at, Instruccio.Camp1.Idp'Img &
Ascii.Ht);
when Var =>
Put(F3at, Instruccio.Camp1.Idv'Img &
Ascii.Ht);
when Const =>
Put(F3at, Instruccio.Camp1.Idc'Img &
Ascii.Ht);
when Etiq =>
Put(F3at, Instruccio.Camp1.Ide'Img &
Ascii.Ht);
when others =>
null;
end case;
case Instruccio.Camp2.Tc is
when Proc =>
Put_Line(F3at, Instruccio.Camp2.Idp'Img);
when Var =>
Put_Line(F3at, Instruccio.Camp2.Idv'Img);
when Const =>
Put_Line(F3at, Instruccio.Camp2.Idc'Img);
when Etiq =>
Put_Line(F3at, Instruccio.Camp1.Ide'Img);
when others =>
null;
end case;
else
-- 3 operands
case Instruccio.Camp1.Tc is
when Proc =>
Put(F3at, Instruccio.Camp1.Idp'Img &
Ascii.Ht);
when Var =>
Put(F3at, Instruccio.Camp1.Idv'Img &
Ascii.Ht);
when Const =>
Put(F3at, Instruccio.Camp1.Idc'Img &
Ascii.Ht);
when Etiq =>
Put(F3at, Instruccio.Camp1.Ide'Img &
Ascii.Ht);
when others =>
null;
end case;
case Instruccio.Camp2.Tc is
when Proc =>
Put(F3at, Instruccio.Camp2.Idp'Img &
Ascii.Ht);
when Var =>
Put(F3at, Instruccio.Camp2.Idv'Img &
Ascii.Ht);
when Const =>
Put(F3at, Instruccio.Camp2.Idc'Img &
Ascii.Ht);
when Etiq =>
Put(F3at, Instruccio.Camp1.Ide'Img &
Ascii.Ht);
when others =>
null;
end case;
case Instruccio.Camp3.Tc is
when Proc =>
Put_Line(F3at, Instruccio.Camp3.Idp'Img);
when Var =>
Put_Line(F3at, Instruccio.Camp3.Idv'Img);
when Const =>
Put_Line(F3at, Instruccio.Camp3.Idc'Img);
when Etiq =>
Put_Line(F3at, Instruccio.Camp3.Ide'Img);
when others =>
null;
end case;
end if;
end Escriure_Fitxer;
function Fi_Fitxer return Boolean is
begin
return End_Of_File(F3as);
end Fi_Fitxer;
end Semantica.Declsc3a;
|
-- Copyright (c) 2020-2021 Bartek thindil Jasicki <thindil@laeran.pl>
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Ada.Containers; use Ada.Containers;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
with GNAT.String_Split; use GNAT.String_Split;
with CArgv;
with Tcl; use Tcl;
with Tcl.Ada; use Tcl.Ada;
with Tcl.Tk.Ada; use Tcl.Tk.Ada;
with Tcl.Tk.Ada.Grid;
with Tcl.Tk.Ada.Widgets; use Tcl.Tk.Ada.Widgets;
with Tcl.Tk.Ada.Widgets.TtkButton; use Tcl.Tk.Ada.Widgets.TtkButton;
with Tcl.Tk.Ada.Widgets.TtkEntry; use Tcl.Tk.Ada.Widgets.TtkEntry;
with Tcl.Tk.Ada.Widgets.TtkEntry.TtkComboBox;
use Tcl.Tk.Ada.Widgets.TtkEntry.TtkComboBox;
with Tcl.Tk.Ada.Widgets.TtkEntry.TtkSpinBox;
use Tcl.Tk.Ada.Widgets.TtkEntry.TtkSpinBox;
with Tcl.Tk.Ada.Widgets.TtkFrame; use Tcl.Tk.Ada.Widgets.TtkFrame;
with Tcl.Tk.Ada.Widgets.TtkLabel; use Tcl.Tk.Ada.Widgets.TtkLabel;
with Bases; use Bases;
with BasesTypes; use BasesTypes;
with Crew; use Crew;
with Events; use Events;
with Factions; use Factions;
with Game; use Game;
with Game.SaveLoad; use Game.SaveLoad;
with Items; use Items;
with Maps; use Maps;
with Maps.UI; use Maps.UI;
with ShipModules; use ShipModules;
with Ships; use Ships;
with Ships.Cargo; use Ships.Cargo;
with Utils.UI; use Utils.UI;
package body DebugUI is
-- ****o* DebugUI/DebugUI.Refresh_Module_Command
-- FUNCTION
-- Refresh the information about selected module
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- RefreshModule
-- SOURCE
function Refresh_Module_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Refresh_Module_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc, Argv);
FrameName: constant String := ".debugdialog.main.ship";
ProtoCombo: constant Ttk_ComboBox :=
Get_Widget(FrameName & ".proto", Interp);
ModuleCombo: constant Ttk_ComboBox :=
Get_Widget(FrameName & ".module", Interp);
ModuleIndex: Positive;
SpinBox: Ttk_SpinBox := Get_Widget(FrameName & ".weight", Interp);
begin
ModuleIndex := Natural'Value(Current(ModuleCombo)) + 1;
Set
(ProtoCombo,
"{" &
To_String
(Modules_List(Player_Ship.Modules(ModuleIndex).Proto_Index).Name) &
"}");
Set(SpinBox, Positive'Image(Player_Ship.Modules(ModuleIndex).Weight));
SpinBox.Name := New_String(FrameName & ".dur");
Set(SpinBox, Integer'Image(Player_Ship.Modules(ModuleIndex).Durability));
SpinBox.Name := New_String(FrameName & ".maxdur");
Set
(SpinBox,
Positive'Image(Player_Ship.Modules(ModuleIndex).Max_Durability));
SpinBox.Name := New_String(FrameName & ".upgrade");
Set
(SpinBox,
Natural'Image(Player_Ship.Modules(ModuleIndex).Upgrade_Progress));
return TCL_OK;
end Refresh_Module_Command;
-- ****o* DebugUI/DebugUI.Refresh_Member_Command
-- FUNCTION
-- Refresh the information about selected crew member
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- RefreshMember
-- SOURCE
function Refresh_Member_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Refresh_Member_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc, Argv);
use Tiny_String;
FrameName: constant String := ".debugdialog.main.crew";
ComboBox: Ttk_ComboBox := Get_Widget(FrameName & ".member", Interp);
SpinBox: Ttk_SpinBox := Get_Widget(FrameName & ".stats2.health", Interp);
MemberFrame: Ttk_Frame := Get_Widget(FrameName & ".stats", Interp);
Rows: Natural := 0;
Tokens: Slice_Set;
Label: Ttk_Label;
Member: Member_Data
(Amount_Of_Attributes => Attributes_Amount,
Amount_Of_Skills => Skills_Amount);
SkillsIndexes: Positive_Container.Vector;
SkillsList: Unbounded_String;
begin
Member := Player_Ship.Crew(Natural'Value(Current(ComboBox)) + 1);
Set(SpinBox, Positive'Image(Member.Health));
SpinBox.Name := New_String(FrameName & ".stats2.thirst");
Set(SpinBox, Positive'Image(Member.Thirst));
SpinBox.Name := New_String(FrameName & ".stats2.hunger");
Set(SpinBox, Positive'Image(Member.Hunger));
SpinBox.Name := New_String(FrameName & ".stats2.tired");
Set(SpinBox, Positive'Image(Member.Tired));
SpinBox.Name := New_String(FrameName & ".stats2.morale");
Set(SpinBox, Positive'Image(Member.Morale(1)));
SpinBox.Name := New_String(FrameName & ".stats2.loyalty");
Set(SpinBox, Positive'Image(Member.Loyalty));
Create(Tokens, Tcl.Tk.Ada.Grid.Grid_Size(MemberFrame), " ");
Rows := Natural'Value(Slice(Tokens, 2));
Delete_Widgets(1, Rows - 1, MemberFrame);
Show_Stats_Loop :
for I in Member.Attributes'Range loop
Label :=
Create
(MemberFrame & ".label" & Trim(Positive'Image(I), Left),
"-text {" &
To_String
(AttributesData_Container.Element(Attributes_List, I).Name) &
"}");
Tcl.Tk.Ada.Grid.Grid(Label);
SpinBox :=
Create
(MemberFrame & ".value" & Trim(Positive'Image(I), Left),
"-from 1 -to 50 -validate key -validatecommand {ValidateSpinbox %W %P} -width 5");
Set(SpinBox, Positive'Image(Member.Attributes(I).Level));
Tcl.Tk.Ada.Grid.Grid(SpinBox, "-column 1 -row" & Positive'Image(I));
end loop Show_Stats_Loop;
MemberFrame.Name := New_String(FrameName & ".skills");
Create(Tokens, Tcl.Tk.Ada.Grid.Grid_Size(MemberFrame), " ");
Rows := Natural'Value(Slice(Tokens, 2));
Delete_Widgets(1, Rows - 1, MemberFrame);
Show_Skills_Loop :
for I in Member.Skills.Iterate loop
Label :=
Create
(MemberFrame & ".label" &
Trim(Positive'Image(Skills_Container.To_Index(I)), Left),
"-text {" &
To_String
(SkillsData_Container.Element
(Skills_List, Member.Skills(I).Index)
.Name) &
"}");
Tcl.Tk.Ada.Grid.Grid(Label);
SpinBox :=
Create
(MemberFrame & ".value" &
Trim(Positive'Image(Skills_Container.To_Index(I)), Left),
"-from 1 -to 100 -validate key -validatecommand {ValidateSpinbox %W %P} -width 5");
Set(SpinBox, Positive'Image(Member.Skills(I).Level));
Tcl.Tk.Ada.Grid.Grid
(SpinBox,
"-column 1 -row" & Positive'Image(Skills_Container.To_Index(I)));
SkillsIndexes.Append(Member.Skills(I).Index);
end loop Show_Skills_Loop;
Show_Add_Skills_Loop :
for I in 1 .. Skills_Amount loop
if not SkillsIndexes.Contains(I) then
Append
(SkillsList,
" " &
To_String(SkillsData_Container.Element(Skills_List, I).Name));
end if;
end loop Show_Add_Skills_Loop;
ComboBox.Name := New_String(FrameName & ".addskill.skills");
configure(ComboBox, "-values [list" & To_String(SkillsList) & "]");
Current(ComboBox, "0");
return TCL_OK;
end Refresh_Member_Command;
-- ****o* DebugUI/DebugUI.Refresh_Cargo_Command
-- FUNCTION
-- Refresh the information about the player ship cargo
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- RefreshCargo
-- SOURCE
function Refresh_Cargo_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Refresh_Cargo_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc, Argv);
FrameName: constant String := ".debugdialog.main.cargo";
CargoCombo: constant Ttk_ComboBox :=
Get_Widget(FrameName & ".update", Interp);
ItemIndex: Positive;
AmountBox: constant Ttk_SpinBox :=
Get_Widget(FrameName & ".updateamount", Interp);
begin
ItemIndex := Natural'Value(Current(CargoCombo)) + 1;
Set(AmountBox, Positive'Image(Player_Ship.Cargo(ItemIndex).Amount));
return TCL_OK;
end Refresh_Cargo_Command;
-- ****o* DebugUI/DebugUI.Refresh_Events_Command
-- FUNCTION
-- Refresh the list of events
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- RefreshEvents
-- SOURCE
function Refresh_Events_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Refresh_Events_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc, Argv);
FrameName: constant String := ".debugdialog.main.world.deleteevent";
EventsBox: constant Ttk_ComboBox :=
Get_Widget(FrameName & ".delete", Interp);
ValuesList: Unbounded_String;
EventsButton: constant Ttk_Button :=
Get_Widget(FrameName & ".deleteevent", Interp);
begin
if Events_List.Length = 0 then
Tcl.Tk.Ada.Grid.Grid_Remove(EventsButton);
Tcl.Tk.Ada.Grid.Grid_Remove(EventsBox);
return TCL_OK;
else
Tcl.Tk.Ada.Grid.Grid(EventsButton);
Tcl.Tk.Ada.Grid.Grid(EventsBox);
end if;
Update_Events_Loop :
for Event of Events_List loop
case Event.EType is
when EnemyShip =>
Append
(ValuesList,
" {Enemy ship: " &
To_String(Proto_Ships_List(Event.ShipIndex).Name) & "}");
when AttackOnBase =>
Append
(ValuesList,
" {Attack on base: " &
To_String(Proto_Ships_List(Event.ShipIndex).Name) & "}");
when Disease =>
Append
(ValuesList,
" {Disease in base: " &
To_String
(Sky_Bases(SkyMap(Event.SkyX, Event.SkyY).BaseIndex)
.Name) &
"}");
when DoublePrice =>
Append
(ValuesList,
" {Double price in base: " &
To_String
(Sky_Bases(SkyMap(Event.SkyX, Event.SkyY).BaseIndex)
.Name) &
"}");
when FullDocks =>
Append
(ValuesList,
" {Full docks in base: " &
To_String
(Sky_Bases(SkyMap(Event.SkyX, Event.SkyY).BaseIndex)
.Name) &
"}");
when EnemyPatrol =>
Append
(ValuesList,
" {Enemy patrol: " &
To_String(Proto_Ships_List(Event.ShipIndex).Name) & "}");
when Trader =>
Append
(ValuesList,
" {Trader: " &
To_String(Proto_Ships_List(Event.ShipIndex).Name) & "}");
when FriendlyShip =>
Append
(ValuesList,
" {Friendly ship: " &
To_String(Proto_Ships_List(Event.ShipIndex).Name) & "}");
when others =>
null;
end case;
end loop Update_Events_Loop;
configure(EventsBox, "-values [list" & To_String(ValuesList) & "]");
Current(EventsBox, "0");
return TCL_OK;
end Refresh_Events_Command;
-- ****o* DebugUI/DebugUI.Refresh_Command
-- FUNCTION
-- Refresh the whole game information
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command.
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- Refresh
-- SOURCE
function Refresh_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Refresh_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
use Interfaces.C;
FrameName: constant String := ".debugdialog.main";
SpinBox: Ttk_SpinBox := Get_Widget(FrameName & ".ship.x", Interp);
ComboBox: Ttk_ComboBox := Get_Widget(FrameName & ".ship.module", Interp);
ValuesList: Unbounded_String;
begin
Set(SpinBox, Positive'Image(Player_Ship.Sky_X));
SpinBox.Name := New_String(FrameName & ".ship.y");
Set(SpinBox, Positive'Image(Player_Ship.Sky_Y));
Update_Modules_Loop :
for Module of Player_Ship.Modules loop
Append(ValuesList, " {" & Module.Name & "}");
end loop Update_Modules_Loop;
configure(ComboBox, "-values [list" & To_String(ValuesList) & "]");
Current(ComboBox, "0");
if Refresh_Module_Command(ClientData, Interp, Argc, Argv) /= TCL_OK then
return TCL_ERROR;
end if;
ComboBox.Name := New_String(FrameName & ".crew.member");
ValuesList := Null_Unbounded_String;
Update_Members_Loop :
for Member of Player_Ship.Crew loop
Append(ValuesList, " {" & Member.Name & "}");
end loop Update_Members_Loop;
configure(ComboBox, "-values [list" & To_String(ValuesList) & "]");
Current(ComboBox, "0");
if Refresh_Member_Command(ClientData, Interp, Argc, Argv) /= TCL_OK then
return TCL_ERROR;
end if;
ComboBox.Name := New_String(FrameName & ".cargo.update");
ValuesList := Null_Unbounded_String;
Update_Cargo_Loop :
for Item of Player_Ship.Cargo loop
Append(ValuesList, " {" & GetItemName(Item, False, False) & "}");
end loop Update_Cargo_Loop;
configure(ComboBox, "-values [list" & To_String(ValuesList) & "]");
Current(ComboBox, "0");
if Refresh_Cargo_Command(ClientData, Interp, Argc, Argv) /= TCL_OK then
return TCL_ERROR;
end if;
if Refresh_Events_Command(ClientData, Interp, Argc, Argv) /= TCL_OK then
return TCL_ERROR;
end if;
return TCL_OK;
end Refresh_Command;
-- ****o* DebugUI/DebugUI.Refresh_Base_Command
-- FUNCTION
-- Refresh the information about the selected base
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- RefreshBase
-- SOURCE
function Refresh_Base_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Refresh_Base_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc, Argv);
FrameName: constant String := ".debugdialog.main.bases";
NameEntry: constant Ttk_Entry := Get_Widget(FrameName & ".name", Interp);
BaseIndex: Natural := 0;
BaseName: constant Unbounded_String :=
To_Unbounded_String(Get(NameEntry));
ComboBox: Ttk_ComboBox := Get_Widget(FrameName & ".type", Interp);
SpinBox: Ttk_SpinBox := Get_Widget(FrameName & ".population", Interp);
begin
Find_Base_Index_Loop :
for I in Sky_Bases'Range loop
if Sky_Bases(I).Name = BaseName then
BaseIndex := I;
exit Find_Base_Index_Loop;
end if;
end loop Find_Base_Index_Loop;
if BaseIndex = 0 then
return TCL_OK;
end if;
Set
(ComboBox,
To_String(Bases_Types_List(Sky_Bases(BaseIndex).Base_Type).Name));
ComboBox.Name := New_String(FrameName & ".owner");
Set(ComboBox, To_String(Factions_List(Sky_Bases(BaseIndex).Owner).Name));
ComboBox.Name := New_String(FrameName & ".size");
Current
(ComboBox, Natural'Image(Bases_Size'Pos(Sky_Bases(BaseIndex).Size)));
Set(SpinBox, Natural'Image(Sky_Bases(BaseIndex).Population));
SpinBox.Name := New_String(FrameName & ".reputation");
Set(SpinBox, Integer'Image(Sky_Bases(BaseIndex).Reputation(1)));
SpinBox.Name := New_String(FrameName & ".money");
if Sky_Bases(BaseIndex).Cargo.Length > 0 then
Set(SpinBox, Natural'Image(Sky_Bases(BaseIndex).Cargo(1).Amount));
else
Set(SpinBox, "0");
end if;
return TCL_OK;
end Refresh_Base_Command;
-- ****o* DebugUI/DebugUI.Save_Game_Command
-- FUNCTION
-- Save the game
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed. Unused
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- DebugSaveGame
-- SOURCE
function Save_Game_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Save_Game_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Interp, Argc, Argv);
begin
Save_Game(True);
return TCL_OK;
end Save_Game_Command;
-- ****o* DebugUI/DebugUI.Move_Ship_Command
-- FUNCTION
-- Move the player ship
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- DebugMoveShip
-- SOURCE
function Move_Ship_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Move_Ship_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc, Argv);
FrameName: constant String := ".debugdialog.main.ship";
SpinBox: Ttk_SpinBox := Get_Widget(FrameName & ".x", Interp);
begin
Player_Ship.Sky_X := Positive'Value(Get(SpinBox));
SpinBox.Name := New_String(FrameName & ".y");
Player_Ship.Sky_Y := Positive'Value(Get(SpinBox));
ShowSkyMap(True);
return TCL_OK;
end Move_Ship_Command;
-- ****o* DebugUI/DebugUI.Update_Module_Command
-- FUNCTION
-- Update the selected module
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- DebugUpdateModule
-- SOURCE
function Update_Module_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Update_Module_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc, Argv);
FrameName: constant String := ".debugdialog.main.ship";
ModuleBox: constant Ttk_ComboBox :=
Get_Widget(FrameName & ".module", Interp);
ModuleIndex: constant Positive := Natural'Value(Current(ModuleBox)) + 1;
ProtoCombo: constant Ttk_ComboBox :=
Get_Widget(FrameName & ".proto", Interp);
Value: Unbounded_String := To_Unbounded_String(Get(ProtoCombo));
SpinBox: Ttk_SpinBox := Get_Widget(FrameName & ".weight", Interp);
begin
Update_Proto_Index_Loop :
for I in Modules_List.Iterate loop
if Modules_List(I).Name = Value then
Value := Null_Unbounded_String;
Player_Ship.Modules(ModuleIndex).Proto_Index :=
BaseModules_Container.Key(I);
exit Update_Proto_Index_Loop;
end if;
end loop Update_Proto_Index_Loop;
Player_Ship.Modules(ModuleIndex).Weight := Natural'Value(Get(SpinBox));
SpinBox.Name := New_String(FrameName & ".dur");
Player_Ship.Modules(ModuleIndex).Durability :=
Natural'Value(Get(SpinBox));
SpinBox.Name := New_String(FrameName & ".maxdur");
Player_Ship.Modules(ModuleIndex).Max_Durability :=
Natural'Value(Get(SpinBox));
SpinBox.Name := New_String(FrameName & ".upgrade");
Player_Ship.Modules(ModuleIndex).Upgrade_Progress :=
Natural'Value(Get(SpinBox));
return TCL_OK;
end Update_Module_Command;
-- ****o* DebugUI/DebugUI.Add_Skill_Command
-- FUNCTION
-- Add a new skill to the selected crew member
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command.
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- DebugAddSkill
-- SOURCE
function Add_Skill_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Add_Skill_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
use Tiny_String;
FrameName: constant String := ".debugdialog.main.crew";
ComboBox: Ttk_ComboBox := Get_Widget(FrameName & ".member", Interp);
MemberIndex: constant Positive := Natural'Value(Current(ComboBox)) + 1;
SkillName: Unbounded_String;
begin
ComboBox.Name := New_String(FrameName & ".addskill.skills");
SkillName := To_Unbounded_String(Get(ComboBox));
Add_Skill_Loop :
for I in 1 .. Skills_Amount loop
if To_Unbounded_String
(To_String(SkillsData_Container.Element(Skills_List, I).Name)) =
SkillName then
Player_Ship.Crew(MemberIndex).Skills.Append((I, 1, 0));
return Refresh_Member_Command(ClientData, Interp, Argc, Argv);
end if;
end loop Add_Skill_Loop;
return TCL_OK;
end Add_Skill_Command;
-- ****o* DebugUI/DebugUI.Update_Member_Command
-- FUNCTION
-- Update the selected crew member
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- DebugUpdateMember
-- SOURCE
function Update_Member_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Update_Member_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc, Argv);
FrameName: constant String := ".debugdialog.main.crew";
ComboBox: constant Ttk_ComboBox :=
Get_Widget(FrameName & ".member", Interp);
MemberIndex: Positive;
SpinBox: Ttk_SpinBox := Get_Widget(FrameName & ".stats2.health", Interp);
Local_Attribute: Mob_Attribute_Record;
begin
MemberIndex := Natural'Value(Current(ComboBox)) + 1;
Player_Ship.Crew(MemberIndex).Health := Skill_Range'Value(Get(SpinBox));
SpinBox.Name := New_String(FrameName & ".stats2.thirst");
Player_Ship.Crew(MemberIndex).Thirst := Skill_Range'Value(Get(SpinBox));
SpinBox.Name := New_String(FrameName & ".stats2.hunger");
Player_Ship.Crew(MemberIndex).Hunger := Skill_Range'Value(Get(SpinBox));
SpinBox.Name := New_String(FrameName & ".stats2.tired");
Player_Ship.Crew(MemberIndex).Tired := Skill_Range'Value(Get(SpinBox));
SpinBox.Name := New_String(FrameName & ".stats2.morale");
Player_Ship.Crew(MemberIndex).Morale(1) :=
Skill_Range'Value(Get(SpinBox));
SpinBox.Name := New_String(FrameName & ".stats2.loyalty");
Player_Ship.Crew(MemberIndex).Loyalty := Skill_Range'Value(Get(SpinBox));
Update_Stats_Loop :
for I in Player_Ship.Crew(MemberIndex).Attributes'Range loop
SpinBox.Name :=
New_String
(FrameName & ".stats.value" & Trim(Positive'Image(I), Left));
Local_Attribute :=
(Positive'Value(Get(SpinBox)),
Player_Ship.Crew(MemberIndex).Attributes(I).Experience);
Player_Ship.Crew(MemberIndex).Attributes(I) := Local_Attribute;
end loop Update_Stats_Loop;
Update_Skills_Loop :
for I in Player_Ship.Crew(MemberIndex).Skills.Iterate loop
SpinBox.Name :=
New_String
(FrameName & ".skills.value" &
Trim(Positive'Image(Skills_Container.To_Index(I)), Left));
Player_Ship.Crew(MemberIndex).Skills(I).Level :=
Positive'Value(Get(SpinBox));
end loop Update_Skills_Loop;
return TCL_OK;
end Update_Member_Command;
-- ****o* DebugUI/DebugUI.Add_Item_Command
-- FUNCTION
-- Add a new item to the player ship cargo
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command.
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- DebugAddItem
-- SOURCE
function Add_Item_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Add_Item_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
FrameName: constant String := ".debugdialog.main.cargo";
ItemEntry: constant Ttk_Entry := Get_Widget(FrameName & ".add", Interp);
ItemBox: constant Ttk_SpinBox :=
Get_Widget(FrameName & ".amount", Interp);
ItemIndex, ItemName: Unbounded_String;
begin
ItemName := To_Unbounded_String(Get(ItemEntry));
Find_Index_Loop :
for I in Items_List.Iterate loop
if Items_List(I).Name = ItemName then
ItemIndex := Objects_Container.Key(I);
exit Find_Index_Loop;
end if;
end loop Find_Index_Loop;
if ItemIndex = Null_Unbounded_String then
return TCL_OK;
end if;
UpdateCargo(Player_Ship, ItemIndex, Positive'Value(Get(ItemBox)));
return Refresh_Command(ClientData, Interp, Argc, Argv);
end Add_Item_Command;
-- ****o* DebugUI/DebugUI.Update_Item_Command
-- FUNCTION
-- Update the amount of an item in the player ship cargo
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command.
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- DebugUpdateItem
-- SOURCE
function Update_Item_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Update_Item_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
FrameName: constant String := ".debugdialog.main.cargo";
ItemCombo: constant Ttk_ComboBox :=
Get_Widget(FrameName & ".update", Interp);
ItemBox: constant Ttk_SpinBox :=
Get_Widget(FrameName & ".updateamount", Interp);
ItemIndex: Positive;
begin
ItemIndex := Natural'Value(Current(ItemCombo)) + 1;
UpdateCargo
(Ship => Player_Ship, Amount => Positive'Value(Get(ItemBox)),
CargoIndex => ItemIndex);
return Refresh_Command(ClientData, Interp, Argc, Argv);
end Update_Item_Command;
-- ****o* DebugUI/DebugUI.Update_Base_Command
-- FUNCTION
-- Update the selected base
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- DebugUpdateBase
-- SOURCE
function Update_Base_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Update_Base_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc, Argv);
FrameName: constant String := ".debugdialog.main.bases";
BaseIndex: Natural := 0;
BaseEntry: constant Ttk_Entry := Get_Widget(FrameName & ".name", Interp);
BaseName: Unbounded_String;
BaseCombo: Ttk_ComboBox := Get_Widget(FrameName & ".type", Interp);
BaseBox: Ttk_SpinBox := Get_Widget(FrameName & ".population", Interp);
begin
BaseName := To_Unbounded_String(Get(BaseEntry));
Find_Index_Loop :
for I in Sky_Bases'Range loop
if Sky_Bases(I).Name = BaseName then
BaseIndex := I;
exit Find_Index_Loop;
end if;
end loop Find_Index_Loop;
if BaseIndex = 0 then
return TCL_OK;
end if;
Update_Base_Type_Loop :
for I in Bases_Types_List.Iterate loop
if Bases_Types_List(I).Name = To_Unbounded_String(Get(BaseCombo)) then
Sky_Bases(BaseIndex).Base_Type := BasesTypes_Container.Key(I);
exit Update_Base_Type_Loop;
end if;
end loop Update_Base_Type_Loop;
BaseCombo.Name := New_String(FrameName & ".owner");
Update_Base_Owner_Loop :
for I in Factions_List.Iterate loop
if Factions_List(I).Name = To_Unbounded_String(Get(BaseCombo)) then
Sky_Bases(BaseIndex).Owner := Factions_Container.Key(I);
exit Update_Base_Owner_Loop;
end if;
end loop Update_Base_Owner_Loop;
BaseCombo.Name := New_String(FrameName & ".size");
Sky_Bases(BaseIndex).Size := Bases_Size'Value(Get(BaseCombo));
Sky_Bases(BaseIndex).Population := Natural'Value(Get(BaseBox));
BaseBox.Name := New_String(FrameName & ".reputation");
Sky_Bases(BaseIndex).Reputation(1) := Integer'Value(Get(BaseBox));
BaseBox.Name := New_String(FrameName & ".money");
Sky_Bases(BaseIndex).Cargo(1).Amount := Natural'Value(Get(BaseBox));
return TCL_OK;
end Update_Base_Command;
-- ****o* DebugUI/DebugUI.Add_Ship_Command
-- FUNCTION
-- Add a new ship based event to the game
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command.
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- DebugAddShip
-- SOURCE
function Add_Ship_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Add_Ship_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
FrameName: constant String := ".debugdialog.main.world";
ShipEntry: constant Ttk_Entry := Get_Widget(FrameName & ".ship", Interp);
ShipName: Unbounded_String;
NpcShipX, NpcShipY, Duration: Positive;
ShipBox: Ttk_SpinBox := Get_Widget(FrameName & ".x", Interp);
begin
ShipName := To_Unbounded_String(Get(ShipEntry));
NpcShipX := Positive'Value(Get(ShipBox));
ShipBox.Name := New_String(FrameName & ".y");
NpcShipY := Positive'Value(Get(ShipBox));
ShipBox.Name := New_String(FrameName & ".duration");
Duration := Positive'Value(Get(ShipBox));
Add_Ship_Event_Loop :
for I in Proto_Ships_List.Iterate loop
if Proto_Ships_List(I).Name = ShipName then
if Traders.Contains(Proto_Ships_Container.Key(I)) then
Events_List.Append
(New_Item =>
(Trader, NpcShipX, NpcShipY, Duration,
Proto_Ships_Container.Key(I)));
elsif FriendlyShips.Contains(Proto_Ships_Container.Key(I)) then
Events_List.Append
(New_Item =>
(FriendlyShip, NpcShipX, NpcShipY, Duration,
Proto_Ships_Container.Key(I)));
else
Events_List.Append
(New_Item =>
(EnemyShip, NpcShipX, NpcShipY, Duration,
Proto_Ships_Container.Key(I)));
end if;
SkyMap(NpcShipX, NpcShipY).EventIndex := Events_List.Last_Index;
return Refresh_Events_Command(ClientData, Interp, Argc, Argv);
end if;
end loop Add_Ship_Event_Loop;
return TCL_OK;
end Add_Ship_Command;
-- ****o* DebugUI/DebugUI.Toggle_Item_Entry_Command
-- FUNCTION
-- Show or hide item entry for bases events
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ToggleItemEntry
-- SOURCE
function Toggle_Item_Entry_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Toggle_Item_Entry_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc, Argv);
FrameName: constant String := ".debugdialog.main.world";
EventCombo: constant Ttk_ComboBox :=
Get_Widget(FrameName & ".event", Interp);
ItemEntry: constant Ttk_Entry := Get_Widget(FrameName & ".item", Interp);
ItemLabel: constant Ttk_Label :=
Get_Widget(FrameName & ".itemlbl", Interp);
begin
if Current(EventCombo) = "1" then
Tcl.Tk.Ada.Grid.Grid(ItemLabel);
Tcl.Tk.Ada.Grid.Grid(ItemEntry);
else
Tcl.Tk.Ada.Grid.Grid_Remove(ItemLabel);
Tcl.Tk.Ada.Grid.Grid_Remove(ItemEntry);
end if;
return TCL_OK;
end Toggle_Item_Entry_Command;
-- ****o* DebugUI/DebugUI.Add_Event_Command
-- FUNCTION
-- Add a new base event to the game
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command.
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- DebugAddEvent
-- SOURCE
function Add_Event_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Add_Event_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
FrameName: constant String := ".debugdialog.main.world";
EventEntry: constant Ttk_Entry :=
Get_Widget(FrameName & ".base", Interp);
EventName: Unbounded_String;
BaseIndex, EventType: Natural := 0;
EventBox: Ttk_ComboBox := Get_Widget(FrameName & ".event", Interp);
DurationBox: constant Ttk_SpinBox :=
Get_Widget(FrameName & ".baseduration", Interp);
Added: Boolean := True;
begin
EventName := To_Unbounded_String(Get(EventEntry));
Find_Base_Index_Loop :
for I in Sky_Bases'Range loop
if Sky_Bases(I).Name = EventName then
BaseIndex := I;
exit Find_Base_Index_Loop;
end if;
end loop Find_Base_Index_Loop;
if BaseIndex = 0 then
return TCL_OK;
end if;
EventType := Natural'Value(Current(EventBox));
case EventType is
when 0 =>
Events_List.Append
(New_Item =>
(Disease, Sky_Bases(BaseIndex).Sky_X,
Sky_Bases(BaseIndex).Sky_Y, Positive'Value(Get(DurationBox)),
1));
when 1 =>
EventBox.Name := New_String(FrameName & ".item");
EventName := To_Unbounded_String(Get(EventBox));
Added := False;
Find_Item_Loop :
for I in Items_List.Iterate loop
if Items_List(I).Name = EventName then
Events_List.Append
(New_Item =>
(DoublePrice, Sky_Bases(BaseIndex).Sky_X,
Sky_Bases(BaseIndex).Sky_Y,
Positive'Value(Get(DurationBox)),
Objects_Container.Key(I)));
Added := True;
exit Find_Item_Loop;
end if;
end loop Find_Item_Loop;
when 2 =>
Events_List.Append
(New_Item =>
(Disease, Sky_Bases(BaseIndex).Sky_X,
Sky_Bases(BaseIndex).Sky_Y, Positive'Value(Get(DurationBox)),
1));
when others =>
null;
end case;
if not Added then
return TCL_OK;
end if;
SkyMap(Sky_Bases(BaseIndex).Sky_X, Sky_Bases(BaseIndex).Sky_Y)
.EventIndex :=
Events_List.Last_Index;
return Refresh_Events_Command(ClientData, Interp, Argc, Argv);
end Add_Event_Command;
-- ****o* DebugUI/DebugUI.Delete_Event_Command
-- FUNCTION
-- Remove the selected event from the game
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command.
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- DebugDeleteEvent
-- SOURCE
function Delete_Event_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Delete_Event_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
EventBox: constant Ttk_ComboBox :=
Get_Widget(".debugdialog.main.world.deleteevent.delete", Interp);
begin
DeleteEvent(Natural'Value(Current(EventBox)) + 1);
return Refresh_Events_Command(ClientData, Interp, Argc, Argv);
end Delete_Event_Command;
procedure ShowDebugUI is
FrameName: constant String := ".debugdialog.main.bases";
ComboBox: Ttk_ComboBox := Get_Widget(FrameName & ".type");
ValuesList: Unbounded_String;
begin
Tcl_EvalFile
(Get_Context,
To_String(Data_Directory) & "ui" & Dir_Separator & "debug.tcl");
Add_Command("Refresh", Refresh_Command'Access);
Add_Command("RefreshModule", Refresh_Module_Command'Access);
Add_Command("RefreshMember", Refresh_Member_Command'Access);
Add_Command("RefreshCargo", Refresh_Cargo_Command'Access);
Add_Command("RefreshBase", Refresh_Base_Command'Access);
Add_Command("RefreshEvents", Refresh_Events_Command'Access);
Add_Command("DebugSaveGame", Save_Game_Command'Access);
Add_Command("DebugMoveShip", Move_Ship_Command'Access);
Add_Command("DebugUpdateModule", Update_Module_Command'Access);
Add_Command("DebugAddSkill", Add_Skill_Command'Access);
Add_Command("DebugUpdateMember", Update_Member_Command'Access);
Add_Command("DebugAddItem", Add_Item_Command'Access);
Add_Command("DebugUpdateItem", Update_Item_Command'Access);
Add_Command("DebugUpdateBase", Update_Base_Command'Access);
Add_Command("DebugAddShip", Add_Ship_Command'Access);
Add_Command("ToggleItemEntry", Toggle_Item_Entry_Command'Access);
Add_Command("DebugAddEvent", Add_Event_Command'Access);
Add_Command("DebugDeleteEvent", Delete_Event_Command'Access);
Load_Bases_Types_Loop :
for BaseType of Bases_Types_List loop
Append(ValuesList, " {" & BaseType.Name & "}");
end loop Load_Bases_Types_Loop;
configure(ComboBox, "-values [list" & To_String(ValuesList) & "]");
ValuesList := Null_Unbounded_String;
ComboBox.Name := New_String(FrameName & ".owner");
Load_Factions_Loop :
for Faction of Factions_List loop
Append(ValuesList, " {" & Faction.Name & "}");
end loop Load_Factions_Loop;
configure(ComboBox, "-values [list" & To_String(ValuesList) & "]");
ValuesList := Null_Unbounded_String;
ComboBox.Name := New_String(FrameName & ".name");
Load_Bases_Loop :
for Base of Sky_Bases loop
Append(ValuesList, " {" & Base.Name & "}");
end loop Load_Bases_Loop;
configure(ComboBox, "-values [list" & To_String(ValuesList) & "]");
ComboBox.Name := New_String(".debugdialog.main.world.base");
configure(ComboBox, "-values [list" & To_String(ValuesList) & "]");
ValuesList := Null_Unbounded_String;
ComboBox.Name := New_String(".debugdialog.main.ship.proto");
Load_Modules_Prototypes_Loop :
for Module of Modules_List loop
Append(ValuesList, " {" & Module.Name & "}");
end loop Load_Modules_Prototypes_Loop;
configure(ComboBox, "-values [list" & To_String(ValuesList) & "]");
ValuesList := Null_Unbounded_String;
ComboBox.Name := New_String(".debugdialog.main.cargo.add");
Load_Items_Loop :
for Item of Items_List loop
Append(ValuesList, " {" & Item.Name & "}");
end loop Load_Items_Loop;
configure(ComboBox, "-values [list" & To_String(ValuesList) & "]");
ComboBox.Name := New_String(".debugdialog.main.world.item");
configure(ComboBox, "-values [list" & To_String(ValuesList) & "]");
ValuesList := Null_Unbounded_String;
ComboBox.Name := New_String(".debugdialog.main.world.ship");
Load_Ships_Loop :
for Ship of Proto_Ships_List loop
Append(ValuesList, " {" & Ship.Name & "}");
end loop Load_Ships_Loop;
configure(ComboBox, "-values [list" & To_String(ValuesList) & "]");
Tcl_Eval(Get_Context, "Refresh");
end ShowDebugUI;
end DebugUI;
|
with Extraction.Graph_Operations;
private package Extraction.Deferred_Constants is
procedure Extract_Edges
(Node : LAL.Ada_Node'Class;
Graph : Graph_Operations.Graph_Context);
end Extraction.Deferred_Constants;
|
-- RUN: %llvmgcc -S %s
procedure VCE_LV is
type P is access String ;
type T is new P (5 .. 7);
subtype U is String (5 .. 7);
X : T := new U'(others => 'A');
begin
null;
end;
|
-- Copyright (c) 2015-2017 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
-- @summary
-- Incremental Analysis Component
--
-- @description
-- This package provides namespace for incremental analysis algorithms
-- and related data structures.
--
-- We try to (re-)implement ideas described by Tim A. Wagner his work
-- "Practical Algorithms for Incremental Software Development Environments"
--
-- For each analysed document we keep a persistent history of its parsing
-- tree changes as a sequence (actually tree) of versions. Each such version
-- represents consistent state. Each node of parsing tree provides a flag
-- to report if nested nodes were changed in given version of the document.
-- This allows us to quickly locate the changed subtrees.
--
package Incr is
pragma Pure;
end Incr;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- A D A B K E N D --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2019, 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. --
-- --
------------------------------------------------------------------------------
-- Generic package implementing the common parts of back_end.adb for back ends
-- written in Ada, thereby reducing code duplication.
with Types;
generic
Product_Name : String;
Copyright_Years : String;
with procedure Driver (Root : Types.Node_Id);
-- Main driver procedure for back end
with function Is_Back_End_Switch (Switch : String) return Boolean;
-- Back-end specific function to determine validity of switches
package Adabkend is
procedure Call_Back_End;
-- Call back end, i.e. make call to the Driver passing the root
-- node for this compilation unit.
procedure Scan_Compiler_Arguments;
-- Acquires command-line parameters passed to the compiler and processes
-- them. Calls Scan_Front_End_Switches for any front-end switches
-- encountered. See spec of Back_End for more details.
end Adabkend; |
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with Definitions; use Definitions;
private with Ada.Characters.Latin_1;
private with Parameters;
package Configure is
menu_error : exception;
-- Interactive configuration menu
procedure launch_configure_menu;
-- Print out configuration value
-- If input not 'A' - 'Q', return "Error: Input must be character 'A'...'Q'"
procedure print_configuration_value (option : Character);
private
package LAT renames Ada.Characters.Latin_1;
package PM renames Parameters;
indent : constant String (1 .. 3) := (others => LAT.Space);
type option is range 1 .. 17;
type default is range 1 .. 10;
subtype ofield is String (1 .. 30);
type desc_type is array (option) of ofield;
type default_type is array (default) of ofield;
descriptions : constant desc_type :=
(
"[A] System root directory ",
"[B] Toolchain directory ",
"[C] Localbase directory ",
"[D] Conspiracy directory ",
"[E] Custom ports directory ",
"[F] Distfiles directory ",
"[G] Profile directory (logs+) ",
"[H] Packages directory ",
"[I] Compiler cache directory ",
"[J] Build base directory ",
"[K] Num. concurrent builders ",
"[L] Max. jobs per builder ",
"[M] Avoid use of tmpfs ",
"[N] Fetch prebuilt packages ",
"[O] Display using ncurses ",
"[P] Always record options ",
"[Q] Assume default options "
);
version_desc : constant default_type :=
(
"[A] Firebird SQL server ",
"[B] Lua (language) ",
"[C] MySQL-workalike server ",
"[D] Perl (language) ",
"[E] PHP (language) ",
"[F] PostgreSQL server ",
"[G] Python 3 (language) ",
"[H] Ruby (language) ",
"[I] SSL/TLS library ",
"[J] TCL/TK toolkit "
);
optX5A : constant String := "[V] Set version defaults (e.g. perl, ruby, mysql ...)";
optX1A : constant String := "[>] Switch/create profiles (changes discarded)";
optX1B : constant String := "[>] Switch/create profiles";
optX4B : constant String := "[<] Delete alternative profile";
optX2A : constant String := "[ESC] Exit without saving changes";
optX3A : constant String := "[RET] Save changes (starred) ";
optX3B : constant String := "[RET] Exit ";
dupe : PM.configuration_record;
version_A : constant String := default_firebird & ":3.0";
version_B : constant String := "5.2:" & default_lua & ":5.4";
version_C : constant String := "oracle-5.6:oracle-5.7:" & default_mysql & ":" &
"mariadb-10.2:mariadb-10.3:mariadb-10.4:mariadb-10.5:" &
"percona-5.6:percona-5.7:percona-8.0";
version_D : constant String := default_perl & ":5.32";
version_E : constant String := "7.3:" & default_php & ":8.0";
version_F : constant String := "9.6:10:11:" & default_pgsql & ":13";
version_G : constant String := default_python3 & ":3.9";
version_H : constant String := "2.6:" & default_ruby & ":3.0";
version_I : constant String := "openssl:openssl-devel:" & default_ssl & ":libressl-devel";
version_J : constant String := "8.5:" & default_tcltk;
procedure clear_screen;
procedure print_header;
procedure print_opt (opt : option; pristine : in out Boolean);
procedure change_directory_option (opt : option; pristine : in out Boolean);
procedure change_boolean_option (opt : option; pristine : in out Boolean);
procedure change_positive_option (opt : option; pristine : in out Boolean);
procedure delete_profile;
procedure switch_profile;
procedure move_to_defaults_menu (pristine_def : in out Boolean);
procedure print_default (def : default; pristine_def : in out Boolean);
procedure update_version
(def : default;
choices : String;
label : String);
procedure print_menu
(pristine : in out Boolean;
extra_profiles : Boolean;
pristine_def : Boolean);
end Configure;
|
package Input_0 is
-- Expecting above to create tag 'Input_0/s' as this is 'package spec'-definition with name 'Input_0'.
-- Emacs tag-search on Input_0/s should navigate to the above.
function My_Function return Boolean;
-- Expecting above to create tag 'My_Function/f' as this is 'function'-definition with name My_Function.
-- Emacs tag-search on My_Function/f should navigate to the above.
procedure My_Procedure;
-- Expecting above to create tag 'My_Procedure/p' as this is 'procedure'-definition with name My_Procedure.
-- Emacs tag-search on My_Procedure/p should navigate to the above.
-- Expecting above to create tag 'Input_0/s' as this is 'package spec'-definition with name 'Input_0'.
-- Emacs tag-search on Input_0/s should navigate to the above.
type My_T is (A, B, C);
-- Expecting above to create tag 'My_T/t' as this is 'type'-definition with name 'My_T'.
-- Emacs tag-search on My_T/t should navigate to the above.
task My_Task is
-- Expecting above to create tag 'My_Task/k' as this is 'task'-definition with name 'My_Task'.
-- Emacs tag-search on My_Task/k should navigate to the above.
entry GET (X : in My_T);
end My_Task;
end Input_0;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . T A S K _ T E R M I N A T I O N --
-- --
-- S p e c --
-- --
-- Copyright (C) 2005-2014, 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 was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is a simplified version of this package to be used in when the
-- Ravenscar profile and there are no exception handlers present (either of
-- the restrictions No_Exception_Handlers or No_Exception_Propagation are in
-- effect). This means that the only task termination cause that need to be
-- taken into account is normal task termination (abort is not allowed by
-- the Ravenscar profile and the restricted exception support does not
-- include Exception_Occurrence).
with Ada.Task_Identification;
package Ada.Task_Termination
with SPARK_Mode => On is
pragma Preelaborate (Task_Termination);
type Termination_Handler is access
protected procedure (T : Ada.Task_Identification.Task_Id);
-- ??? This type is not conformant with the RM, as cause and exception
-- occurrence are missing. Adding cause would be easy, but in the sfp
-- profile there is no declaration of Exception_Occurrence.
procedure Set_Dependents_Fallback_Handler
(Handler : Termination_Handler);
function Current_Task_Fallback_Handler return Termination_Handler;
end Ada.Task_Termination;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . W I D E _ T E X T _ I O . W I D E _ U N B O U N D E D _ I O --
-- --
-- S p e c --
-- --
-- This specification is adapted from the Ada Reference Manual for use with --
-- GNAT. In accordance with the copyright of that document, you can freely --
-- copy and modify this specification, provided that if you redistribute a --
-- modified version, any changes that you have made are clearly indicated. --
-- --
------------------------------------------------------------------------------
-- Note: historically GNAT provided these subprograms as a child of the
-- package Ada.Strings.Wide_Unbounded. So we implement this new Ada 2005
-- package by renaming the subprograms in that child. This is a more
-- straightforward implementation anyway, since we need access to the
-- internal representation of Unbounded_Wide_String.
with Ada.Strings.Wide_Unbounded;
with Ada.Strings.Wide_Unbounded.Wide_Text_IO;
package Ada.Wide_Text_IO.Wide_Unbounded_IO is
procedure Put
(File : File_Type;
Item : Strings.Wide_Unbounded.Unbounded_Wide_String)
renames Ada.Strings.Wide_Unbounded.Wide_Text_IO.Put;
procedure Put
(Item : Strings.Wide_Unbounded.Unbounded_Wide_String)
renames Ada.Strings.Wide_Unbounded.Wide_Text_IO.Put;
procedure Put_Line
(File : Wide_Text_IO.File_Type;
Item : Strings.Wide_Unbounded.Unbounded_Wide_String)
renames Ada.Strings.Wide_Unbounded.Wide_Text_IO.Put_Line;
procedure Put_Line
(Item : Strings.Wide_Unbounded.Unbounded_Wide_String)
renames Ada.Strings.Wide_Unbounded.Wide_Text_IO.Put_Line;
function Get_Line
(File : File_Type) return Strings.Wide_Unbounded.Unbounded_Wide_String
renames Ada.Strings.Wide_Unbounded.Wide_Text_IO.Get_Line;
function Get_Line return Strings.Wide_Unbounded.Unbounded_Wide_String
renames Ada.Strings.Wide_Unbounded.Wide_Text_IO.Get_Line;
procedure Get_Line
(File : File_Type;
Item : out Strings.Wide_Unbounded.Unbounded_Wide_String)
renames Ada.Strings.Wide_Unbounded.Wide_Text_IO.Get_Line;
procedure Get_Line
(Item : out Strings.Wide_Unbounded.Unbounded_Wide_String)
renames Ada.Strings.Wide_Unbounded.Wide_Text_IO.Get_Line;
end Ada.Wide_Text_IO.Wide_Unbounded_IO;
|
-- Copyright 2016-2019 NXP
-- All rights reserved.SPDX-License-Identifier: BSD-3-Clause
-- This spec has been automatically generated from LPC55S6x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NXP_SVD.ADC is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Resolution
type VERID_RES_Field is
(
-- Up to 13-bit differential/12-bit single ended resolution supported.
Res_0,
-- Up to 16-bit differential/16-bit single ended resolution supported.
Res_1)
with Size => 1;
for VERID_RES_Field use
(Res_0 => 0,
Res_1 => 1);
-- Differential Supported
type VERID_DIFFEN_Field is
(
-- Differential operation not supported.
Diffen_0,
-- Differential operation supported. CMDLa[CTYPE] controls fields
-- implemented.
Diffen_1)
with Size => 1;
for VERID_DIFFEN_Field use
(Diffen_0 => 0,
Diffen_1 => 1);
-- Multi Vref Implemented
type VERID_MVI_Field is
(
-- Single voltage reference high (VREFH) input supported.
Mvi_0,
-- Multiple voltage reference high (VREFH) inputs supported.
Mvi_1)
with Size => 1;
for VERID_MVI_Field use
(Mvi_0 => 0,
Mvi_1 => 1);
-- Channel Scale Width
type VERID_CSW_Field is
(
-- Channel scaling not supported.
Csw_0,
-- Channel scaling supported. 1-bit CSCALE control field.
Csw_1,
-- Channel scaling supported. 6-bit CSCALE control field.
Csw_6)
with Size => 3;
for VERID_CSW_Field use
(Csw_0 => 0,
Csw_1 => 1,
Csw_6 => 6);
-- Voltage Reference 1 Range Control Bit Implemented
type VERID_VR1RNGI_Field is
(
-- Range control not required. CFG[VREF1RNG] is not implemented.
Vr1Rngi_0,
-- Range control required. CFG[VREF1RNG] is implemented.
Vr1Rngi_1)
with Size => 1;
for VERID_VR1RNGI_Field use
(Vr1Rngi_0 => 0,
Vr1Rngi_1 => 1);
-- Internal ADC Clock implemented
type VERID_IADCKI_Field is
(
-- Internal clock source not implemented.
Iadcki_0,
-- Internal clock source (and CFG[ADCKEN]) implemented.
Iadcki_1)
with Size => 1;
for VERID_IADCKI_Field use
(Iadcki_0 => 0,
Iadcki_1 => 1);
-- Calibration Function Implemented
type VERID_CALOFSI_Field is
(
-- Calibration Not Implemented.
Calofsi_0,
-- Calibration Implemented.
Calofsi_1)
with Size => 1;
for VERID_CALOFSI_Field use
(Calofsi_0 => 0,
Calofsi_1 => 1);
-- Number of Single Ended Outputs Supported
type VERID_NUM_SEC_Field is
(
-- This design supports one single ended conversion at a time.
Num_Sec_0,
-- This design supports two simultanious single ended conversions.
Num_Sec_1)
with Size => 1;
for VERID_NUM_SEC_Field use
(Num_Sec_0 => 0,
Num_Sec_1 => 1);
-- Number of FIFOs
type VERID_NUM_FIFO_Field is
(
-- N/A
Num_Fifo_0,
-- This design supports one result FIFO.
Num_Fifo_1,
-- This design supports two result FIFOs.
Num_Fifo_2,
-- This design supports three result FIFOs.
Num_Fifo_3,
-- This design supports four result FIFOs.
Num_Fifo_4)
with Size => 3;
for VERID_NUM_FIFO_Field use
(Num_Fifo_0 => 0,
Num_Fifo_1 => 1,
Num_Fifo_2 => 2,
Num_Fifo_3 => 3,
Num_Fifo_4 => 4);
subtype VERID_MINOR_Field is HAL.UInt8;
subtype VERID_MAJOR_Field is HAL.UInt8;
-- Version ID Register
type VERID_Register is record
-- Read-only. Resolution
RES : VERID_RES_Field;
-- Read-only. Differential Supported
DIFFEN : VERID_DIFFEN_Field;
-- unspecified
Reserved_2_2 : HAL.Bit;
-- Read-only. Multi Vref Implemented
MVI : VERID_MVI_Field;
-- Read-only. Channel Scale Width
CSW : VERID_CSW_Field;
-- unspecified
Reserved_7_7 : HAL.Bit;
-- Read-only. Voltage Reference 1 Range Control Bit Implemented
VR1RNGI : VERID_VR1RNGI_Field;
-- Read-only. Internal ADC Clock implemented
IADCKI : VERID_IADCKI_Field;
-- Read-only. Calibration Function Implemented
CALOFSI : VERID_CALOFSI_Field;
-- Read-only. Number of Single Ended Outputs Supported
NUM_SEC : VERID_NUM_SEC_Field;
-- Read-only. Number of FIFOs
NUM_FIFO : VERID_NUM_FIFO_Field;
-- unspecified
Reserved_15_15 : HAL.Bit;
-- Read-only. Minor Version Number
MINOR : VERID_MINOR_Field;
-- Read-only. Major Version Number
MAJOR : VERID_MAJOR_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for VERID_Register use record
RES at 0 range 0 .. 0;
DIFFEN at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
MVI at 0 range 3 .. 3;
CSW at 0 range 4 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
VR1RNGI at 0 range 8 .. 8;
IADCKI at 0 range 9 .. 9;
CALOFSI at 0 range 10 .. 10;
NUM_SEC at 0 range 11 .. 11;
NUM_FIFO at 0 range 12 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
MINOR at 0 range 16 .. 23;
MAJOR at 0 range 24 .. 31;
end record;
subtype PARAM_TRIG_NUM_Field is HAL.UInt8;
-- Result FIFO Depth
type PARAM_FIFOSIZE_Field is
(
-- Result FIFO depth = 1 dataword.
Fifosize_1,
-- Result FIFO depth = 4 datawords.
Fifosize_4,
-- Result FIFO depth = 8 datawords.
Fifosize_8,
-- Result FIFO depth = 16 datawords.
Fifosize_16,
-- Result FIFO depth = 32 datawords.
Fifosize_32,
-- Result FIFO depth = 64 datawords.
Fifosize_64)
with Size => 8;
for PARAM_FIFOSIZE_Field use
(Fifosize_1 => 1,
Fifosize_4 => 4,
Fifosize_8 => 8,
Fifosize_16 => 16,
Fifosize_32 => 32,
Fifosize_64 => 64);
subtype PARAM_CV_NUM_Field is HAL.UInt8;
subtype PARAM_CMD_NUM_Field is HAL.UInt8;
-- Parameter Register
type PARAM_Register is record
-- Read-only. Trigger Number
TRIG_NUM : PARAM_TRIG_NUM_Field;
-- Read-only. Result FIFO Depth
FIFOSIZE : PARAM_FIFOSIZE_Field;
-- Read-only. Compare Value Number
CV_NUM : PARAM_CV_NUM_Field;
-- Read-only. Command Buffer Number
CMD_NUM : PARAM_CMD_NUM_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PARAM_Register use record
TRIG_NUM at 0 range 0 .. 7;
FIFOSIZE at 0 range 8 .. 15;
CV_NUM at 0 range 16 .. 23;
CMD_NUM at 0 range 24 .. 31;
end record;
-- ADC Enable
type CTRL_ADCEN_Field is
(
-- ADC is disabled.
Adcen_0,
-- ADC is enabled.
Adcen_1)
with Size => 1;
for CTRL_ADCEN_Field use
(Adcen_0 => 0,
Adcen_1 => 1);
-- Software Reset
type CTRL_RST_Field is
(
-- ADC logic is not reset.
Rst_0,
-- ADC logic is reset.
Rst_1)
with Size => 1;
for CTRL_RST_Field use
(Rst_0 => 0,
Rst_1 => 1);
-- Doze Enable
type CTRL_DOZEN_Field is
(
-- ADC is enabled in Doze mode.
Dozen_0,
-- ADC is disabled in Doze mode.
Dozen_1)
with Size => 1;
for CTRL_DOZEN_Field use
(Dozen_0 => 0,
Dozen_1 => 1);
-- Auto-Calibration Request
type CTRL_CAL_REQ_Field is
(
-- No request for auto-calibration has been made.
Cal_Req_0,
-- A request for auto-calibration has been made
Cal_Req_1)
with Size => 1;
for CTRL_CAL_REQ_Field use
(Cal_Req_0 => 0,
Cal_Req_1 => 1);
-- Configure for offset calibration function
type CTRL_CALOFS_Field is
(
-- Calibration function disabled
Calofs_0,
-- Request for offset calibration function
Calofs_1)
with Size => 1;
for CTRL_CALOFS_Field use
(Calofs_0 => 0,
Calofs_1 => 1);
-- Reset FIFO 0
type CTRL_RSTFIFO0_Field is
(
-- No effect.
Rstfifo0_0,
-- FIFO 0 is reset.
Rstfifo0_1)
with Size => 1;
for CTRL_RSTFIFO0_Field use
(Rstfifo0_0 => 0,
Rstfifo0_1 => 1);
-- Reset FIFO 1
type CTRL_RSTFIFO1_Field is
(
-- No effect.
Rstfifo1_0,
-- FIFO 1 is reset.
Rstfifo1_1)
with Size => 1;
for CTRL_RSTFIFO1_Field use
(Rstfifo1_0 => 0,
Rstfifo1_1 => 1);
-- Auto-Calibration Averages
type CTRL_CAL_AVGS_Field is
(
-- Single conversion.
Cal_Avgs_0,
-- 2 conversions averaged.
Cal_Avgs_1,
-- 4 conversions averaged.
Cal_Avgs_2,
-- 8 conversions averaged.
Cal_Avgs_3,
-- 16 conversions averaged.
Cal_Avgs_4,
-- 32 conversions averaged.
Cal_Avgs_5,
-- 64 conversions averaged.
Cal_Avgs_6,
-- 128 conversions averaged.
Cal_Avgs_7)
with Size => 3;
for CTRL_CAL_AVGS_Field use
(Cal_Avgs_0 => 0,
Cal_Avgs_1 => 1,
Cal_Avgs_2 => 2,
Cal_Avgs_3 => 3,
Cal_Avgs_4 => 4,
Cal_Avgs_5 => 5,
Cal_Avgs_6 => 6,
Cal_Avgs_7 => 7);
-- ADC Control Register
type CTRL_Register is record
-- ADC Enable
ADCEN : CTRL_ADCEN_Field := NXP_SVD.ADC.Adcen_0;
-- Software Reset
RST : CTRL_RST_Field := NXP_SVD.ADC.Rst_0;
-- Doze Enable
DOZEN : CTRL_DOZEN_Field := NXP_SVD.ADC.Dozen_0;
-- Auto-Calibration Request
CAL_REQ : CTRL_CAL_REQ_Field := NXP_SVD.ADC.Cal_Req_0;
-- Configure for offset calibration function
CALOFS : CTRL_CALOFS_Field := NXP_SVD.ADC.Calofs_0;
-- unspecified
Reserved_5_7 : HAL.UInt3 := 16#0#;
-- Reset FIFO 0
RSTFIFO0 : CTRL_RSTFIFO0_Field := NXP_SVD.ADC.Rstfifo0_0;
-- Reset FIFO 1
RSTFIFO1 : CTRL_RSTFIFO1_Field := NXP_SVD.ADC.Rstfifo1_0;
-- unspecified
Reserved_10_15 : HAL.UInt6 := 16#0#;
-- Auto-Calibration Averages
CAL_AVGS : CTRL_CAL_AVGS_Field := NXP_SVD.ADC.Cal_Avgs_0;
-- unspecified
Reserved_19_31 : HAL.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CTRL_Register use record
ADCEN at 0 range 0 .. 0;
RST at 0 range 1 .. 1;
DOZEN at 0 range 2 .. 2;
CAL_REQ at 0 range 3 .. 3;
CALOFS at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
RSTFIFO0 at 0 range 8 .. 8;
RSTFIFO1 at 0 range 9 .. 9;
Reserved_10_15 at 0 range 10 .. 15;
CAL_AVGS at 0 range 16 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
-- Result FIFO 0 Ready Flag
type STAT_RDY0_Field is
(
-- Result FIFO 0 data level not above watermark level.
Rdy0_0,
-- Result FIFO 0 holding data above watermark level.
Rdy0_1)
with Size => 1;
for STAT_RDY0_Field use
(Rdy0_0 => 0,
Rdy0_1 => 1);
-- Result FIFO 0 Overflow Flag
type STAT_FOF0_Field is
(
-- No result FIFO 0 overflow has occurred since the last time the flag
-- was cleared.
Fof0_0,
-- At least one result FIFO 0 overflow has occurred since the last time
-- the flag was cleared.
Fof0_1)
with Size => 1;
for STAT_FOF0_Field use
(Fof0_0 => 0,
Fof0_1 => 1);
-- Result FIFO1 Ready Flag
type STAT_RDY1_Field is
(
-- Result FIFO1 data level not above watermark level.
Rdy1_0,
-- Result FIFO1 holding data above watermark level.
Rdy1_1)
with Size => 1;
for STAT_RDY1_Field use
(Rdy1_0 => 0,
Rdy1_1 => 1);
-- Result FIFO1 Overflow Flag
type STAT_FOF1_Field is
(
-- No result FIFO1 overflow has occurred since the last time the flag
-- was cleared.
Fof1_0,
-- At least one result FIFO1 overflow has occurred since the last time
-- the flag was cleared.
Fof1_1)
with Size => 1;
for STAT_FOF1_Field use
(Fof1_0 => 0,
Fof1_1 => 1);
-- Interrupt Flag For High Priority Trigger Exception
type STAT_TEXC_INT_Field is
(
-- No trigger exceptions have occurred.
Texc_Int_0,
-- A trigger exception has occurred and is pending acknowledgement.
Texc_Int_1)
with Size => 1;
for STAT_TEXC_INT_Field use
(Texc_Int_0 => 0,
Texc_Int_1 => 1);
-- Interrupt Flag For Trigger Completion
type STAT_TCOMP_INT_Field is
(
-- Either IE[TCOMP_IE] is set to 0, or no trigger sequences have run to
-- completion.
Tcomp_Int_0,
-- Trigger sequence has been completed and all data is stored in the
-- associated FIFO.
Tcomp_Int_1)
with Size => 1;
for STAT_TCOMP_INT_Field use
(Tcomp_Int_0 => 0,
Tcomp_Int_1 => 1);
-- Calibration Ready
type STAT_CAL_RDY_Field is
(
-- Calibration is incomplete or hasn't been ran.
Cal_Rdy_0,
-- The ADC is calibrated.
Cal_Rdy_1)
with Size => 1;
for STAT_CAL_RDY_Field use
(Cal_Rdy_0 => 0,
Cal_Rdy_1 => 1);
-- ADC Active
type STAT_ADC_ACTIVE_Field is
(
-- The ADC is IDLE. There are no pending triggers to service and no
-- active commands are being processed.
Adc_Active_0,
-- The ADC is processing a conversion, running through the power up
-- delay, or servicing a trigger.
Adc_Active_1)
with Size => 1;
for STAT_ADC_ACTIVE_Field use
(Adc_Active_0 => 0,
Adc_Active_1 => 1);
-- Trigger Active
type STAT_TRGACT_Field is
(
-- Command (sequence) associated with Trigger 0 currently being
-- executed.
Trgact_0,
-- Command (sequence) associated with Trigger 1 currently being
-- executed.
Trgact_1,
-- Command (sequence) associated with Trigger 2 currently being
-- executed.
Trgact_2,
-- Command (sequence) from the associated Trigger number is currently
-- being executed.
Trgact_3,
-- Command (sequence) from the associated Trigger number is currently
-- being executed.
Trgact_4,
-- Command (sequence) from the associated Trigger number is currently
-- being executed.
Trgact_5,
-- Command (sequence) from the associated Trigger number is currently
-- being executed.
Trgact_6,
-- Command (sequence) from the associated Trigger number is currently
-- being executed.
Trgact_7,
-- Command (sequence) from the associated Trigger number is currently
-- being executed.
Trgact_8,
-- Command (sequence) from the associated Trigger number is currently
-- being executed.
Trgact_9)
with Size => 4;
for STAT_TRGACT_Field use
(Trgact_0 => 0,
Trgact_1 => 1,
Trgact_2 => 2,
Trgact_3 => 3,
Trgact_4 => 4,
Trgact_5 => 5,
Trgact_6 => 6,
Trgact_7 => 7,
Trgact_8 => 8,
Trgact_9 => 9);
-- Command Active
type STAT_CMDACT_Field is
(
-- No command is currently in progress.
Cmdact_0,
-- Command 1 currently being executed.
Cmdact_1,
-- Command 2 currently being executed.
Cmdact_2,
-- Associated command number is currently being executed.
Cmdact_3,
-- Associated command number is currently being executed.
Cmdact_4,
-- Associated command number is currently being executed.
Cmdact_5,
-- Associated command number is currently being executed.
Cmdact_6,
-- Associated command number is currently being executed.
Cmdact_7,
-- Associated command number is currently being executed.
Cmdact_8,
-- Associated command number is currently being executed.
Cmdact_9)
with Size => 4;
for STAT_CMDACT_Field use
(Cmdact_0 => 0,
Cmdact_1 => 1,
Cmdact_2 => 2,
Cmdact_3 => 3,
Cmdact_4 => 4,
Cmdact_5 => 5,
Cmdact_6 => 6,
Cmdact_7 => 7,
Cmdact_8 => 8,
Cmdact_9 => 9);
-- ADC Status Register
type STAT_Register is record
-- Read-only. Result FIFO 0 Ready Flag
RDY0 : STAT_RDY0_Field := NXP_SVD.ADC.Rdy0_0;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field. Result FIFO 0 Overflow Flag
FOF0 : STAT_FOF0_Field := NXP_SVD.ADC.Fof0_0;
-- Read-only. Result FIFO1 Ready Flag
RDY1 : STAT_RDY1_Field := NXP_SVD.ADC.Rdy1_0;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field. Result FIFO1 Overflow Flag
FOF1 : STAT_FOF1_Field := NXP_SVD.ADC.Fof1_0;
-- unspecified
Reserved_4_7 : HAL.UInt4 := 16#0#;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field. Interrupt Flag For High Priority Trigger Exception
TEXC_INT : STAT_TEXC_INT_Field := NXP_SVD.ADC.Texc_Int_0;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field. Interrupt Flag For Trigger Completion
TCOMP_INT : STAT_TCOMP_INT_Field := NXP_SVD.ADC.Tcomp_Int_0;
-- Read-only. Calibration Ready
CAL_RDY : STAT_CAL_RDY_Field := NXP_SVD.ADC.Cal_Rdy_0;
-- Read-only. ADC Active
ADC_ACTIVE : STAT_ADC_ACTIVE_Field := NXP_SVD.ADC.Adc_Active_0;
-- unspecified
Reserved_12_15 : HAL.UInt4 := 16#0#;
-- Read-only. Trigger Active
TRGACT : STAT_TRGACT_Field := NXP_SVD.ADC.Trgact_0;
-- unspecified
Reserved_20_23 : HAL.UInt4 := 16#0#;
-- Read-only. Command Active
CMDACT : STAT_CMDACT_Field := NXP_SVD.ADC.Cmdact_0;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for STAT_Register use record
RDY0 at 0 range 0 .. 0;
FOF0 at 0 range 1 .. 1;
RDY1 at 0 range 2 .. 2;
FOF1 at 0 range 3 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
TEXC_INT at 0 range 8 .. 8;
TCOMP_INT at 0 range 9 .. 9;
CAL_RDY at 0 range 10 .. 10;
ADC_ACTIVE at 0 range 11 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
TRGACT at 0 range 16 .. 19;
Reserved_20_23 at 0 range 20 .. 23;
CMDACT at 0 range 24 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
-- FIFO 0 Watermark Interrupt Enable
type IE_FWMIE0_Field is
(
-- FIFO 0 watermark interrupts are not enabled.
Fwmie0_0,
-- FIFO 0 watermark interrupts are enabled.
Fwmie0_1)
with Size => 1;
for IE_FWMIE0_Field use
(Fwmie0_0 => 0,
Fwmie0_1 => 1);
-- Result FIFO 0 Overflow Interrupt Enable
type IE_FOFIE0_Field is
(
-- FIFO 0 overflow interrupts are not enabled.
Fofie0_0,
-- FIFO 0 overflow interrupts are enabled.
Fofie0_1)
with Size => 1;
for IE_FOFIE0_Field use
(Fofie0_0 => 0,
Fofie0_1 => 1);
-- FIFO1 Watermark Interrupt Enable
type IE_FWMIE1_Field is
(
-- FIFO1 watermark interrupts are not enabled.
Fwmie1_0,
-- FIFO1 watermark interrupts are enabled.
Fwmie1_1)
with Size => 1;
for IE_FWMIE1_Field use
(Fwmie1_0 => 0,
Fwmie1_1 => 1);
-- Result FIFO1 Overflow Interrupt Enable
type IE_FOFIE1_Field is
(
-- No result FIFO1 overflow has occurred since the last time the flag
-- was cleared.
Fofie1_0,
-- At least one result FIFO1 overflow has occurred since the last time
-- the flag was cleared.
Fofie1_1)
with Size => 1;
for IE_FOFIE1_Field use
(Fofie1_0 => 0,
Fofie1_1 => 1);
-- Trigger Exception Interrupt Enable
type IE_TEXC_IE_Field is
(
-- Trigger exception interrupts are disabled.
Texc_Ie_0,
-- Trigger exception interrupts are enabled.
Texc_Ie_1)
with Size => 1;
for IE_TEXC_IE_Field use
(Texc_Ie_0 => 0,
Texc_Ie_1 => 1);
-- Trigger Completion Interrupt Enable
type IE_TCOMP_IE_Field is
(
-- Trigger completion interrupts are disabled.
Tcomp_Ie_0,
-- Trigger completion interrupts are enabled for trigger source 0 only.
Tcomp_Ie_1,
-- Trigger completion interrupts are enabled for trigger source 1 only.
Tcomp_Ie_2,
-- Associated trigger completion interrupts are enabled.
Tcomp_Ie_3,
-- Associated trigger completion interrupts are enabled.
Tcomp_Ie_4,
-- Associated trigger completion interrupts are enabled.
Tcomp_Ie_5,
-- Associated trigger completion interrupts are enabled.
Tcomp_Ie_6,
-- Associated trigger completion interrupts are enabled.
Tcomp_Ie_7,
-- Associated trigger completion interrupts are enabled.
Tcomp_Ie_8,
-- Associated trigger completion interrupts are enabled.
Tcomp_Ie_9,
-- Trigger completion interrupts are enabled for every trigger source.
Tcomp_Ie_65535)
with Size => 16;
for IE_TCOMP_IE_Field use
(Tcomp_Ie_0 => 0,
Tcomp_Ie_1 => 1,
Tcomp_Ie_2 => 2,
Tcomp_Ie_3 => 3,
Tcomp_Ie_4 => 4,
Tcomp_Ie_5 => 5,
Tcomp_Ie_6 => 6,
Tcomp_Ie_7 => 7,
Tcomp_Ie_8 => 8,
Tcomp_Ie_9 => 9,
Tcomp_Ie_65535 => 65535);
-- Interrupt Enable Register
type IE_Register is record
-- FIFO 0 Watermark Interrupt Enable
FWMIE0 : IE_FWMIE0_Field := NXP_SVD.ADC.Fwmie0_0;
-- Result FIFO 0 Overflow Interrupt Enable
FOFIE0 : IE_FOFIE0_Field := NXP_SVD.ADC.Fofie0_0;
-- FIFO1 Watermark Interrupt Enable
FWMIE1 : IE_FWMIE1_Field := NXP_SVD.ADC.Fwmie1_0;
-- Result FIFO1 Overflow Interrupt Enable
FOFIE1 : IE_FOFIE1_Field := NXP_SVD.ADC.Fofie1_0;
-- unspecified
Reserved_4_7 : HAL.UInt4 := 16#0#;
-- Trigger Exception Interrupt Enable
TEXC_IE : IE_TEXC_IE_Field := NXP_SVD.ADC.Texc_Ie_0;
-- unspecified
Reserved_9_15 : HAL.UInt7 := 16#0#;
-- Trigger Completion Interrupt Enable
TCOMP_IE : IE_TCOMP_IE_Field := NXP_SVD.ADC.Tcomp_Ie_0;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IE_Register use record
FWMIE0 at 0 range 0 .. 0;
FOFIE0 at 0 range 1 .. 1;
FWMIE1 at 0 range 2 .. 2;
FOFIE1 at 0 range 3 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
TEXC_IE at 0 range 8 .. 8;
Reserved_9_15 at 0 range 9 .. 15;
TCOMP_IE at 0 range 16 .. 31;
end record;
-- FIFO 0 Watermark DMA Enable
type DE_FWMDE0_Field is
(
-- DMA request disabled.
Fwmde0_0,
-- DMA request enabled.
Fwmde0_1)
with Size => 1;
for DE_FWMDE0_Field use
(Fwmde0_0 => 0,
Fwmde0_1 => 1);
-- FIFO1 Watermark DMA Enable
type DE_FWMDE1_Field is
(
-- DMA request disabled.
Fwmde1_0,
-- DMA request enabled.
Fwmde1_1)
with Size => 1;
for DE_FWMDE1_Field use
(Fwmde1_0 => 0,
Fwmde1_1 => 1);
-- DMA Enable Register
type DE_Register is record
-- FIFO 0 Watermark DMA Enable
FWMDE0 : DE_FWMDE0_Field := NXP_SVD.ADC.Fwmde0_0;
-- FIFO1 Watermark DMA Enable
FWMDE1 : DE_FWMDE1_Field := NXP_SVD.ADC.Fwmde1_0;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DE_Register use record
FWMDE0 at 0 range 0 .. 0;
FWMDE1 at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- ADC trigger priority control
type CFG_TPRICTRL_Field is
(
-- If a higher priority trigger is detected during command processing,
-- the current conversion is aborted and the new command specified by
-- the trigger is started.
Tprictrl_0,
-- If a higher priority trigger is received during command processing,
-- the current command is stopped after after completing the current
-- conversion. If averaging is enabled, the averaging loop will be
-- completed. However, CMDHa[LOOP] will be ignored and the higher
-- priority trigger will be serviced.
Tprictrl_1,
-- If a higher priority trigger is received during command processing,
-- the current command will be completed (averaging, looping, compare)
-- before servicing the higher priority trigger.
Tprictrl_2)
with Size => 2;
for CFG_TPRICTRL_Field use
(Tprictrl_0 => 0,
Tprictrl_1 => 1,
Tprictrl_2 => 2);
-- Power Configuration Select
type CFG_PWRSEL_Field is
(
-- Lowest power setting.
Pwrsel_0,
-- Higher power setting than 0b0.
Pwrsel_1,
-- Higher power setting than 0b1.
Pwrsel_2,
-- Highest power setting.
Pwrsel_3)
with Size => 2;
for CFG_PWRSEL_Field use
(Pwrsel_0 => 0,
Pwrsel_1 => 1,
Pwrsel_2 => 2,
Pwrsel_3 => 3);
-- Voltage Reference Selection
type CFG_REFSEL_Field is
(
-- (Default) Option 1 setting.
Refsel_0,
-- Option 2 setting.
Refsel_1,
-- Option 3 setting.
Refsel_2)
with Size => 2;
for CFG_REFSEL_Field use
(Refsel_0 => 0,
Refsel_1 => 1,
Refsel_2 => 2);
-- Trigger Resume Enable
type CFG_TRES_Field is
(
-- Trigger sequences interrupted by a high priority trigger exception
-- will not be automatically resumed or restarted.
Tres_0,
-- Trigger sequences interrupted by a high priority trigger exception
-- will be automatically resumed or restarted.
Tres_1)
with Size => 1;
for CFG_TRES_Field use
(Tres_0 => 0,
Tres_1 => 1);
-- Trigger Command Resume
type CFG_TCMDRES_Field is
(
-- Trigger sequences interrupted by a high priority trigger exception
-- will be automatically restarted.
Tcmdres_0,
-- Trigger sequences interrupted by a high priority trigger exception
-- will be resumed from the command executing before the exception.
Tcmdres_1)
with Size => 1;
for CFG_TCMDRES_Field use
(Tcmdres_0 => 0,
Tcmdres_1 => 1);
-- High Priority Trigger Exception Disable
type CFG_HPT_EXDI_Field is
(
-- High priority trigger exceptions are enabled.
Hpt_Exdi_0,
-- High priority trigger exceptions are disabled.
Hpt_Exdi_1)
with Size => 1;
for CFG_HPT_EXDI_Field use
(Hpt_Exdi_0 => 0,
Hpt_Exdi_1 => 1);
subtype CFG_PUDLY_Field is HAL.UInt8;
-- ADC Analog Pre-Enable
type CFG_PWREN_Field is
(
-- ADC analog circuits are only enabled while conversions are active.
-- Performance is affected due to analog startup delays.
Pwren_0,
-- ADC analog circuits are pre-enabled and ready to execute conversions
-- without startup delays (at the cost of higher DC current
-- consumption). A single power up delay (CFG[PUDLY]) is executed
-- immediately once PWREN is set, and any detected trigger does not
-- begin ADC operation until the power up delay time has passed. After
-- this initial delay expires the analog will remain pre-enabled, and no
-- additional delays will be executed.
Pwren_1)
with Size => 1;
for CFG_PWREN_Field use
(Pwren_0 => 0,
Pwren_1 => 1);
-- ADC Configuration Register
type CFG_Register is record
-- ADC trigger priority control
TPRICTRL : CFG_TPRICTRL_Field := NXP_SVD.ADC.Tprictrl_0;
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- Power Configuration Select
PWRSEL : CFG_PWRSEL_Field := NXP_SVD.ADC.Pwrsel_0;
-- Voltage Reference Selection
REFSEL : CFG_REFSEL_Field := NXP_SVD.ADC.Refsel_0;
-- Trigger Resume Enable
TRES : CFG_TRES_Field := NXP_SVD.ADC.Tres_0;
-- Trigger Command Resume
TCMDRES : CFG_TCMDRES_Field := NXP_SVD.ADC.Tcmdres_0;
-- High Priority Trigger Exception Disable
HPT_EXDI : CFG_HPT_EXDI_Field := NXP_SVD.ADC.Hpt_Exdi_0;
-- unspecified
Reserved_11_15 : HAL.UInt5 := 16#0#;
-- Power Up Delay
PUDLY : CFG_PUDLY_Field := 16#80#;
-- unspecified
Reserved_24_27 : HAL.UInt4 := 16#0#;
-- ADC Analog Pre-Enable
PWREN : CFG_PWREN_Field := NXP_SVD.ADC.Pwren_0;
-- unspecified
Reserved_29_31 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CFG_Register use record
TPRICTRL at 0 range 0 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
PWRSEL at 0 range 4 .. 5;
REFSEL at 0 range 6 .. 7;
TRES at 0 range 8 .. 8;
TCMDRES at 0 range 9 .. 9;
HPT_EXDI at 0 range 10 .. 10;
Reserved_11_15 at 0 range 11 .. 15;
PUDLY at 0 range 16 .. 23;
Reserved_24_27 at 0 range 24 .. 27;
PWREN at 0 range 28 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
subtype PAUSE_PAUSEDLY_Field is HAL.UInt9;
-- PAUSE Option Enable
type PAUSE_PAUSEEN_Field is
(
-- Pause operation disabled
Pauseen_0,
-- Pause operation enabled
Pauseen_1)
with Size => 1;
for PAUSE_PAUSEEN_Field use
(Pauseen_0 => 0,
Pauseen_1 => 1);
-- ADC Pause Register
type PAUSE_Register is record
-- Pause Delay
PAUSEDLY : PAUSE_PAUSEDLY_Field := 16#0#;
-- unspecified
Reserved_9_30 : HAL.UInt22 := 16#0#;
-- PAUSE Option Enable
PAUSEEN : PAUSE_PAUSEEN_Field := NXP_SVD.ADC.Pauseen_0;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PAUSE_Register use record
PAUSEDLY at 0 range 0 .. 8;
Reserved_9_30 at 0 range 9 .. 30;
PAUSEEN at 0 range 31 .. 31;
end record;
-- Software trigger 0 event
type SWTRIG_SWT0_Field is
(
-- No trigger 0 event generated.
Swt0_0,
-- Trigger 0 event generated.
Swt0_1)
with Size => 1;
for SWTRIG_SWT0_Field use
(Swt0_0 => 0,
Swt0_1 => 1);
-- Software trigger 1 event
type SWTRIG_SWT1_Field is
(
-- No trigger 1 event generated.
Swt1_0,
-- Trigger 1 event generated.
Swt1_1)
with Size => 1;
for SWTRIG_SWT1_Field use
(Swt1_0 => 0,
Swt1_1 => 1);
-- Software trigger 2 event
type SWTRIG_SWT2_Field is
(
-- No trigger 2 event generated.
Swt2_0,
-- Trigger 2 event generated.
Swt2_1)
with Size => 1;
for SWTRIG_SWT2_Field use
(Swt2_0 => 0,
Swt2_1 => 1);
-- Software trigger 3 event
type SWTRIG_SWT3_Field is
(
-- No trigger 3 event generated.
Swt3_0,
-- Trigger 3 event generated.
Swt3_1)
with Size => 1;
for SWTRIG_SWT3_Field use
(Swt3_0 => 0,
Swt3_1 => 1);
-- Software trigger 4 event
type SWTRIG_SWT4_Field is
(
-- No trigger 4 event generated.
Swt4_0,
-- Trigger 4 event generated.
Swt4_1)
with Size => 1;
for SWTRIG_SWT4_Field use
(Swt4_0 => 0,
Swt4_1 => 1);
-- Software trigger 5 event
type SWTRIG_SWT5_Field is
(
-- No trigger 5 event generated.
Swt5_0,
-- Trigger 5 event generated.
Swt5_1)
with Size => 1;
for SWTRIG_SWT5_Field use
(Swt5_0 => 0,
Swt5_1 => 1);
-- Software trigger 6 event
type SWTRIG_SWT6_Field is
(
-- No trigger 6 event generated.
Swt6_0,
-- Trigger 6 event generated.
Swt6_1)
with Size => 1;
for SWTRIG_SWT6_Field use
(Swt6_0 => 0,
Swt6_1 => 1);
-- Software trigger 7 event
type SWTRIG_SWT7_Field is
(
-- No trigger 7 event generated.
Swt7_0,
-- Trigger 7 event generated.
Swt7_1)
with Size => 1;
for SWTRIG_SWT7_Field use
(Swt7_0 => 0,
Swt7_1 => 1);
-- Software trigger 8 event
type SWTRIG_SWT8_Field is
(
-- No trigger 8 event generated.
Swt8_0,
-- Trigger 8 event generated.
Swt8_1)
with Size => 1;
for SWTRIG_SWT8_Field use
(Swt8_0 => 0,
Swt8_1 => 1);
-- Software trigger 9 event
type SWTRIG_SWT9_Field is
(
-- No trigger 9 event generated.
Swt9_0,
-- Trigger 9 event generated.
Swt9_1)
with Size => 1;
for SWTRIG_SWT9_Field use
(Swt9_0 => 0,
Swt9_1 => 1);
-- Software trigger 10 event
type SWTRIG_SWT10_Field is
(
-- No trigger 10 event generated.
Swt10_0,
-- Trigger 10 event generated.
Swt10_1)
with Size => 1;
for SWTRIG_SWT10_Field use
(Swt10_0 => 0,
Swt10_1 => 1);
-- Software trigger 11 event
type SWTRIG_SWT11_Field is
(
-- No trigger 11 event generated.
Swt11_0,
-- Trigger 11 event generated.
Swt11_1)
with Size => 1;
for SWTRIG_SWT11_Field use
(Swt11_0 => 0,
Swt11_1 => 1);
-- Software trigger 12 event
type SWTRIG_SWT12_Field is
(
-- No trigger 12 event generated.
Swt12_0,
-- Trigger 12 event generated.
Swt12_1)
with Size => 1;
for SWTRIG_SWT12_Field use
(Swt12_0 => 0,
Swt12_1 => 1);
-- Software trigger 13 event
type SWTRIG_SWT13_Field is
(
-- No trigger 13 event generated.
Swt13_0,
-- Trigger 13 event generated.
Swt13_1)
with Size => 1;
for SWTRIG_SWT13_Field use
(Swt13_0 => 0,
Swt13_1 => 1);
-- Software trigger 14 event
type SWTRIG_SWT14_Field is
(
-- No trigger 14 event generated.
Swt14_0,
-- Trigger 14 event generated.
Swt14_1)
with Size => 1;
for SWTRIG_SWT14_Field use
(Swt14_0 => 0,
Swt14_1 => 1);
-- Software trigger 15 event
type SWTRIG_SWT15_Field is
(
-- No trigger 15 event generated.
Swt15_0,
-- Trigger 15 event generated.
Swt15_1)
with Size => 1;
for SWTRIG_SWT15_Field use
(Swt15_0 => 0,
Swt15_1 => 1);
-- Software Trigger Register
type SWTRIG_Register is record
-- Software trigger 0 event
SWT0 : SWTRIG_SWT0_Field := NXP_SVD.ADC.Swt0_0;
-- Software trigger 1 event
SWT1 : SWTRIG_SWT1_Field := NXP_SVD.ADC.Swt1_0;
-- Software trigger 2 event
SWT2 : SWTRIG_SWT2_Field := NXP_SVD.ADC.Swt2_0;
-- Software trigger 3 event
SWT3 : SWTRIG_SWT3_Field := NXP_SVD.ADC.Swt3_0;
-- Software trigger 4 event
SWT4 : SWTRIG_SWT4_Field := NXP_SVD.ADC.Swt4_0;
-- Software trigger 5 event
SWT5 : SWTRIG_SWT5_Field := NXP_SVD.ADC.Swt5_0;
-- Software trigger 6 event
SWT6 : SWTRIG_SWT6_Field := NXP_SVD.ADC.Swt6_0;
-- Software trigger 7 event
SWT7 : SWTRIG_SWT7_Field := NXP_SVD.ADC.Swt7_0;
-- Software trigger 8 event
SWT8 : SWTRIG_SWT8_Field := NXP_SVD.ADC.Swt8_0;
-- Software trigger 9 event
SWT9 : SWTRIG_SWT9_Field := NXP_SVD.ADC.Swt9_0;
-- Software trigger 10 event
SWT10 : SWTRIG_SWT10_Field := NXP_SVD.ADC.Swt10_0;
-- Software trigger 11 event
SWT11 : SWTRIG_SWT11_Field := NXP_SVD.ADC.Swt11_0;
-- Software trigger 12 event
SWT12 : SWTRIG_SWT12_Field := NXP_SVD.ADC.Swt12_0;
-- Software trigger 13 event
SWT13 : SWTRIG_SWT13_Field := NXP_SVD.ADC.Swt13_0;
-- Software trigger 14 event
SWT14 : SWTRIG_SWT14_Field := NXP_SVD.ADC.Swt14_0;
-- Software trigger 15 event
SWT15 : SWTRIG_SWT15_Field := NXP_SVD.ADC.Swt15_0;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SWTRIG_Register use record
SWT0 at 0 range 0 .. 0;
SWT1 at 0 range 1 .. 1;
SWT2 at 0 range 2 .. 2;
SWT3 at 0 range 3 .. 3;
SWT4 at 0 range 4 .. 4;
SWT5 at 0 range 5 .. 5;
SWT6 at 0 range 6 .. 6;
SWT7 at 0 range 7 .. 7;
SWT8 at 0 range 8 .. 8;
SWT9 at 0 range 9 .. 9;
SWT10 at 0 range 10 .. 10;
SWT11 at 0 range 11 .. 11;
SWT12 at 0 range 12 .. 12;
SWT13 at 0 range 13 .. 13;
SWT14 at 0 range 14 .. 14;
SWT15 at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- Trigger Exception Number
type TSTAT_TEXC_NUM_Field is
(
-- No triggers have been interrupted by a high priority exception. Or
-- CFG[TRES] = 1.
Texc_Num_0,
-- Trigger 0 has been interrupted by a high priority exception.
Texc_Num_1,
-- Trigger 1 has been interrupted by a high priority exception.
Texc_Num_2,
-- Associated trigger sequence has interrupted by a high priority
-- exception.
Texc_Num_3,
-- Associated trigger sequence has interrupted by a high priority
-- exception.
Texc_Num_4,
-- Associated trigger sequence has interrupted by a high priority
-- exception.
Texc_Num_5,
-- Associated trigger sequence has interrupted by a high priority
-- exception.
Texc_Num_6,
-- Associated trigger sequence has interrupted by a high priority
-- exception.
Texc_Num_7,
-- Associated trigger sequence has interrupted by a high priority
-- exception.
Texc_Num_8,
-- Associated trigger sequence has interrupted by a high priority
-- exception.
Texc_Num_9,
-- Every trigger sequence has been interrupted by a high priority
-- exception.
Texc_Num_65535)
with Size => 16;
for TSTAT_TEXC_NUM_Field use
(Texc_Num_0 => 0,
Texc_Num_1 => 1,
Texc_Num_2 => 2,
Texc_Num_3 => 3,
Texc_Num_4 => 4,
Texc_Num_5 => 5,
Texc_Num_6 => 6,
Texc_Num_7 => 7,
Texc_Num_8 => 8,
Texc_Num_9 => 9,
Texc_Num_65535 => 65535);
-- Trigger Completion Flag
type TSTAT_TCOMP_FLAG_Field is
(
-- No triggers have been completed. Trigger completion interrupts are
-- disabled.
Tcomp_Flag_0,
-- Trigger 0 has been completed and triger 0 has enabled completion
-- interrupts.
Tcomp_Flag_1,
-- Trigger 1 has been completed and triger 1 has enabled completion
-- interrupts.
Tcomp_Flag_2,
-- Associated trigger sequence has completed and has enabled completion
-- interrupts.
Tcomp_Flag_3,
-- Associated trigger sequence has completed and has enabled completion
-- interrupts.
Tcomp_Flag_4,
-- Associated trigger sequence has completed and has enabled completion
-- interrupts.
Tcomp_Flag_5,
-- Associated trigger sequence has completed and has enabled completion
-- interrupts.
Tcomp_Flag_6,
-- Associated trigger sequence has completed and has enabled completion
-- interrupts.
Tcomp_Flag_7,
-- Associated trigger sequence has completed and has enabled completion
-- interrupts.
Tcomp_Flag_8,
-- Associated trigger sequence has completed and has enabled completion
-- interrupts.
Tcomp_Flag_9,
-- Every trigger sequence has been completed and every trigger has
-- enabled completion interrupts.
Tcomp_Flag_65535)
with Size => 16;
for TSTAT_TCOMP_FLAG_Field use
(Tcomp_Flag_0 => 0,
Tcomp_Flag_1 => 1,
Tcomp_Flag_2 => 2,
Tcomp_Flag_3 => 3,
Tcomp_Flag_4 => 4,
Tcomp_Flag_5 => 5,
Tcomp_Flag_6 => 6,
Tcomp_Flag_7 => 7,
Tcomp_Flag_8 => 8,
Tcomp_Flag_9 => 9,
Tcomp_Flag_65535 => 65535);
-- Trigger Status Register
type TSTAT_Register is record
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field. Trigger Exception Number
TEXC_NUM : TSTAT_TEXC_NUM_Field := NXP_SVD.ADC.Texc_Num_0;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field. Trigger Completion Flag
TCOMP_FLAG : TSTAT_TCOMP_FLAG_Field := NXP_SVD.ADC.Tcomp_Flag_0;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for TSTAT_Register use record
TEXC_NUM at 0 range 0 .. 15;
TCOMP_FLAG at 0 range 16 .. 31;
end record;
subtype OFSTRIM_OFSTRIM_A_Field is HAL.UInt5;
subtype OFSTRIM_OFSTRIM_B_Field is HAL.UInt5;
-- ADC Offset Trim Register
type OFSTRIM_Register is record
-- Trim for offset
OFSTRIM_A : OFSTRIM_OFSTRIM_A_Field := 16#0#;
-- unspecified
Reserved_5_15 : HAL.UInt11 := 16#0#;
-- Trim for offset
OFSTRIM_B : OFSTRIM_OFSTRIM_B_Field := 16#0#;
-- unspecified
Reserved_21_31 : HAL.UInt11 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OFSTRIM_Register use record
OFSTRIM_A at 0 range 0 .. 4;
Reserved_5_15 at 0 range 5 .. 15;
OFSTRIM_B at 0 range 16 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
-- Trigger enable
type TCTRL_HTEN_Field is
(
-- Hardware trigger source disabled
Hten_0,
-- Hardware trigger source enabled
Hten_1)
with Size => 1;
for TCTRL_HTEN_Field use
(Hten_0 => 0,
Hten_1 => 1);
-- SAR Result Destination For Channel A
type TCTRL_FIFO_SEL_A_Field is
(
-- Result written to FIFO 0
Fifo_Sel_A_0,
-- Result written to FIFO 1
Fifo_Sel_A_1)
with Size => 1;
for TCTRL_FIFO_SEL_A_Field use
(Fifo_Sel_A_0 => 0,
Fifo_Sel_A_1 => 1);
-- SAR Result Destination For Channel B
type TCTRL_FIFO_SEL_B_Field is
(
-- Result written to FIFO 0
Fifo_Sel_B_0,
-- Result written to FIFO 1
Fifo_Sel_B_1)
with Size => 1;
for TCTRL_FIFO_SEL_B_Field use
(Fifo_Sel_B_0 => 0,
Fifo_Sel_B_1 => 1);
-- Trigger priority setting
type TCTRL_TPRI_Field is
(
-- Set to highest priority, Level 1
Tpri_0,
-- Set to corresponding priority level
Tpri_1,
-- Set to corresponding priority level
Tpri_2,
-- Set to corresponding priority level
Tpri_3,
-- Set to corresponding priority level
Tpri_4,
-- Set to corresponding priority level
Tpri_5,
-- Set to corresponding priority level
Tpri_6,
-- Set to corresponding priority level
Tpri_7,
-- Set to corresponding priority level
Tpri_8,
-- Set to corresponding priority level
Tpri_9,
-- Set to lowest priority, Level 16
Tpri_15)
with Size => 4;
for TCTRL_TPRI_Field use
(Tpri_0 => 0,
Tpri_1 => 1,
Tpri_2 => 2,
Tpri_3 => 3,
Tpri_4 => 4,
Tpri_5 => 5,
Tpri_6 => 6,
Tpri_7 => 7,
Tpri_8 => 8,
Tpri_9 => 9,
Tpri_15 => 15);
subtype TCTRL_TDLY_Field is HAL.UInt4;
-- Trigger command select
type TCTRL_TCMD_Field is
(
-- Not a valid selection from the command buffer. Trigger event is
-- ignored.
Tcmd_0,
-- CMD1 is executed
Tcmd_1,
-- Corresponding CMD is executed
Tcmd_2,
-- Corresponding CMD is executed
Tcmd_3,
-- Corresponding CMD is executed
Tcmd_4,
-- Corresponding CMD is executed
Tcmd_5,
-- Corresponding CMD is executed
Tcmd_6,
-- Corresponding CMD is executed
Tcmd_7,
-- Corresponding CMD is executed
Tcmd_8,
-- Corresponding CMD is executed
Tcmd_9,
-- CMD15 is executed
Tcmd_15)
with Size => 4;
for TCTRL_TCMD_Field use
(Tcmd_0 => 0,
Tcmd_1 => 1,
Tcmd_2 => 2,
Tcmd_3 => 3,
Tcmd_4 => 4,
Tcmd_5 => 5,
Tcmd_6 => 6,
Tcmd_7 => 7,
Tcmd_8 => 8,
Tcmd_9 => 9,
Tcmd_15 => 15);
-- Trigger Control Register
type TCTRL_Register is record
-- Trigger enable
HTEN : TCTRL_HTEN_Field := NXP_SVD.ADC.Hten_0;
-- SAR Result Destination For Channel A
FIFO_SEL_A : TCTRL_FIFO_SEL_A_Field := NXP_SVD.ADC.Fifo_Sel_A_0;
-- SAR Result Destination For Channel B
FIFO_SEL_B : TCTRL_FIFO_SEL_B_Field := NXP_SVD.ADC.Fifo_Sel_B_0;
-- unspecified
Reserved_3_7 : HAL.UInt5 := 16#0#;
-- Trigger priority setting
TPRI : TCTRL_TPRI_Field := NXP_SVD.ADC.Tpri_0;
-- unspecified
Reserved_12_14 : HAL.UInt3 := 16#0#;
-- Trigger Resync
RSYNC : Boolean := False;
-- Trigger delay select
TDLY : TCTRL_TDLY_Field := 16#0#;
-- unspecified
Reserved_20_23 : HAL.UInt4 := 16#0#;
-- Trigger command select
TCMD : TCTRL_TCMD_Field := NXP_SVD.ADC.Tcmd_0;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for TCTRL_Register use record
HTEN at 0 range 0 .. 0;
FIFO_SEL_A at 0 range 1 .. 1;
FIFO_SEL_B at 0 range 2 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
TPRI at 0 range 8 .. 11;
Reserved_12_14 at 0 range 12 .. 14;
RSYNC at 0 range 15 .. 15;
TDLY at 0 range 16 .. 19;
Reserved_20_23 at 0 range 20 .. 23;
TCMD at 0 range 24 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
-- Trigger Control Register
type TCTRL_Registers is array (0 .. 15) of TCTRL_Register
with Volatile;
subtype FCTRL_FCOUNT_Field is HAL.UInt5;
subtype FCTRL_FWMARK_Field is HAL.UInt4;
-- FIFO Control Register
type FCTRL_Register is record
-- Read-only. Result FIFO counter
FCOUNT : FCTRL_FCOUNT_Field := 16#0#;
-- unspecified
Reserved_5_15 : HAL.UInt11 := 16#0#;
-- Watermark level selection
FWMARK : FCTRL_FWMARK_Field := 16#0#;
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FCTRL_Register use record
FCOUNT at 0 range 0 .. 4;
Reserved_5_15 at 0 range 5 .. 15;
FWMARK at 0 range 16 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
-- FIFO Control Register
type FCTRL_Registers is array (0 .. 1) of FCTRL_Register
with Volatile;
subtype GCC_GAIN_CAL_Field is HAL.UInt16;
-- Gain Calibration Value Valid
type GCC_RDY_Field is
(
-- The gain calibration value is invalid. Run the auto-calibration
-- routine for this value to be written.
Rdy_0,
-- The gain calibration value is valid. It should be used to update the
-- GCRa[GCALR] register field.
Rdy_1)
with Size => 1;
for GCC_RDY_Field use
(Rdy_0 => 0,
Rdy_1 => 1);
-- Gain Calibration Control
type GCC_Register is record
-- Read-only. Gain Calibration Value
GAIN_CAL : GCC_GAIN_CAL_Field;
-- unspecified
Reserved_16_23 : HAL.UInt8;
-- Read-only. Gain Calibration Value Valid
RDY : GCC_RDY_Field;
-- unspecified
Reserved_25_31 : HAL.UInt7;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for GCC_Register use record
GAIN_CAL at 0 range 0 .. 15;
Reserved_16_23 at 0 range 16 .. 23;
RDY at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
-- Gain Calibration Control
type GCC_Registers is array (0 .. 1) of GCC_Register
with Volatile;
subtype GCR_GCALR_Field is HAL.UInt16;
-- Gain Calculation Ready
type GCR_RDY_Field is
(
-- The gain offset calculation value is invalid.
Rdy_0,
-- The gain calibration value is valid.
Rdy_1)
with Size => 1;
for GCR_RDY_Field use
(Rdy_0 => 0,
Rdy_1 => 1);
-- Gain Calculation Result
type GCR_Register is record
-- Gain Calculation Result
GCALR : GCR_GCALR_Field := 16#0#;
-- unspecified
Reserved_16_23 : HAL.UInt8 := 16#0#;
-- Gain Calculation Ready
RDY : GCR_RDY_Field := NXP_SVD.ADC.Rdy_0;
-- unspecified
Reserved_25_31 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for GCR_Register use record
GCALR at 0 range 0 .. 15;
Reserved_16_23 at 0 range 16 .. 23;
RDY at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
-- Gain Calculation Result
type GCR_Registers is array (0 .. 1) of GCR_Register
with Volatile;
-- Input channel select
type CMDL1_ADCH_Field is
(
-- Select CH0A or CH0B or CH0A/CH0B pair.
Adch_0,
-- Select CH1A or CH1B or CH1A/CH1B pair.
Adch_1,
-- Select CH2A or CH2B or CH2A/CH2B pair.
Adch_2,
-- Select CH3A or CH3B or CH3A/CH3B pair.
Adch_3,
-- Select corresponding channel CHnA or CHnB or CHnA/CHnB pair.
Adch_4,
-- Select corresponding channel CHnA or CHnB or CHnA/CHnB pair.
Adch_5,
-- Select corresponding channel CHnA or CHnB or CHnA/CHnB pair.
Adch_6,
-- Select corresponding channel CHnA or CHnB or CHnA/CHnB pair.
Adch_7,
-- Select corresponding channel CHnA or CHnB or CHnA/CHnB pair.
Adch_8,
-- Select corresponding channel CHnA or CHnB or CHnA/CHnB pair.
Adch_9,
-- Select CH30A or CH30B or CH30A/CH30B pair.
Adch_30,
-- Select CH31A or CH31B or CH31A/CH31B pair.
Adch_31)
with Size => 5;
for CMDL1_ADCH_Field use
(Adch_0 => 0,
Adch_1 => 1,
Adch_2 => 2,
Adch_3 => 3,
Adch_4 => 4,
Adch_5 => 5,
Adch_6 => 6,
Adch_7 => 7,
Adch_8 => 8,
Adch_9 => 9,
Adch_30 => 30,
Adch_31 => 31);
-- Conversion Type
type CMDL1_CTYPE_Field is
(
-- Single-Ended Mode. Only A side channel is converted.
Ctype_0,
-- Single-Ended Mode. Only B side channel is converted.
Ctype_1,
-- Differential Mode. A-B.
Ctype_2,
-- Dual-Single-Ended Mode. Both A side and B side channels are converted
-- independently.
Ctype_3)
with Size => 2;
for CMDL1_CTYPE_Field use
(Ctype_0 => 0,
Ctype_1 => 1,
Ctype_2 => 2,
Ctype_3 => 3);
-- Select resolution of conversions
type CMDL1_MODE_Field is
(
-- Standard resolution. Single-ended 12-bit conversion; Differential
-- 13-bit conversion with 2's complement output.
Mode_0,
-- High resolution. Single-ended 16-bit conversion; Differential 16-bit
-- conversion with 2's complement output.
Mode_1)
with Size => 1;
for CMDL1_MODE_Field use
(Mode_0 => 0,
Mode_1 => 1);
-- ADC Command Low Buffer Register
type CMDL_Register is record
-- Input channel select
ADCH : CMDL1_ADCH_Field := NXP_SVD.ADC.Adch_0;
-- Conversion Type
CTYPE : CMDL1_CTYPE_Field := NXP_SVD.ADC.Ctype_0;
-- Select resolution of conversions
MODE : CMDL1_MODE_Field := NXP_SVD.ADC.Mode_0;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CMDL_Register use record
ADCH at 0 range 0 .. 4;
CTYPE at 0 range 5 .. 6;
MODE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- Compare Function Enable
type CMDH1_CMPEN_Field is
(
-- Compare disabled.
Cmpen_0,
-- Compare enabled. Store on true.
Cmpen_2,
-- Compare enabled. Repeat channel acquisition (sample/convert/compare)
-- until true.
Cmpen_3)
with Size => 2;
for CMDH1_CMPEN_Field use
(Cmpen_0 => 0,
Cmpen_2 => 2,
Cmpen_3 => 3);
-- Wait for trigger assertion before execution.
type CMDH1_WAIT_TRIG_Field is
(
-- This command will be automatically executed.
Wait_Trig_0,
-- The active trigger must be asserted again before executing this
-- command.
Wait_Trig_1)
with Size => 1;
for CMDH1_WAIT_TRIG_Field use
(Wait_Trig_0 => 0,
Wait_Trig_1 => 1);
-- Loop with Increment
type CMDH1_LWI_Field is
(
-- Auto channel increment disabled
Lwi_0,
-- Auto channel increment enabled
Lwi_1)
with Size => 1;
for CMDH1_LWI_Field use
(Lwi_0 => 0,
Lwi_1 => 1);
-- Sample Time Select
type CMDH1_STS_Field is
(
-- Minimum sample time of 3 ADCK cycles.
Sts_0,
-- 3 + 21 ADCK cycles; 5 ADCK cycles total sample time.
Sts_1,
-- 3 + 22 ADCK cycles; 7 ADCK cycles total sample time.
Sts_2,
-- 3 + 23 ADCK cycles; 11 ADCK cycles total sample time.
Sts_3,
-- 3 + 24 ADCK cycles; 19 ADCK cycles total sample time.
Sts_4,
-- 3 + 25 ADCK cycles; 35 ADCK cycles total sample time.
Sts_5,
-- 3 + 26 ADCK cycles; 67 ADCK cycles total sample time.
Sts_6,
-- 3 + 27 ADCK cycles; 131 ADCK cycles total sample time.
Sts_7)
with Size => 3;
for CMDH1_STS_Field use
(Sts_0 => 0,
Sts_1 => 1,
Sts_2 => 2,
Sts_3 => 3,
Sts_4 => 4,
Sts_5 => 5,
Sts_6 => 6,
Sts_7 => 7);
-- Hardware Average Select
type CMDH1_AVGS_Field is
(
-- Single conversion.
Avgs_0,
-- 2 conversions averaged.
Avgs_1,
-- 4 conversions averaged.
Avgs_2,
-- 8 conversions averaged.
Avgs_3,
-- 16 conversions averaged.
Avgs_4,
-- 32 conversions averaged.
Avgs_5,
-- 64 conversions averaged.
Avgs_6,
-- 128 conversions averaged.
Avgs_7)
with Size => 3;
for CMDH1_AVGS_Field use
(Avgs_0 => 0,
Avgs_1 => 1,
Avgs_2 => 2,
Avgs_3 => 3,
Avgs_4 => 4,
Avgs_5 => 5,
Avgs_6 => 6,
Avgs_7 => 7);
-- Loop Count Select
type CMDH1_LOOP_Field is
(
-- Looping not enabled. Command executes 1 time.
Loop_0,
-- Loop 1 time. Command executes 2 times.
Loop_1,
-- Loop 2 times. Command executes 3 times.
Loop_2,
-- Loop corresponding number of times. Command executes LOOP+1 times.
Loop_3,
-- Loop corresponding number of times. Command executes LOOP+1 times.
Loop_4,
-- Loop corresponding number of times. Command executes LOOP+1 times.
Loop_5,
-- Loop corresponding number of times. Command executes LOOP+1 times.
Loop_6,
-- Loop corresponding number of times. Command executes LOOP+1 times.
Loop_7,
-- Loop corresponding number of times. Command executes LOOP+1 times.
Loop_8,
-- Loop corresponding number of times. Command executes LOOP+1 times.
Loop_9,
-- Loop 15 times. Command executes 16 times.
Loop_15)
with Size => 4;
for CMDH1_LOOP_Field use
(Loop_0 => 0,
Loop_1 => 1,
Loop_2 => 2,
Loop_3 => 3,
Loop_4 => 4,
Loop_5 => 5,
Loop_6 => 6,
Loop_7 => 7,
Loop_8 => 8,
Loop_9 => 9,
Loop_15 => 15);
-- Next Command Select
type CMDH1_NEXT_Field is
(
-- No next command defined. Terminate conversions at completion of
-- current command. If lower priority trigger pending, begin command
-- associated with lower priority trigger.
Next_0,
-- Select CMD1 command buffer register as next command.
Next_1,
-- Select corresponding CMD command buffer register as next command
Next_2,
-- Select corresponding CMD command buffer register as next command
Next_3,
-- Select corresponding CMD command buffer register as next command
Next_4,
-- Select corresponding CMD command buffer register as next command
Next_5,
-- Select corresponding CMD command buffer register as next command
Next_6,
-- Select corresponding CMD command buffer register as next command
Next_7,
-- Select corresponding CMD command buffer register as next command
Next_8,
-- Select corresponding CMD command buffer register as next command
Next_9,
-- Select CMD15 command buffer register as next command.
Next_15)
with Size => 4;
for CMDH1_NEXT_Field use
(Next_0 => 0,
Next_1 => 1,
Next_2 => 2,
Next_3 => 3,
Next_4 => 4,
Next_5 => 5,
Next_6 => 6,
Next_7 => 7,
Next_8 => 8,
Next_9 => 9,
Next_15 => 15);
-- ADC Command High Buffer Register
type CMDH_Register is record
-- Compare Function Enable
CMPEN : CMDH1_CMPEN_Field := NXP_SVD.ADC.Cmpen_0;
-- Wait for trigger assertion before execution.
WAIT_TRIG : CMDH1_WAIT_TRIG_Field := NXP_SVD.ADC.Wait_Trig_0;
-- unspecified
Reserved_3_6 : HAL.UInt4 := 16#0#;
-- Loop with Increment
LWI : CMDH1_LWI_Field := NXP_SVD.ADC.Lwi_0;
-- Sample Time Select
STS : CMDH1_STS_Field := NXP_SVD.ADC.Sts_0;
-- unspecified
Reserved_11_11 : HAL.Bit := 16#0#;
-- Hardware Average Select
AVGS : CMDH1_AVGS_Field := NXP_SVD.ADC.Avgs_0;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#0#;
-- Loop Count Select
LOOP_k : CMDH1_LOOP_Field := NXP_SVD.ADC.Loop_0;
-- unspecified
Reserved_20_23 : HAL.UInt4 := 16#0#;
-- Next Command Select
NEXT : CMDH1_NEXT_Field := NXP_SVD.ADC.Next_0;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CMDH_Register use record
CMPEN at 0 range 0 .. 1;
WAIT_TRIG at 0 range 2 .. 2;
Reserved_3_6 at 0 range 3 .. 6;
LWI at 0 range 7 .. 7;
STS at 0 range 8 .. 10;
Reserved_11_11 at 0 range 11 .. 11;
AVGS at 0 range 12 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
LOOP_k at 0 range 16 .. 19;
Reserved_20_23 at 0 range 20 .. 23;
NEXT at 0 range 24 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
-- Wait for trigger assertion before execution.
type CMDH5_WAIT_TRIG_Field is
(
-- This command will be automatically executed.
Wait_Trig_0,
-- The active trigger must be asserted again before executing this
-- command.
Wait_Trig_1)
with Size => 1;
for CMDH5_WAIT_TRIG_Field use
(Wait_Trig_0 => 0,
Wait_Trig_1 => 1);
-- Loop with Increment
type CMDH5_LWI_Field is
(
-- Auto channel increment disabled
Lwi_0,
-- Auto channel increment enabled
Lwi_1)
with Size => 1;
for CMDH5_LWI_Field use
(Lwi_0 => 0,
Lwi_1 => 1);
-- Sample Time Select
type CMDH5_STS_Field is
(
-- Minimum sample time of 3 ADCK cycles.
Sts_0,
-- 3 + 21 ADCK cycles; 5 ADCK cycles total sample time.
Sts_1,
-- 3 + 22 ADCK cycles; 7 ADCK cycles total sample time.
Sts_2,
-- 3 + 23 ADCK cycles; 11 ADCK cycles total sample time.
Sts_3,
-- 3 + 24 ADCK cycles; 19 ADCK cycles total sample time.
Sts_4,
-- 3 + 25 ADCK cycles; 35 ADCK cycles total sample time.
Sts_5,
-- 3 + 26 ADCK cycles; 67 ADCK cycles total sample time.
Sts_6,
-- 3 + 27 ADCK cycles; 131 ADCK cycles total sample time.
Sts_7)
with Size => 3;
for CMDH5_STS_Field use
(Sts_0 => 0,
Sts_1 => 1,
Sts_2 => 2,
Sts_3 => 3,
Sts_4 => 4,
Sts_5 => 5,
Sts_6 => 6,
Sts_7 => 7);
-- Hardware Average Select
type CMDH5_AVGS_Field is
(
-- Single conversion.
Avgs_0,
-- 2 conversions averaged.
Avgs_1,
-- 4 conversions averaged.
Avgs_2,
-- 8 conversions averaged.
Avgs_3,
-- 16 conversions averaged.
Avgs_4,
-- 32 conversions averaged.
Avgs_5,
-- 64 conversions averaged.
Avgs_6,
-- 128 conversions averaged.
Avgs_7)
with Size => 3;
for CMDH5_AVGS_Field use
(Avgs_0 => 0,
Avgs_1 => 1,
Avgs_2 => 2,
Avgs_3 => 3,
Avgs_4 => 4,
Avgs_5 => 5,
Avgs_6 => 6,
Avgs_7 => 7);
-- Loop Count Select
type CMDH5_LOOP_Field is
(
-- Looping not enabled. Command executes 1 time.
Loop_0,
-- Loop 1 time. Command executes 2 times.
Loop_1,
-- Loop 2 times. Command executes 3 times.
Loop_2,
-- Loop corresponding number of times. Command executes LOOP+1 times.
Loop_3,
-- Loop corresponding number of times. Command executes LOOP+1 times.
Loop_4,
-- Loop corresponding number of times. Command executes LOOP+1 times.
Loop_5,
-- Loop corresponding number of times. Command executes LOOP+1 times.
Loop_6,
-- Loop corresponding number of times. Command executes LOOP+1 times.
Loop_7,
-- Loop corresponding number of times. Command executes LOOP+1 times.
Loop_8,
-- Loop corresponding number of times. Command executes LOOP+1 times.
Loop_9,
-- Loop 15 times. Command executes 16 times.
Loop_15)
with Size => 4;
for CMDH5_LOOP_Field use
(Loop_0 => 0,
Loop_1 => 1,
Loop_2 => 2,
Loop_3 => 3,
Loop_4 => 4,
Loop_5 => 5,
Loop_6 => 6,
Loop_7 => 7,
Loop_8 => 8,
Loop_9 => 9,
Loop_15 => 15);
-- Next Command Select
type CMDH5_NEXT_Field is
(
-- No next command defined. Terminate conversions at completion of
-- current command. If lower priority trigger pending, begin command
-- associated with lower priority trigger.
Next_0,
-- Select CMD1 command buffer register as next command.
Next_1,
-- Select corresponding CMD command buffer register as next command
Next_2,
-- Select corresponding CMD command buffer register as next command
Next_3,
-- Select corresponding CMD command buffer register as next command
Next_4,
-- Select corresponding CMD command buffer register as next command
Next_5,
-- Select corresponding CMD command buffer register as next command
Next_6,
-- Select corresponding CMD command buffer register as next command
Next_7,
-- Select corresponding CMD command buffer register as next command
Next_8,
-- Select corresponding CMD command buffer register as next command
Next_9,
-- Select CMD15 command buffer register as next command.
Next_15)
with Size => 4;
for CMDH5_NEXT_Field use
(Next_0 => 0,
Next_1 => 1,
Next_2 => 2,
Next_3 => 3,
Next_4 => 4,
Next_5 => 5,
Next_6 => 6,
Next_7 => 7,
Next_8 => 8,
Next_9 => 9,
Next_15 => 15);
-- ADC Command High Buffer Register
type CMDH_Register_1 is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- Wait for trigger assertion before execution.
WAIT_TRIG : CMDH5_WAIT_TRIG_Field := NXP_SVD.ADC.Wait_Trig_0;
-- unspecified
Reserved_3_6 : HAL.UInt4 := 16#0#;
-- Loop with Increment
LWI : CMDH5_LWI_Field := NXP_SVD.ADC.Lwi_0;
-- Sample Time Select
STS : CMDH5_STS_Field := NXP_SVD.ADC.Sts_0;
-- unspecified
Reserved_11_11 : HAL.Bit := 16#0#;
-- Hardware Average Select
AVGS : CMDH5_AVGS_Field := NXP_SVD.ADC.Avgs_0;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#0#;
-- Loop Count Select
LOOP_k : CMDH5_LOOP_Field := NXP_SVD.ADC.Loop_0;
-- unspecified
Reserved_20_23 : HAL.UInt4 := 16#0#;
-- Next Command Select
NEXT : CMDH5_NEXT_Field := NXP_SVD.ADC.Next_0;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CMDH_Register_1 use record
Reserved_0_1 at 0 range 0 .. 1;
WAIT_TRIG at 0 range 2 .. 2;
Reserved_3_6 at 0 range 3 .. 6;
LWI at 0 range 7 .. 7;
STS at 0 range 8 .. 10;
Reserved_11_11 at 0 range 11 .. 11;
AVGS at 0 range 12 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
LOOP_k at 0 range 16 .. 19;
Reserved_20_23 at 0 range 20 .. 23;
NEXT at 0 range 24 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
subtype CV_CVL_Field is HAL.UInt16;
subtype CV_CVH_Field is HAL.UInt16;
-- Compare Value Register
type CV_Register is record
-- Compare Value Low.
CVL : CV_CVL_Field := 16#0#;
-- Compare Value High.
CVH : CV_CVH_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CV_Register use record
CVL at 0 range 0 .. 15;
CVH at 0 range 16 .. 31;
end record;
-- Compare Value Register
type CV_Registers is array (0 .. 3) of CV_Register
with Volatile;
subtype RESFIFO_D_Field is HAL.UInt16;
-- Trigger Source
type RESFIFO_TSRC_Field is
(
-- Trigger source 0 initiated this conversion.
Tsrc_0,
-- Trigger source 1 initiated this conversion.
Tsrc_1,
-- Corresponding trigger source initiated this conversion.
Tsrc_2,
-- Corresponding trigger source initiated this conversion.
Tsrc_3,
-- Corresponding trigger source initiated this conversion.
Tsrc_4,
-- Corresponding trigger source initiated this conversion.
Tsrc_5,
-- Corresponding trigger source initiated this conversion.
Tsrc_6,
-- Corresponding trigger source initiated this conversion.
Tsrc_7,
-- Corresponding trigger source initiated this conversion.
Tsrc_8,
-- Corresponding trigger source initiated this conversion.
Tsrc_9,
-- Trigger source 15 initiated this conversion.
Tsrc_15)
with Size => 4;
for RESFIFO_TSRC_Field use
(Tsrc_0 => 0,
Tsrc_1 => 1,
Tsrc_2 => 2,
Tsrc_3 => 3,
Tsrc_4 => 4,
Tsrc_5 => 5,
Tsrc_6 => 6,
Tsrc_7 => 7,
Tsrc_8 => 8,
Tsrc_9 => 9,
Tsrc_15 => 15);
-- Loop count value
type RESFIFO_LOOPCNT_Field is
(
-- Result is from initial conversion in command.
Loopcnt_0,
-- Result is from second conversion in command.
Loopcnt_1,
-- Result is from LOOPCNT+1 conversion in command.
Loopcnt_2,
-- Result is from LOOPCNT+1 conversion in command.
Loopcnt_3,
-- Result is from LOOPCNT+1 conversion in command.
Loopcnt_4,
-- Result is from LOOPCNT+1 conversion in command.
Loopcnt_5,
-- Result is from LOOPCNT+1 conversion in command.
Loopcnt_6,
-- Result is from LOOPCNT+1 conversion in command.
Loopcnt_7,
-- Result is from LOOPCNT+1 conversion in command.
Loopcnt_8,
-- Result is from LOOPCNT+1 conversion in command.
Loopcnt_9,
-- Result is from 16th conversion in command.
Loopcnt_15)
with Size => 4;
for RESFIFO_LOOPCNT_Field use
(Loopcnt_0 => 0,
Loopcnt_1 => 1,
Loopcnt_2 => 2,
Loopcnt_3 => 3,
Loopcnt_4 => 4,
Loopcnt_5 => 5,
Loopcnt_6 => 6,
Loopcnt_7 => 7,
Loopcnt_8 => 8,
Loopcnt_9 => 9,
Loopcnt_15 => 15);
-- Command Buffer Source
type RESFIFO_CMDSRC_Field is
(
-- Not a valid value CMDSRC value for a dataword in RESFIFO. 0x0 is only
-- found in initial FIFO state prior to an ADC conversion result
-- dataword being stored to a RESFIFO buffer.
Cmdsrc_0,
-- CMD1 buffer used as control settings for this conversion.
Cmdsrc_1,
-- Corresponding command buffer used as control settings for this
-- conversion.
Cmdsrc_2,
-- Corresponding command buffer used as control settings for this
-- conversion.
Cmdsrc_3,
-- Corresponding command buffer used as control settings for this
-- conversion.
Cmdsrc_4,
-- Corresponding command buffer used as control settings for this
-- conversion.
Cmdsrc_5,
-- Corresponding command buffer used as control settings for this
-- conversion.
Cmdsrc_6,
-- Corresponding command buffer used as control settings for this
-- conversion.
Cmdsrc_7,
-- Corresponding command buffer used as control settings for this
-- conversion.
Cmdsrc_8,
-- Corresponding command buffer used as control settings for this
-- conversion.
Cmdsrc_9,
-- CMD15 buffer used as control settings for this conversion.
Cmdsrc_15)
with Size => 4;
for RESFIFO_CMDSRC_Field use
(Cmdsrc_0 => 0,
Cmdsrc_1 => 1,
Cmdsrc_2 => 2,
Cmdsrc_3 => 3,
Cmdsrc_4 => 4,
Cmdsrc_5 => 5,
Cmdsrc_6 => 6,
Cmdsrc_7 => 7,
Cmdsrc_8 => 8,
Cmdsrc_9 => 9,
Cmdsrc_15 => 15);
-- FIFO entry is valid
type RESFIFO_VALID_Field is
(
-- FIFO is empty. Discard any read from RESFIFO.
Valid_0,
-- FIFO record read from RESFIFO is valid.
Valid_1)
with Size => 1;
for RESFIFO_VALID_Field use
(Valid_0 => 0,
Valid_1 => 1);
-- ADC Data Result FIFO Register
type RESFIFO_Register is record
-- Read-only. Data result
D : RESFIFO_D_Field;
-- Read-only. Trigger Source
TSRC : RESFIFO_TSRC_Field;
-- Read-only. Loop count value
LOOPCNT : RESFIFO_LOOPCNT_Field;
-- Read-only. Command Buffer Source
CMDSRC : RESFIFO_CMDSRC_Field;
-- unspecified
Reserved_28_30 : HAL.UInt3;
-- Read-only. FIFO entry is valid
VALID : RESFIFO_VALID_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RESFIFO_Register use record
D at 0 range 0 .. 15;
TSRC at 0 range 16 .. 19;
LOOPCNT at 0 range 20 .. 23;
CMDSRC at 0 range 24 .. 27;
Reserved_28_30 at 0 range 28 .. 30;
VALID at 0 range 31 .. 31;
end record;
-- ADC Data Result FIFO Register
type RESFIFO_Registers is array (0 .. 1) of RESFIFO_Register
with Volatile;
subtype CAL_GAR_CAL_GAR_VAL_Field is HAL.UInt16;
-- Calibration General A-Side Registers
type CAL_GAR_Register is record
-- Calibration General A Side Register Element
CAL_GAR_VAL : CAL_GAR_CAL_GAR_VAL_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAL_GAR_Register use record
CAL_GAR_VAL at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- Calibration General A-Side Registers
type CAL_GAR_Registers is array (0 .. 32) of CAL_GAR_Register
with Volatile;
subtype CAL_GBR_CAL_GBR_VAL_Field is HAL.UInt16;
-- Calibration General B-Side Registers
type CAL_GBR_Register is record
-- Calibration General B Side Register Element
CAL_GBR_VAL : CAL_GBR_CAL_GBR_VAL_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAL_GBR_Register use record
CAL_GBR_VAL at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- Calibration General B-Side Registers
type CAL_GBR_Registers is array (0 .. 32) of CAL_GBR_Register
with Volatile;
-- Calibration Sample Time Long
type TST_CST_LONG_Field is
(
-- Normal sample time. Minimum sample time of 3 ADCK cycles.
Cst_Long_0,
-- Increased sample time. 67 ADCK cycles total sample time.
Cst_Long_1)
with Size => 1;
for TST_CST_LONG_Field use
(Cst_Long_0 => 0,
Cst_Long_1 => 1);
-- Force M-side positive offset
type TST_FOFFM_Field is
(
-- Normal operation. No forced offset.
Foffm_0,
-- Test configuration. Forced positive offset on MDAC.
Foffm_1)
with Size => 1;
for TST_FOFFM_Field use
(Foffm_0 => 0,
Foffm_1 => 1);
-- Force P-side positive offset
type TST_FOFFP_Field is
(
-- Normal operation. No forced offset.
Foffp_0,
-- Test configuration. Forced positive offset on PDAC.
Foffp_1)
with Size => 1;
for TST_FOFFP_Field use
(Foffp_0 => 0,
Foffp_1 => 1);
-- Force M-side negative offset
type TST_FOFFM2_Field is
(
-- Normal operation. No forced offset.
Foffm2_0,
-- Test configuration. Forced negative offset on MDAC.
Foffm2_1)
with Size => 1;
for TST_FOFFM2_Field use
(Foffm2_0 => 0,
Foffm2_1 => 1);
-- Force P-side negative offset
type TST_FOFFP2_Field is
(
-- Normal operation. No forced offset.
Foffp2_0,
-- Test configuration. Forced negative offset on PDAC.
Foffp2_1)
with Size => 1;
for TST_FOFFP2_Field use
(Foffp2_0 => 0,
Foffp2_1 => 1);
-- Enable test configuration
type TST_TESTEN_Field is
(
-- Normal operation. Test configuration not enabled.
Testen_0,
-- Hardware BIST Test in progress.
Testen_1)
with Size => 1;
for TST_TESTEN_Field use
(Testen_0 => 0,
Testen_1 => 1);
-- ADC Test Register
type TST_Register is record
-- Calibration Sample Time Long
CST_LONG : TST_CST_LONG_Field := NXP_SVD.ADC.Cst_Long_0;
-- unspecified
Reserved_1_7 : HAL.UInt7 := 16#0#;
-- Force M-side positive offset
FOFFM : TST_FOFFM_Field := NXP_SVD.ADC.Foffm_0;
-- Force P-side positive offset
FOFFP : TST_FOFFP_Field := NXP_SVD.ADC.Foffp_0;
-- Force M-side negative offset
FOFFM2 : TST_FOFFM2_Field := NXP_SVD.ADC.Foffm2_0;
-- Force P-side negative offset
FOFFP2 : TST_FOFFP2_Field := NXP_SVD.ADC.Foffp2_0;
-- unspecified
Reserved_12_22 : HAL.UInt11 := 16#0#;
-- Enable test configuration
TESTEN : TST_TESTEN_Field := NXP_SVD.ADC.Testen_0;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for TST_Register use record
CST_LONG at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
FOFFM at 0 range 8 .. 8;
FOFFP at 0 range 9 .. 9;
FOFFM2 at 0 range 10 .. 10;
FOFFP2 at 0 range 11 .. 11;
Reserved_12_22 at 0 range 12 .. 22;
TESTEN at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- ADC
type ADC0_Peripheral is record
-- Version ID Register
VERID : aliased VERID_Register;
-- Parameter Register
PARAM : aliased PARAM_Register;
-- ADC Control Register
CTRL : aliased CTRL_Register;
-- ADC Status Register
STAT : aliased STAT_Register;
-- Interrupt Enable Register
IE : aliased IE_Register;
-- DMA Enable Register
DE : aliased DE_Register;
-- ADC Configuration Register
CFG : aliased CFG_Register;
-- ADC Pause Register
PAUSE : aliased PAUSE_Register;
-- Software Trigger Register
SWTRIG : aliased SWTRIG_Register;
-- Trigger Status Register
TSTAT : aliased TSTAT_Register;
-- ADC Offset Trim Register
OFSTRIM : aliased OFSTRIM_Register;
-- Trigger Control Register
TCTRL : aliased TCTRL_Registers;
-- FIFO Control Register
FCTRL : aliased FCTRL_Registers;
-- Gain Calibration Control
GCC : aliased GCC_Registers;
-- Gain Calculation Result
GCR : aliased GCR_Registers;
-- ADC Command Low Buffer Register
CMDL1 : aliased CMDL_Register;
-- ADC Command High Buffer Register
CMDH1 : aliased CMDH_Register;
-- ADC Command Low Buffer Register
CMDL2 : aliased CMDL_Register;
-- ADC Command High Buffer Register
CMDH2 : aliased CMDH_Register;
-- ADC Command Low Buffer Register
CMDL3 : aliased CMDL_Register;
-- ADC Command High Buffer Register
CMDH3 : aliased CMDH_Register;
-- ADC Command Low Buffer Register
CMDL4 : aliased CMDL_Register;
-- ADC Command High Buffer Register
CMDH4 : aliased CMDH_Register;
-- ADC Command Low Buffer Register
CMDL5 : aliased CMDL_Register;
-- ADC Command High Buffer Register
CMDH5 : aliased CMDH_Register_1;
-- ADC Command Low Buffer Register
CMDL6 : aliased CMDL_Register;
-- ADC Command High Buffer Register
CMDH6 : aliased CMDH_Register_1;
-- ADC Command Low Buffer Register
CMDL7 : aliased CMDL_Register;
-- ADC Command High Buffer Register
CMDH7 : aliased CMDH_Register_1;
-- ADC Command Low Buffer Register
CMDL8 : aliased CMDL_Register;
-- ADC Command High Buffer Register
CMDH8 : aliased CMDH_Register_1;
-- ADC Command Low Buffer Register
CMDL9 : aliased CMDL_Register;
-- ADC Command High Buffer Register
CMDH9 : aliased CMDH_Register_1;
-- ADC Command Low Buffer Register
CMDL10 : aliased CMDL_Register;
-- ADC Command High Buffer Register
CMDH10 : aliased CMDH_Register_1;
-- ADC Command Low Buffer Register
CMDL11 : aliased CMDL_Register;
-- ADC Command High Buffer Register
CMDH11 : aliased CMDH_Register_1;
-- ADC Command Low Buffer Register
CMDL12 : aliased CMDL_Register;
-- ADC Command High Buffer Register
CMDH12 : aliased CMDH_Register_1;
-- ADC Command Low Buffer Register
CMDL13 : aliased CMDL_Register;
-- ADC Command High Buffer Register
CMDH13 : aliased CMDH_Register_1;
-- ADC Command Low Buffer Register
CMDL14 : aliased CMDL_Register;
-- ADC Command High Buffer Register
CMDH14 : aliased CMDH_Register_1;
-- ADC Command Low Buffer Register
CMDL15 : aliased CMDL_Register;
-- ADC Command High Buffer Register
CMDH15 : aliased CMDH_Register_1;
-- Compare Value Register
CV : aliased CV_Registers;
-- ADC Data Result FIFO Register
RESFIFO : aliased RESFIFO_Registers;
-- Calibration General A-Side Registers
CAL_GAR : aliased CAL_GAR_Registers;
-- Calibration General B-Side Registers
CAL_GBR : aliased CAL_GBR_Registers;
-- ADC Test Register
TST : aliased TST_Register;
end record
with Volatile;
for ADC0_Peripheral use record
VERID at 16#0# range 0 .. 31;
PARAM at 16#4# range 0 .. 31;
CTRL at 16#10# range 0 .. 31;
STAT at 16#14# range 0 .. 31;
IE at 16#18# range 0 .. 31;
DE at 16#1C# range 0 .. 31;
CFG at 16#20# range 0 .. 31;
PAUSE at 16#24# range 0 .. 31;
SWTRIG at 16#34# range 0 .. 31;
TSTAT at 16#38# range 0 .. 31;
OFSTRIM at 16#40# range 0 .. 31;
TCTRL at 16#A0# range 0 .. 511;
FCTRL at 16#E0# range 0 .. 63;
GCC at 16#F0# range 0 .. 63;
GCR at 16#F8# range 0 .. 63;
CMDL1 at 16#100# range 0 .. 31;
CMDH1 at 16#104# range 0 .. 31;
CMDL2 at 16#108# range 0 .. 31;
CMDH2 at 16#10C# range 0 .. 31;
CMDL3 at 16#110# range 0 .. 31;
CMDH3 at 16#114# range 0 .. 31;
CMDL4 at 16#118# range 0 .. 31;
CMDH4 at 16#11C# range 0 .. 31;
CMDL5 at 16#120# range 0 .. 31;
CMDH5 at 16#124# range 0 .. 31;
CMDL6 at 16#128# range 0 .. 31;
CMDH6 at 16#12C# range 0 .. 31;
CMDL7 at 16#130# range 0 .. 31;
CMDH7 at 16#134# range 0 .. 31;
CMDL8 at 16#138# range 0 .. 31;
CMDH8 at 16#13C# range 0 .. 31;
CMDL9 at 16#140# range 0 .. 31;
CMDH9 at 16#144# range 0 .. 31;
CMDL10 at 16#148# range 0 .. 31;
CMDH10 at 16#14C# range 0 .. 31;
CMDL11 at 16#150# range 0 .. 31;
CMDH11 at 16#154# range 0 .. 31;
CMDL12 at 16#158# range 0 .. 31;
CMDH12 at 16#15C# range 0 .. 31;
CMDL13 at 16#160# range 0 .. 31;
CMDH13 at 16#164# range 0 .. 31;
CMDL14 at 16#168# range 0 .. 31;
CMDH14 at 16#16C# range 0 .. 31;
CMDL15 at 16#170# range 0 .. 31;
CMDH15 at 16#174# range 0 .. 31;
CV at 16#200# range 0 .. 127;
RESFIFO at 16#300# range 0 .. 63;
CAL_GAR at 16#400# range 0 .. 1055;
CAL_GBR at 16#500# range 0 .. 1055;
TST at 16#FFC# range 0 .. 31;
end record;
-- ADC
ADC0_Periph : aliased ADC0_Peripheral
with Import, Address => System'To_Address (16#400A0000#);
end NXP_SVD.ADC;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
package body GL.Vectors is
function "+" (Left, Right : Vector) return Vector is
Ret : Vector;
begin
for I in Index_Type'Range loop
Ret (I) := Left (I) + Right (I);
end loop;
return Ret;
end "+";
function "-" (Left, Right : Vector) return Vector is
Ret : Vector;
begin
for I in Index_Type'Range loop
Ret (I) := Left (I) - Right (I);
end loop;
return Ret;
end "-";
function "-" (Left : Vector) return Vector is
Ret : Vector;
begin
for I in Index_Type loop
Ret (I) := -Left (I);
end loop;
return Ret;
end "-";
function "*" (Left : Vector; Right : Element_Type) return Vector is
Ret : Vector;
begin
for I in Index_Type'Range loop
Ret (I) := Left (I) * Right;
end loop;
return Ret;
end "*";
function "*" (Left : Element_Type; Right : Vector) return Vector is
begin
return Right * Left;
end "*";
function "/" (Left : Vector; Right : Element_Type) return Vector is
Ret : Vector;
begin
for I in Index_Type'Range loop
Ret (I) := Left (I) / Right;
end loop;
return Ret;
end "/";
function Dot_Product (Left, Right : Vector) return Element_Type is
Ret : Element_Type;
begin
Ret := Left (Left'First) * Right (Right'First);
for Index in Index_Type'Succ (Index_Type'First) .. Index_Type'Last loop
Ret := Ret + Left (Index) * Right (Index);
end loop;
return Ret;
end Dot_Product;
end GL.Vectors;
|
-------------------------------------------------------------------------------
-- This file is part of libsparkcrypto.
--
-- Copyright (C) 2010, Alexander Senier
-- Copyright (C) 2010, secunet Security Networks AG
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
--
-- * Neither the name of the nor the names of its contributors may be used
-- to endorse or promote products derived from this software without
-- specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
-- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with Interfaces;
with LSC.Internal.Byteorder32;
with LSC.Internal.SHA256.Tables;
with LSC.Internal.Pad32;
with LSC.Internal.Debug;
pragma Unreferenced (LSC.Internal.Debug);
package body LSC.Internal.SHA256 is
function Init_Data_Length return Data_Length;
function Init_Data_Length return Data_Length is
begin
return Data_Length'(0, 0);
end Init_Data_Length;
----------------------------------------------------------------------------
procedure Add (Item : in out Data_Length;
Value : in Types.Word32)
with
Depends => (Item =>+ Value),
Inline;
procedure Add (Item : in out Data_Length;
Value : in Types.Word32)
is
begin
if Item.LSW > Types.Word32'Last - Value then
Item.MSW := Item.MSW + 1;
end if;
Item.LSW := Item.LSW + Value;
end Add;
----------------------------------------------------------------------------
function Ch
(x : Types.Word32;
y : Types.Word32;
z : Types.Word32)
return Types.Word32
with
Post => Ch'Result = ((x and y) xor ((not x) and z)),
Inline;
function Ch
(x : Types.Word32;
y : Types.Word32;
z : Types.Word32)
return Types.Word32
is
begin
return (x and y) xor ((not x) and z);
end Ch;
----------------------------------------------------------------------------
function Maj
(x : Types.Word32;
y : Types.Word32;
z : Types.Word32)
return Types.Word32
with
Post => Maj'Result = ((x and y) xor (x and z) xor (y and z)),
Inline;
function Maj
(x : Types.Word32;
y : Types.Word32;
z : Types.Word32)
return Types.Word32
is
begin
return (x and y) xor (x and z) xor (y and z);
end Maj;
----------------------------------------------------------------------------
function Cap_Sigma_0_256 (x : Types.Word32) return Types.Word32
is
begin
return Interfaces.Rotate_Right (x, 2) xor
Interfaces.Rotate_Right (x, 13) xor
Interfaces.Rotate_Right (x, 22);
end Cap_Sigma_0_256;
pragma Inline (Cap_Sigma_0_256);
----------------------------------------------------------------------------
function Cap_Sigma_1_256 (x : Types.Word32) return Types.Word32
is
begin
return Interfaces.Rotate_Right (x, 6) xor
Interfaces.Rotate_Right (x, 11) xor
Interfaces.Rotate_Right (x, 25);
end Cap_Sigma_1_256;
pragma Inline (Cap_Sigma_1_256);
----------------------------------------------------------------------------
function Sigma_0_256 (x : Types.Word32) return Types.Word32
is
begin
return Interfaces.Rotate_Right (x, 7) xor
Interfaces.Rotate_Right (x, 18) xor
Interfaces.Shift_Right (x, 3);
end Sigma_0_256;
pragma Inline (Sigma_0_256);
----------------------------------------------------------------------------
function Sigma_1_256 (x : Types.Word32) return Types.Word32
is
begin
return Interfaces.Rotate_Right (x, 17) xor
Interfaces.Rotate_Right (x, 19) xor
Interfaces.Shift_Right (x, 10);
end Sigma_1_256;
pragma Inline (Sigma_1_256);
----------------------------------------------------------------------------
function SHA256_Context_Init return Context_Type is
begin
return Context_Type'
(Length => Init_Data_Length,
H => SHA256_Hash_Type'(0 => 16#6a09e667#,
1 => 16#bb67ae85#,
2 => 16#3c6ef372#,
3 => 16#a54ff53a#,
4 => 16#510e527f#,
5 => 16#9b05688c#,
6 => 16#1f83d9ab#,
7 => 16#5be0cd19#),
W => Null_Schedule);
end SHA256_Context_Init;
----------------------------------------------------------------------------
procedure Context_Update_Internal
(Context : in out Context_Type;
Block : in Block_Type)
with Depends => (Context =>+ Block);
procedure Context_Update_Internal
(Context : in out Context_Type;
Block : in Block_Type)
is
a, b, c, d, e, f, g, h : Types.Word32;
procedure SHA256_Op (r : in Schedule_Index;
a0 : in Types.Word32;
a1 : in Types.Word32;
a2 : in Types.Word32;
a3 : in out Types.Word32;
a4 : in Types.Word32;
a5 : in Types.Word32;
a6 : in Types.Word32;
a7 : in out Types.Word32)
with
Global => Context,
Depends =>
(a3 =>+ (a4, a5, a6, a7, r, Context),
a7 => (a0, a1, a2, a4, a5, a6, a7, r, Context));
procedure SHA256_Op (r : in Schedule_Index;
a0 : in Types.Word32;
a1 : in Types.Word32;
a2 : in Types.Word32;
a3 : in out Types.Word32;
a4 : in Types.Word32;
a5 : in Types.Word32;
a6 : in Types.Word32;
a7 : in out Types.Word32)
is
T1, T2 : Types.Word32;
begin
T1 := a7 + Cap_Sigma_1_256 (a4) + Ch (a4, a5, a6) + Tables.K (r) + Context.W (r);
T2 := Cap_Sigma_0_256 (a0) + Maj (a0, a1, a2);
a3 := a3 + T1;
a7 := T1 + T2;
end SHA256_Op;
begin
pragma Debug (Debug.Put_Line ("BLOCK UPDATE:"));
-- Print out initial state of H
pragma Debug (Debug.Put_Line ("SHA-256 initial hash values:"));
pragma Debug (Debug.Print_Word32_Array (Context.H, 2, Types.Index'Last, True));
-------------------------------------------
-- Section 6.3.2 SHA-256 Hash Computations
-------------------------------------------
-- 1. Prepare the message schedule, Context.W(t):
for t in Schedule_Index range 0 .. 15
loop
Context.W (t) := Byteorder32.Native_To_BE (Block (t));
end loop;
for t in Schedule_Index range 16 .. 63
loop
Context.W (t) := Sigma_1_256 (Context.W (t - 2)) +
Context.W (t - 7) +
Sigma_0_256 (Context.W (t - 15)) +
Context.W (t - 16);
end loop;
pragma Debug (Debug.Put_Line ("Message block:"));
pragma Debug (Debug.Print_Word32_Array (Context.W, 2, 8, True));
-- 2. Initialize the eight working variables a, b, c, d, e, f, g, and
-- h with the (i-1)st hash value:
a := Context.H (0);
b := Context.H (1);
c := Context.H (2);
d := Context.H (3);
e := Context.H (4);
f := Context.H (5);
g := Context.H (6);
h := Context.H (7);
-- 3. For t = 0 to 63:
SHA256_Op (0, a, b, c, d, e, f, g, h);
SHA256_Op (1, h, a, b, c, d, e, f, g);
SHA256_Op (2, g, h, a, b, c, d, e, f);
SHA256_Op (3, f, g, h, a, b, c, d, e);
SHA256_Op (4, e, f, g, h, a, b, c, d);
SHA256_Op (5, d, e, f, g, h, a, b, c);
SHA256_Op (6, c, d, e, f, g, h, a, b);
SHA256_Op (7, b, c, d, e, f, g, h, a);
SHA256_Op (8, a, b, c, d, e, f, g, h);
SHA256_Op (9, h, a, b, c, d, e, f, g);
SHA256_Op (10, g, h, a, b, c, d, e, f);
SHA256_Op (11, f, g, h, a, b, c, d, e);
SHA256_Op (12, e, f, g, h, a, b, c, d);
SHA256_Op (13, d, e, f, g, h, a, b, c);
SHA256_Op (14, c, d, e, f, g, h, a, b);
SHA256_Op (15, b, c, d, e, f, g, h, a);
SHA256_Op (16, a, b, c, d, e, f, g, h);
SHA256_Op (17, h, a, b, c, d, e, f, g);
SHA256_Op (18, g, h, a, b, c, d, e, f);
SHA256_Op (19, f, g, h, a, b, c, d, e);
SHA256_Op (20, e, f, g, h, a, b, c, d);
SHA256_Op (21, d, e, f, g, h, a, b, c);
SHA256_Op (22, c, d, e, f, g, h, a, b);
SHA256_Op (23, b, c, d, e, f, g, h, a);
SHA256_Op (24, a, b, c, d, e, f, g, h);
SHA256_Op (25, h, a, b, c, d, e, f, g);
SHA256_Op (26, g, h, a, b, c, d, e, f);
SHA256_Op (27, f, g, h, a, b, c, d, e);
SHA256_Op (28, e, f, g, h, a, b, c, d);
SHA256_Op (29, d, e, f, g, h, a, b, c);
SHA256_Op (30, c, d, e, f, g, h, a, b);
SHA256_Op (31, b, c, d, e, f, g, h, a);
SHA256_Op (32, a, b, c, d, e, f, g, h);
SHA256_Op (33, h, a, b, c, d, e, f, g);
SHA256_Op (34, g, h, a, b, c, d, e, f);
SHA256_Op (35, f, g, h, a, b, c, d, e);
SHA256_Op (36, e, f, g, h, a, b, c, d);
SHA256_Op (37, d, e, f, g, h, a, b, c);
SHA256_Op (38, c, d, e, f, g, h, a, b);
SHA256_Op (39, b, c, d, e, f, g, h, a);
SHA256_Op (40, a, b, c, d, e, f, g, h);
SHA256_Op (41, h, a, b, c, d, e, f, g);
SHA256_Op (42, g, h, a, b, c, d, e, f);
SHA256_Op (43, f, g, h, a, b, c, d, e);
SHA256_Op (44, e, f, g, h, a, b, c, d);
SHA256_Op (45, d, e, f, g, h, a, b, c);
SHA256_Op (46, c, d, e, f, g, h, a, b);
SHA256_Op (47, b, c, d, e, f, g, h, a);
SHA256_Op (48, a, b, c, d, e, f, g, h);
SHA256_Op (49, h, a, b, c, d, e, f, g);
SHA256_Op (50, g, h, a, b, c, d, e, f);
SHA256_Op (51, f, g, h, a, b, c, d, e);
SHA256_Op (52, e, f, g, h, a, b, c, d);
SHA256_Op (53, d, e, f, g, h, a, b, c);
SHA256_Op (54, c, d, e, f, g, h, a, b);
SHA256_Op (55, b, c, d, e, f, g, h, a);
SHA256_Op (56, a, b, c, d, e, f, g, h);
SHA256_Op (57, h, a, b, c, d, e, f, g);
SHA256_Op (58, g, h, a, b, c, d, e, f);
SHA256_Op (59, f, g, h, a, b, c, d, e);
SHA256_Op (60, e, f, g, h, a, b, c, d);
SHA256_Op (61, d, e, f, g, h, a, b, c);
SHA256_Op (62, c, d, e, f, g, h, a, b);
SHA256_Op (63, b, c, d, e, f, g, h, a);
-- 4. Compute the i-th intermediate hash value H-i:
Context.H :=
SHA256_Hash_Type'
(0 => a + Context.H (0),
1 => b + Context.H (1),
2 => c + Context.H (2),
3 => d + Context.H (3),
4 => e + Context.H (4),
5 => f + Context.H (5),
6 => g + Context.H (6),
7 => h + Context.H (7));
pragma Debug (Debug.Put_Line ("SHA-256 final hash values:"));
pragma Debug (Debug.Print_Word32_Array (Context.H, 2, Types.Index'Last, True));
end Context_Update_Internal;
----------------------------------------------------------------------------
procedure Context_Update
(Context : in out Context_Type;
Block : in Block_Type)
is
begin
Context_Update_Internal (Context, Block);
Add (Context.Length, 512);
end Context_Update;
----------------------------------------------------------------------------
procedure Context_Finalize
(Context : in out Context_Type;
Block : in Block_Type;
Length : in Block_Length_Type)
is
Final_Block : Block_Type;
begin
pragma Debug (Debug.Put_Line ("FINAL BLOCK:"));
Final_Block := Block;
-- Add length of last block to data length.
Add (Context.Length, Length);
-- Set trailing '1' marker and zero out rest of the block.
Pad32.Block_Terminate (Block => Final_Block,
Length => Types.Word64 (Length));
-- Terminator and length values won't fit into current block.
if Length >= 448 then
Context_Update_Internal (Context => Context, Block => Final_Block);
Final_Block := Null_Block;
end if;
-- Set length in final block.
Final_Block (Block_Type'Last - 1) := Byteorder32.BE_To_Native (Context.Length.MSW);
Final_Block (Block_Type'Last) := Byteorder32.BE_To_Native (Context.Length.LSW);
Context_Update_Internal (Context => Context, Block => Final_Block);
end Context_Finalize;
----------------------------------------------------------------------------
function SHA256_Get_Hash (Context : Context_Type) return SHA256_Hash_Type is
begin
return SHA256_Hash_Type'(0 => Byteorder32.BE_To_Native (Context.H (0)),
1 => Byteorder32.BE_To_Native (Context.H (1)),
2 => Byteorder32.BE_To_Native (Context.H (2)),
3 => Byteorder32.BE_To_Native (Context.H (3)),
4 => Byteorder32.BE_To_Native (Context.H (4)),
5 => Byteorder32.BE_To_Native (Context.H (5)),
6 => Byteorder32.BE_To_Native (Context.H (6)),
7 => Byteorder32.BE_To_Native (Context.H (7)));
end SHA256_Get_Hash;
----------------------------------------------------------------------------
procedure Hash_Context
(Message : in Message_Type;
Length : in Message_Index;
Ctx : in out Context_Type)
is
Dummy : constant Block_Type := Null_Block;
Last_Length : Block_Length_Type;
Last_Block : Message_Index;
begin
Last_Length := Types.Word32 (Length mod Block_Size);
Last_Block := Message'First + Length / Block_Size;
-- handle all blocks, but the last.
if Last_Block > Message'First then
for I in Message_Index range Message'First .. Last_Block - 1
loop
pragma Loop_Invariant
(Last_Block - 1 <= Message'Last and
(if Last_Length /= 0 then Last_Block <= Message'Last) and
I < Last_Block);
Context_Update (Ctx, Message (I));
end loop;
end if;
if Last_Length = 0 then
Context_Finalize (Ctx, Dummy, 0);
else
Context_Finalize (Ctx, Message (Last_Block), Last_Length);
end if;
end Hash_Context;
----------------------------------------------------------------------------
function Hash
(Message : Message_Type;
Length : Message_Index) return SHA256_Hash_Type
is
Ctx : Context_Type;
begin
Ctx := SHA256_Context_Init;
Hash_Context (Message, Length, Ctx);
return SHA256_Get_Hash (Ctx);
end Hash;
end LSC.Internal.SHA256;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Test is
type t is record a: integer; a: character; end record;
begin new_line; end;
|
-- Abstract :
--
-- Ada implementation of:
--
-- [1] gpr-wisi.el
-- [2] gpr-indent-user-options.el
--
-- Copyright (C) 2017 - 2019 Free Software Foundation, Inc.
--
-- This library is free software; you can redistribute it and/or modify it
-- under terms of the GNU General Public License as published by the Free
-- Software Foundation; either version 3, or (at your option) any later
-- version. This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-- As a special exception under Section 7 of GPL version 3, you are granted
-- additional permissions described in the GCC Runtime Library Exception,
-- version 3.1, as published by the Free Software Foundation.
pragma License (Modified_GPL);
package Wisi.Gpr is
Language_Protocol_Version : constant String := "1";
-- Defines the data passed to Initialize in Params.
--
-- This value must match gpr-wisi.el
-- gpr-wisi-language-protocol-version.
-- Indent parameters from [2]
Gpr_Indent : Integer := 3;
Gpr_Indent_Broken : Integer := 2;
Gpr_Indent_When : Integer := 3;
-- Other parameters
End_Names_Optional : Boolean := False;
type Parse_Data_Type is new Wisi.Parse_Data_Type with null record;
overriding
procedure Initialize
(Data : in out Parse_Data_Type;
Lexer : in WisiToken.Lexer.Handle;
Descriptor : access constant WisiToken.Descriptor;
Base_Terminals : in WisiToken.Base_Token_Array_Access;
Post_Parse_Action : in Post_Parse_Action_Type;
Begin_Line : in WisiToken.Line_Number_Type;
End_Line : in WisiToken.Line_Number_Type;
Begin_Indent : in Integer;
Params : in String);
-- Call Wisi_Runtime.Initialize, then:
--
-- If Params /= "", set all indent parameters from Params, in
-- declaration order; otherwise keep default values. Boolean is
-- represented by 0 | 1. Parameter values are space delimited.
--
-- Also do any other initialization that Gpr_Data needs.
end Wisi.Gpr;
|
-- WORDS, a Latin dictionary, by Colonel William Whitaker (USAF, Retired)
--
-- Copyright William A. Whitaker (1936–2010)
--
-- This is a free program, which means it is proper to copy it and pass
-- it on to your friends. Consider it a developmental item for which
-- there is no charge. However, just for form, it is Copyrighted
-- (c). Permission is hereby freely given for any and all use of program
-- and data. You can sell it as your own, but at least tell me.
--
-- This version is distributed without obligation, but the developer
-- would appreciate comments and suggestions.
--
-- All parts of the WORDS system, source code and data files, are made freely
-- available to anyone who wishes to use them, for whatever purpose.
separate (Support_Utils.Addons_Package)
package body Tackon_Entry_Io is
procedure Get (F : in File_Type; I : out Tackon_Entry) is
begin
Get (F, I.Base);
end Get;
procedure Get (I : out Tackon_Entry) is
begin
Get (I.Base);
end Get;
procedure Put (F : in File_Type; I : in Tackon_Entry) is
begin
Put (F, I.Base);
end Put;
procedure Put (I : in Tackon_Entry) is
begin
Put (I.Base);
end Put;
procedure Get (S : in String; I : out Tackon_Entry; Last : out Integer) is
L : constant Integer := S'First - 1;
begin
Get (S (L + 1 .. S'Last), I.Base, Last);
end Get;
procedure Put (S : out String; I : in Tackon_Entry) is
L : constant Integer := S'First - 1;
M : Integer := 0;
begin
M := L + Target_Entry_Io.Default_Width;
Put (S (L + 1 .. M), I.Base);
S (S'First .. S'Last) := (others => ' ');
end Put;
end Tackon_Entry_Io;
|
package body Ethiopian is
function Is_Even(Item : Integer) return Boolean is
begin
return Item mod 2 = 0;
end Is_Even;
function Double(Item : Integer) return Integer is
begin
return Item * 2;
end Double;
function Half(Item : Integer) return Integer is
begin
return Item / 2;
end Half;
function Multiply(Left, Right : Integer) return Integer is
Temp : Integer := 0;
Plier : Integer := Left;
Plicand : Integer := Right;
begin
while Plier >= 1 loop
if not Is_Even(Plier) then
Temp := Temp + Plicand;
end if;
Plier := Half(Plier);
Plicand := Double(Plicand);
end loop;
return Temp;
end Multiply;
end Ethiopian;
|
pragma Ada_2012;
package Base64.Routines with
Pure,
Preelaborate
is
generic
type Element is mod <>;
function Standard_Character_To_Value (C : Character) return Element;
generic
type Element is mod <>;
function Standard_Value_To_Character (E : Element) return Character;
generic
type Element is mod <>;
function URLSafe_Character_To_Value (C : Character) return Element;
generic
type Element is mod <>;
function URLSafe_Value_To_Character (E : Element) return Character;
end Base64.Routines;
|
with avtas.lmcp.types; use avtas.lmcp.types;
with afrl.cmasi.object; use afrl.cmasi.object;
with afrl.cmasi.enumerations; use afrl.cmasi.enumerations;
with afrl.cmasi.AbstractGeometry; use afrl.cmasi.AbstractGeometry;
with ada.Containers.Vectors;
with ada.Strings.Unbounded; use ada.Strings.Unbounded;
package afrl.cmasi.abstractZone is
type AbstractZone is new afrl.cmasi.object.Object with private;
type AbstractZone_Acc is access all AbstractZone;
type AbstractZone_Class_Acc is access all AbstractZone'Class;
package Vect_Int64_t is new Ada.Containers.Vectors
(Index_Type => Natural,
Element_Type => Int64_t);
type Vect_Int64_t_Acc is access all Vect_Int64_t.Vector;
function getFullLmcpTypeName(this : AbstractZone'Class) return String;
function getLmcpTypeName(this : AbstractZone'Class) return String;
function getLmcpType(this : AbstractZone'Class) return UInt32_t;
function getZoneId(this : AbstractZone'Class) return Int64_t;
procedure setZoneId(this : out AbstractZone'Class; ZoneId : in Int64_t);
function getMinAltitude(this : AbstractZone'Class) return Float_t;
procedure setMinAltitude(this : out AbstractZone'Class; MinAltitude : in Float_t);
function getMinAltitudeType(this : AbstractZone'Class) return AltitudeTypeEnum;
procedure setMinAltitudeType(this : out AbstractZone'Class; MinAltitudeType : in AltitudeTypeEnum);
function getMaxAltitude(this : AbstractZone'Class) return Float_t;
procedure setMaxAltitude(this : out AbstractZone'Class; MaxAltitude : in Float_t);
function getMaxAltitudeType(this : AbstractZone'Class) return AltitudeTypeEnum;
procedure setMaxAltitudeType(this : out AbstractZone'Class; MaxAltitudeType : in AltitudeTypeEnum);
function getAffectedAircraft(this : AbstractZone'Class) return Vect_Int64_t_Acc;
function getStartTime(this : AbstractZone'Class) return Int64_t;
procedure setStartTime(this : out AbstractZone'Class; StartTime : in Int64_t);
function getEndTime(this : AbstractZone'Class) return Int64_t;
procedure setEndTime(this : out AbstractZone'Class; EndTime : in Int64_t);
function getPadding(this : AbstractZone'Class) return Float_t;
procedure setPadding(this : out AbstractZone'Class; Padding : in Float_t);
function getLabel(this : AbstractZone'Class) return Unbounded_String;
procedure setLabel(this : out AbstractZone'Class; Label : in Unbounded_String);
function getBoundary(this : AbstractZone'Class) return AbstractGeometry_Acc;
procedure setBoundary(this : out AbstractZone'Class; Boundary : in AbstractGeometry_Acc);
private
type AbstractZone is new afrl.cmasi.object.Object with record
ZoneID : Int64_t := 0;
MinAltitude : Float_t := 0.0;
MinAltitudeType : AltitudeTypeEnum := AGL;
MaxAltitude : Float_t := 0.0;
MaxAltitudeType : AltitudeTypeEnum := MSL;
AffectedAircraft : Vect_Int64_t_Acc := new Vect_Int64_t.Vector;
StartTime : Int64_t := 0;
EndTime : Int64_t := 0;
Padding : Float_t := 0.0;
Label : Unbounded_String;
Boundary : AbstractGeometry_Acc;
end record;
end afrl.cmasi.abstractZone;
|
-- { dg-do compile }
-- { dg-options "-gnatwu" }
with Ada.Command_Line; use Ada.Command_Line;
with Text_IO; use Text_IO;
procedure warn3 is
type Weekdays is (Sun, Mon, Tue, Wed, Thu, Fri, Sat);
begin
if Argument_Count > 0 then
Put_Line
(Argument (1) & " is weekday number"
& Integer'Image
(Weekdays'Pos (Weekdays'Value (Argument (1)))));
end if;
end;
|
-- { dg-do compile }
procedure Array11 is
type Rec is null record;
type Ptr is access all Rec;
type Arr1 is array (1..8) of aliased Rec; -- { dg-warning "padded" }
type Arr2 is array (Long_Integer) of aliased Rec; -- { dg-warning "padded" }
A1 : Arr1;
A2 : Arr2; -- { dg-warning "Storage_Error" }
begin
null;
end;
|
procedure Last_Chance_Handler
(Source_Location : System.Address; Line : Integer) is
pragma Unreferenced (Source_Location, Line);
begin
-- TODO: Add in code to dump the info to serial/screen which
-- is obviously board specific.
loop
null;
end loop;
end Last_Chance_Handler;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 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 GL.Low_Level.Enums;
with GL.Objects.Programs.Uniforms;
with GL.Objects.Textures;
with GL.Pixels.Extensions;
with GL.Types;
with Orka.Rendering.Textures;
with Orka.Types;
package Orka.Rendering.Programs.Uniforms is
pragma Preelaborate;
package LE renames GL.Low_Level.Enums;
package PE renames GL.Pixels.Extensions;
use type LE.Texture_Kind;
use type LE.Resource_Type;
use type PE.Format_Type;
-----------------------------------------------------------------------------
function Texture_Kind (Sampler : LE.Resource_Type) return LE.Texture_Kind;
function Image_Kind (Image : LE.Resource_Type) return LE.Texture_Kind;
function Sampler_Format_Type (Sampler : LE.Resource_Type) return PE.Format_Type;
function Image_Format_Type (Image : LE.Resource_Type) return PE.Format_Type;
-----------------------------------------------------------------------------
type Uniform (Kind : LE.Resource_Type) is tagged private;
procedure Set_Matrix (Object : Uniform; Value : Types.Singles.Matrix4)
with Pre => Object.Kind = LE.Single_Matrix4;
procedure Set_Matrix (Object : Uniform; Value : Types.Doubles.Matrix4)
with Pre => Object.Kind = LE.Double_Matrix4;
procedure Set_Vector (Object : Uniform; Value : Types.Singles.Vector4)
with Pre => Object.Kind = LE.Single_Vec4;
procedure Set_Vector (Object : Uniform; Value : Types.Doubles.Vector4)
with Pre => Object.Kind = LE.Double_Vec4;
-----------------------------------------------------------------------------
procedure Set_Vector
(Object : Uniform;
Data : GL.Types.Int_Array)
with Pre => (case Object.Kind is
when LE.Int_Vec2 => Data'Length = 2,
when LE.Int_Vec3 => Data'Length = 3,
when LE.Int_Vec4 => Data'Length = 4,
when others => raise Constraint_Error);
procedure Set_Vector
(Object : Uniform;
Data : GL.Types.UInt_Array)
with Pre => (case Object.Kind is
when LE.UInt_Vec2 => Data'Length = 2,
when LE.UInt_Vec3 => Data'Length = 3,
when LE.UInt_Vec4 => Data'Length = 4,
when others => raise Constraint_Error);
procedure Set_Vector
(Object : Uniform;
Data : GL.Types.Single_Array)
with Pre => (case Object.Kind is
when LE.Single_Vec2 => Data'Length = 2,
when LE.Single_Vec3 => Data'Length = 3,
when LE.Single_Vec4 => Data'Length = 4,
when others => raise Constraint_Error);
procedure Set_Vector
(Object : Uniform;
Data : GL.Types.Double_Array)
with Pre => (case Object.Kind is
when LE.Double_Vec2 => Data'Length = 2,
when LE.Double_Vec3 => Data'Length = 3,
when LE.Double_Vec4 => Data'Length = 4,
when others => raise Constraint_Error);
-----------------------------------------------------------------------------
procedure Set_Single (Object : Uniform; Value : GL.Types.Single)
with Pre => Object.Kind = LE.Single_Type;
procedure Set_Double (Object : Uniform; Value : GL.Types.Double)
with Pre => Object.Kind = LE.Double_Type;
procedure Set_Int (Object : Uniform; Value : GL.Types.Int)
with Pre => Object.Kind = LE.Int_Type;
procedure Set_UInt (Object : Uniform; Value : GL.Types.UInt)
with Pre => Object.Kind = LE.UInt_Type;
procedure Set_Integer (Object : Uniform; Value : Integer)
with Pre => Object.Kind = LE.Int_Type;
procedure Set_Boolean (Object : Uniform; Value : Boolean)
with Pre => Object.Kind = LE.Bool_Type;
-----------------------------------------------------------------------------
type Uniform_Sampler (Kind : LE.Resource_Type) is tagged private;
procedure Verify_Compatibility
(Object : Uniform_Sampler;
Texture : GL.Objects.Textures.Texture) is null
with Pre'Class =>
(Texture.Kind = Texture_Kind (Object.Kind) or else
raise Constraint_Error with
"Cannot bind " & Rendering.Textures.Image (Texture) & " to " &
Texture_Kind (Object.Kind)'Image & " sampler")
and then
-- If the texture is a depth texture, the sampler can be a normal or shadow sampler
-- (The bound Sampler object must have comparison mode enabled iff the sampler in the
-- shader is a shadow sampler)
(Texture.Compressed
or else
(if PE.Texture_Format_Type (Texture.Internal_Format) = PE.Depth_Type then
Sampler_Format_Type (Object.Kind) in PE.Depth_Type | PE.Float_Or_Normalized_Type
else
Sampler_Format_Type (Object.Kind) =
PE.Texture_Format_Type (Texture.Internal_Format))
or else raise Constraint_Error with
"Cannot bind " & Rendering.Textures.Image (Texture) & " to " &
Object.Kind'Image & " sampler");
-----------------------------------------------------------------------------
type Uniform_Image (Kind : LE.Resource_Type) is tagged private;
procedure Verify_Compatibility
(Object : Uniform_Image;
Texture : GL.Objects.Textures.Texture) is null
with Pre'Class =>
(Texture.Kind = Image_Kind (Object.Kind) or else
raise Constraint_Error with
"Cannot bind " & Rendering.Textures.Image (Texture) & " to " &
Image_Kind (Object.Kind)'Image & " image sampler")
and then
-- If the texture is a depth texture, the sampler can be a normal or shadow sampler
-- (The bound Sampler object must have comparison mode enabled iff the sampler in the
-- shader is a shadow sampler)
(Texture.Compressed
or else
Sampler_Format_Type (Object.Kind) = PE.Image_Format_Type (Texture.Internal_Format)
or else raise Constraint_Error with
"Cannot bind " & Rendering.Textures.Image (Texture) & " to " &
Object.Kind'Image & " image sampler");
-----------------------------------------------------------------------------
function Create_Uniform_Sampler
(Object : Program;
Name : String) return Uniform_Sampler;
function Create_Uniform_Image
(Object : Program;
Name : String) return Uniform_Image;
function Create_Uniform_Variable
(Object : Program;
Name : String) return Uniform;
Uniform_Inactive_Error : exception renames GL.Objects.Programs.Uniform_Inactive_Error;
Uniform_Type_Error : exception;
private
type Uniform (Kind : LE.Resource_Type) is tagged record
GL_Uniform : GL.Objects.Programs.Uniforms.Uniform;
end record;
type Uniform_Sampler (Kind : LE.Resource_Type) is tagged record
GL_Uniform : GL.Objects.Programs.Uniforms.Uniform;
end record;
type Uniform_Image (Kind : LE.Resource_Type) is tagged record
GL_Uniform : GL.Objects.Programs.Uniforms.Uniform;
end record;
end Orka.Rendering.Programs.Uniforms;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with Glfw.API;
package body Glfw.Events.Joysticks is
function Index (Source : Joystick) return Joystick_Index is
begin
return Enums.Joystick_ID'Pos (Source.Raw_Index) + 1;
end Index;
procedure Set_Index (Target : in out Joystick; Value : Joystick_Index) is
begin
Target.Raw_Index := Enums.Joystick_ID'Val (Value - 1);
end Set_Index;
function Present (Source : Joystick) return Boolean is
begin
return API.Get_Joystick_Param (Source.Raw_Index, Enums.Present) /= 0;
end Present;
function Num_Axis (Source : Joystick) return Natural is
begin
return Natural (API.Get_Joystick_Param (Source.Raw_Index, Enums.Axis));
end Num_Axis;
function Num_Buttons (Source : Joystick) return Natural is
begin
return Natural (API.Get_Joystick_Param (Source.Raw_Index, Enums.Buttons));
end Num_Buttons;
procedure Get_Positions (Source : Joystick; Values : in out Axis_Positions) is
Unused : Interfaces.C.int := API.Get_Joystick_Pos (
Source.Raw_Index, Values,
Interfaces.C.int (Values'Last - Values'First + 1));
begin
null;
end Get_Positions;
procedure Get_Buttons (Source : Joystick; Values : in out Button_States) is
Unused : Interfaces.C.int := API.Get_Joystick_Buttons (
Source.Raw_Index, Values,
Interfaces.C.int (Values'Last - Values'First + 1));
begin
null;
end Get_Buttons;
end Glfw.Events.Joysticks;
|
--- ad-setup.ads.orig 2021-09-04 15:36:33 UTC
+++ ad-setup.ads
@@ -11,6 +11,6 @@ package AD.Setup is
private
GNAT_Name : constant String :=
- "gcc";
+ "ada";
end AD.Setup;
|
with ObjectPack;
use ObjectPack;
package PathPackage is
type Path is interface and Object;
type IntArray is array (Natural range <> ) of Integer;
type IntArrayPtr is access all IntArray;
function add(p1, p2: Path) return Path is abstract;
function sub(p1, p2: Path) return Path is abstract;
function inverse(p:Path) return Path is abstract;
function length(p: Path) return Natural is abstract;
function getHead(p: Path) return Integer is abstract;
function getTail(p: Path) return Path is abstract;
function conc(p: Path; i: Integer) return Path is abstract;
function getCanonicalPath(p: Path) return Path is abstract;
function toIntArray(p: Path) return IntArrayPtr is abstract;
end PathPackage;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of AdaCore nor the names of its contributors may --
-- be used to endorse or promote products derived from this software --
-- without specific prior written permission.
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with System.Machine_Code;
with System.Storage_Elements;
with Ada.Unchecked_Conversion;
with Interfaces; use Interfaces;
with HAL; use HAL;
package body Cortex_M.Cache is
type CCSIDR_Register is record
Line_Size : UInt3;
Associativity : UInt10;
Num_Sets : UInt15;
Write_Allocation : Boolean;
Read_Allocation : Boolean;
Write_Back : Boolean;
Write_Through : Boolean;
end record with Volatile_Full_Access, Size => 32;
for CCSIDR_Register use record
Line_Size at 0 range 0 .. 2;
Associativity at 0 range 3 .. 12;
Num_Sets at 0 range 13 .. 27;
Write_Allocation at 0 range 28 .. 28;
Read_Allocation at 0 range 29 .. 29;
Write_Back at 0 range 30 .. 30;
Write_Through at 0 range 31 .. 31;
end record;
CCSIDR : CCSIDR_Register
with Address => System'To_Address (16#E000ED80#);
DCCSW : Word
with Volatile, Address => System'To_Address (16#E000EF6C#);
function CLZ (Ways : Word) return Word;
pragma Import (Intrinsic, CLZ, "__builtin_clz");
------------------
-- Clean_DCache --
------------------
procedure Clean_DCache (Start, Stop : System.Address)
is
function To_Word is new Ada.Unchecked_Conversion
(System.Address, Word);
use System.Machine_Code;
Start_W : Word;
S_Mask : Word;
S_Shift : Natural;
Ways : Word;
W_Shift : Natural;
S_Size : Word;
Tmp_Ways : Word;
Set : Word;
begin
S_Mask := Word (CCSIDR.Num_Sets);
S_Shift := Natural (CCSIDR.Line_Size) + 4;
Ways := Word (CCSIDR.Associativity);
W_Shift := Natural (CLZ (Ways) and 16#1F#);
S_Size := Shift_Left (1, S_Shift);
Start_W := To_Word (Start) and not (S_Size - 1);
Asm ("dsb", Volatile => True);
while Start_W < To_Word (Stop) loop
Tmp_Ways := Ways;
Set := Shift_Right (Start_W, S_Shift) and S_Mask;
loop
DCCSW :=
Shift_Left (Tmp_Ways, W_Shift) or Shift_Left (Set, S_Shift);
exit when Tmp_Ways = 0;
Tmp_Ways := Tmp_Ways - 1;
end loop;
Start_W := Start_W + S_Size;
end loop;
Asm ("dsb", Volatile => True);
Asm ("isb", Volatile => True);
end Clean_DCache;
------------------
-- Clean_DCache --
------------------
procedure Clean_DCache (Start : System.Address;
Len : Natural)
is
use System.Storage_Elements;
begin
Clean_DCache
(Start,
Start + System.Storage_Elements.Storage_Offset (Len - 1));
end Clean_DCache;
end Cortex_M.Cache;
|
-- GLOBE_3D.Software_Anti_Aliasing provides a software method for
-- smoothing pictures by displaying several times a scene with
-- subpixel translations.
generic
with procedure Display;
package GLOBE_3D.Software_Anti_Aliasing is
-- Returns the number of phases needed for anti - aliasing:
-- 1 for clearing accum buffer + #jitterings + 1 for display
function Anti_Alias_phases return Positive;
-- Display only one layer of anti - aliasing:
procedure Display_with_Anti_Aliasing (phase : Positive);
type Quality is (Q1, Q3, Q4, Q11, Q16, Q29, Q90);
-- Q1 means no aliasing at all
procedure Set_Quality (q : Quality);
end GLOBE_3D.Software_Anti_Aliasing;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Internals.Elements;
with AMF.Internals.Extents;
with AMF.Internals.Helpers;
with AMF.Internals.Links;
with AMF.Internals.Listener_Registry;
with AMF.Internals.Tables.UTP_Constructors;
with AMF.Internals.Tables.Utp_Metamodel;
with AMF.Utp.Holders.Verdicts;
package body AMF.Internals.Factories.Utp_Factories is
None_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("none");
Pass_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("pass");
Inconclusive_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("inconclusive");
Fail_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("fail");
Error_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("error");
function Convert_Duration_To_String
(Value : League.Holders.Holder) return League.Strings.Universal_String
is separate;
function Create_Duration_From_String
(Image : League.Strings.Universal_String) return League.Holders.Holder
is separate;
function Convert_Time_To_String
(Value : League.Holders.Holder) return League.Strings.Universal_String
is separate;
function Create_Time_From_String
(Image : League.Strings.Universal_String) return League.Holders.Holder
is separate;
function Convert_Timezone_To_String
(Value : League.Holders.Holder) return League.Strings.Universal_String
is separate;
function Create_Timezone_From_String
(Image : League.Strings.Universal_String) return League.Holders.Holder
is separate;
-----------------
-- Constructor --
-----------------
function Constructor
(Extent : AMF.Internals.AMF_Extent)
return not null AMF.Factories.Factory_Access is
begin
return new Utp_Factory'(Extent => Extent);
end Constructor;
-----------------------
-- Convert_To_String --
-----------------------
overriding function Convert_To_String
(Self : not null access Utp_Factory;
Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class;
Value : League.Holders.Holder) return League.Strings.Universal_String
is
pragma Unreferenced (Self);
DT : constant AMF.Internals.CMOF_Element
:= AMF.Internals.Elements.Element_Base'Class (Data_Type.all).Element;
begin
if DT = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Duration then
return Convert_Duration_To_String (Value);
elsif DT = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Time then
return Convert_Time_To_String (Value);
elsif DT = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Timezone then
return Convert_Timezone_To_String (Value);
elsif DT = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Verdict then
declare
Item : constant AMF.Utp.Utp_Verdict
:= AMF.Utp.Holders.Verdicts.Element (Value);
begin
case Item is
when AMF.Utp.None =>
return None_Img;
when AMF.Utp.Pass =>
return Pass_Img;
when AMF.Utp.Inconclusive =>
return Inconclusive_Img;
when AMF.Utp.Fail =>
return Fail_Img;
when AMF.Utp.Error =>
return Error_Img;
end case;
end;
else
raise Program_Error;
end if;
end Convert_To_String;
------------
-- Create --
------------
overriding function Create
(Self : not null access Utp_Factory;
Meta_Class : not null access AMF.CMOF.Classes.CMOF_Class'Class)
return not null AMF.Elements.Element_Access
is
MC : constant AMF.Internals.CMOF_Element
:= AMF.Internals.Elements.Element_Base'Class (Meta_Class.all).Element;
Element : AMF.Internals.AMF_Element;
begin
if MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Coding_Rule then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Coding_Rule;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Data_Partition then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Data_Partition;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Data_Pool then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Data_Pool;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Data_Selector then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Data_Selector;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Default then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Default;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Default_Application then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Default_Application;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Determ_Alt then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Determ_Alt;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Finish_Action then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Finish_Action;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Get_Timezone_Action then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Get_Timezone_Action;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Literal_Any then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Literal_Any;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Literal_Any_Or_Null then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Literal_Any_Or_Null;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Log_Action then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Log_Action;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Managed_Element then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Managed_Element;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Read_Timer_Action then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Read_Timer_Action;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_SUT then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_SUT;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Set_Timezone_Action then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Set_Timezone_Action;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Start_Timer_Action then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Start_Timer_Action;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Stop_Timer_Action then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Stop_Timer_Action;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Test_Case then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Test_Case;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Test_Component then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Test_Component;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Test_Context then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Test_Context;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Test_Log then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Test_Log;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Test_Log_Application then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Test_Log_Application;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Test_Objective then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Test_Objective;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Test_Suite then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Test_Suite;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Time_Out then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Time_Out;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Time_Out_Action then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Time_Out_Action;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Time_Out_Message then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Time_Out_Message;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Timer_Running_Action then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Timer_Running_Action;
elsif MC = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Validation_Action then
Element := AMF.Internals.Tables.UTP_Constructors.Create_Utp_Validation_Action;
else
raise Program_Error;
end if;
AMF.Internals.Extents.Internal_Append (Self.Extent, Element);
AMF.Internals.Listener_Registry.Notify_Instance_Create
(AMF.Internals.Helpers.To_Element (Element));
return AMF.Internals.Helpers.To_Element (Element);
end Create;
------------------------
-- Create_From_String --
------------------------
overriding function Create_From_String
(Self : not null access Utp_Factory;
Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class;
Image : League.Strings.Universal_String) return League.Holders.Holder
is
pragma Unreferenced (Self);
use type League.Strings.Universal_String;
DT : constant AMF.Internals.CMOF_Element
:= AMF.Internals.Elements.Element_Base'Class (Data_Type.all).Element;
begin
if DT = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Duration then
return Create_Duration_From_String (Image);
elsif DT = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Time then
return Create_Time_From_String (Image);
elsif DT = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Timezone then
return Create_Timezone_From_String (Image);
elsif DT = AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Verdict then
if Image = None_Img then
return
AMF.Utp.Holders.Verdicts.To_Holder
(AMF.Utp.None);
elsif Image = Pass_Img then
return
AMF.Utp.Holders.Verdicts.To_Holder
(AMF.Utp.Pass);
elsif Image = Inconclusive_Img then
return
AMF.Utp.Holders.Verdicts.To_Holder
(AMF.Utp.Inconclusive);
elsif Image = Fail_Img then
return
AMF.Utp.Holders.Verdicts.To_Holder
(AMF.Utp.Fail);
elsif Image = Error_Img then
return
AMF.Utp.Holders.Verdicts.To_Holder
(AMF.Utp.Error);
else
raise Constraint_Error;
end if;
else
raise Program_Error;
end if;
end Create_From_String;
-----------------
-- Create_Link --
-----------------
overriding function Create_Link
(Self : not null access Utp_Factory;
Association :
not null access AMF.CMOF.Associations.CMOF_Association'Class;
First_Element : not null AMF.Elements.Element_Access;
Second_Element : not null AMF.Elements.Element_Access)
return not null AMF.Links.Link_Access
is
pragma Unreferenced (Self);
begin
return
AMF.Internals.Links.Proxy
(AMF.Internals.Links.Create_Link
(AMF.Internals.Elements.Element_Base'Class
(Association.all).Element,
AMF.Internals.Helpers.To_Element (First_Element),
AMF.Internals.Helpers.To_Element (Second_Element)));
end Create_Link;
-----------------
-- Get_Package --
-----------------
overriding function Get_Package
(Self : not null access constant Utp_Factory)
return AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package
is
pragma Unreferenced (Self);
begin
return Result : AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package do
Result.Add (Get_Package);
end return;
end Get_Package;
-----------------
-- Get_Package --
-----------------
function Get_Package return not null AMF.CMOF.Packages.CMOF_Package_Access is
begin
return
AMF.CMOF.Packages.CMOF_Package_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MM_Utp_Utp));
end Get_Package;
------------------------
-- Create_Coding_Rule --
------------------------
overriding function Create_Coding_Rule
(Self : not null access Utp_Factory)
return AMF.Utp.Coding_Rules.Utp_Coding_Rule_Access is
begin
return
AMF.Utp.Coding_Rules.Utp_Coding_Rule_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Coding_Rule))));
end Create_Coding_Rule;
---------------------------
-- Create_Data_Partition --
---------------------------
overriding function Create_Data_Partition
(Self : not null access Utp_Factory)
return AMF.Utp.Data_Partitions.Utp_Data_Partition_Access is
begin
return
AMF.Utp.Data_Partitions.Utp_Data_Partition_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Data_Partition))));
end Create_Data_Partition;
----------------------
-- Create_Data_Pool --
----------------------
overriding function Create_Data_Pool
(Self : not null access Utp_Factory)
return AMF.Utp.Data_Pools.Utp_Data_Pool_Access is
begin
return
AMF.Utp.Data_Pools.Utp_Data_Pool_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Data_Pool))));
end Create_Data_Pool;
--------------------------
-- Create_Data_Selector --
--------------------------
overriding function Create_Data_Selector
(Self : not null access Utp_Factory)
return AMF.Utp.Data_Selectors.Utp_Data_Selector_Access is
begin
return
AMF.Utp.Data_Selectors.Utp_Data_Selector_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Data_Selector))));
end Create_Data_Selector;
--------------------
-- Create_Default --
--------------------
overriding function Create_Default
(Self : not null access Utp_Factory)
return AMF.Utp.Defaults.Utp_Default_Access is
begin
return
AMF.Utp.Defaults.Utp_Default_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Default))));
end Create_Default;
--------------------------------
-- Create_Default_Application --
--------------------------------
overriding function Create_Default_Application
(Self : not null access Utp_Factory)
return AMF.Utp.Default_Applications.Utp_Default_Application_Access is
begin
return
AMF.Utp.Default_Applications.Utp_Default_Application_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Default_Application))));
end Create_Default_Application;
-----------------------
-- Create_Determ_Alt --
-----------------------
overriding function Create_Determ_Alt
(Self : not null access Utp_Factory)
return AMF.Utp.Determ_Alts.Utp_Determ_Alt_Access is
begin
return
AMF.Utp.Determ_Alts.Utp_Determ_Alt_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Determ_Alt))));
end Create_Determ_Alt;
--------------------------
-- Create_Finish_Action --
--------------------------
overriding function Create_Finish_Action
(Self : not null access Utp_Factory)
return AMF.Utp.Finish_Actions.Utp_Finish_Action_Access is
begin
return
AMF.Utp.Finish_Actions.Utp_Finish_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Finish_Action))));
end Create_Finish_Action;
--------------------------------
-- Create_Get_Timezone_Action --
--------------------------------
overriding function Create_Get_Timezone_Action
(Self : not null access Utp_Factory)
return AMF.Utp.Get_Timezone_Actions.Utp_Get_Timezone_Action_Access is
begin
return
AMF.Utp.Get_Timezone_Actions.Utp_Get_Timezone_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Get_Timezone_Action))));
end Create_Get_Timezone_Action;
------------------------
-- Create_Literal_Any --
------------------------
overriding function Create_Literal_Any
(Self : not null access Utp_Factory)
return AMF.Utp.Literal_Anies.Utp_Literal_Any_Access is
begin
return
AMF.Utp.Literal_Anies.Utp_Literal_Any_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Literal_Any))));
end Create_Literal_Any;
--------------------------------
-- Create_Literal_Any_Or_Null --
--------------------------------
overriding function Create_Literal_Any_Or_Null
(Self : not null access Utp_Factory)
return AMF.Utp.Literal_Any_Or_Nulls.Utp_Literal_Any_Or_Null_Access is
begin
return
AMF.Utp.Literal_Any_Or_Nulls.Utp_Literal_Any_Or_Null_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Literal_Any_Or_Null))));
end Create_Literal_Any_Or_Null;
-----------------------
-- Create_Log_Action --
-----------------------
overriding function Create_Log_Action
(Self : not null access Utp_Factory)
return AMF.Utp.Log_Actions.Utp_Log_Action_Access is
begin
return
AMF.Utp.Log_Actions.Utp_Log_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Log_Action))));
end Create_Log_Action;
----------------------------
-- Create_Managed_Element --
----------------------------
overriding function Create_Managed_Element
(Self : not null access Utp_Factory)
return AMF.Utp.Managed_Elements.Utp_Managed_Element_Access is
begin
return
AMF.Utp.Managed_Elements.Utp_Managed_Element_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Managed_Element))));
end Create_Managed_Element;
------------------------------
-- Create_Read_Timer_Action --
------------------------------
overriding function Create_Read_Timer_Action
(Self : not null access Utp_Factory)
return AMF.Utp.Read_Timer_Actions.Utp_Read_Timer_Action_Access is
begin
return
AMF.Utp.Read_Timer_Actions.Utp_Read_Timer_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Read_Timer_Action))));
end Create_Read_Timer_Action;
----------------
-- Create_SUT --
----------------
overriding function Create_SUT
(Self : not null access Utp_Factory)
return AMF.Utp.SUTs.Utp_SUT_Access is
begin
return
AMF.Utp.SUTs.Utp_SUT_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_SUT))));
end Create_SUT;
--------------------------------
-- Create_Set_Timezone_Action --
--------------------------------
overriding function Create_Set_Timezone_Action
(Self : not null access Utp_Factory)
return AMF.Utp.Set_Timezone_Actions.Utp_Set_Timezone_Action_Access is
begin
return
AMF.Utp.Set_Timezone_Actions.Utp_Set_Timezone_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Set_Timezone_Action))));
end Create_Set_Timezone_Action;
-------------------------------
-- Create_Start_Timer_Action --
-------------------------------
overriding function Create_Start_Timer_Action
(Self : not null access Utp_Factory)
return AMF.Utp.Start_Timer_Actions.Utp_Start_Timer_Action_Access is
begin
return
AMF.Utp.Start_Timer_Actions.Utp_Start_Timer_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Start_Timer_Action))));
end Create_Start_Timer_Action;
------------------------------
-- Create_Stop_Timer_Action --
------------------------------
overriding function Create_Stop_Timer_Action
(Self : not null access Utp_Factory)
return AMF.Utp.Stop_Timer_Actions.Utp_Stop_Timer_Action_Access is
begin
return
AMF.Utp.Stop_Timer_Actions.Utp_Stop_Timer_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Stop_Timer_Action))));
end Create_Stop_Timer_Action;
----------------------
-- Create_Test_Case --
----------------------
overriding function Create_Test_Case
(Self : not null access Utp_Factory)
return AMF.Utp.Test_Cases.Utp_Test_Case_Access is
begin
return
AMF.Utp.Test_Cases.Utp_Test_Case_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Test_Case))));
end Create_Test_Case;
---------------------------
-- Create_Test_Component --
---------------------------
overriding function Create_Test_Component
(Self : not null access Utp_Factory)
return AMF.Utp.Test_Components.Utp_Test_Component_Access is
begin
return
AMF.Utp.Test_Components.Utp_Test_Component_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Test_Component))));
end Create_Test_Component;
-------------------------
-- Create_Test_Context --
-------------------------
overriding function Create_Test_Context
(Self : not null access Utp_Factory)
return AMF.Utp.Test_Contexts.Utp_Test_Context_Access is
begin
return
AMF.Utp.Test_Contexts.Utp_Test_Context_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Test_Context))));
end Create_Test_Context;
---------------------
-- Create_Test_Log --
---------------------
overriding function Create_Test_Log
(Self : not null access Utp_Factory)
return AMF.Utp.Test_Logs.Utp_Test_Log_Access is
begin
return
AMF.Utp.Test_Logs.Utp_Test_Log_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Test_Log))));
end Create_Test_Log;
---------------------------------
-- Create_Test_Log_Application --
---------------------------------
overriding function Create_Test_Log_Application
(Self : not null access Utp_Factory)
return AMF.Utp.Test_Log_Applications.Utp_Test_Log_Application_Access is
begin
return
AMF.Utp.Test_Log_Applications.Utp_Test_Log_Application_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Test_Log_Application))));
end Create_Test_Log_Application;
---------------------------
-- Create_Test_Objective --
---------------------------
overriding function Create_Test_Objective
(Self : not null access Utp_Factory)
return AMF.Utp.Test_Objectives.Utp_Test_Objective_Access is
begin
return
AMF.Utp.Test_Objectives.Utp_Test_Objective_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Test_Objective))));
end Create_Test_Objective;
-----------------------
-- Create_Test_Suite --
-----------------------
overriding function Create_Test_Suite
(Self : not null access Utp_Factory)
return AMF.Utp.Test_Suites.Utp_Test_Suite_Access is
begin
return
AMF.Utp.Test_Suites.Utp_Test_Suite_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Test_Suite))));
end Create_Test_Suite;
---------------------
-- Create_Time_Out --
---------------------
overriding function Create_Time_Out
(Self : not null access Utp_Factory)
return AMF.Utp.Time_Outs.Utp_Time_Out_Access is
begin
return
AMF.Utp.Time_Outs.Utp_Time_Out_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Time_Out))));
end Create_Time_Out;
----------------------------
-- Create_Time_Out_Action --
----------------------------
overriding function Create_Time_Out_Action
(Self : not null access Utp_Factory)
return AMF.Utp.Time_Out_Actions.Utp_Time_Out_Action_Access is
begin
return
AMF.Utp.Time_Out_Actions.Utp_Time_Out_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Time_Out_Action))));
end Create_Time_Out_Action;
-----------------------------
-- Create_Time_Out_Message --
-----------------------------
overriding function Create_Time_Out_Message
(Self : not null access Utp_Factory)
return AMF.Utp.Time_Out_Messages.Utp_Time_Out_Message_Access is
begin
return
AMF.Utp.Time_Out_Messages.Utp_Time_Out_Message_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Time_Out_Message))));
end Create_Time_Out_Message;
---------------------------------
-- Create_Timer_Running_Action --
---------------------------------
overriding function Create_Timer_Running_Action
(Self : not null access Utp_Factory)
return AMF.Utp.Timer_Running_Actions.Utp_Timer_Running_Action_Access is
begin
return
AMF.Utp.Timer_Running_Actions.Utp_Timer_Running_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Timer_Running_Action))));
end Create_Timer_Running_Action;
------------------------------
-- Create_Validation_Action --
------------------------------
overriding function Create_Validation_Action
(Self : not null access Utp_Factory)
return AMF.Utp.Validation_Actions.Utp_Validation_Action_Access is
begin
return
AMF.Utp.Validation_Actions.Utp_Validation_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Utp_Metamodel.MC_Utp_Validation_Action))));
end Create_Validation_Action;
end AMF.Internals.Factories.Utp_Factories;
|
-----------------------------------------------------------------------
-- core-factory -- Factory for Core UI Components
-- Copyright (C) 2009, 2010, 2011, 2012, 2013, 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 Ada.Calendar;
with Ada.Strings.Maps;
with ASF.Views.Nodes;
with ASF.Components.Utils.Files;
with ASF.Components.Utils.Flush;
with ASF.Components.Utils.Scripts;
with ASF.Components.Utils.Escapes;
with ASF.Components.Utils.Beans;
with ASF.Components.Html.Messages;
with Util.Dates.ISO8601;
with Util.Beans.Objects.Time;
with Util.Strings.Transforms; use Util.Strings;
package body ASF.Components.Utils.Factory is
use ASF.Components.Base;
function Create_File return UIComponent_Access;
function Create_Flush return UIComponent_Access;
function Create_Script return UIComponent_Access;
function Create_Escape return UIComponent_Access;
function Create_Set return UIComponent_Access;
-- -------------------------
-- ------------------------------
-- Create a UIFile component
-- ------------------------------
function Create_File return UIComponent_Access is
begin
return new ASF.Components.Utils.Files.UIFile;
end Create_File;
-- ------------------------------
-- Create a UIFlush component
-- ------------------------------
function Create_Flush return UIComponent_Access is
begin
return new ASF.Components.Utils.Flush.UIFlush;
end Create_Flush;
-- ------------------------------
-- Create a UIScript component
-- ------------------------------
function Create_Script return UIComponent_Access is
begin
return new ASF.Components.Utils.Scripts.UIScript;
end Create_Script;
-- ------------------------------
-- Create a UIEscape component
-- ------------------------------
function Create_Escape return UIComponent_Access is
begin
return new ASF.Components.Utils.Escapes.UIEscape;
end Create_Escape;
-- ------------------------------
-- Create a UISetBean component
-- ------------------------------
function Create_Set return UIComponent_Access is
begin
return new ASF.Components.Utils.Beans.UISetBean;
end Create_Set;
use ASF.Views.Nodes;
URI : aliased constant String := "http://code.google.com/p/ada-asf/util";
ESCAPE_TAG : aliased constant String := "escape";
FILE_TAG : aliased constant String := "file";
FLUSH_TAG : aliased constant String := "flush";
SCRIPT_TAG : aliased constant String := "script";
SET_TAG : aliased constant String := "set";
Core_Bindings : aliased constant ASF.Factory.Binding_Array
:= (1 => (Name => ESCAPE_TAG'Access,
Component => Create_Escape'Access,
Tag => Create_Component_Node'Access),
2 => (Name => FILE_TAG'Access,
Component => Create_File'Access,
Tag => Create_Component_Node'Access),
3 => (Name => FLUSH_TAG'Access,
Component => Create_Flush'Access,
Tag => Create_Component_Node'Access),
4 => (Name => SCRIPT_TAG'Access,
Component => Create_Script'Access,
Tag => Create_Component_Node'Access),
5 => (Name => SET_TAG'Access,
Component => Create_Set'Access,
Tag => Create_Component_Node'Access)
);
Core_Factory : aliased constant ASF.Factory.Factory_Bindings
:= (URI => URI'Access, Bindings => Core_Bindings'Access);
-- ------------------------------
-- Get the HTML component factory.
-- ------------------------------
function Definition return ASF.Factory.Factory_Bindings_Access is
begin
return Core_Factory'Access;
end Definition;
-- Truncate the string representation represented by <b>Value</b> to
-- the length specified by <b>Size</b>.
function Escape_Javascript (Value : EL.Objects.Object) return EL.Objects.Object;
-- Escape the string using XML escape rules.
function Escape_Xml (Value : EL.Objects.Object) return EL.Objects.Object;
-- Translate the value into an ISO8606 date.
function To_ISO8601 (Value : in EL.Objects.Object) return EL.Objects.Object;
-- Encode the string for URL.
function Url_Encode (Value : in EL.Objects.Object) return EL.Objects.Object;
procedure Set_Functions (Mapper : in out EL.Functions.Function_Mapper'Class) is
begin
Mapper.Set_Function (Name => "escapeJavaScript",
Namespace => URI,
Func => Escape_Javascript'Access);
Mapper.Set_Function (Name => "escapeXml",
Namespace => URI,
Func => Escape_Xml'Access);
Mapper.Set_Function (Name => "iso8601",
Namespace => URI,
Func => To_ISO8601'Access);
Mapper.Set_Function (Name => "hasMessage",
Namespace => URI,
Func => ASF.Components.Html.Messages.Has_Message'Access,
Optimize => False);
Mapper.Set_Function (Name => "urlEncode",
Namespace => URI,
Func => Url_Encode'Access);
end Set_Functions;
function Escape_Javascript (Value : EL.Objects.Object) return EL.Objects.Object is
Result : Ada.Strings.Unbounded.Unbounded_String;
Content : constant String := EL.Objects.To_String (Value);
begin
Transforms.Escape_Javascript (Content => Content,
Into => Result);
return EL.Objects.To_Object (Result);
end Escape_Javascript;
function Escape_Xml (Value : EL.Objects.Object) return EL.Objects.Object is
Result : Ada.Strings.Unbounded.Unbounded_String;
Content : constant String := EL.Objects.To_String (Value);
begin
Transforms.Escape_Xml (Content => Content,
Into => Result);
return EL.Objects.To_Object (Result);
end Escape_Xml;
-- ------------------------------
-- Translate the value into an ISO8606 date.
-- ------------------------------
function To_ISO8601 (Value : in EL.Objects.Object) return EL.Objects.Object is
D : constant Ada.Calendar.Time := Util.Beans.Objects.Time.To_Time (Value);
S : constant String := Util.Dates.ISO8601.Image (D);
begin
return Util.Beans.Objects.To_Object (S);
end To_ISO8601;
use Ada.Strings.Maps;
Conversion : constant String (1 .. 16) := "0123456789ABCDEF";
Url_Encode_Set : constant Ada.Strings.Maps.Character_Set
:= Ada.Strings.Maps.To_Set (Span => (Low => Character'Val (0),
High => ' '))
or
Ada.Strings.Maps.To_Set (Span => (Low => Character'Val (128),
High => Character'Val (255)))
or
Ada.Strings.Maps.To_Set (":/?#[]@!$&'""()*+,;=");
-- ------------------------------
-- Encode the string for URL.
-- ------------------------------
function Url_Encode (Value : in EL.Objects.Object) return EL.Objects.Object is
S : constant String := Util.Beans.Objects.To_String (Value);
T : String (1 .. S'Length * 3);
Pos : Positive := 1;
C : Character;
begin
for I in S'Range loop
C := S (I);
if Ada.Strings.Maps.Is_In (C, Url_Encode_Set) then
T (Pos) := '%';
T (Pos + 1) := Conversion (1 + Character'Pos (C) / 16);
T (Pos + 2) := Conversion (1 + Character'Pos (C) mod 16);
Pos := Pos + 3;
else
T (Pos) := C;
Pos := Pos + 1;
end if;
end loop;
return Util.Beans.Objects.To_Object (T (1 .. Pos - 1));
end Url_Encode;
end ASF.Components.Utils.Factory;
|
pragma Style_Checks (Off);
-- This spec has been automatically generated from STM32H743x.svd
pragma Restrictions (No_Elaboration_Code);
with HAL;
with System;
package STM32_SVD.SPDIFRX is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CR_SPDIFRXEN_Field is HAL.UInt2;
subtype CR_DRFMT_Field is HAL.UInt2;
subtype CR_NBTR_Field is HAL.UInt2;
subtype CR_INSEL_Field is HAL.UInt3;
-- Control register
type CR_Register is record
-- Peripheral Block Enable
SPDIFRXEN : CR_SPDIFRXEN_Field := 16#0#;
-- Receiver DMA ENable for data flow
RXDMAEN : Boolean := False;
-- STerEO Mode
RXSTEO : Boolean := False;
-- RX Data format
DRFMT : CR_DRFMT_Field := 16#0#;
-- Mask Parity error bit
PMSK : Boolean := False;
-- Mask of Validity bit
VMSK : Boolean := False;
-- Mask of channel status and user bits
CUMSK : Boolean := False;
-- Mask of Preamble Type bits
PTMSK : Boolean := False;
-- Control Buffer DMA ENable for control flow
CBDMAEN : Boolean := False;
-- Channel Selection
CHSEL : Boolean := False;
-- Maximum allowed re-tries during synchronization phase
NBTR : CR_NBTR_Field := 16#0#;
-- Wait For Activity
WFA : Boolean := False;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#0#;
-- input selection
INSEL : CR_INSEL_Field := 16#0#;
-- unspecified
Reserved_19_19 : HAL.Bit := 16#0#;
-- Symbol Clock Enable
CKSEN : Boolean := False;
-- Backup Symbol Clock Enable
CKSBKPEN : Boolean := False;
-- unspecified
Reserved_22_31 : HAL.UInt10 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
SPDIFRXEN at 0 range 0 .. 1;
RXDMAEN at 0 range 2 .. 2;
RXSTEO at 0 range 3 .. 3;
DRFMT at 0 range 4 .. 5;
PMSK at 0 range 6 .. 6;
VMSK at 0 range 7 .. 7;
CUMSK at 0 range 8 .. 8;
PTMSK at 0 range 9 .. 9;
CBDMAEN at 0 range 10 .. 10;
CHSEL at 0 range 11 .. 11;
NBTR at 0 range 12 .. 13;
WFA at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
INSEL at 0 range 16 .. 18;
Reserved_19_19 at 0 range 19 .. 19;
CKSEN at 0 range 20 .. 20;
CKSBKPEN at 0 range 21 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
-- Interrupt mask register
type IMR_Register is record
-- RXNE interrupt enable
RXNEIE : Boolean := False;
-- Control Buffer Ready Interrupt Enable
CSRNEIE : Boolean := False;
-- Parity error interrupt enable
PERRIE : Boolean := False;
-- Overrun error Interrupt Enable
OVRIE : Boolean := False;
-- Synchronization Block Detected Interrupt Enable
SBLKIE : Boolean := False;
-- Synchronization Done
SYNCDIE : Boolean := False;
-- Serial Interface Error Interrupt Enable
IFEIE : Boolean := False;
-- unspecified
Reserved_7_31 : HAL.UInt25 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for IMR_Register use record
RXNEIE at 0 range 0 .. 0;
CSRNEIE at 0 range 1 .. 1;
PERRIE at 0 range 2 .. 2;
OVRIE at 0 range 3 .. 3;
SBLKIE at 0 range 4 .. 4;
SYNCDIE at 0 range 5 .. 5;
IFEIE at 0 range 6 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
subtype SR_WIDTH5_Field is HAL.UInt15;
-- Status register
type SR_Register is record
-- Read-only. Read data register not empty
RXNE : Boolean;
-- Read-only. Control Buffer register is not empty
CSRNE : Boolean;
-- Read-only. Parity error
PERR : Boolean;
-- Read-only. Overrun error
OVR : Boolean;
-- Read-only. Synchronization Block Detected
SBD : Boolean;
-- Read-only. Synchronization Done
SYNCD : Boolean;
-- Read-only. Framing error
FERR : Boolean;
-- Read-only. Synchronization error
SERR : Boolean;
-- Read-only. Time-out error
TERR : Boolean;
-- unspecified
Reserved_9_15 : HAL.UInt7;
-- Read-only. Duration of 5 symbols counted with SPDIF_CLK
WIDTH5 : SR_WIDTH5_Field;
-- unspecified
Reserved_31_31 : HAL.Bit;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register use record
RXNE at 0 range 0 .. 0;
CSRNE at 0 range 1 .. 1;
PERR at 0 range 2 .. 2;
OVR at 0 range 3 .. 3;
SBD at 0 range 4 .. 4;
SYNCD at 0 range 5 .. 5;
FERR at 0 range 6 .. 6;
SERR at 0 range 7 .. 7;
TERR at 0 range 8 .. 8;
Reserved_9_15 at 0 range 9 .. 15;
WIDTH5 at 0 range 16 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
-- Interrupt Flag Clear register
type IFCR_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- Write-only. Clears the Parity error flag
PERRCF : Boolean := False;
-- Write-only. Clears the Overrun error flag
OVRCF : Boolean := False;
-- Write-only. Clears the Synchronization Block Detected flag
SBDCF : Boolean := False;
-- Write-only. Clears the Synchronization Done flag
SYNCDCF : Boolean := False;
-- unspecified
Reserved_6_31 : HAL.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for IFCR_Register use record
Reserved_0_1 at 0 range 0 .. 1;
PERRCF at 0 range 2 .. 2;
OVRCF at 0 range 3 .. 3;
SBDCF at 0 range 4 .. 4;
SYNCDCF at 0 range 5 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
subtype DR_00_DR_Field is HAL.UInt24;
subtype DR_00_PT_Field is HAL.UInt2;
-- Data input register
type DR_00_Register is record
-- Read-only. Parity Error bit
DR : DR_00_DR_Field;
-- Read-only. Parity Error bit
PE : Boolean;
-- Read-only. Validity bit
V : Boolean;
-- Read-only. User bit
U : Boolean;
-- Read-only. Channel Status bit
C : Boolean;
-- Read-only. Preamble Type
PT : DR_00_PT_Field;
-- unspecified
Reserved_30_31 : HAL.UInt2;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DR_00_Register use record
DR at 0 range 0 .. 23;
PE at 0 range 24 .. 24;
V at 0 range 25 .. 25;
U at 0 range 26 .. 26;
C at 0 range 27 .. 27;
PT at 0 range 28 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
subtype DR_01_PT_Field is HAL.UInt2;
subtype DR_01_DR_Field is HAL.UInt24;
-- Data input register
type DR_01_Register is record
-- Read-only. Parity Error bit
PE : Boolean;
-- Read-only. Validity bit
V : Boolean;
-- Read-only. User bit
U : Boolean;
-- Read-only. Channel Status bit
C : Boolean;
-- Read-only. Preamble Type
PT : DR_01_PT_Field;
-- unspecified
Reserved_6_7 : HAL.UInt2;
-- Read-only. Data value
DR : DR_01_DR_Field;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DR_01_Register use record
PE at 0 range 0 .. 0;
V at 0 range 1 .. 1;
U at 0 range 2 .. 2;
C at 0 range 3 .. 3;
PT at 0 range 4 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
DR at 0 range 8 .. 31;
end record;
-- DR_10_DRNL array element
subtype DR_10_DRNL_Element is HAL.UInt16;
-- DR_10_DRNL array
type DR_10_DRNL_Field_Array is array (1 .. 2) of DR_10_DRNL_Element
with Component_Size => 16, Size => 32;
-- Data input register
type DR_10_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- DRNL as a value
Val : HAL.UInt32;
when True =>
-- DRNL as an array
Arr : DR_10_DRNL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DR_10_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
subtype CSR_USR_Field is HAL.UInt16;
subtype CSR_CS_Field is HAL.UInt8;
-- Channel Status register
type CSR_Register is record
-- Read-only. User data information
USR : CSR_USR_Field;
-- Read-only. Channel A status information
CS : CSR_CS_Field;
-- Read-only. Start Of Block
SOB : Boolean;
-- unspecified
Reserved_25_31 : HAL.UInt7;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CSR_Register use record
USR at 0 range 0 .. 15;
CS at 0 range 16 .. 23;
SOB at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
subtype DIR_THI_Field is HAL.UInt13;
subtype DIR_TLO_Field is HAL.UInt13;
-- Debug Information register
type DIR_Register is record
-- Read-only. Threshold HIGH
THI : DIR_THI_Field;
-- unspecified
Reserved_13_15 : HAL.UInt3;
-- Read-only. Threshold LOW
TLO : DIR_TLO_Field;
-- unspecified
Reserved_29_31 : HAL.UInt3;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DIR_Register use record
THI at 0 range 0 .. 12;
Reserved_13_15 at 0 range 13 .. 15;
TLO at 0 range 16 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
subtype VERR_MINREV_Field is HAL.UInt4;
subtype VERR_MAJREV_Field is HAL.UInt4;
-- SPDIFRX version register
type VERR_Register is record
-- Read-only. Minor revision
MINREV : VERR_MINREV_Field;
-- Read-only. Major revision
MAJREV : VERR_MAJREV_Field;
-- unspecified
Reserved_8_31 : HAL.UInt24;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for VERR_Register use record
MINREV at 0 range 0 .. 3;
MAJREV at 0 range 4 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
type SPDIFRX_Disc is
(Val_00,
Val_01,
Val_10);
-- Receiver Interface
type SPDIFRX_Peripheral
(Discriminent : SPDIFRX_Disc := Val_00)
is record
-- Control register
CR : aliased CR_Register;
-- Interrupt mask register
IMR : aliased IMR_Register;
-- Status register
SR : aliased SR_Register;
-- Interrupt Flag Clear register
IFCR : aliased IFCR_Register;
-- Channel Status register
CSR : aliased CSR_Register;
-- Debug Information register
DIR : aliased DIR_Register;
-- SPDIFRX version register
VERR : aliased VERR_Register;
-- SPDIFRX identification register
IDR : aliased HAL.UInt32;
-- SPDIFRX size identification register
SIDR : aliased HAL.UInt32;
case Discriminent is
when Val_00 =>
-- Data input register
DR_00 : aliased DR_00_Register;
when Val_01 =>
-- Data input register
DR_01 : aliased DR_01_Register;
when Val_10 =>
-- Data input register
DR_10 : aliased DR_10_Register;
end case;
end record
with Unchecked_Union, Volatile;
for SPDIFRX_Peripheral use record
CR at 16#0# range 0 .. 31;
IMR at 16#4# range 0 .. 31;
SR at 16#8# range 0 .. 31;
IFCR at 16#C# range 0 .. 31;
CSR at 16#14# range 0 .. 31;
DIR at 16#18# range 0 .. 31;
VERR at 16#3F4# range 0 .. 31;
IDR at 16#3F8# range 0 .. 31;
SIDR at 16#3FC# range 0 .. 31;
DR_00 at 16#10# range 0 .. 31;
DR_01 at 16#10# range 0 .. 31;
DR_10 at 16#10# range 0 .. 31;
end record;
-- Receiver Interface
SPDIFRX_Periph : aliased SPDIFRX_Peripheral
with Import, Address => SPDIFRX_Base;
end STM32_SVD.SPDIFRX;
|
with AdaBase;
with Connect;
with CommonText;
with Ada.Text_IO;
with AdaBase.Results.Sets;
with Spatial_Data;
procedure Spatial3 is
package CON renames Connect;
package TIO renames Ada.Text_IO;
package ARS renames AdaBase.Results.Sets;
package CT renames CommonText;
package SD renames Spatial_Data;
procedure print_wkt (GM : SD.Geometry; cn, wkt : String);
procedure print_point (point : SD.Geometric_Point; label : String);
procedure print_wkt (GM : SD.Geometry; cn, wkt : String) is
begin
TIO.Put_Line ("");
TIO.Put_Line ("Column Name : " & cn);
TIO.Put_Line ("Geo subtype : " & SD.type_of_collection (GM)'Img);
TIO.Put_Line ("WKT value : " & wkt);
end print_wkt;
procedure print_point (point : SD.Geometric_Point; label : String) is
begin
TIO.Put_Line ("X=" & point.X'Img & " (" & label & ")");
TIO.Put_Line ("Y=" & point.Y'Img);
end print_point;
begin
CON.connect_database;
declare
sql : constant String := "SELECT * FROM spatial_plus";
stmt : CON.Stmt_Type := CON.DR.query (sql);
row : ARS.Datarow := stmt.fetch_next;
PT : constant String := "sp_point";
LN : constant String := "sp_linestring";
PG : constant String := "sp_polygon";
MP : constant String := "sp_multi_point";
ML : constant String := "sp_multi_line_string";
MPG : constant String := "sp_multi_polygon";
GC : constant String := "sp_geo_collection";
begin
TIO.Put_Line ("Demonstrate direct geometry retrieval and manipulation");
-- Point
print_wkt (row.column (PT).as_geometry, PT, row.column (PT).as_string);
print_point (SD.retrieve_point (row.column (PT).as_geometry), PT);
-- Line
print_wkt (row.column (LN).as_geometry, LN, row.column (LN).as_string);
declare
LNS : SD.Geometric_Line_String :=
SD.retrieve_line (row.column (LN).as_geometry);
begin
for component in LNS'Range loop
print_point (LNS (component), LN & component'Img);
end loop;
end;
-- Polygon
print_wkt (row.column (PG).as_geometry, PG, row.column (PG).as_string);
declare
PG1 : SD.Geometric_Polygon :=
SD.retrieve_polygon (row.column (PG).as_geometry);
ring_count : Natural := SD.number_of_rings (PG1);
begin
for Ring_ID in 1 .. ring_count loop
declare
RG : SD.Geometric_Ring := SD.retrieve_ring (PG1, Ring_ID);
SZ : Natural := RG'Length;
begin
TIO.Put_Line ("Ring#" & Ring_ID'Img);
for component in 1 .. SZ loop
print_point (RG (component), "point" & component'Img);
end loop;
end;
end loop;
end;
-- Multi-Point
declare
GM : SD.Geometry := row.column (MP).as_geometry;
SZ : Natural := SD.size_of_collection (GM);
begin
print_wkt (GM, MP, row.column (MP).as_string);
for component in 1 .. SZ loop
print_point (SD.retrieve_point (GM, component),
"Multipoint#" & component'Img);
end loop;
end;
-- Multi-Line
declare
GM : SD.Geometry := row.column (ML).as_geometry;
SZ : Natural := SD.size_of_collection (GM);
begin
print_wkt (GM, ML, row.column (ML).as_string);
for component in 1 .. SZ loop
declare
-- extract line string type
SLS : SD.Geometric_Line_String :=
SD.retrieve_line (GM, component);
-- convert to a simple geometry type
NGM : SD.Geometry := SD.initialize_as_line (SLS);
begin
TIO.Put_Line ("line#" & component'Img & ": " &
SD.Well_Known_Text (NGM));
end;
end loop;
end;
-- Multi-Polygon
declare
GM : SD.Geometry := row.column (MPG).as_geometry;
SZ : Natural := SD.size_of_collection (GM);
begin
print_wkt (GM, MPG, row.column (MPG).as_string);
for component in 1 .. SZ loop
declare
-- extract single polygon
SPG : SD.Geometric_Polygon :=
SD.retrieve_polygon (GM, component);
-- convert to a simple geometry type
NGM : SD.Geometry := SD.initialize_as_polygon (SPG);
num_rings : Natural := SD.number_of_rings (SPG);
begin
TIO.Put_Line ("polygon#" & component'Img & ": " &
SD.Well_Known_Text (NGM));
for ring in 2 .. num_rings loop
declare
IR : SD.Geometric_Ring := SD.retrieve_ring (SPG, ring);
newpoly : SD.Geometric_Polygon := SD.start_polygon (IR);
begin
TIO.Put_Line ("Inner ring" & Integer (ring - 1)'Img &
" of polygon" & component'Img & " : " &
SD.Well_Known_Text
(SD.initialize_as_polygon (newpoly)));
end;
end loop;
end;
end loop;
end;
-- Geometry Collection
declare
GM : SD.Geometry := row.column (GC).as_geometry;
SZ : Natural := SD.size_of_collection (GM);
begin
TIO.Put_Line ("");
TIO.Put_Line ("Column Name : " & GC);
TIO.Put_Line ("Geo subtype : " & SD.type_of_collection (GM)'Img);
TIO.Put_Line ("Number of elements in collection :" & SZ'Img);
for component in 1 .. SZ loop
declare
NGM : SD.Geometry := SD.retrieve_subcollection (GM, component);
SZC : Natural := SD.size_of_collection (NGM);
begin
TIO.Put_Line ("");
TIO.Put_Line ("Element" & component'Img & " type : " &
SD.collection_item_type (GM, component)'Img);
TIO.Put_Line ("Element" & component'Img & " size : " &
CT.int2str (SZC));
TIO.Put_Line ("Element" & component'Img & " wkt : " &
SD.Well_Known_Text (NGM));
end;
end loop;
end;
end;
CON.DR.disconnect;
end Spatial3;
|
-- ___ _ ___ _ _ --
-- / __| |/ (_) | | Common SKilL implementation --
-- \__ \ ' <| | | |__ type handling in skill --
-- |___/_|\_\_|_|____| by: Timm Felden --
-- --
pragma Ada_2012;
with Ada.Containers.Vectors;
with Skill.Field_Restrictions;
with Skill.Field_Types;
limited with Skill.Field_Types.Builtin;
limited with Skill.Field_Types.Builtin.String_Type_P;
with Skill.Field_Declarations;
with Skill.Internal.Parts;
limited with Skill.Files;
with Skill.Containers.Vectors;
with Skill.Internal;
with Skill.Types.Iterators;
with Ada.Containers.Hashed_Maps;
with Ada.Strings;
with Ada.Strings.Hash;
with Ada.Unchecked_Conversion;
-- in contrast to a solution in c++ or java, we will represent data and most of
-- the internal implementation in a type erasure version of the java
-- implementation. The Facade will use the generic type system to create methods
-- of the right types without producing significant excess code
package Skill.Types.Pools is
-- pragma Preelaborate;
-- = abstract storage pool
type Pool_T is abstract new Field_Types.Field_Type_Base with private;
type Pool is access Pool_T;
type Pool_Dyn is access Pool_T'Class;
type Sub_Pool_T is abstract new Pool_T with private;
type Sub_Pool is access Sub_Pool_T;
type Base_Pool_T is abstract new Pool_T with private;
type Base_Pool is access Base_Pool_T;
-- clone some general purpose code to make ada compile it...dafuq
function Hash
(Element : Skill.Types.String_Access) return Ada.Containers.Hash_Type is
(Ada.Strings.Hash (Element.all));
function Equals
(A, B : Skill.Types.String_Access) return Boolean is
(A = B or else ((null /= A and null /= B) and then A.all = B.all));
-- data structures using pools
package P_Type_Vector is new Skill.Containers.Vectors
(Natural,
Skill.Types.Pools.Pool);
subtype Type_Vector is P_Type_Vector.Vector;
package Sub_Pool_Vector_P is new Containers.Vectors (Natural, Sub_Pool);
subtype Sub_Pool_Vector is Sub_Pool_Vector_P.Vector;
package P_Type_Map is new Ada.Containers.Hashed_Maps
(Key_Type => Skill.Types.String_Access,
Element_Type => Skill.Types.Pools.Pool,
Hash => Hash,
Equivalent_Keys => Equals);
subtype Type_Map is P_Type_Map.Map;
-- pointer conversions
function Dynamic (This : access Pool_T) return Pool_Dyn;
pragma Inline (Dynamic);
function To_Pool (This : access Pool_T'Class) return Pool;
pragma Inline (To_Pool);
function To_Base_Pool is new Ada.Unchecked_Conversion (Pool, Base_Pool);
-- pool properties
function To_String (This : Pool_T) return String;
function Skill_Name (This : access Pool_T) return String_Access;
function ID (This : access Pool_T) return Natural;
function Base (This : access Pool_T'Class) return Base_Pool;
function Super (This : access Pool_T) return Pool;
function Next (This : access Pool_T'Class) return Pool;
procedure Establish_Next (This : access Base_Pool_T'Class);
function Type_Hierarchy_Height (This : access Pool_T'Class) return Natural;
function Size (This : access Pool_T'Class) return Natural;
function Make_Boxed_Instance (This : access Pool_T) return Box is abstract;
function Make_Boxed_Instance
(This : access Sub_Pool_T) return Box is abstract;
function Make_Boxed_Instance
(This : access Base_Pool_T) return Box is abstract;
procedure Do_In_Type_Order
(This : access Pool_T'Class;
F : not null access procedure (I : Annotation));
procedure Do_For_Static_Instances
(This : access Pool_T'Class;
F : not null access procedure (I : Annotation));
function First_Dynamic_New_Instance
(This : access Pool_T'Class) return Annotation;
-- the number of instances of exactly this type, excluding sub-types
-- @return size excluding subtypes
function Static_Size (This : access Pool_T'Class) return Natural;
-- the number of instances of exactly this type, excluding sub-types
-- @return size excluding subtypes taking deleted objects into account
function Static_Size_With_Deleted
(This : access Pool_T'Class) return Natural;
-- the number of new instances of exactly this type, excluding sub-types
-- @return new_objects.size
function New_Objects_Size (This : access Pool_T'Class) return Natural;
function New_Objects_Element
(This : access Pool_T'Class;
Idx : Natural) return Annotation;
-- internal use only
function Blocks (This : access Pool_T) return Skill.Internal.Parts.Blocks;
-- internal use only
function Data_Fields
(This : access Pool_T) return Skill.Field_Declarations.Field_Vector;
-- internal use only
function Add_Field
(This : access Pool_T;
ID : Natural;
T : Field_Types.Field_Type;
Name : String_Access;
Restrictions : Field_Restrictions.Vector)
return Skill.Field_Declarations.Field_Declaration;
function Add_Field
(This : access Base_Pool_T;
ID : Natural;
T : Field_Types.Field_Type;
Name : String_Access;
Restrictions : Field_Restrictions.Vector)
return Skill.Field_Declarations.Field_Declaration;
function Add_Field
(This : access Sub_Pool_T;
ID : Natural;
T : Field_Types.Field_Type;
Name : String_Access;
Restrictions : Field_Restrictions.Vector)
return Skill.Field_Declarations.Field_Declaration;
function Known_Fields
(This : access Pool_T'Class) return String_Access_Array_Access;
procedure Add_Known_Field
(This : access Pool_T;
Name : String_Access;
String_Type : Field_Types.Builtin.String_Type_P.Field_Type;
Annotation_Type : Field_Types.Builtin.Annotation_Type_P
.Field_Type) is abstract;
procedure Add_Known_Field
(This : access Sub_Pool_T;
Name : String_Access;
String_Type : Field_Types.Builtin.String_Type_P.Field_Type;
Annotation_Type : Field_Types.Builtin.Annotation_Type_P
.Field_Type) is abstract;
procedure Add_Known_Field
(This : access Base_Pool_T;
Name : String_Access;
String_Type : Field_Types.Builtin.String_Type_P.Field_Type;
Annotation_Type : Field_Types.Builtin.Annotation_Type_P
.Field_Type) is abstract;
function Make_Sub_Pool
(This : access Pool_T;
ID : Natural;
Name : String_Access) return Skill.Types.Pools.Pool is abstract;
function Make_Sub_Pool
(This : access Sub_Pool_T;
ID : Natural;
Name : String_Access) return Skill.Types.Pools.Pool is abstract;
function Make_Sub_Pool
(This : access Base_Pool_T;
ID : Natural;
Name : String_Access) return Skill.Types.Pools.Pool is abstract;
-- internal use only
procedure Free (This : access Pool_T) is abstract;
procedure Free (This : access Sub_Pool_T) is abstract;
procedure Free (This : access Base_Pool_T) is abstract;
-- internal use only
-- return the tag of content stored in this pool (=static type)
function Content_Tag (This : access Pool_T) return Ada.Tags.Tag is abstract;
function Content_Tag
(This : access Sub_Pool_T) return Ada.Tags.Tag is abstract;
function Content_Tag
(This : access Base_Pool_T) return Ada.Tags.Tag is abstract;
-- internal use only
function Data
(This : access Base_Pool_T) return Skill.Types.Annotation_Array;
-- internal use only
-- @note: this method is invoked in type order on exactly the pools that
-- ought to be resized
procedure Resize_Pool (This : access Pool_T) is abstract;
procedure Resize_Pool (This : access Base_Pool_T) is abstract;
procedure Resize_Pool (This : access Sub_Pool_T) is abstract;
-- internal use only
-- type_ID - 32
function Pool_Offset (This : access Pool_T'Class) return Integer;
-- internal use only
function Sub_Pools (This : access Pool_T'Class) return Sub_Pool_Vector;
-- internal use only
procedure Fixed (This : access Pool_T'Class; Fix : Boolean);
-- internal use only
procedure Compress
(This : access Base_Pool_T'Class;
Lbpo_Map : Skill.Internal.Lbpo_Map_T);
procedure Update_After_Compress
(This : access Pool_T'Class;
Lbpo_Map : Skill.Internal.Lbpo_Map_T);
procedure Prepare_Append
(This : access Base_Pool_T'Class;
Chunk_Map : Skill.Field_Declarations.Chunk_Map);
-- internal use only
procedure Resize_Data (This : access Base_Pool_T'Class);
-- internal use only
procedure Set_Owner
(This : access Base_Pool_T'Class;
Owner : access Skill.Files.File_T'Class);
-- internal use only
-- @note: invoking this method manually may likely damage your state;
-- use the delete procedure of skill.files instead.
procedure Delete
(This : access Pool_T'Class;
Target : access Skill_Object'Class);
private
package New_Objects_P is new Skill.Containers.Vectors (Natural, Annotation);
type Pool_T is abstract new Field_Types.Field_Type_Base with record
-- the pools name
Name : not null String_Access;
-- the pools type id
Type_Id : Natural;
-- representation of the immediate super type (null if none exists)
Super : Pool;
-- representation of the base type (nonnull, maybe a self-reference)
Base : Base_Pool;
-- a list of sub-pools, mostly used to simplify some algorithms
Sub_Pools : Sub_Pool_Vector;
-- next pool in type order
Next : Pool;
-- number of super types
Super_Type_Count : Natural;
-- the list of all data fields
Data_Fields_F : Skill.Field_Declarations.Field_Vector;
-- names of all known fields of this pool
Known_Fields : String_Access_Array_Access;
-- layout of skill ids of this type
Blocks : Skill.Internal.Parts.Blocks;
-- Storage pools can be fixed, i.e. no dynamic instances can be added
-- to the pool. Fixing a pool requires that it does not contain a new
-- object. Fixing a pool will fix subpools as well. Un-fixing a pool
-- will un-fix super pools as well, thus being fixed is a transitive
-- property over the sub pool relation. Pools will be fixed by flush
-- operations.
Fixed : Boolean := False;
Cached_Size : Natural;
-- number of deleted objects in this pool (excluding subpools)
Deleted_Count : Natural := 0;
-- number of static instances of this inside base.data
Static_Data_Instances : Natural;
-- new objects stored as annotation references
New_Objects : New_Objects_P.Vector;
end record;
type Owner_T is access Skill.Files.File_T;
No_Known_Fields : Skill.Types.String_Access_Array_Access :=
new Skill.Types.String_Access_Array (1 .. 0);
-- note it is important to have the empty array start at 1, because that way
-- all descendent arrays will start at 1 as well and thus, no manual index
-- adjustment is necessary
Empty_Data : Skill.Types.Annotation_Array :=
new Skill.Types.Annotation_Array_T (1 .. 0);
type Base_Pool_T is abstract new Pool_T with record
Data : Skill.Types.Annotation_Array;
Owner : Owner_T;
end record;
type Sub_Pool_T is abstract new Pool_T with null record;
end Skill.Types.Pools;
|
-----------------------------------------------------------------------
-- Util.Streams.Files -- File Stream utilities
-- Copyright (C) 2010, 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.
-----------------------------------------------------------------------
package body Util.Streams.Files is
-- ------------------------------
-- Open the file and initialize the stream for reading or writing.
-- ------------------------------
procedure Open (Stream : in out File_Stream;
Mode : in Ada.Streams.Stream_IO.File_Mode;
Name : in String := "";
Form : in String := "") is
begin
Ada.Streams.Stream_IO.Open (Stream.File, Mode, Name, Form);
end Open;
-- ------------------------------
-- Create the file and initialize the stream for writing.
-- ------------------------------
procedure Create (Stream : in out File_Stream;
Mode : in Ada.Streams.Stream_IO.File_Mode;
Name : in String := "";
Form : in String := "") is
begin
Ada.Streams.Stream_IO.Create (Stream.File, Mode, Name, Form);
end Create;
-- ------------------------------
-- Close the stream.
-- ------------------------------
overriding
procedure Close (Stream : in out File_Stream) is
begin
Ada.Streams.Stream_IO.Close (Stream.File);
end Close;
-- ------------------------------
-- Write the buffer array to the output stream.
-- ------------------------------
overriding
procedure Write (Stream : in out File_Stream;
Buffer : in Ada.Streams.Stream_Element_Array) is
begin
Ada.Streams.Stream_IO.Write (Stream.File, Buffer);
end Write;
-- ------------------------------
-- Read into the buffer as many bytes as possible and return in
-- <b>last</b> the position of the last byte read.
-- ------------------------------
overriding
procedure Read (Stream : in out File_Stream;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset) is
begin
Ada.Streams.Stream_IO.Read (Stream.File, Into, Last);
end Read;
-- ------------------------------
-- Flush the stream and release the buffer.
-- ------------------------------
overriding
procedure Finalize (Object : in out File_Stream) is
begin
if Ada.Streams.Stream_IO.Is_Open (Object.File) then
Object.Close;
end if;
end Finalize;
end Util.Streams.Files;
|
-- *************************************************************************************
--
-- The recipient is warned that this code should be handled in accordance
-- with the HM Government Security Classification indicated throughout.
--
-- This code and its contents shall not be used for other than UK Government
-- purposes.
--
-- The copyright in this code is the property of BAE SYSTEMS Electronic Systems Limited.
-- The Code is supplied by BAE SYSTEMS on the express terms that it is to be treated in
-- confidence and that it may not be copied, used or disclosed to others for any
-- purpose except in accordance with DEFCON 91 (Edn 10/92).
--
-- File Name: Many_To_Many_Associative.ads
-- Version: As detailed by ClearCase
-- Version Date: As detailed by ClearCase
-- Creation Date: 03-11-99
-- Security Classification: Unclassified
-- Project: SRLE (Sting Ray Life Extension)
-- Author: J Mann
-- Section: Tactical Software/ Software Architecture
-- Division: Underwater Systems Division
-- Description: Generic specification of 1-M:M relationship
-- Comments:
--
-- MODIFICATION RECORD
-- --------------------
-- NAME DATE ECR No MODIFICATION
--
-- DB 24/09/01 TBA Rename Link, Unlink & Unassociate parameters
-- to match those for 1:1 type relationships,
-- at the request of George.
--
-- db 17/04/02 SRLE100003005 Correlated associative navigations supported.
--
-- db 22/04/02 SRLE100002907 Procedure initialise removed as surplus to requirements
--
-- DNS 20/05/15 CR 10265 For Navigate procedures returning a list,
-- the Return is now an "in" parameter
--
-- **************************************************************************************
with Root_Object;
with Ada.Tags;
generic
package Many_To_Many_Associative is
procedure Register_M1_End_Class (M1_Instance: in Ada.Tags.Tag);
procedure Register_M2_End_Class (M2_Instance: in Ada.Tags.Tag);
procedure Register_Associative_End_Class (Associative_Instance: in Ada.Tags.Tag);
--
function Report_M1_End_Class return Ada.Tags.Tag;
function Report_M2_End_Class return Ada.Tags.Tag;
function Report_Associative_End_Class return Ada.Tags.Tag;
---------------------------------------------------------------------
procedure Link (
A_Instance : in Root_Object.Object_Access;
B_Instance : in Root_Object.Object_Access;
Using : in Root_Object.Object_Access);
procedure Unassociate (
A_Instance : in Root_Object.Object_Access;
B_Instance : in Root_Object.Object_Access;
From : in Root_Object.Object_Access);
procedure Unlink (
A_Instance : in Root_Object.Object_Access;
B_Instance : in Root_Object.Object_Access);
procedure Navigate (
From : in Root_Object.Object_List.List_Header_Access_Type;
Class : in Ada.Tags.Tag;
To : in Root_Object.Object_List.List_Header_Access_Type);
--
-- navigate from a set to a set
-- valid for all traversals
--
--
procedure Navigate (
From : in Root_Object.Object_Access;
Class : in Ada.Tags.Tag;
To : in Root_Object.Object_List.List_Header_Access_Type);
--
-- navigate from a single to a set
-- valid for:
-- M1 -> M2
-- M1 -> A
-- M2 -> M1
-- M2 -> A
--
procedure Navigate (
From : in Root_Object.Object_Access;
Class : in Ada.Tags.Tag;
To : out Root_Object.Object_Access);
--
-- navigate from a single to a single
-- valid for:
-- A -> M1
-- A -> M2
--
-- associative correlated navigation
procedure Navigate (
From : in Root_Object.Object_Access;
Also : in Root_Object.Object_Access;
Class : in Ada.Tags.Tag;
To : out Root_Object.Object_Access);
end Many_To_Many_Associative;
|
with Interfaces;
package HWIF_Types is
pragma Pure;
type Octet is new Interfaces.Unsigned_8 with Size => 8;
-- Integer.
type Int is new Interfaces.Unsigned_32 with Size => 32;
end HWIF_Types;
|
------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- Reference Implementation --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Assertions;
with Ada.Directories;
with Ada.Unchecked_Deallocation;
with Ada.Containers.Vectors;
with Ada.Streams.Stream_IO;
with Unit_Names;
with User_Queries;
with Stream_Hashing.Collective;
with Registrar.Library_Units;
with Registrar.Queries;
separate (Repositories.Cache)
package body Validate_Local_Or_System is
type Hash_Queue_Access is
access Stream_Hashing.Collective.Hash_Queues.Queue;
--
-- Hash_File_Order
--
type Hash_File_Order is new Workers.Work_Order with
record
Path : UBS.Unbounded_String;
Hashes: Hash_Queue_Access;
-- The following is along for the ride - it will be used to
-- fill-out a Validate_Local_Or_System_Order in the Phase_Trigger
Index : Repository_Index;
end record;
overriding procedure Execute (Order: in out Hash_File_Order);
overriding procedure Phase_Trigger (Order: in out Hash_File_Order);
overriding function Image (Order: Hash_File_Order) return String;
--
-- Validate_Local_Or_System_Order
--
-- This order is actually called from the last Hash_File_Order, and
-- generates the collective hash, and then updates/validates the repo
type Validate_Local_Or_System_Order is new Workers.Work_Order with
record
Index : Repository_Index;
Hashes: Hash_Queue_Access;
end record;
overriding procedure Execute (Order: in out Validate_Local_Or_System_Order);
overriding function Image (Order: Validate_Local_Or_System_Order)
return String;
--
-- Hash_File_Order
--
-----------
-- Image --
-----------
function Image (Order: Hash_File_Order) return String
is ( "[Hash_File_Order] (Repositories.Cache.Validate_Local_Or_System)"
& New_Line
& " Path: " & UBS.To_String (Order.Path) & New_Line
& " (For validation/generation of Repository No."
& Repository_Index'Image (Order.Index) & ')');
-------------
-- Execute --
-------------
procedure Execute (Order: in out Hash_File_Order) is
use Ada.Streams.Stream_IO;
File: File_Type;
begin
Open (File => File,
Mode => In_File,
Name => UBS.To_String (Order.Path));
Order.Hashes.Enqueue
(Stream_Hashing.Digest_Stream (Stream (File)));
Close (File);
exception
when others =>
if Is_Open (File) then
Close (File);
end if;
raise;
end Execute;
-------------------
-- Phase_Trigger --
-------------------
-- This is executred one, when all Hash_Orders have been completed. We can
-- safely deallocate the dynamic tracker, and then submit a
-- Validate_Local_Or_System_Order, which handles the rest
procedure Phase_Trigger (Order: in out Hash_File_Order) is
procedure Free is new Ada.Unchecked_Deallocation
(Object => Progress.Progress_Tracker,
Name => Progress.Progress_Tracker_Access);
Next_Phase: Validate_Local_Or_System_Order
:= (Tracker => Caching_Progress'Access,
-- Note that Total_Items was incremented on the call to
-- Dispatch that got the whole proverbial ball rolling
Index => Order.Index,
Hashes => Order.Hashes);
begin
Free (Order.Tracker);
Workers.Enqueue_Order (Next_Phase);
end Phase_Trigger;
--
-- Validate_Local_Or_System_Order
--
-----------
-- Image --
-----------
function Image (Order: Validate_Local_Or_System_Order) return String
is ( "[Validate_Local_Or_System_Order] "
& "(Repositories.Cache.Validate_Local_Or_System)"
& New_Line
& " Repository No."
& Repository_Index'Image (Order.Index));
-------------
-- Execute --
-------------
procedure Execute (Order: in out Validate_Local_Or_System_Order) is
use Stream_Hashing;
use Stream_Hashing.Collective;
procedure Free is new Ada.Unchecked_Deallocation
(Object => Hash_Queues.Queue,
Name => Hash_Queue_Access);
Repo: Repository := Extract_Repository (Order.Index);
Collect_Hash: Hash_Type;
Hash_String : UBS.Unbounded_String;
begin
pragma Assert (Repo.Format in System | Local);
pragma Assert (Repo.Cache_State = Requested);
Compute_Collective_Hash (Hash_Queue => Order.Hashes.all,
Collective_Hash => Collect_Hash);
-- Release the queue
Free (Order.Hashes);
UBS.Set_Unbounded_String (Target => Hash_String,
Source => Collect_Hash.To_String);
if UBS.Length (Repo.Snapshot) = 0 then
-- New repo
Repo.Snapshot := Hash_String;
Repo.Cache_State := Available;
Repo.Cache_Path := Repo.Location;
Update_Repository (Index => Order.Index,
Updated => Repo);
Generate_Repo_Spec (Order.Index);
return;
else
-- Verify the hash
if Collect_Hash.To_String /= UBS.To_String (Repo.Snapshot) then
-- Mismatch. Ask the user if they want to proceed (use the new
-- hash), or abort
declare
use User_Queries;
Response: String (1..1);
Last: Natural;
begin
Query_Manager.Start_Query;
loop
Query_Manager.Post_Query
(Prompt => "Repository"
& Repository_Index'Image (Order.Index)
& '(' & UBS.To_String (Repo.Location) & ')'
& " has been modified. Accept changes? (Y/[N]): ",
Default => "N",
Response_Size => Response'Length);
Query_Manager.Wait_Response (Response => Response,
Last => Last);
if Last < Response'First then
-- Default (N)
Response := "N";
end if;
exit when Response in "Y" | "y" | "N" | "n";
end loop;
Query_Manager.End_Query;
if Response in "Y" | "y" then
-- Update with new hash
Repo.Snapshot := Hash_String;
Repo.Cache_State := Available;
Repo.Cache_Path := Repo.Location;
Update_Repository (Index => Order.Index,
Updated => Repo);
Generate_Repo_Spec (Order.Index);
else
-- Abort
raise Ada.Assertions.Assertion_Error with
"Repository hash mismatch. User rejected changes.";
end if;
end;
else
-- Hash ok
Repo.Cache_State := Available;
Repo.Cache_Path := Repo.Location;
Update_Repository (Index => Order.Index,
Updated => Repo);
end if;
end if;
end Execute;
--------------
-- Dispatch --
--------------
procedure Dispatch (Repo: in Repository; Index: in Repository_Index) is
use Ada.Directories;
use type Ada.Containers.Count_Type;
package Path_Vectors is new Ada.Containers.Vectors
(Index_Type => Positive,
Element_Type => UBS.Unbounded_String,
"=" => UBS."=");
Path_Vector: Path_Vectors.Vector;
Group_Tracker: Progress.Progress_Tracker_Access
:= new Progress.Progress_Tracker;
New_Order: Hash_File_Order
:= (Tracker => Group_Tracker,
Hashes => new Stream_Hashing.Collective.Hash_Queues.Queue,
Index => Index,
others => <>);
Filter: constant Filter_Type := (Directory => True,
Ordinary_File => True,
Special_File => False);
procedure Recursive_Add (E: in Directory_Entry_Type);
procedure Recursive_Add (E: in Directory_Entry_Type) is
S_Name: constant String := Simple_Name (E);
begin
-- Don't process hidden files
if S_Name(S_Name'First) = '.' then
return;
end if;
if Kind (E) = Directory then
Search (Directory => Full_Name (E),
Pattern => "*",
Filter => Filter,
Process => Recursive_Add'Access);
else
Path_Vector.Append (UBS.To_Unbounded_String (Full_Name (E)));
end if;
end Recursive_Add;
begin
-- For System repositories, we want to make sure the AURA spec matches
if Repo.Format = System then
declare
use Ada.Streams.Stream_IO;
use Stream_Hashing;
AURA_Unit: constant Registrar.Library_Units.Library_Unit
:= Registrar.Queries.Lookup_Unit
(Unit_Names.Set_Name ("aura"));
Repo_AURA_Spec: File_Type;
Repo_AURA_Hash: Hash_Type;
begin
Open (File => Repo_AURA_Spec,
Mode => In_File,
Name => UBS.To_String (Repo.Cache_Path) & "/aura.ads");
Repo_AURA_Hash := Digest_Stream (Stream (Repo_AURA_Spec));
Ada.Assertions.Assert
(Check => Repo_AURA_Hash = AURA_Unit.Spec_File.Hash,
Message => "System repository's AURA package does not match "
& "the local AURA package");
end;
end if;
-- Start with the location of the repository, which shall be a directory
Search (Directory => UBS.To_String (Repo.Location),
Pattern => "*",
Filter => Filter,
Process => Recursive_Add'Access);
Ada.Assertions.Assert (Check => Path_Vector.Length > 0,
Message => "Location path is invalid");
-- Set up the group tracker and dispatch
Group_Tracker.Set_Total_Items (Natural (Path_Vector.Length));
-- Dispatch
for Path of Path_Vector loop
New_Order.Path := Path;
Workers.Enqueue_Order (New_Order);
end loop;
end Dispatch;
end Validate_Local_Or_System;
|
-- SPDX-FileCopyrightText: 2019-2021 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
--
-- This package is about Ada Visibility Rules as they defined in the Reference
-- Manual (Section 8).
--
-- The package provides Context type. The user populates context by creating
-- named entities and declarative regions. The user also queries the context
-- to find the view corresponding to given symbol (identifier, operator or
-- character literal).
--
-- View provides access to defining name nodes, entity kind and properties.
with Ada.Iterator_Interfaces;
private with Ada.Containers.Hashed_Maps;
private with Ada.Containers.Vectors;
with Program.Elements.Defining_Names;
with Program.Symbols;
package Program.Visibility is
pragma Preelaborate;
subtype Defining_Name is
Program.Elements.Defining_Names.Defining_Name_Access;
-- Defining name AST node
subtype Symbol is Program.Symbols.Symbol;
-- A representation of an identifier, operator or character literal
function Standard return Symbol renames Program.Symbols.Standard;
-- Symbol of Standard Ada package
type View_Kind is
(Unresolved_View,
Subtype_View,
Exception_View,
Enumeration_Literal_View,
Character_Literal_View,
Implicit_Type_View, -- Type_View_Kind v
Enumeration_Type_View,
Signed_Integer_Type_View,
Modular_Type_View,
Float_Point_Type_View,
Object_Access_Type_View,
Incomplete_Type_View, -- Has_Region v
Array_Type_View,
Record_Type_View, -- Type_View_Kind ^,
Variable_View, -- Object_View v
Component_View,
Parameter_View, -- Object_View ^
Procedure_View,
Function_View,
Package_View); -- Has_Region ^
-- Kind of entity view
subtype Type_View_Kind is View_Kind
range Implicit_Type_View .. Record_Type_View;
-- Kind of type view
subtype Object_View is View_Kind
range Variable_View .. Parameter_View;
-- Kind of an object declaration
type View (Kind : View_Kind := Unresolved_View) is private;
-- An information about a program entity
type View_Array is array (Positive range <>) of View;
-- Array of views
function Name (Self : View) return Defining_Name;
-- Get defining name of the entity
function Has_Region (Self : View) return Boolean;
-- Check if given entity could contain nested declarative region
function Enumeration_Type (Self : View) return View
with Pre => Self.Kind in
Enumeration_Literal_View | Character_Literal_View;
-- Return enumeration type for given enumeration or character literal
function Enumeration_Literals (Self : View) return View_Array
with Pre => Self.Kind = Enumeration_Type_View;
-- Return enumeration or character literals for given enumeration type
function Is_Character_Type (Self : View) return Boolean
with Pre => Self.Kind = Enumeration_Type_View;
-- If given enumeration type is a character type
function Subtype_Mark (Self : View) return View
with Pre => Self.Kind in Subtype_View | Object_View;
-- Return type of subtype, parameter, variable declarations
function Designated_Type (Self : View) return View
with Pre => Self.Kind in Object_Access_Type_View;
-- Return designated type of an access-to-object type
function Has_Constraint (Self : View) return Boolean
with Pre => Self.Kind = Subtype_View;
-- If given subtype has a constraint
function First_Subtype (Self : View) return View
with Pre => Self.Kind in Subtype_View | Type_View_Kind,
Post => First_Subtype'Result.Kind in Type_View_Kind;
-- Return first subtype of a type
function Indexes (Self : View) return View_Array
with Pre => Self.Kind = Array_Type_View;
-- Return index types for given array type
function Component (Self : View) return View
with Pre => Self.Kind = Array_Type_View;
-- Return component type for given array type
type Parameter_Mode is (In_Mode, In_Out_Mode, Out_Mode);
function Mode (Self : View) return Parameter_Mode
with Pre => Self.Kind = Parameter_View;
-- Return Mode of parameter declaration
function Has_Default (Self : View) return Boolean
with Pre => Self.Kind = Parameter_View;
-- Check if parameter has a default value
function Parameters (Self : View) return View_Array
with Pre => Self.Kind in Procedure_View | Function_View;
-- Return parameters for given subprogram
function Result (Self : View) return View
with Pre => Self.Kind = Function_View;
-- Return result type for function
function Type_Of (Self : View) return View
with Pre => Self.Kind in
Enumeration_Literal_View |
Character_Literal_View |
Object_View;
-- Return a corresponding type:
-- * for enumeration/character literal - Enumeration_Type
-- * for parameter/variable - Subtype_Mark
function Is_Expected_Type (Self, Expected : View) return Boolean
with Pre => Self.Kind in Type_View_Kind
and Expected.Kind in Type_View_Kind;
-- Check in given type is expected type
type View_Cursor is private;
-- A cursor to iterate over visible views
function Get_View (Self : View_Cursor) return View;
-- Get a view corresponding to the cursor
function "+" (Self : View_Cursor) return View renames Get_View;
-- Get a view corresponding to the cursor
function Has_Element (Self : View_Cursor) return Boolean;
-- Check if cursor still points to a view
package Iterators is new Ada.Iterator_Interfaces (View_Cursor, Has_Element);
subtype View_Iterator is Iterators.Forward_Iterator'Class;
function Immediate_Visible
(Self : View;
Symbol : Program.Visibility.Symbol)
return View_Iterator
with Pre => Has_Region (Self);
-- Return iterator of views for immediate visible names with given symbol
function Region_Items (Self : View) return View_Array
with Pre => Has_Region (Self);
-- Return array of views for immediate visible names
type Snapshot is tagged limited private;
-- Snapshot keeps state of a context. We save snapshots for private
-- and public parts of entities.
type Snapshot_Access is access all Snapshot'Class
with Storage_Size => 0;
type Context is tagged limited private;
-- A context keeps map from symbol to its view. It also tracks set of
-- snapshots.
type Context_Access is access all Program.Visibility.Context'Class
with Storage_Size => 0;
procedure Create_Empty_Context
(Self : in out Context'Class);
-- Initialize a context to empty state before loading Standard package
procedure Leave_Declarative_Region (Self : in out Context'Class);
-- Leave current declarative region the context.
function Create_Snapshot
(Self : in out Context'Class) return Snapshot_Access;
-- Store state of the context into a snapshot
procedure Restore_Snapshot
(Self : in out Context'Class;
Snapshot : not null Snapshot_Access);
-- Restore snapshot. For example before leaving a package, restore
-- the snapshot of its public part.
procedure Enter_Snapshot
(Self : in out Context'Class;
Snapshot : not null Snapshot_Access);
-- Take topmost element of the snapshot and enter its declarative region.
-- Use-case example:
--
-- declare
-- package P is
-- type T is private;
-- procedure Proc (X : T);
-- private --> Public_Snap := Create_Snapshot;
-- type T is new Integer;
-- end P; --> Private_Snap := Create_Snapshot;
--
-- --> Restore_Snapshot (Public_Snap); Leave_Declaration;
-- V : P.T;
-- package body P is --> Enter_Snapshot (Private_Snap);
--
-- procedure Start_Private_Part
-- (Self : in out Context'Class;
-- Snapshot : not null Snapshot_Access);
-- Make private declarations visible. Current "point of view" should be
-- in a public part of a library unit. Snapshot should be taken from the
-- parent of the current unit.
-- Use-case example:
--
-- package P is
-- type T is private;
-- private --> Public_Snap := Create_Snapshot;
-- type T is new Integer;
-- end P; --> Private_Snap := Create_Snapshot;
--
-- --> Restore_Snapshot (Public_Snap); Leave_Declaration;
-- package P.Q is --> Create_Package (P.Q)
-- V : T;
-- private --> Start_Private_Part (Private_Snap);
-- --> Now we see that T is integer and its oprerations like "+", "/"
--
procedure Create_Implicit_Type
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name);
-- Add an implicit type view to the context. Don't create a region.
procedure Create_Incomplete_Type
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name);
-- Add an incomplete type view to the context. Create a region.
procedure Create_Object_Access_Type
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name;
Designated : View);
-- Add an access-to-object type view to the context.
-- Don't create a region.
procedure Create_Enumeration_Type
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name);
-- Add an enumeration type view to the context. Don't create a region.
procedure Create_Enumeration_Literal
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name;
Enumeration_Type : View)
with Pre => Enumeration_Type.Kind = Enumeration_Type_View;
-- Add an enumeration literal view to the context. Don't create a region.
procedure Create_Character_Literal
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name;
Enumeration_Type : View)
with Pre => Enumeration_Type.Kind = Enumeration_Type_View;
-- Add a character literal view to the context. Don't create a region.
type Meta_Character_Literal_Kind is
(Meta_Character, Meta_Wide_Character, Meta_Wide_Wide_Character);
-- Meta character literal matches any character name in its class.
-- We use them to avoid a million of defining names in the context.
procedure Create_Character_Literal
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name;
Meta_Character : Meta_Character_Literal_Kind;
Enumeration_Type : View)
with Pre => Enumeration_Type.Kind = Enumeration_Type_View;
-- Add a meta character literal view to the context. Don't create a region.
procedure Create_Signed_Integer_Type
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name);
-- Add a signed integer type view to the context. Create a region.
procedure Create_Modular_Type
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name);
-- Add a unsigned integer type view to the context. Create a region.
procedure Create_Float_Point_Type
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name);
-- Add a float point type view to the context. Create a region.
procedure Create_Array_Type
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name;
Indexes : View_Array;
Component : View)
with Pre => Component.Kind in Type_View_Kind;
-- Add an array type view to the context. Create a region.
procedure Create_Record_Type
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name);
-- Add a (untagged) record type view to the context.
procedure Create_Subtype
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name;
Subtype_Mark : View;
Has_Constraint : Boolean)
with Pre => Subtype_Mark.Kind in Type_View_Kind;
-- Add a subtype view to the context. Create a region.
procedure Create_Package
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name);
-- Add an empty package view to the context. Create a region.
procedure Create_Procedure
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name);
-- Add a procedure view to the context. Create declarative region.
-- The typical flow is
-- * Create_Procedure
-- ** Create_Parameter
-- ** Leave_Declarative_Region
-- ** Set_Object_Type
-- * Leave_Declarative_Region
procedure Create_Parameter
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name;
Mode : Parameter_Mode;
Has_Default : Boolean);
-- Add a parameter view to the context and to the topmost subprogram
-- declaration. Create declarative region.
procedure Create_Component
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name;
Has_Default : Boolean);
-- Add a component view to the context and to the topmost record
-- declaration. Create declarative region.
procedure Set_Object_Type
(Self : in out Context'Class;
Definition : View);
-- Assign given subtype to the topmost Object_View declaration
procedure Create_Function
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name);
-- Add a function view to the context. Create declarative region.
-- The typical flow is
-- * Create_Function
-- ** Create_Parameter
-- ** Leave_Declarative_Region
-- ** Set_Object_Type
-- * Set_Result_Type
-- * Leave_Declarative_Region
procedure Set_Result_Type
(Self : in out Context'Class;
Definition : View);
-- Assign given subtype as a result type to the topmost function decl.
procedure Create_Variable
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name);
-- Add a variable view to the context. Create declarative region.
-- The typical flow is
-- * Create_Variable
-- * Leave_Declarative_Region
-- * Set_Object_Type
procedure Create_Exception
(Self : in out Context'Class;
Symbol : Program.Visibility.Symbol;
Name : Defining_Name);
-- Add an exception view to the context. Don't create a region.
procedure Add_Use_Package
(Self : in out Context'Class;
Pkg : View);
-- Add use package clause to the context.
function Immediate_Visible
(Self : Context'Class;
Symbol : Program.Visibility.Symbol)
return View_Iterator;
-- Return iterator of views for immediate visible names with given symbol
function Use_Visible
(Self : Context'Class;
Symbol : Program.Visibility.Symbol)
return View_Iterator;
-- Return iterator of views for use visible names with given symbol
type Directly_Visible_Name_Iterator is
new Iterators.Forward_Iterator with private;
overriding function First
(Self : Directly_Visible_Name_Iterator) return View_Cursor;
overriding function Next
(Self : Directly_Visible_Name_Iterator;
Position : View_Cursor) return View_Cursor;
function Directly_Visible
(Self : Context'Class;
Symbol : Program.Visibility.Symbol)
return Directly_Visible_Name_Iterator;
-- Return iterator of views for directly visible (use or immediate) names
-- with given symbol
function Latest_View (Self : Context'Class) return View;
-- View that was added to the context
function Get_Name_View
(Self : Context'Class;
Name : not null Program.Elements.Element_Access) return View;
private
type Entity_Identifier is range 1 .. Integer'Last;
type Region_Identifier is range 1 .. Integer'Last;
type Entity_Reference is record
Region : Region_Identifier;
Entity_Id : Entity_Identifier;
end record;
No_Entity : constant Entity_Reference :=
(Region_Identifier'Last, Entity_Identifier'Last);
package Entity_References is new Ada.Containers.Vectors
(Index_Type => Positive,
Element_Type => Entity_Reference);
subtype Has_Region_Kind is
View_Kind range Incomplete_Type_View .. Package_View;
type Entity (Kind : View_Kind := Package_View) is record
Symbol : Program.Visibility.Symbol;
Name : Defining_Name;
Prev : Entity_Reference; -- An upper entity with the same symbol
-- Entity_Id : Entity_Identifier;
-- The index of the item from which we copied this item
case Kind is
when Has_Region_Kind =>
Region : Region_Identifier;
-- If Item has nested region, it's region index
case Kind is
when Function_View =>
Result_Def : Entity_Reference;
when Array_Type_View =>
Indexes : Entity_References.Vector;
Component : Entity_Reference;
when Parameter_View | Component_View | Variable_View =>
Object_Def : Entity_Reference;
Mode : Parameter_Mode;
Has_Default : Boolean;
when others =>
null;
end case;
when others =>
case Kind is
when Enumeration_Type_View =>
Is_Character_Type : Boolean;
First_Literal : Entity_Identifier;
Last_Literal : Entity_Identifier;
-- indexes of its enumeration literals
when Enumeration_Literal_View =>
Enumeration_Type : Entity_Identifier;
when Character_Literal_View =>
Character_Type : Entity_Identifier;
when Subtype_View =>
Subtype_Mark : Entity_Reference;
Has_Constraint : Boolean;
when Object_Access_Type_View =>
Designated_Type : Entity_Reference;
when others =>
null;
end case;
end case;
end record;
package Entity_Vectors is new Ada.Containers.Vectors
(Index_Type => Entity_Identifier,
Element_Type => Entity);
package Region_Id_Vectors is new Ada.Containers.Vectors
(Index_Type => Positive,
Element_Type => Region_Identifier);
type Snapshot is tagged limited record
Region_Id : Region_Identifier; -- Ignore Region_Id if Entities is empty
Entities : Entity_Vectors.Vector;
Uses : Region_Id_Vectors.Vector;
end record;
function Hash
(Value : Program.Elements.Defining_Names.Defining_Name_Access)
return Ada.Containers.Hash_Type;
package Defining_Name_Maps is new Ada.Containers.Hashed_Maps
(Key_Type => Program.Elements.Defining_Names.Defining_Name_Access,
Element_Type => Entity_Reference,
Hash => Hash,
Equivalent_Keys => Program.Elements.Defining_Names."=",
"=" => "=");
type Region is record
Enclosing : Region_Identifier'Base;
Entities : Entity_Vectors.Vector;
Uses : Region_Id_Vectors.Vector;
end record;
package Region_Vectors is new Ada.Containers.Vectors
(Index_Type => Region_Identifier,
Element_Type => Region);
package Entity_Maps is new Ada.Containers.Hashed_Maps
(Key_Type => Program.Visibility.Symbol,
Element_Type => Entity_Reference,
Hash => Program.Symbols.Hash,
Equivalent_Keys => Program.Symbols."=",
"=" => "=");
type Context is tagged limited record
Data : Region_Vectors.Vector;
-- All items are stored here
Top : Region_Identifier;
-- Current region
Xref : Defining_Name_Maps.Map;
-- For each defining name a corresponding reference
Directly : Entity_Maps.Map;
-- A Directly visible symbols mapped to corresponding entities
end record;
type Constant_Context_Access is access constant Context'Class;
type View (Kind : View_Kind := Unresolved_View) is record
Env : Constant_Context_Access;
Index : Entity_Reference;
end record;
type View_Cursor is record
Region : Region_Identifier;
Entity : Entity_Identifier'Base;
Use_Id : Positive;
View : Program.Visibility.View;
end record;
type Region_Immediate_Visible_Iterator is new Iterators.Forward_Iterator
with record
Context : Constant_Context_Access;
Region : Region_Identifier;
Symbol : Program.Visibility.Symbol;
end record;
overriding function First
(Self : Region_Immediate_Visible_Iterator) return View_Cursor;
overriding function Next
(Self : Region_Immediate_Visible_Iterator;
Position : View_Cursor) return View_Cursor;
type Context_Immediate_Visible_Iterator is new Iterators.Forward_Iterator
with record
Context : Constant_Context_Access;
First : Entity_Reference;
end record;
overriding function First
(Self : Context_Immediate_Visible_Iterator) return View_Cursor;
overriding function Next
(Self : Context_Immediate_Visible_Iterator;
Position : View_Cursor) return View_Cursor;
type Use_Visible_Iterator is
new Region_Immediate_Visible_Iterator with null record;
overriding function First
(Self : Use_Visible_Iterator) return View_Cursor;
overriding function Next
(Self : Use_Visible_Iterator;
Position : View_Cursor) return View_Cursor;
type Directly_Visible_Name_Iterator is new Iterators.Forward_Iterator
with record
Immediate : Context_Immediate_Visible_Iterator;
Uses : Use_Visible_Iterator;
end record;
end Program.Visibility;
|
------------------------------------------------------------------------------
-- G E L A X 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:
-- Helper functions
with Asis;
package XASIS.Utils is
function Are_Equal_Identifiers
(Left, Right : Asis.Program_Text)
return Boolean;
function Declaration_Direct_Name
(Item : Asis.Declaration) return Asis.Program_Text;
function Declaration_Name
(Item : Asis.Declaration) return Asis.Defining_Name;
function Direct_Name (Name : Asis.Defining_Name) return Asis.Program_Text;
function Has_Defining_Name
(Declaration : Asis.Declaration;
Direct_Name : Asis.Program_Text) return Boolean;
function Has_Name
(Element : Asis.Defining_Name;
Direct_Name : Asis.Program_Text) return Boolean;
function Get_Defining_Name
(Declaration : Asis.Declaration;
Direct_Name : Asis.Program_Text) return Asis.Defining_Name;
function Named_By
(Element : Asis.Expression;
Name : Asis.Program_Text) return Boolean;
function Name_Image (Name : Asis.Expression) return Asis.Program_Text;
function External_Name_Image
(Name : Asis.Defining_Name)
return Asis.Program_Text;
function External_Image
(Decl : Asis.Declaration)
return Asis.Program_Text;
-- Expected:
-- An_Identifier
-- A_Selected_Component
-- An_Operator_Symbol
-- A_Character_Literal
-- An_Enumeration_Literal
function Overloadable
(Element : Asis.Defining_Name)
return Boolean;
function Overloadable_Declaration
(Element : Asis.Declaration)
return Boolean;
-----------------
-- Completion --
-----------------
function Can_Be_Completion
(Declaration : Asis.Declaration) return Boolean;
function Must_Be_Completion
(Declaration : Asis.Declaration) return Boolean;
function Is_Completion
(Declaration : Asis.Declaration) return Boolean;
function Declaration_For_Completion
(Declaration : Asis.Declaration) return Asis.Declaration;
function Completion_For_Declaration
(Declaration : Asis.Declaration) return Asis.Declaration;
function Completion_For_Name
(Name : Asis.Defining_Name) return Asis.Declaration;
function Parent_Declaration
(Element : Asis.Element) return Asis.Declaration;
function Check_Callable_Name (Name : Asis.Declaration) return Boolean;
function Get_Profile (Name : Asis.Declaration)
return Asis.Parameter_Specification_List;
function Get_Result_Profile (Name : Asis.Declaration)
return Asis.Expression;
function Get_Result_Subtype (Name : Asis.Declaration)
return Asis.Definition;
function Parameterless (Name : Asis.Declaration) return Boolean;
function Is_Empty_Profile
(List : Asis.Parameter_Specification_List) return Boolean;
procedure Dump_Tree
(Unit : Asis.Compilation_Unit;
File_Name : String);
function Operator_Kind
(Name_Image : Asis.Program_Text;
Binary : Boolean := True)
return Asis.Operator_Kinds;
function Debug_Image (Element : in Asis.Element) return Asis.Program_Text;
function Selected_Name_Selector
(Expr : Asis.Expression;
Skip_Attr : Boolean) return Asis.Expression;
function Selected_Name_Declaration
(Expr : Asis.Expression;
Skip_Attr : Boolean;
Unwind : Boolean := False) return Asis.Declaration;
function Is_Child_Of (Child, Parent : Asis.Element) return Boolean;
function Has_Representation_Item (Tipe : Asis.Declaration) return Boolean;
function Is_Entry_Family (Decl : Asis.Declaration) return Boolean;
function Is_Parameter_Specification
(Decl : Asis.Declaration) return Boolean;
function Lexic_Level (Name : Asis.Defining_Name) return Positive;
function Is_Expanded_Name (Expr : Asis.Expression) return Boolean;
function Is_Package_Name (Name : Asis.Defining_Name) return Boolean;
function Is_Enclosing_Named_Construct
(Element : Asis.Element;
Name : Asis.Defining_Name) return Boolean;
function Is_Predefined_Operator (Decl : Asis.Declaration) return Boolean;
function Get_Attribute_Profile
(Tipe : Asis.Declaration;
Kind : Asis.Attribute_Kinds) return Asis.Element_List;
function Last_Constraint (Decl : Asis.Declaration) return Asis.Declaration;
-- Like Corresponding_Last_Constraint but doen't unwind if an argument
-- declaration itself has a constraint.
function Get_Ancestors (Decl : Asis.Declaration) return Asis.Name_List;
function Unique (List : Asis.Element_List) return Asis.Element_List;
-- Remove dublicated elements from the List
function Unwind_Renamed (Item : Asis.Declaration) return Asis.Declaration;
-- If Item rename declaration get renamed declaration
end XASIS.Utils;
------------------------------------------------------------------------------
-- 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.
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2013, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Characters.Wide_Wide_Latin_1;
with Matreshka.Internals.Regexps.Compiler.Scanner.Tables;
package body Matreshka.Internals.Regexps.Compiler.Scanner is
use Ada.Characters.Wide_Wide_Latin_1;
use Matreshka.Internals.Unicode;
use Matreshka.Internals.Utf16;
use Matreshka.Internals.Regexps.Compiler.Scanner.Tables;
procedure Enter_Start_Condition
(Self : not null access Compiler_State; State : Integer);
-- Enter a start condition.
function YY_EOF_State
(Self : not null access Compiler_State) return Integer;
-- Action number for EOF rule of a current start state
---------------------------
-- Enter_Start_Condition --
---------------------------
procedure Enter_Start_Condition
(Self : not null access Compiler_State; State : Integer) is
begin
Self.YY_Start_State := 1 + 2 * State;
end Enter_Start_Condition;
------------------
-- YY_EOF_State --
------------------
function YY_EOF_State
(Self : not null access Compiler_State) return Integer is
begin
return YY_End_Of_Buffer + (Self.YY_Start_State - 1) / 2 + 1;
end YY_EOF_State;
-----------
-- YYLex --
-----------
function YYLex (Self : not null access Compiler_State) return Token is
YY_Action : Integer;
YY_Back_Position : Utf16_String_Index;
YY_Back_Index : Positive;
YY_Next_Position : Utf16_String_Index;
-- Position of the next character in the source string.
YY_Current_State : Integer;
YY_Current_Code : Code_Point;
YY_C : Integer;
YY_Last_Accepting_State : Integer;
YY_Last_Accepting_Position : Utf16_String_Index;
YY_Last_Accepting_Index : Positive;
function YYText return Wide_Wide_String;
-- XXX Dummy function to support transition
------------
-- YYText --
------------
function YYText return Wide_Wide_String is
Length : constant Natural :=
Natural (Self.YY_Current_Position - YY_Back_Position);
Result : Wide_Wide_String (1 .. Length);
Last : Natural := 0;
Index : Utf16_String_Index := YY_Back_Position;
Code : Code_Point;
begin
while Index < Self.YY_Current_Position loop
Unchecked_Next (Self.Data.Value, Index, Code);
Last := Last + 1;
Result (Last) := Wide_Wide_Character'Val (Code);
end loop;
return Result (1 .. Last);
end YYText;
YYLVal : YYSType renames Self.YYLVal;
begin
loop -- Loops until end-of-string is reached
YY_Back_Position := Self.YY_Current_Position;
YY_Back_Index := Self.YY_Current_Index;
YY_Current_State := Self.YY_Start_State;
if YY_Back_Position = Self.Data.Unused then
-- End of string already reached
YY_Action := YY_EOF_State (Self);
else
loop
YY_Next_Position := Self.YY_Current_Position;
if YY_Next_Position = Self.Data.Unused then
-- By convention, aflex always assign zero equivalence class
-- to the end-of-buffer state.
YY_C := 0;
else
Unchecked_Next
(Self.Data.Value, YY_Next_Position, YY_Current_Code);
YY_C :=
YY_EC_Base
(YY_Current_Code / 16#100#) (YY_Current_Code mod 16#100#);
end if;
if YY_Accept (YY_Current_State) /= 0 then
-- Accepting state reached, save if to backtrack
YY_Last_Accepting_State := YY_Current_State;
YY_Last_Accepting_Position := Self.YY_Current_Position;
YY_Last_Accepting_Index := Self.YY_Current_Index;
exit when Self.YY_Current_Position = Self.Data.Unused;
-- End of string has been reached.
end if;
while YY_Chk (YY_Base (YY_Current_State) + YY_C)
/= YY_Current_State
loop
YY_Current_State := YY_Def (YY_Current_State);
if YY_Current_State >= YY_First_Template then
YY_C := YY_Meta (YY_C);
end if;
end loop;
YY_Current_State := YY_Nxt (YY_Base (YY_Current_State) + YY_C);
Self.YY_Current_Position := YY_Next_Position;
Self.YY_Current_Index := Self.YY_Current_Index + 1;
exit when YY_Current_State = YY_Jam_State;
end loop;
-- Return back to last accepting state.
Self.YY_Current_Position := YY_Last_Accepting_Position;
Self.YY_Current_Index := YY_Last_Accepting_Index;
YY_Current_State := YY_Last_Accepting_State;
-- Retrieve associated action and execute it.
YY_Action := YY_Accept (YY_Current_State);
end if;
case YY_Action is
when 0 =>
-- Backtrack
Self.YY_Current_Position := YY_Last_Accepting_Position;
Self.YY_Current_Index := YY_Last_Accepting_Index;
YY_Current_State := YY_Last_Accepting_State;
pragma Style_Checks ("M127");
when 1 =>
return Token_Any_Code_Point;
when 2 =>
Enter_Start_Condition (Self, LITERAL);
when 3 =>
Enter_Start_Condition (Self, INITIAL);
when 4 =>
-- aflex . is any but newline
declare
S : constant Wide_Wide_String := YYText;
begin
YYLVal := (Match_Code_Point, S (S'First));
return Token_Code_Point;
end;
when 6 =>
-- Start of subexpression (non-capturing)
return Token_Subexpression_Begin;
when 7 =>
-- Start of the comment
Enter_Start_Condition (Self, COMMENT);
when 8 =>
-- End of comment
Enter_Start_Condition (Self, INITIAL);
when 9 =>
-- Comment
null;
when 11 =>
-- Start of line anchor
return Token_Start_Of_Line;
when 12 =>
-- End of line anchor
return Token_End_Of_Line;
when 13 =>
-- Start of subexpression (capturing)
return Token_Subexpression_Capture_Begin;
when 14 =>
-- End of subexpression
return Token_Subexpression_End;
when 15 =>
-- Alternation
return Token_Alternation;
when 16 =>
return Token_Optional_Lazy;
when 17 =>
return Token_Optional_Greedy;
when 18 =>
return Token_Zero_Or_More_Lazy;
when 19 =>
return Token_Zero_Or_More_Greedy;
when 20 =>
return Token_One_Or_More_Lazy;
when 21 =>
return Token_One_Or_More_Greedy;
when 22 =>
-- Enter character class
Self.Character_Class_Mode := True;
Enter_Start_Condition (Self, CHARACTER_CLASS);
return Token_Character_Class_Begin;
when 23 =>
-- XXX Leave character class
Self.Character_Class_Mode := False;
Enter_Start_Condition (Self, INITIAL);
return Token_Character_Class_End;
when 24 =>
-- Negate character class
return Token_Negate_Character_Class;
when 25 =>
-- Range of characters
return Token_Character_Class_Range;
when 27 =>
-- Multiplicity
Enter_Start_Condition (Self, MULTIPLICITY);
return Token_Multiplicity_Begin;
when 28 =>
-- End of multiplicity specifier
Enter_Start_Condition (Self, INITIAL);
return Token_Multiplicity_End_Greedy;
when 29 =>
-- End of multiplicity specifier
Enter_Start_Condition (Self, INITIAL);
return Token_Multiplicity_End_Lazy;
when 30 =>
-- Number separator
return Token_Multiplicity_Comma;
when 31 =>
-- Number
YYLVal := (Number, Natural'Wide_Wide_Value (YYText));
return Token_Multiplicity_Number;
when 32 =>
-- Unexpected character in multiplicidy declaration
YYError (Self, Unexpected_Character_in_Multiplicity_Specifier, YY_Back_Index);
return Error;
when 34 =>
-- Escaped pattern special code point
declare
S : constant Wide_Wide_String := YYText;
begin
YYLVal := (Match_Code_Point, S (S'First + 1));
return Token_Code_Point;
end;
when 35 =>
YYLVal := (Match_Code_Point, Ada.Characters.Wide_Wide_Latin_1.LF);
return Token_Code_Point;
when 36 =>
YYLVal := (Match_Code_Point, Ada.Characters.Wide_Wide_Latin_1.CR);
return Token_Code_Point;
when 37 =>
YYLVal := (Match_Code_Point, Ada.Characters.Wide_Wide_Latin_1.HT);
return Token_Code_Point;
when 38 =>
YYLVal := (Match_Code_Point, Ada.Characters.Wide_Wide_Latin_1.BEL);
return Token_Code_Point;
when 39 =>
YYLVal := (Match_Code_Point, Ada.Characters.Wide_Wide_Latin_1.ESC);
return Token_Code_Point;
when 40 =>
YYLVal := (Match_Code_Point, Ada.Characters.Wide_Wide_Latin_1.FF);
return Token_Code_Point;
when 41 =>
YYLVal := (Match_Code_Point, Ada.Characters.Wide_Wide_Latin_1.VT);
return Token_Code_Point;
when 42 =>
-- YYLVal := (Match_Code_Point, Ada.Characters.Wide_Wide_Latin_1.VT);
raise Program_Error;
return Token_Code_Point;
when 43 =>
-- Short hex notation of the code point
YYLVal :=
(Match_Code_Point,
Wide_Wide_Character'Val
(Integer'Wide_Wide_Value ("16#" & YYText (3 .. 6) & "#")));
return Token_Code_Point;
when 44 =>
-- Long hex notation of the code point
YYLVal :=
(Match_Code_Point,
Wide_Wide_Character'Val
(Integer'Wide_Wide_Value ("16#" & YYText (3 .. 10) & "#")));
return Token_Code_Point;
when 45 =>
-- Unicode property specification
Enter_Start_Condition (Self, PROPERTY_SPECIFICATION_UNICODE);
return Token_Property_Begin_Positive;
when 46 =>
-- Unicode property specification
Enter_Start_Condition (Self, PROPERTY_SPECIFICATION_POSIX);
return Token_Property_Begin_Positive;
when 47 =>
-- Unicode property specification
Enter_Start_Condition (Self, PROPERTY_SPECIFICATION_UNICODE);
return Token_Property_Begin_Negative;
when 48 =>
-- Unicode property specification
Enter_Start_Condition (Self, PROPERTY_SPECIFICATION_POSIX);
return Token_Property_Begin_Negative;
when 49 =>
-- End of Unicode property specification
if Self.Character_Class_Mode then
Enter_Start_Condition (Self, CHARACTER_CLASS);
else
Enter_Start_Condition (Self, INITIAL);
end if;
return Token_Property_End;
when 50 =>
-- End of Unicode property specification
if Self.Character_Class_Mode then
Enter_Start_Condition (Self, CHARACTER_CLASS);
else
Enter_Start_Condition (Self, INITIAL);
end if;
return Token_Property_End;
when 51 =>
-- ASCII_Hex_Digit
YYLVal := (Property_Keyword, ASCII_Hex_Digit);
return Token_Property_Keyword;
when 52 =>
-- Alphabetic
YYLVal := (Property_Keyword, Alphabetic);
return Token_Property_Keyword;
when 53 =>
-- Bidi_Control
YYLVal := (Property_Keyword, Bidi_Control);
return Token_Property_Keyword;
when 54 =>
-- Bidi_Mirrored
-- XXX Bidi_Mirrored is absent in UCD now
-- YYLVal := (Property_Keyword, Bidi_Mirrored);
--
-- return Token_Property_Keyword;
raise Program_Error;
when 55 =>
-- Cased
YYLVal := (Property_Keyword, Cased);
return Token_Property_Keyword;
when 56 =>
-- Case_Ignorable
YYLVal := (Property_Keyword, Case_Ignorable);
return Token_Property_Keyword;
when 57 =>
-- Changes_When_Casefolded
YYLVal := (Property_Keyword, Changes_When_Casefolded);
return Token_Property_Keyword;
when 58 =>
-- Changes_When_Casemapped
YYLVal := (Property_Keyword, Changes_When_Casemapped);
return Token_Property_Keyword;
when 59 =>
-- Changes_When_Lowercased
YYLVal := (Property_Keyword, Changes_When_Lowercased);
return Token_Property_Keyword;
when 60 =>
-- Changes_When_NFKC_Casefolded
YYLVal := (Property_Keyword, Changes_When_NFKC_Casefolded);
return Token_Property_Keyword;
when 61 =>
-- Changes_When_Titlecased
YYLVal := (Property_Keyword, Changes_When_Titlecased);
return Token_Property_Keyword;
when 62 =>
-- Changes_When_Uppercased
YYLVal := (Property_Keyword, Changes_When_Uppercased);
return Token_Property_Keyword;
when 63 =>
-- Composition_Exclusion
YYLVal := (Property_Keyword, Composition_Exclusion);
return Token_Property_Keyword;
when 64 =>
-- Full_Composition_Exclusion
YYLVal := (Property_Keyword, Full_Composition_Exclusion);
return Token_Property_Keyword;
when 65 =>
-- Dash
YYLVal := (Property_Keyword, Dash);
return Token_Property_Keyword;
when 66 =>
-- Deprecated
YYLVal := (Property_Keyword, Deprecated);
return Token_Property_Keyword;
when 67 =>
-- Default_Ignorable_Code_Point
YYLVal := (Property_Keyword, Default_Ignorable_Code_Point);
return Token_Property_Keyword;
when 68 =>
-- Diacritic
YYLVal := (Property_Keyword, Diacritic);
return Token_Property_Keyword;
when 69 =>
-- Extender
YYLVal := (Property_Keyword, Extender);
return Token_Property_Keyword;
when 70 =>
-- Grapheme_Base
YYLVal := (Property_Keyword, Grapheme_Base);
return Token_Property_Keyword;
when 71 =>
-- Grapheme_Extend
YYLVal := (Property_Keyword, Grapheme_Extend);
return Token_Property_Keyword;
when 72 =>
-- Grapheme_Link
YYLVal := (Property_Keyword, Grapheme_Link);
return Token_Property_Keyword;
when 73 =>
-- Hex_Digit
YYLVal := (Property_Keyword, Hex_Digit);
return Token_Property_Keyword;
when 74 =>
-- Hyphen
YYLVal := (Property_Keyword, Hyphen);
return Token_Property_Keyword;
when 75 =>
-- ID_Continue
YYLVal := (Property_Keyword, ID_Continue);
return Token_Property_Keyword;
when 76 =>
-- Ideographic
YYLVal := (Property_Keyword, Ideographic);
return Token_Property_Keyword;
when 77 =>
-- ID_Start
YYLVal := (Property_Keyword, ID_Start);
return Token_Property_Keyword;
when 78 =>
-- IDS_Binary_Operator
YYLVal := (Property_Keyword, IDS_Binary_Operator);
return Token_Property_Keyword;
when 79 =>
-- IDS_Trinary_Operator
YYLVal := (Property_Keyword, IDS_Trinary_Operator);
return Token_Property_Keyword;
when 80 =>
-- Join_Control
YYLVal := (Property_Keyword, Join_Control);
return Token_Property_Keyword;
when 81 =>
-- Logical_Order_Exception
YYLVal := (Property_Keyword, Logical_Order_Exception);
return Token_Property_Keyword;
when 82 =>
-- Lowercase
YYLVal := (Property_Keyword, Lowercase);
return Token_Property_Keyword;
when 83 =>
-- Math
YYLVal := (Property_Keyword, Math);
return Token_Property_Keyword;
when 84 =>
-- Noncharacter_Code_Point
YYLVal := (Property_Keyword, Noncharacter_Code_Point);
return Token_Property_Keyword;
when 85 =>
-- Other_Alphabetic
YYLVal := (Property_Keyword, Other_Alphabetic);
return Token_Property_Keyword;
when 86 =>
-- Other_Default_Ignorable_Code_Point
YYLVal := (Property_Keyword, Other_Default_Ignorable_Code_Point);
return Token_Property_Keyword;
when 87 =>
-- Other_Grapheme_Extend
YYLVal := (Property_Keyword, Other_Grapheme_Extend);
return Token_Property_Keyword;
when 88 =>
-- Other_ID_Continue
YYLVal := (Property_Keyword, Other_ID_Continue);
return Token_Property_Keyword;
when 89 =>
-- Other_ID_Start
YYLVal := (Property_Keyword, Other_ID_Start);
return Token_Property_Keyword;
when 90 =>
-- Other_Lowercase
YYLVal := (Property_Keyword, Other_Lowercase);
return Token_Property_Keyword;
when 91 =>
-- Other_Math
YYLVal := (Property_Keyword, Other_Math);
return Token_Property_Keyword;
when 92 =>
-- Other_Uppercase
YYLVal := (Property_Keyword, Other_Uppercase);
return Token_Property_Keyword;
when 93 =>
-- Pattern_Syntax
YYLVal := (Property_Keyword, Pattern_Syntax);
return Token_Property_Keyword;
when 94 =>
-- Pattern_White_Space
YYLVal := (Property_Keyword, Pattern_White_Space);
return Token_Property_Keyword;
when 95 =>
-- Quotation_Mark
YYLVal := (Property_Keyword, Quotation_Mark);
return Token_Property_Keyword;
when 96 =>
-- Radical
YYLVal := (Property_Keyword, Radical);
return Token_Property_Keyword;
when 97 =>
-- Soft_Dotted
YYLVal := (Property_Keyword, Soft_Dotted);
return Token_Property_Keyword;
when 98 =>
-- STerm
YYLVal := (Property_Keyword, STerm);
return Token_Property_Keyword;
when 99 =>
-- Terminal_Punctuation
YYLVal := (Property_Keyword, Terminal_Punctuation);
return Token_Property_Keyword;
when 100 =>
-- Unified_Ideograph
YYLVal := (Property_Keyword, Unified_Ideograph);
return Token_Property_Keyword;
when 101 =>
-- Uppercase
YYLVal := (Property_Keyword, Uppercase);
return Token_Property_Keyword;
when 102 =>
-- Variation_Selector
YYLVal := (Property_Keyword, Variation_Selector);
return Token_Property_Keyword;
when 103 =>
-- White_Space
YYLVal := (Property_Keyword, White_Space);
return Token_Property_Keyword;
when 104 =>
-- XID_Continue
YYLVal := (Property_Keyword, XID_Continue);
return Token_Property_Keyword;
when 105 =>
-- XID_Start
YYLVal := (Property_Keyword, XID_Start);
return Token_Property_Keyword;
when 106 =>
-- Expands_On_NFC
YYLVal := (Property_Keyword, Expands_On_NFC);
return Token_Property_Keyword;
when 107 =>
-- Expands_On_NFD
YYLVal := (Property_Keyword, Expands_On_NFD);
return Token_Property_Keyword;
when 108 =>
-- Expands_On_NFKC
YYLVal := (Property_Keyword, Expands_On_NFKC);
return Token_Property_Keyword;
when 109 =>
-- Expands_On_NFKD
YYLVal := (Property_Keyword, Expands_On_NFKD);
return Token_Property_Keyword;
when 110 =>
-- Other
YYLVal := (Property_Keyword, Other);
return Token_Property_Keyword;
when 111 =>
-- Control
YYLVal := (Property_Keyword, Control);
return Token_Property_Keyword;
when 112 =>
-- Format
YYLVal := (Property_Keyword, Format);
return Token_Property_Keyword;
when 113 =>
-- Unassigned
YYLVal := (Property_Keyword, Unassigned);
return Token_Property_Keyword;
when 114 =>
-- Private_Use
YYLVal := (Property_Keyword, Private_Use);
return Token_Property_Keyword;
when 115 =>
-- Surrogate
YYLVal := (Property_Keyword, Surrogate);
return Token_Property_Keyword;
when 116 =>
-- Letter
YYLVal := (Property_Keyword, Letter);
return Token_Property_Keyword;
when 117 =>
-- Cased_Letter
YYLVal := (Property_Keyword, Cased_Letter);
return Token_Property_Keyword;
when 118 =>
-- Lowercase_Letter
YYLVal := (Property_Keyword, Lowercase_Letter);
return Token_Property_Keyword;
when 119 =>
-- Modifier_Letter
YYLVal := (Property_Keyword, Modifier_Letter);
return Token_Property_Keyword;
when 120 =>
-- Other_Letter
YYLVal := (Property_Keyword, Other_Letter);
return Token_Property_Keyword;
when 121 =>
-- Titlecase_Letter
YYLVal := (Property_Keyword, Titlecase_Letter);
return Token_Property_Keyword;
when 122 =>
-- Uppercase_Letter
YYLVal := (Property_Keyword, Uppercase_Letter);
return Token_Property_Keyword;
when 123 =>
-- Mark
YYLVal := (Property_Keyword, Mark);
return Token_Property_Keyword;
when 124 =>
-- Spacing_Mark
YYLVal := (Property_Keyword, Spacing_Mark);
return Token_Property_Keyword;
when 125 =>
-- Enclosing_Mark
YYLVal := (Property_Keyword, Enclosing_Mark);
return Token_Property_Keyword;
when 126 =>
-- Nonspacing_Mark
YYLVal := (Property_Keyword, Nonspacing_Mark);
return Token_Property_Keyword;
when 127 =>
-- Number
YYLVal := (Property_Keyword, Number);
return Token_Property_Keyword;
when 128 =>
-- Decimal_Number
YYLVal := (Property_Keyword, Decimal_Number);
return Token_Property_Keyword;
when 129 =>
-- Letter_Number
YYLVal := (Property_Keyword, Letter_Number);
return Token_Property_Keyword;
when 130 =>
-- Other_Number
YYLVal := (Property_Keyword, Other_Number);
return Token_Property_Keyword;
when 131 =>
-- Punctuation
YYLVal := (Property_Keyword, Punctuation);
return Token_Property_Keyword;
when 132 =>
-- Connector_Punctuation
YYLVal := (Property_Keyword, Connector_Punctuation);
return Token_Property_Keyword;
when 133 =>
-- Dash_Punctuation
YYLVal := (Property_Keyword, Dash_Punctuation);
return Token_Property_Keyword;
when 134 =>
-- Close_Punctuation
YYLVal := (Property_Keyword, Close_Punctuation);
return Token_Property_Keyword;
when 135 =>
-- Final_Punctuation
YYLVal := (Property_Keyword, Final_Punctuation);
return Token_Property_Keyword;
when 136 =>
-- Initial_Punctuation
YYLVal := (Property_Keyword, Initial_Punctuation);
return Token_Property_Keyword;
when 137 =>
-- Other_Punctuation
YYLVal := (Property_Keyword, Other_Punctuation);
return Token_Property_Keyword;
when 138 =>
-- Open_Punctuation
YYLVal := (Property_Keyword, Open_Punctuation);
return Token_Property_Keyword;
when 139 =>
-- Symbol
YYLVal := (Property_Keyword, Symbol);
return Token_Property_Keyword;
when 140 =>
-- Currency_Symbol
YYLVal := (Property_Keyword, Currency_Symbol);
return Token_Property_Keyword;
when 141 =>
-- Modifier_Symbol
YYLVal := (Property_Keyword, Modifier_Symbol);
return Token_Property_Keyword;
when 142 =>
-- Math_Symbol
YYLVal := (Property_Keyword, Math_Symbol);
return Token_Property_Keyword;
when 143 =>
-- Other_Symbol
YYLVal := (Property_Keyword, Other_Symbol);
return Token_Property_Keyword;
when 144 =>
-- Separator
YYLVal := (Property_Keyword, Separator);
return Token_Property_Keyword;
when 145 =>
-- Line_Separator
YYLVal := (Property_Keyword, Line_Separator);
return Token_Property_Keyword;
when 146 =>
-- Paragraph_Separator
YYLVal := (Property_Keyword, Paragraph_Separator);
return Token_Property_Keyword;
when 147 =>
-- Space_Separator
YYLVal := (Property_Keyword, Space_Separator);
return Token_Property_Keyword;
when 148 =>
-- Pattern syntax character in property specification
YYError (Self, Unrecognized_Character_In_Property_Specification, 0);
return Error;
when 150 =>
-- Sequence of whitespaces is ignored in all modes
null;
when 151 =>
-- Single code point
declare
S : constant Wide_Wide_String := YYText;
begin
YYLVal := (Match_Code_Point, S (S'First));
return Token_Code_Point;
end;
when 152 =>
-- Special outside of sequence
YYError (Self, Unescaped_Pattern_Syntax_Character, YY_Back_Index);
return Error;
when 156 =>
-- End of data
return End_Of_Input;
when 157 =>
-- Unexprected end of literal
YYError (Self, Unexpected_End_Of_Literal, 0);
return Error;
when 158 =>
-- Unexpected and of character class
YYError (Self, Unexpected_End_Of_Character_Class, 0);
return Error;
when 159 =>
-- Unexpected end of multiplicity specifier
YYError (Self, Unexpected_End_Of_Multiplicity_Specifier, 0);
return Error;
when 160 =>
-- Unexpected end of comment
return Error;
when 161 =>
-- Unexpected end of string in property specification
YYError (Self, Unexpected_End_Of_Property_Specification, 0);
return Error;
when 162 =>
-- Unexpected end of string in property specification
YYError (Self, Unexpected_End_Of_Property_Specification, 0);
return Error;
pragma Style_Checks ("M79");
when others =>
raise Program_Error
with "Unhandled action"
& Integer'Image (YY_Action) & " in scanner";
end case;
end loop; -- end of loop waiting for end of file
end YYLex;
end Matreshka.Internals.Regexps.Compiler.Scanner;
|
-- $Header: /cf/ua/arcadia/alex-ayacc/ayacc/src/RCS/ayacc_separates.a,v 1.1 88/08/08 12:07:39 arcadia Exp $
--***************************************************************************
-- This file is subject to the Arcadia License Agreement.
--
-- (see notice in ayacc.a)
--
--***************************************************************************
-- Module : ayacc_separates.ada
-- Component of : ayacc
-- Version : 1.2
-- Date : 11/21/86 12:28:51
-- SCCS File : disk21~/rschm/hasee/sccs/ayacc/sccs/sxayacc_separates.ada
-- $Header: /cf/ua/arcadia/alex-ayacc/ayacc/src/RCS/ayacc_separates.a,v 1.1 88/08/08 12:07:39 arcadia Exp $
-- $Log: ayacc_separates.a,v $
--Revision 1.1 88/08/08 12:07:39 arcadia
--Initial revision
--
-- Revision 0.0 86/02/19 18:36:14 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.
--
-- Revision 0.1 88/03/16
-- Additional argument added to allow user to specify file extension
-- to be used for generated Ada files. -- kn
with String_Pkg; use String_Pkg;
separate (Ayacc)
procedure Initialize is
use File_Names, Options;
Input_File, Extension, Options : String_Type := Create ("");
type Switch is ( On , Off );
C_Lex_Flag,
Debug_Flag,
Summary_Flag,
-- UMASS CODES :
Error_Recovery_Flag,
-- END OF UMASS CODES.
Verbose_Flag : Switch;
Invalid_Command_Line : exception;
procedure Get_Arguments (File : out String_Type;
C_Lex : out Switch;
Debug : out Switch;
Summary : out Switch;
Verbose : out Switch;
-- UMASS CODES :
Error_Recovery : out Switch;
-- END OF UMASS CODES.
Extension : out String_Type) is separate;
begin
Get_Arguments (Input_File,
C_Lex_Flag,
Debug_Flag,
Summary_Flag,
Verbose_Flag,
-- UMASS CODES :
Error_Recovery_Flag,
-- END OF UMASS CODES.
Extension);
New_Line;
Put_Line (" Ayacc (File => """ & Value (Input_File) & """,");
Put_Line (" C_Lex => " &
Value (Mixed (Switch'Image(C_Lex_Flag))) & ',');
Put_Line (" Debug => " &
Value (Mixed (Switch'Image(Debug_Flag))) & ',');
Put_Line (" Summary => " &
Value (Mixed (Switch'Image(Summary_Flag))) & ',');
Put_Line (" Verbose => " &
Value (Mixed (Switch'Image(Verbose_Flag))) & ",");
-- UMASS CODES :
Put_Line (" Error_Recovery => " &
Value (Mixed (Switch'Image(Error_Recovery_Flag))) & ",");
-- END OF UMASS CODES.
Put_Line (" Extension => """ & Value (Extension) & """);");
New_Line;
if C_Lex_Flag = On then
Options := Options & Create ("i");
end if;
if Debug_Flag = On then
Options := Options & Create ("d");
end if;
if Summary_Flag = On then
Options := Options & Create ("s");
end if;
if Verbose_Flag = On then
Options := Options & Create ("v");
end if;
-- UMASS CODES :
if Error_Recovery_Flag = On then
Options := Options & Create ("e");
end if;
-- END OF UMASS CODES.
Set_File_Names (Value (Input_File), Value(Extension));
Set_Options (Value (Options));
exception
when Invalid_Command_Line =>
raise Illegal_Argument_List;
end Initialize;
separate (Ayacc)
procedure Print_Statistics is
use Text_IO, Parse_Table, Rule_Table, Symbol_Table;
begin
if Options.Summary then
Put_Line(Rule'Image(Last_Rule - First_Rule + 1) & " Productions");
Put_Line(Grammar_Symbol'Image
(Last_Symbol(Nonterminal) - First_Symbol(Nonterminal) + 1) &
" Nonterminals");
Put_Line(Grammar_Symbol'Image
(Last_Symbol(Terminal) - First_Symbol(Terminal) + 1) &
" Terminals");
Put_Line(Integer'Image(Number_of_States) & " States");
Put_Line (Integer'Image(Shift_Reduce_Conflicts) &
" Shift/Reduce conflicts");
Put_Line (Integer'Image(Reduce_Reduce_Conflicts) &
" Reduce/Reduce conflicts");
else
if Shift_Reduce_Conflicts /= 0 then
Put_Line (Integer'Image(Shift_Reduce_Conflicts) &
" Shift/Reduce Conflicts");
end if;
if Reduce_Reduce_Conflicts /= 0 then
Put_Line (Integer'Image(Reduce_Reduce_Conflicts) &
" Reduce/Reduce Conflicts");
end if;
end if;
end Print_Statistics;
with Command_Line_Interface; use Command_Line_Interface;
with String_Pkg; use String_Pkg;
--VAX with Vms_Lib;
separate (Ayacc.Initialize)
procedure Get_Arguments (File : out String_Type;
C_Lex : out Switch;
Debug : out Switch;
Summary : out Switch;
Verbose : out Switch;
-- UMASS CODES :
Error_Recovery : out Switch;
-- END OF UMASS CODES.
Extension : out String_Type) is
C_Lex_Argument : String_Type;
Debug_Argument : String_Type;
Summary_Argument : String_Type;
Verbose_Argument : String_Type;
-- UMASS CODES :
Error_Recovery_Argument : String_Type;
-- END OF UMASS CODES.
Positional : Natural := 0;
-- Number of positional parameters
Total : Natural := 0;
-- Total number of parameters
Max_Parameters : constant := 7;
Incorrect_Call : exception;
function Convert_Switch is new
Convert (Parameter_Type => Switch,
Type_Name => "Switch");
procedure Put_Help_Message is
begin
New_Line;
Put_Line (" -- Ayacc: An Ada Parser Generator.");
New_Line;
Put_Line (" type Switch is (On, Off);");
New_Line;
Put_Line (" procedure Ayacc (File : in String;");
Put_Line (" C_Lex : in Switch := Off;");
Put_Line (" Debug : in Switch := Off;");
Put_Line (" Summary : in Switch := On;");
Put_Line (" Verbose : in Switch := Off;");
-- UMASS CODES :
Put_Line (" Error_Recovery : in Switch := Off;");
-- END OF UMASS CODES.
Put_Line (" Extension : in String := "".ada"");");
New_Line;
Put_Line (" -- File Specifies the Ayacc Input Source File.");
Put_Line (" -- C_Lex Specifies the Generation of a 'C' Lex Interface.");
Put_Line (" -- Debug Specifies the Production of Debugging Output");
Put_Line (" -- By the Generated Parser.");
Put_Line (" -- Summary Specifies the Printing of Statistics About the");
Put_Line (" -- Generated Parser.");
Put_Line (" -- Verbose Specifies the Production of a Human Readable");
Put_Line (" -- Report of States in the Generated Parser.");
-- UMASS CODES :
Put_Line (" -- Error_Recovery Specifies the Generation of extension of");
Put_Line (" -- error recovery.");
-- END OF UMASS CODES.
Put_Line (" -- Extension Specifies the file extension to be used for");
Put_Line (" generated Ada files.");
New_Line;
end Put_Help_Message;
begin
--VAX Vms_Lib.Set_Error;
Command_Line_Interface.Initialize (Tool_Name => "Ayacc");
Positional := Positional_Arg_Count;
Total := Named_Arg_Count + Positional;
if Total = 0 then
raise Incorrect_Call;
elsif Total > Max_Parameters then
Put_Line ("Ayacc: Too many parameters.");
raise Incorrect_Call;
end if;
-- Get named values
File := Named_Arg_Value ("File", "");
C_Lex_Argument := Named_Arg_Value ("C_Lex", "Off");
Debug_Argument := Named_Arg_Value ("Debug", "Off");
Summary_Argument := Named_Arg_Value ("Summary", "On");
Verbose_Argument := Named_Arg_Value ("Verbose", "Off");
-- UMASS CODES :
Error_Recovery_Argument := Named_Arg_Value ("Error_Recovery", "Off");
-- END OF UMASS CODES.
Extension := Named_Arg_Value ("Extension", ".ada");
-- Get any positional associations
if Positional >= 1 then
File := Positional_Arg_Value (1);
if Positional >= 2 then
C_Lex_Argument := Positional_Arg_Value (2);
if Positional >= 3 then
Debug_Argument := Positional_Arg_Value (3);
if Positional >= 4 then
Summary_Argument := Positional_Arg_Value (4);
if Positional >= 5 then
Verbose_Argument := Positional_Arg_Value (5);
-- UMASS CODES :
if Positional >= 6 then
Error_Recovery_Argument := Positional_Arg_Value (5);
-- END OF UMASS CODES.
if Positional = Max_Parameters then
Extension := Positional_Arg_Value (Max_Parameters);
end if;
-- UMASS CODES :
end if;
-- END OF UMASS CODES.
end if;
end if;
end if;
end if;
end if;
Command_Line_Interface.Finalize;
C_Lex := Convert_Switch (Value (C_Lex_Argument));
Debug := Convert_Switch (Value (Debug_Argument));
Summary := Convert_Switch (Value (Summary_Argument));
Verbose := Convert_Switch (Value (Verbose_Argument));
-- UMASS CODES :
Error_Recovery := Convert_Switch (Value (Error_Recovery_Argument));
-- END OF UMASS CODES.
exception
when Incorrect_Call | Invalid_Parameter |
Invalid_Parameter_Order | Missing_Positional_Arg |
Unreferenced_Named_Arg | Invalid_Named_Association |
Unbalanced_Parentheses =>
Put_Help_Message ;
raise Invalid_Command_Line ;
end Get_Arguments;
|
with NRF52_DK.IOs;
package SteeringControl is --Servo and Motor controls --
procedure Servocontrol(ServoPin : NRF52_DK.IOs.Pin_Id; Value : NRF52_DK.IOs.Analog_Value); --- Servo--
procedure Direction_Controller; --Left or right write to servo to turn car --
procedure Motor_Controller; --Motor forward/backward --
procedure Crash_Stop_Forward; --When triggering emergency stop --
procedure Crash_Stop_Backward; --When triggering emergency stop --
end SteeringControl;
|
-----------------------------------------------------------------------
-- Babel.Base.Models -- Babel.Base.Models
-----------------------------------------------------------------------
-- File generated by ada-gen DO NOT MODIFY
-- Template used: templates/model/package-spec.xhtml
-- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095
-----------------------------------------------------------------------
-- 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.
-----------------------------------------------------------------------
pragma Warnings (Off, "unit * is not referenced");
with ADO.Sessions;
with ADO.Objects;
with ADO.Statements;
with ADO.SQL;
with ADO.Schemas;
with Ada.Calendar;
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded;
with Util.Beans.Objects;
with Util.Beans.Basic.Lists;
pragma Warnings (On, "unit * is not referenced");
package Babel.Base.Models is
type Store_Ref is new ADO.Objects.Object_Ref with null record;
type Backup_Ref is new ADO.Objects.Object_Ref with null record;
type FileSet_Ref is new ADO.Objects.Object_Ref with null record;
type Path_Ref is new ADO.Objects.Object_Ref with null record;
type File_Ref is new ADO.Objects.Object_Ref with null record;
-- Create an object key for Store.
function Store_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Store from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Store_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Store : constant Store_Ref;
function "=" (Left, Right : Store_Ref'Class) return Boolean;
--
procedure Set_Id (Object : in out Store_Ref;
Value : in ADO.Identifier);
--
function Get_Id (Object : in Store_Ref)
return ADO.Identifier;
--
procedure Set_Name (Object : in out Store_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Name (Object : in out Store_Ref;
Value : in String);
--
function Get_Name (Object : in Store_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Name (Object : in Store_Ref)
return String;
--
procedure Set_Parameter (Object : in out Store_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Parameter (Object : in out Store_Ref;
Value : in String);
--
function Get_Parameter (Object : in Store_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Parameter (Object : in Store_Ref)
return String;
--
procedure Set_Server (Object : in out Store_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Server (Object : in out Store_Ref;
Value : in String);
--
function Get_Server (Object : in Store_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Server (Object : in Store_Ref)
return String;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Store_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Store_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Store_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Store_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Store_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Store_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
STORE_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Store_Ref);
-- Copy of the object.
procedure Copy (Object : in Store_Ref;
Into : in out Store_Ref);
-- Create an object key for Backup.
function Backup_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Backup from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Backup_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Backup : constant Backup_Ref;
function "=" (Left, Right : Backup_Ref'Class) return Boolean;
--
procedure Set_Id (Object : in out Backup_Ref;
Value : in ADO.Identifier);
--
function Get_Id (Object : in Backup_Ref)
return ADO.Identifier;
--
procedure Set_Create_Date (Object : in out Backup_Ref;
Value : in Ada.Calendar.Time);
--
function Get_Create_Date (Object : in Backup_Ref)
return Ada.Calendar.Time;
--
procedure Set_Store (Object : in out Backup_Ref;
Value : in Babel.Base.Models.Store_Ref'Class);
--
function Get_Store (Object : in Backup_Ref)
return Babel.Base.Models.Store_Ref'Class;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Backup_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Backup_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Backup_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Backup_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Backup_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Backup_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
BACKUP_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Backup_Ref);
-- Copy of the object.
procedure Copy (Object : in Backup_Ref;
Into : in out Backup_Ref);
-- Create an object key for FileSet.
function FileSet_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for FileSet from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function FileSet_Key (Id : in String) return ADO.Objects.Object_Key;
Null_FileSet : constant FileSet_Ref;
function "=" (Left, Right : FileSet_Ref'Class) return Boolean;
--
procedure Set_Id (Object : in out Fileset_Ref;
Value : in ADO.Identifier);
--
function Get_Id (Object : in Fileset_Ref)
return ADO.Identifier;
--
procedure Set_First_Id (Object : in out Fileset_Ref;
Value : in ADO.Identifier);
--
function Get_First_Id (Object : in Fileset_Ref)
return ADO.Identifier;
--
procedure Set_Last_Id (Object : in out Fileset_Ref;
Value : in ADO.Identifier);
--
function Get_Last_Id (Object : in Fileset_Ref)
return ADO.Identifier;
--
procedure Set_Backup (Object : in out Fileset_Ref;
Value : in Babel.Base.Models.Backup_Ref'Class);
--
function Get_Backup (Object : in Fileset_Ref)
return Babel.Base.Models.Backup_Ref'Class;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Fileset_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Fileset_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Fileset_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Fileset_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Fileset_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Fileset_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
FILESET_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Fileset_Ref);
-- Copy of the object.
procedure Copy (Object : in Fileset_Ref;
Into : in out Fileset_Ref);
-- Create an object key for Path.
function Path_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Path from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Path_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Path : constant Path_Ref;
function "=" (Left, Right : Path_Ref'Class) return Boolean;
-- Set the path identifier.
procedure Set_Id (Object : in out Path_Ref;
Value : in ADO.Identifier);
-- Get the path identifier.
function Get_Id (Object : in Path_Ref)
return ADO.Identifier;
-- Set the file or path name.
procedure Set_Name (Object : in out Path_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Name (Object : in out Path_Ref;
Value : in String);
-- Get the file or path name.
function Get_Name (Object : in Path_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Name (Object : in Path_Ref)
return String;
--
procedure Set_Store (Object : in out Path_Ref;
Value : in Babel.Base.Models.Store_Ref'Class);
--
function Get_Store (Object : in Path_Ref)
return Babel.Base.Models.Store_Ref'Class;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Path_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Path_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Path_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Path_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Path_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Path_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
PATH_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Path_Ref);
-- Copy of the object.
procedure Copy (Object : in Path_Ref;
Into : in out Path_Ref);
-- Create an object key for File.
function File_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for File from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function File_Key (Id : in String) return ADO.Objects.Object_Key;
Null_File : constant File_Ref;
function "=" (Left, Right : File_Ref'Class) return Boolean;
-- Set the file identifier.
procedure Set_Id (Object : in out File_Ref;
Value : in ADO.Identifier);
-- Get the file identifier.
function Get_Id (Object : in File_Ref)
return ADO.Identifier;
-- Set the file size.
procedure Set_Size (Object : in out File_Ref;
Value : in Integer);
-- Get the file size.
function Get_Size (Object : in File_Ref)
return Integer;
-- Set the file modification date.
procedure Set_Date (Object : in out File_Ref;
Value : in Ada.Calendar.Time);
-- Get the file modification date.
function Get_Date (Object : in File_Ref)
return Ada.Calendar.Time;
-- Set the file SHA1 signature.
procedure Set_Sha1 (Object : in out File_Ref;
Value : in ADO.Blob_Ref);
-- Get the file SHA1 signature.
function Get_Sha1 (Object : in File_Ref)
return ADO.Blob_Ref;
--
procedure Set_Directory (Object : in out File_Ref;
Value : in Babel.Base.Models.Path_Ref'Class);
--
function Get_Directory (Object : in File_Ref)
return Babel.Base.Models.Path_Ref'Class;
--
procedure Set_Name (Object : in out File_Ref;
Value : in Babel.Base.Models.Path_Ref'Class);
--
function Get_Name (Object : in File_Ref)
return Babel.Base.Models.Path_Ref'Class;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out File_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out File_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out File_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out File_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out File_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in File_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
FILE_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out File_Ref);
-- Copy of the object.
procedure Copy (Object : in File_Ref;
Into : in out File_Ref);
private
STORE_NAME : aliased constant String := "babel_store";
COL_0_1_NAME : aliased constant String := "id";
COL_1_1_NAME : aliased constant String := "name";
COL_2_1_NAME : aliased constant String := "parameter";
COL_3_1_NAME : aliased constant String := "server";
STORE_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 4,
Table => STORE_NAME'Access,
Members => (
1 => COL_0_1_NAME'Access,
2 => COL_1_1_NAME'Access,
3 => COL_2_1_NAME'Access,
4 => COL_3_1_NAME'Access
)
);
STORE_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= STORE_DEF'Access;
Null_Store : constant Store_Ref
:= Store_Ref'(ADO.Objects.Object_Ref with others => <>);
type Store_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => STORE_DEF'Access)
with record
Name : Ada.Strings.Unbounded.Unbounded_String;
Parameter : Ada.Strings.Unbounded.Unbounded_String;
Server : Ada.Strings.Unbounded.Unbounded_String;
end record;
type Store_Access is access all Store_Impl;
overriding
procedure Destroy (Object : access Store_Impl);
overriding
procedure Find (Object : in out Store_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Store_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Store_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Store_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Store_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Store_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Store_Ref'Class;
Impl : out Store_Access);
BACKUP_NAME : aliased constant String := "babel_backup";
COL_0_2_NAME : aliased constant String := "id";
COL_1_2_NAME : aliased constant String := "create_date";
COL_2_2_NAME : aliased constant String := "store_id";
BACKUP_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 3,
Table => BACKUP_NAME'Access,
Members => (
1 => COL_0_2_NAME'Access,
2 => COL_1_2_NAME'Access,
3 => COL_2_2_NAME'Access
)
);
BACKUP_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= BACKUP_DEF'Access;
Null_Backup : constant Backup_Ref
:= Backup_Ref'(ADO.Objects.Object_Ref with others => <>);
type Backup_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => BACKUP_DEF'Access)
with record
Create_Date : Ada.Calendar.Time;
Store : Babel.Base.Models.Store_Ref;
end record;
type Backup_Access is access all Backup_Impl;
overriding
procedure Destroy (Object : access Backup_Impl);
overriding
procedure Find (Object : in out Backup_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Backup_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Backup_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Backup_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Backup_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Backup_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Backup_Ref'Class;
Impl : out Backup_Access);
FILESET_NAME : aliased constant String := "babel_fileset";
COL_0_3_NAME : aliased constant String := "id";
COL_1_3_NAME : aliased constant String := "first_id";
COL_2_3_NAME : aliased constant String := "last_id";
COL_3_3_NAME : aliased constant String := "backup_id";
FILESET_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 4,
Table => FILESET_NAME'Access,
Members => (
1 => COL_0_3_NAME'Access,
2 => COL_1_3_NAME'Access,
3 => COL_2_3_NAME'Access,
4 => COL_3_3_NAME'Access
)
);
FILESET_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= FILESET_DEF'Access;
Null_FileSet : constant FileSet_Ref
:= FileSet_Ref'(ADO.Objects.Object_Ref with others => <>);
type Fileset_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => FILESET_DEF'Access)
with record
First_Id : ADO.Identifier;
Last_Id : ADO.Identifier;
Backup : Babel.Base.Models.Backup_Ref;
end record;
type Fileset_Access is access all Fileset_Impl;
overriding
procedure Destroy (Object : access Fileset_Impl);
overriding
procedure Find (Object : in out Fileset_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Fileset_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Fileset_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Fileset_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Fileset_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Fileset_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Fileset_Ref'Class;
Impl : out Fileset_Access);
PATH_NAME : aliased constant String := "babel_path";
COL_0_4_NAME : aliased constant String := "id";
COL_1_4_NAME : aliased constant String := "name";
COL_2_4_NAME : aliased constant String := "store_id";
PATH_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 3,
Table => PATH_NAME'Access,
Members => (
1 => COL_0_4_NAME'Access,
2 => COL_1_4_NAME'Access,
3 => COL_2_4_NAME'Access
)
);
PATH_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= PATH_DEF'Access;
Null_Path : constant Path_Ref
:= Path_Ref'(ADO.Objects.Object_Ref with others => <>);
type Path_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => PATH_DEF'Access)
with record
Name : Ada.Strings.Unbounded.Unbounded_String;
Store : Babel.Base.Models.Store_Ref;
end record;
type Path_Access is access all Path_Impl;
overriding
procedure Destroy (Object : access Path_Impl);
overriding
procedure Find (Object : in out Path_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Path_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Path_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Path_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Path_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Path_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Path_Ref'Class;
Impl : out Path_Access);
FILE_NAME : aliased constant String := "babel_file";
COL_0_5_NAME : aliased constant String := "id";
COL_1_5_NAME : aliased constant String := "size";
COL_2_5_NAME : aliased constant String := "date";
COL_3_5_NAME : aliased constant String := "sha1";
COL_4_5_NAME : aliased constant String := "directory_id";
COL_5_5_NAME : aliased constant String := "name_id";
FILE_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 6,
Table => FILE_NAME'Access,
Members => (
1 => COL_0_5_NAME'Access,
2 => COL_1_5_NAME'Access,
3 => COL_2_5_NAME'Access,
4 => COL_3_5_NAME'Access,
5 => COL_4_5_NAME'Access,
6 => COL_5_5_NAME'Access
)
);
FILE_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= FILE_DEF'Access;
Null_File : constant File_Ref
:= File_Ref'(ADO.Objects.Object_Ref with others => <>);
type File_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => FILE_DEF'Access)
with record
Size : Integer;
Date : Ada.Calendar.Time;
Sha1 : ADO.Blob_Ref;
Directory : Babel.Base.Models.Path_Ref;
Name : Babel.Base.Models.Path_Ref;
end record;
type File_Access is access all File_Impl;
overriding
procedure Destroy (Object : access File_Impl);
overriding
procedure Find (Object : in out File_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out File_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out File_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out File_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out File_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out File_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out File_Ref'Class;
Impl : out File_Access);
end Babel.Base.Models;
|
-----------------------------------------------------------------------------
-- Implementation of
-- Helpers package for different functions / procedures to minimize
-- code duplication
--
-- Copyright 2022 (C) Holger Rodriguez
--
-- SPDX-License-Identifier: BSD-3-Clause
--
with RP.Device;
with RP.Clock;
with ItsyBitsy;
with Pico;
with Tiny;
package body Helpers is
use HAL;
use EEPROM_I2C;
procedure Initialize_I2C (SDA : in out RP.GPIO.GPIO_Point;
SCL : in out RP.GPIO.GPIO_Point;
I2C_Port : in out RP.I2C_Master.I2C_Master_Port);
The_Trigger : RP.GPIO.GPIO_Point;
procedure Initialize (SDA : in out RP.GPIO.GPIO_Point;
SCL : in out RP.GPIO.GPIO_Point;
I2C_Port : in out RP.I2C_Master.I2C_Master_Port;
Trigger_Port : RP.GPIO.GPIO_Point;
Frequency : Natural) is
begin
-- standard initialization
RP.Clock.Initialize (Frequency);
RP.Clock.Enable (RP.Clock.PERI);
RP.Device.Timer.Enable;
RP.GPIO.Enable;
Initialize_I2C (SDA, SCL, I2C_Port);
The_Trigger := Trigger_Port;
-- define a trigger input to enable oscilloscope tracking
RP.GPIO.Configure (This => The_Trigger,
Mode => RP.GPIO.Input,
Pull => RP.GPIO.Pull_Down,
Func => RP.GPIO.SIO);
end Initialize;
Trigger : Boolean := False;
procedure Trigger_Enable is
begin
Trigger := True;
end Trigger_Enable;
procedure Trigger_Disable is
begin
Trigger := False;
end Trigger_Disable;
function Trigger_Is_Enabled return Boolean is
(Trigger);
procedure Wait_For_Trigger_Fired is
begin
if not Trigger_Is_Enabled then
return;
end if;
loop
exit when RP.GPIO.Get (The_Trigger);
end loop;
end Wait_For_Trigger_Fired;
procedure Wait_For_Trigger_Resume is
begin
if not Trigger_Is_Enabled then
return;
end if;
loop
exit when not RP.GPIO.Get (The_Trigger);
end loop;
end Wait_For_Trigger_Resume;
procedure Initialize_I2C
(SDA : in out RP.GPIO.GPIO_Point;
SCL : in out RP.GPIO.GPIO_Point;
I2C_Port : in out RP.I2C_Master.I2C_Master_Port) is
begin
-- configure the I2C port
SDA.Configure (Mode => RP.GPIO.Output,
Pull => RP.GPIO.Pull_Up,
Func => RP.GPIO.I2C);
SCL.Configure (Mode => RP.GPIO.Output,
Pull => RP.GPIO.Pull_Up,
Func => RP.GPIO.I2C);
I2C_Port.Configure (Baudrate => 400_000);
end Initialize_I2C;
procedure Fill_With (Fill_Data : out HAL.I2C.I2C_Data;
Byte : HAL.UInt8 := 16#FF#) is
begin
for Idx in Fill_Data'First .. Fill_Data'Last loop
Fill_Data (Idx) := Byte;
end loop;
end Fill_With;
procedure Check_Full_Size
(EEP : in out EEPROM_I2C.EEPROM_Memory'Class;
CB_LED_Off : LED_Off) is
Byte : HAL.UInt8;
Ref_Data : HAL.I2C.I2C_Data (1 .. Integer (EEP.Size_In_Bytes));
Read_Data : HAL.I2C.I2C_Data (1 .. Integer (EEP.Size_In_Bytes));
EE_Status : EEPROM_I2C.EEPROM_Operation_Result;
begin
EEPROM_I2C.Wipe (This => EEP,
Status => EE_Status);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
Byte := 0;
for Idx in Ref_Data'First .. Ref_Data'Last loop
Ref_Data (Idx) := Byte;
Byte := Byte + 1;
end loop;
EEPROM_I2C.Write (EEP,
Mem_Addr => 0,
Data => Ref_Data,
Status => EE_Status,
Timeout_MS => 0);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
EEPROM_I2C.Read (EEP,
Mem_Addr => 0,
Data => Read_Data,
Status => EE_Status,
Timeout_MS => 0);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
Verify_Data (Expected => Ref_Data,
Actual => Read_Data,
CB_LED_Off => CB_LED_Off);
end Check_Full_Size;
procedure Check_Header_Only
(EEP : in out EEPROM_I2C.EEPROM_Memory'Class;
CB_LED_Off : LED_Off) is
Byte : HAL.UInt8;
Header_Data : HAL.I2C.I2C_Data (1
..
Integer (EEP.C_Bytes_Per_Page) / 2);
Mem_Addr : constant HAL.UInt16 := EEP.C_Bytes_Per_Page / 2 - 1;
Ref_Data : HAL.I2C.I2C_Data (1 .. Integer (EEP.Size_In_Bytes));
Read_Data : HAL.I2C.I2C_Data (1 .. Integer (EEP.Size_In_Bytes));
EE_Status : EEPROM_I2C.EEPROM_Operation_Result;
begin
EEPROM_I2C.Wipe (This => EEP,
Status => EE_Status);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
Helpers.Fill_With (Fill_Data => Ref_Data);
Byte := 16#01#;
for Idx in Header_Data'First .. Header_Data'Last loop
Header_Data (Idx) := Byte;
Ref_Data (Integer (Mem_Addr) + Idx) := Header_Data (Idx);
Byte := Byte + 1;
end loop;
EEPROM_I2C.Write (EEP,
Mem_Addr => Mem_Addr,
Data => Header_Data,
Status => EE_Status,
Timeout_MS => 0);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
EEPROM_I2C.Read (EEP,
Mem_Addr => 0,
Data => Read_Data,
Status => EE_Status,
Timeout_MS => 0);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
Verify_Data (Expected => Ref_Data,
Actual => Read_Data,
CB_LED_Off => CB_LED_Off);
end Check_Header_Only;
procedure Check_Header_And_Full_Pages
(EEP : in out EEPROM_I2C.EEPROM_Memory'Class;
CB_LED_Off : LED_Off) is
Byte : HAL.UInt8;
Ref_Data : HAL.I2C.I2C_Data (1 .. Integer (EEP.Size_In_Bytes));
Read_Data : HAL.I2C.I2C_Data (1 .. Integer (EEP.Size_In_Bytes));
EE_Status : EEPROM_I2C.EEPROM_Operation_Result;
EE_Data : HAL.I2C.I2C_Data (1
..
Integer (EEP.C_Bytes_Per_Page) / 2 +
2 * Integer (EEP.C_Bytes_Per_Page));
Mem_Addr : constant HAL.UInt16 := EEP.C_Bytes_Per_Page / 2 - 1;
begin
EEPROM_I2C.Wipe (This => EEP,
Status => EE_Status);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
Helpers.Fill_With (Fill_Data => Ref_Data);
Byte := 16#01#;
for Idx in EE_Data'First .. EE_Data'Last loop
EE_Data (Idx) := Byte;
Ref_Data (Integer (Mem_Addr) + Idx) := EE_Data (Idx);
Byte := Byte + 1;
end loop;
EEPROM_I2C.Write (EEP,
Mem_Addr => Mem_Addr,
Data => EE_Data,
Status => EE_Status,
Timeout_MS => 0);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
EEPROM_I2C.Read (EEP,
Mem_Addr => 0,
Data => Read_Data,
Status => EE_Status,
Timeout_MS => 0);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
Helpers.Verify_Data (Expected => Ref_Data,
Actual => Read_Data,
CB_LED_Off => Helpers.Pico_Led_Off'Access);
end Check_Header_And_Full_Pages;
procedure Check_Header_And_Tailing
(EEP : in out EEPROM_I2C.EEPROM_Memory'Class;
CB_LED_Off : LED_Off) is
Byte : HAL.UInt8;
Ref_Data : HAL.I2C.I2C_Data (1 .. Integer (EEP.Size_In_Bytes));
Read_Data : HAL.I2C.I2C_Data (1 .. Integer (EEP.Size_In_Bytes));
EE_Status : EEPROM_I2C.EEPROM_Operation_Result;
EE_Data : HAL.I2C.I2C_Data (1
..
1 * Integer (EEP.C_Bytes_Per_Page));
Mem_Addr : constant HAL.UInt16 := EEP.C_Bytes_Per_Page / 2 - 1;
begin
EEPROM_I2C.Wipe (This => EEP,
Status => EE_Status);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
Helpers.Fill_With (Fill_Data => Ref_Data);
Byte := 16#01#;
for Idx in EE_Data'First .. EE_Data'Last loop
EE_Data (Idx) := Byte;
Ref_Data (Integer (Mem_Addr) + Idx) := EE_Data (Idx);
Byte := Byte + 1;
end loop;
EEPROM_I2C.Write (EEP,
Mem_Addr => Mem_Addr,
Data => EE_Data,
Status => EE_Status,
Timeout_MS => 0);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
EEPROM_I2C.Read (EEP,
Mem_Addr => 0,
Data => Read_Data,
Status => EE_Status,
Timeout_MS => 0);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
Helpers.Verify_Data (Expected => Ref_Data,
Actual => Read_Data,
CB_LED_Off => CB_LED_Off);
end Check_Header_And_Tailing;
procedure Check_Header_And_Full_Pages_And_Tailing
(EEP : in out EEPROM_I2C.EEPROM_Memory'Class;
CB_LED_Off : LED_Off) is
Byte : HAL.UInt8;
Ref_Data : HAL.I2C.I2C_Data (1 .. Integer (EEP.Size_In_Bytes));
Read_Data : HAL.I2C.I2C_Data (1 .. Integer (EEP.Size_In_Bytes));
EE_Status : EEPROM_I2C.EEPROM_Operation_Result;
EE_Data : HAL.I2C.I2C_Data (1
..
2 * Integer (EEP.C_Bytes_Per_Page) +
Integer (EEP.C_Bytes_Per_Page) / 2);
Mem_Addr : constant HAL.UInt16 := EEP.C_Bytes_Per_Page / 2 - 1;
begin
EEPROM_I2C.Wipe (This => EEP,
Status => EE_Status);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
Helpers.Fill_With (Fill_Data => Ref_Data);
Byte := 16#01#;
for Idx in EE_Data'First .. EE_Data'Last loop
EE_Data (Idx) := Byte;
Ref_Data (Integer (Mem_Addr) + Idx) := EE_Data (Idx);
Byte := Byte + 1;
end loop;
EEPROM_I2C.Write (EEP,
Mem_Addr => Mem_Addr,
Data => EE_Data,
Status => EE_Status,
Timeout_MS => 0);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
EEPROM_I2C.Read (EEP,
Mem_Addr => 0,
Data => Read_Data,
Status => EE_Status,
Timeout_MS => 0);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
Helpers.Verify_Data (Expected => Ref_Data,
Actual => Read_Data,
CB_LED_Off => CB_LED_Off);
end Check_Header_And_Full_Pages_And_Tailing;
procedure Check_Full_Pages
(EEP : in out EEPROM_I2C.EEPROM_Memory'Class;
CB_LED_Off : LED_Off) is
Byte : HAL.UInt8;
Ref_Data : HAL.I2C.I2C_Data (1 .. Integer (EEP.Size_In_Bytes));
Read_Data : HAL.I2C.I2C_Data (1 .. Integer (EEP.Size_In_Bytes));
EE_Status : EEPROM_I2C.EEPROM_Operation_Result;
EE_Data : HAL.I2C.I2C_Data (1
..
4 * Integer (EEP.C_Bytes_Per_Page));
Mem_Addr : constant HAL.UInt16 := 2 * EEP.C_Bytes_Per_Page;
begin
EEPROM_I2C.Wipe (This => EEP,
Status => EE_Status);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
Helpers.Fill_With (Fill_Data => Ref_Data);
Byte := 16#01#;
for Idx in EE_Data'First .. EE_Data'Last loop
EE_Data (Idx) := Byte;
Ref_Data (Integer (Mem_Addr) + Idx) := EE_Data (Idx);
Byte := Byte + 1;
end loop;
EEPROM_I2C.Write (EEP,
Mem_Addr => Mem_Addr,
Data => EE_Data,
Status => EE_Status,
Timeout_MS => 0);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
EEPROM_I2C.Read (EEP,
Mem_Addr => 0,
Data => Read_Data,
Status => EE_Status,
Timeout_MS => 0);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
Helpers.Verify_Data (Expected => Ref_Data,
Actual => Read_Data,
CB_LED_Off => CB_LED_Off);
end Check_Full_Pages;
procedure Check_Full_Pages_And_Tailing
(EEP : in out EEPROM_I2C.EEPROM_Memory'Class;
CB_LED_Off : LED_Off) is
Byte : HAL.UInt8;
Ref_Data : HAL.I2C.I2C_Data (1 .. Integer (EEP.Size_In_Bytes));
Read_Data : HAL.I2C.I2C_Data (1 .. Integer (EEP.Size_In_Bytes));
EE_Status : EEPROM_I2C.EEPROM_Operation_Result;
EE_Data : HAL.I2C.I2C_Data (1
..
2 * Integer (EEP.C_Bytes_Per_Page) +
Integer (EEP.C_Bytes_Per_Page) / 2);
Mem_Addr : constant HAL.UInt16 := 2 * EEP.C_Bytes_Per_Page;
begin
EEPROM_I2C.Wipe (This => EEP,
Status => EE_Status);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
Helpers.Fill_With (Fill_Data => Ref_Data);
Byte := 16#01#;
for Idx in EE_Data'First .. EE_Data'Last loop
EE_Data (Idx) := Byte;
Ref_Data (Integer (Mem_Addr) + Idx) := EE_Data (Idx);
Byte := Byte + 1;
end loop;
EEPROM_I2C.Write (EEP,
Mem_Addr => Mem_Addr,
Data => EE_Data,
Status => EE_Status,
Timeout_MS => 0);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
EEPROM_I2C.Read (EEP,
Mem_Addr => 0,
Data => Read_Data,
Status => EE_Status,
Timeout_MS => 0);
if EE_Status.E_Status /= EEPROM_I2C.Ok then
CB_LED_Off.all;
loop
null;
end loop;
end if;
Helpers.Verify_Data (Expected => Ref_Data,
Actual => Read_Data,
CB_LED_Off => CB_LED_Off);
end Check_Full_Pages_And_Tailing;
procedure Verify_Data (Expected : HAL.I2C.I2C_Data;
Actual : HAL.I2C.I2C_Data;
CB_LED_Off : LED_Off) is
begin
for Idx in Expected'First .. Expected'Last loop
if Actual (Idx) /= Expected (Idx) then
CB_LED_Off.all;
loop
null;
end loop;
end if;
end loop;
end Verify_Data;
procedure ItsyBitsy_Led_Off is
begin
ItsyBitsy.LED.Clear;
end ItsyBitsy_Led_Off;
procedure Pico_Led_Off is
begin
Pico.LED.Clear;
end Pico_Led_Off;
procedure Tiny_Led_Off is
begin
Tiny.Switch_Off (This => Tiny.LED_Red);
end Tiny_Led_Off;
end Helpers;
|
with Ada.Text_IO;
-- with Mes_Tasches_P;
with Input_1;
-- procedure Client is
procedure Input is
begin
Ada.Text_IO.Put_Line ("Tasks won't stop, kill it with CTRL-C");
-- Mes_Tasches_P.Ma_Tasche.Accepter (Continuer => True);
Input_1.Ma_Tasche.Accepter (Continuer => True);
end Input;
-- end Client;
|
------------------------------------------------------------------------------
-- 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 Ada.Calendar;
with Ada.Strings.Unbounded;
with Ada.Unchecked_Deallocation;
with Ada.Unchecked_Conversion;
with Interfaces.C.Strings;
with System;
with GNAT.OS_Lib;
with GNAT.Expect;
with GNAT.Regpat;
with GNAT.Strings;
with GNATCOLL.VFS;
with GNATCOLL.Xref;
package Basic_Types is
subtype Pixmap_Array is Interfaces.C.Strings.chars_ptr_array (0 .. 0);
type Pixmap_Access is access all Pixmap_Array;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(GNAT.Strings.String_List, GNAT.Strings.String_List_Access);
-- Free the array, but not the strings it contains.
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(GNAT.Regpat.Pattern_Matcher, GNAT.Expect.Pattern_Matcher_Access);
subtype Unchecked_String is String (Positive);
pragma Suppress (All_Checks, Unchecked_String);
-- Do not use this type directly, use Unchecked_String_Access instead.
type Unchecked_String_Access is access all Unchecked_String;
-- For efficiency reasons, use this type compatible with C char*,
-- so that C strings can be reused without making extra copies.
function To_Unchecked_String is new Ada.Unchecked_Conversion
(System.Address, Unchecked_String_Access);
function To_Unchecked_String is new Ada.Unchecked_Conversion
(Interfaces.C.Strings.chars_ptr, Unchecked_String_Access);
procedure Free is new Ada.Unchecked_Deallocation
(Unchecked_String, Unchecked_String_Access);
subtype UTF8_String is String;
subtype UTF8_Unbounded_String is Ada.Strings.Unbounded.Unbounded_String;
function Is_Equal
(List1, List2 : GNAT.OS_Lib.Argument_List;
Case_Sensitive : Boolean := True;
Ordered : Boolean := False) return Boolean;
-- Return True if List1 has the same contents of List2 (no matter the order
-- of the strings in both arrays).
-- If Ordered is true, then each item of List1 much match the
-- corresponoding item of List2
function Contains
(List : GNAT.OS_Lib.Argument_List;
Str : String;
Case_Sensitive : Boolean := True) return Boolean;
-- Return True if List contains Str
type Date_Type is record
Year : Ada.Calendar.Year_Number;
Month : Ada.Calendar.Month_Number;
Day : Ada.Calendar.Day_Number;
end record;
Null_Date : constant Date_Type := Date_Type'
(Year => Ada.Calendar.Year_Number'First,
Month => Ada.Calendar.Month_Number'First,
Day => Ada.Calendar.Day_Number'First);
function "<" (Left, Right : Date_Type) return Boolean;
-- Compares the two dates, return true if left is before right
function "<=" (Left, Right : Date_Type) return Boolean;
function ">" (Left, Right : Date_Type) return Boolean;
function ">=" (Left, Right : Date_Type) return Boolean;
--------------
-- Entities --
--------------
type File_Error_Reporter_Record is abstract tagged null record;
type File_Error_Reporter is access all File_Error_Reporter_Record'Class;
procedure Error
(Report : in out File_Error_Reporter_Record;
File : GNATCOLL.VFS.Virtual_File) is abstract;
-- Used to report errors while parsing files
------------------
-- Column types --
------------------
subtype Visible_Column_Type is GNATCOLL.Xref.Visible_Column;
-- Visible_Column_Type correspond to user perception of the columns, ie,
-- after TAB expansion. The first character in the line has a value of 1.
-- Columns are counted in terms of UT8 characters.
type Character_Offset_Type is new Integer;
-- Character_Offset_Type indicates the number of characters between the
-- beginning of the line and the character. First character has offset 0.
type String_Index_Type is new Natural;
-- String_Index_Type indicates a index in a string, in bytes, starts at 1.
-----------------
-- File caches --
-----------------
type Packed_Boolean_Array is array (Positive range <>) of Boolean;
pragma Pack (Packed_Boolean_Array);
type Packed_Boolean_Access is access Packed_Boolean_Array;
procedure Free is new Ada.Unchecked_Deallocation
(Packed_Boolean_Array, Packed_Boolean_Access);
type File_Cache;
type File_Cache_List is access File_Cache;
type File_Cache is record
File_Name : GNAT.Strings.String_Access := null;
-- The full name (including directory) for the file associated with
-- this record.
Line_Has_Code : Packed_Boolean_Access := null;
Line_Parsed : Packed_Boolean_Access := null;
File_Contents : GNAT.Strings.String_Access := null;
-- The contents of the file. To save some memory, this is not allocated
-- for files that can be found on the local disk. However, it is used
-- for files that had to be downloaded from a remote machine.
CR_Stripped : Boolean := False;
-- True if the carriage return characters were stripped when the file
-- was read.
Next : File_Cache_List := null;
-- Next file in the cache list
end record;
-- Data associated with each file, and that contain cached data for the
-- file.
-- Line_Parsed indicates whether the line at a given index has been parsed.
-- This array is freed once the parsing has been finished (and in the
-- case Current_Line points to the last line with a breakpoint.
procedure Free is new
Ada.Unchecked_Deallocation (File_Cache, File_Cache_List);
end Basic_Types;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ E L A B --
-- --
-- S p e c --
-- --
-- Copyright (C) 1997-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains routines which handle access-before-elaboration
-- run-time checks and compile-time diagnostics. See the body for details.
with Types; use Types;
package Sem_Elab is
-----------
-- Types --
-----------
-- The following type classifies the various enclosing levels used in ABE
-- diagnostics.
type Enclosing_Level_Kind is
(Declaration_Level,
-- A construct is at the "declaration level" when it appears within the
-- declarations of a block statement, an entry body, a subprogram body,
-- or a task body, ignoring enclosing packages. Example:
-- package Pack is
-- procedure Proc is -- subprogram body
-- package Nested is -- enclosing package ignored
-- X ... -- at declaration level
Generic_Spec_Level,
Generic_Body_Level,
-- A construct is at the "generic level" when it appears in a
-- generic package library unit, ignoring enclosing packages. Example:
-- generic
-- package Pack is -- generic package spec
-- package Nested is -- enclosing package ignored
-- X ... -- at generic library level
Instantiation_Level,
-- A construct is at the "instantiation library level" when it appears
-- in a library unit which is also an instantiation. Example:
-- package Inst is new Gen; -- at instantiation level
Library_Spec_Level,
Library_Body_Level,
-- A construct is at the "library level" when it appears in a package
-- library unit, ignoring enclosing packages. Example:
-- package body Pack is -- package body
-- package Nested is -- enclosing package ignored
-- X ... -- at library level
No_Level);
-- This value is used to indicate that none of the levels above are in
-- effect.
subtype Generic_Level is Enclosing_Level_Kind range
Generic_Spec_Level ..
Generic_Body_Level;
subtype Library_Level is Enclosing_Level_Kind range
Library_Spec_Level ..
Library_Body_Level;
subtype Library_Or_Instantiation_Level is Enclosing_Level_Kind range
Instantiation_Level ..
Library_Body_Level;
procedure Build_Call_Marker (N : Node_Id);
pragma Inline (Build_Call_Marker);
-- Create a call marker for call or requeue statement N and record it for
-- later processing by the ABE mechanism.
procedure Build_Variable_Reference_Marker
(N : Node_Id;
Read : Boolean;
Write : Boolean);
pragma Inline (Build_Variable_Reference_Marker);
-- Create a variable reference marker for arbitrary node N if it mentions a
-- variable, and record it for later processing by the ABE mechanism. Flag
-- Read should be set when the reference denotes a read. Flag Write should
-- be set when the reference denotes a write.
procedure Check_Elaboration_Scenarios;
-- Examine each scenario recorded during analysis/resolution and apply the
-- Ada or SPARK elaboration rules taking into account the model in effect.
-- This processing detects and diagnoses ABE issues, installs conditional
-- ABE checks or guaranteed ABE failures, and ensures the elaboration of
-- units.
function Find_Enclosing_Level (N : Node_Id) return Enclosing_Level_Kind;
pragma Inline (Find_Enclosing_Level);
-- Determine the enclosing level of arbitrary node N
procedure Initialize;
pragma Inline (Initialize);
-- Initialize the internal structures of this unit
procedure Kill_Elaboration_Scenario (N : Node_Id);
-- Determine whether arbitrary node N denotes a scenario which requires
-- ABE diagnostics or runtime checks and eliminate it from a region with
-- dead code.
procedure Record_Elaboration_Scenario (N : Node_Id);
pragma Inline (Record_Elaboration_Scenario);
-- Determine whether atribtray node N denotes a scenario which requires
-- ABE diagnostics or runtime checks. If this is the case, store N for
-- later processing.
---------------------------------------------------------------------------
-- --
-- L E G A C Y A C C E S S B E F O R E E L A B O R A T I O N --
-- --
-- M E C H A N I S M --
-- --
---------------------------------------------------------------------------
-- This section contains the implementation of the pre-18.x Legacy ABE
-- Mechanism. The mechanism can be activated using switch -gnatH (legacy
-- elaboration checking mode enabled).
procedure Check_Elab_Assign (N : Node_Id);
-- N is either the left side of an assignment, or a procedure argument for
-- a mode OUT or IN OUT formal. This procedure checks for a possible case
-- of access to an entity from elaboration code before the entity has been
-- initialized, and issues appropriate warnings.
procedure Check_Elab_Call
(N : Node_Id;
Outer_Scope : Entity_Id := Empty;
In_Init_Proc : Boolean := False);
-- Check a call for possible elaboration problems. The node N is either an
-- N_Function_Call or N_Procedure_Call_Statement node or an access
-- attribute reference whose prefix is a subprogram.
--
-- If SPARK_Mode is On, then N can also be a variable reference, since
-- SPARK requires the use of Elaborate_All for references to variables
-- in other packages.
-- The Outer_Scope argument indicates whether this is an outer level
-- call from Sem_Res (Outer_Scope set to Empty), or an internal recursive
-- call (Outer_Scope set to entity of outermost call, see body). The flag
-- In_Init_Proc should be set whenever the current context is a type
-- init proc.
-- Note: this might better be called Check_Elab_Reference (to recognize
-- the SPARK case), but we prefer to keep the original name, since this
-- is primarily used for checking for calls that could generate an ABE).
procedure Check_Elab_Calls;
-- Not all the processing for Check_Elab_Call can be done at the time
-- of calls to Check_Elab_Call. This is because for internal calls, we
-- need to wait to complete the check until all generic bodies have been
-- instantiated. The Check_Elab_Calls procedure cleans up these waiting
-- checks. It is called once after the completion of instantiation.
procedure Check_Elab_Instantiation
(N : Node_Id;
Outer_Scope : Entity_Id := Empty);
-- Check an instantiation for possible elaboration problems. N is an
-- instantiation node (N_Package_Instantiation, N_Function_Instantiation,
-- or N_Procedure_Instantiation), and Outer_Scope indicates if this is
-- an outer level call from Sem_Ch12 (Outer_Scope set to Empty), or an
-- internal recursive call (Outer_Scope set to scope of outermost call,
-- see body for further details). The returned value is relevant only
-- for an outer level call, and is set to False if an elaboration error
-- is bound to occur on the instantiation, and True otherwise. This is
-- used by the caller to signal that the body of the instance should
-- not be generated (see detailed description in body).
procedure Check_Task_Activation (N : Node_Id);
-- At the point at which tasks are activated in a package body, check
-- that the bodies of the tasks are elaborated.
end Sem_Elab;
|
with ada.text_io;
with interfaces;
with Ada.Sequential_IO;
package byte_package is
type earth is mod 2**3;
type byte is mod 2**8;
type dword is mod 2**32;
type byte_array_8 is array (0..7) of byte;
procedure to_byte (in_dword : in dword; b1, b2, b3, b4 : out byte);
function to_dword (b1, b2, b3, b4 : byte) return dword;
function dword_shift_right (value : dword; amount : integer := 1) return dword;
function dword_shift_left (value : dword; amount : integer := 1) return dword;
procedure increment (e : in out earth);
package byte_io is new Ada.Sequential_IO(byte);
end byte_package; |
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2017-2020, Fabien Chouteau --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with HAL; use HAL;
with System.Storage_Elements; use System.Storage_Elements;
with Tools; use Tools;
with AGATE_Arch_Parameters;
private with AGATE_Types_Data.Traces;
package AGATE is
subtype Word is AGATE_Arch_Parameters.Word;
-- Task --
type Task_ID is private;
Invalid_Task : constant Task_ID;
type Internal_Task_Priority is range -1 .. 256;
subtype Task_Priority is Internal_Task_Priority range 0 .. 256;
type Task_Procedure is access procedure;
type Task_Status is (Created, Ready, Running, Fault, Suspended_Alarm,
Suspended_Semaphore, Suspended_Mutex);
subtype Task_Name is String (1 .. 10);
function Image (Status : Task_Status) return String;
function Name (ID : Task_ID) return String;
function Image (ID : Task_ID) return String;
-- Time --
type Time is new UInt64;
-- Semaphore --
type Semaphore_Count is new Natural;
type Semaphore_ID is private;
Invalid_Semaphore : constant Semaphore_ID;
-- Mutex --
type Mutex_ID is private;
Invalid_Mutex : constant Mutex_ID;
type Process_Stack_Pointer is new System.Address;
private
-- Task --
type Task_Stack is new Storage_Array;
pragma Warnings (Off, "suspiciously large alignment");
for Task_Stack'Alignment use 8 * 8;
pragma Warnings (On, "suspiciously large alignment");
type Task_Stack_Access is access all Task_Stack;
type Task_Sec_Stack is new Storage_Array;
type Task_Sec_Stack_Access is access all Task_Sec_Stack;
type Task_Heap is new Storage_Array;
type Task_Heap_Access is access all Task_Heap;
Null_PSP : constant Process_Stack_Pointer :=
Process_Stack_Pointer (System.Null_Address);
function Image (P : Process_Stack_Pointer) return String
is (Hex (UInt32 (To_Integer (System.Address (P)))));
type Task_Object;
type Task_Object_Access is access all Task_Object;
type Task_Object (Proc : not null Task_Procedure;
Base_Prio : Internal_Task_Priority;
Stack : Task_Stack_Access;
Sec_Stack : Task_Sec_Stack_Access;
Heap : Task_Heap_Access)
is limited record
Canary : UInt32;
Current_Prio : Internal_Task_Priority;
Next : Task_Object_Access := null;
Stack_Pointer : Process_Stack_Pointer := Null_PSP;
Name : Task_Name := (others => ' ');
Context : AGATE_Arch_Parameters.Task_Context;
Alarm_Time : Time := 0;
Status : Task_Status := Created;
All_Task_Next : Task_Object_Access := null;
Trace_Data : AGATE_Types_Data.Traces.Task_Data;
end record;
type Task_ID is new Task_Object_Access;
Invalid_Task : constant Task_ID := null;
All_Tasks_List : Task_Object_Access := null;
procedure Set_Stack_Canary (T : Task_ID);
procedure Check_Stack_Canary (T : Task_ID);
procedure Check_All_Stack_Canaries;
-- Semaphore --
type Semaphore (Initial_Count : Semaphore_Count := 0)
is limited record
Count : Semaphore_Count := Initial_Count;
Waiting_List : Task_Object_Access := null;
Trace_Data : AGATE_Types_Data.Traces.Semaphore_Data;
end record;
type Semaphore_Access is access all Semaphore;
type Semaphore_ID is new Semaphore_Access;
pragma No_Strict_Aliasing (Semaphore_ID);
Invalid_Semaphore : constant Semaphore_ID := null;
function To_Word (ID : Semaphore_ID) return Word;
function To_ID (ID : Word) return Semaphore_ID;
-- Mutex --
type Mutex (Prio : Internal_Task_Priority)
is limited record
Owner : Task_Object_Access := null;
Waiting_List : Task_Object_Access := null;
Trace_Data : AGATE_Types_Data.Traces.Mutex_Data;
end record;
type Mutex_Access is access all Mutex;
type Mutex_ID is new Mutex_Access;
pragma No_Strict_Aliasing (Mutex_ID);
Invalid_Mutex : constant Mutex_ID := null;
function To_Word (ID : Mutex_ID) return Word;
function To_ID (ID : Word) return Mutex_ID;
end AGATE;
|
-- File: test.adb
-- Description: Test suite for AdaID
-- Author: Anthony Arnold
-- License: http://www.gnu.org/licenses/gpl.txt
with AUnit.Test_Suites; use AUnit.Test_Suites;
with AUnit.Run;
with AUnit.Reporter.Text;
with AdaID_Tests;
procedure Test is
function Suite return Access_Test_Suite is
Result : constant Access_Test_Suite := new Test_Suite;
begin
Add_Test(Result, new AdaID_Tests.UUID_Test);
return Result;
end Suite;
procedure Run is new AUnit.Run.Test_Runner(Suite);
Reporter : AUnit.Reporter.Text.Text_Reporter;
begin
Run(Reporter);
end;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2018 onox <denkpadje@gmail.com>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Unchecked_Conversion;
with GL.API;
with GL.Enums.Internalformat;
package body GL.Pixels.Queries is
use all type Enums.Internalformat.Parameter;
function Get_Support
(Format : Internal_Format;
Kind : LE.Texture_Kind;
Parameter : Enums.Internalformat.Parameter) return Support
is
Result : Support := None;
begin
API.Get_Internal_Format_Support.Ref (Kind, Format, Parameter, 1, Result);
return Result;
end Get_Support;
function Get_Size
(Format : Internal_Format;
Kind : LE.Texture_Kind;
Parameter : Enums.Internalformat.Parameter) return Size
is
Result : Size := 0;
begin
API.Get_Internal_Format.Ref (Kind, Format, Parameter, 1, Result);
return Result;
end Get_Size;
function Get_Long_Size
(Format : Internal_Format;
Kind : LE.Texture_Kind;
Parameter : Enums.Internalformat.Parameter) return Long_Size
is
Result : Long_Size := 0;
begin
API.Get_Internal_Format_Long.Ref (Kind, Format, Parameter, 1, Result);
return Result;
end Get_Long_Size;
function Get_Boolean
(Format : Internal_Format;
Kind : LE.Texture_Kind;
Parameter : Enums.Internalformat.Parameter) return Boolean
is (Get_Size (Format, Kind, Parameter) = 1);
function Get_Size
(Format : Compressed_Format;
Kind : LE.Texture_Kind;
Parameter : Enums.Internalformat.Parameter) return Size
is
Result : Size := 0;
begin
API.Get_Internal_Format_C.Ref (Kind, Format, Parameter, 1, Result);
return Result;
end Get_Size;
-----------------------------------------------------------------------------
function Sample_Counts
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Size_Array
is
Count : Size := 0;
begin
API.Get_Internal_Format.Ref (Kind, Format, Num_Sample_Counts, 1, Count);
declare
Result : Size_Array (1 .. Count) := (others => 0);
begin
API.Get_Internal_Format_A.Ref (Kind, Format, Samples, Result'Length, Result);
return Result;
end;
end Sample_Counts;
function Supported
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Boolean
is (Get_Boolean (Format, Kind, Internalformat_Supported));
function Preferred
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Internal_Format
is
Result : Size := 0;
function Convert is new Ada.Unchecked_Conversion
(Source => GL.Types.Int, Target => Pixels.Internal_Format);
begin
API.Get_Internal_Format.Ref (Kind, Format, Internalformat_Preferred, 1, Result);
if Result = 0 then
raise Constraint_Error with "Invalid internal format";
end if;
return Convert (GL.Types.Int (Result));
end Preferred;
-----------------------------------------------------------------------------
function Red_Size
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Size
is (Get_Size (Format, Kind, Internalformat_Red_Size));
function Green_Size
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Size
is (Get_Size (Format, Kind, Internalformat_Green_Size));
function Blue_Size
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Size
is (Get_Size (Format, Kind, Internalformat_Blue_Size));
function Alpha_Size
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Size
is (Get_Size (Format, Kind, Internalformat_Alpha_Size));
function Depth_Size
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Size
is (Get_Size (Format, Kind, Internalformat_Depth_Size));
function Stencil_Size
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Size
is (Get_Size (Format, Kind, Internalformat_Stencil_Size));
function Shared_Size
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Size
is (Get_Size (Format, Kind, Internalformat_Shared_Size));
-----------------------------------------------------------------------------
function Max_Width
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Size
is (Get_Size (Format, Kind, Max_Width));
function Max_Height
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Size
is (Get_Size (Format, Kind, Max_Height));
function Max_Depth
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Size
is (Get_Size (Format, Kind, Max_Depth));
function Max_Layers
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Size
is (Get_Size (Format, Kind, Max_Layers));
function Max_Combined_Dimensions
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Long_Size
is (Get_Long_Size (Format, Kind, Max_Combined_Dimensions));
-----------------------------------------------------------------------------
function Color_Components
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Boolean
is (Get_Boolean (Format, Kind, Color_Components));
function Depth_Components
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Boolean
is (Get_Boolean (Format, Kind, Depth_Components));
function Stencil_Components
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Boolean
is (Get_Boolean (Format, Kind, Stencil_Components));
function Color_Renderable
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Boolean
is (Get_Boolean (Format, Kind, Color_Renderable));
function Depth_Renderable
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Boolean
is (Get_Boolean (Format, Kind, Depth_Renderable));
function Stencil_Renderable
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Boolean
is (Get_Boolean (Format, Kind, Stencil_Renderable));
-----------------------------------------------------------------------------
function Framebuffer_Renderable
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Framebuffer_Renderable));
function Framebuffer_Renderable_Layered
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Framebuffer_Renderable_Layered));
function Framebuffer_Blend
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Framebuffer_Blend));
-----------------------------------------------------------------------------
function Texture_Format
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Pixels.Format
is
Result : Size := 0;
function Convert is new Ada.Unchecked_Conversion
(Source => GL.Types.Int, Target => Pixels.Format);
begin
API.Get_Internal_Format.Ref (Kind, Format, Texture_Image_Format, 1, Result);
if Result = 0 then
raise Constraint_Error with "Invalid internal format for uploading to texture";
end if;
return Convert (GL.Types.Int (Result));
end Texture_Format;
function Texture_Type
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Pixels.Data_Type
is
Result : Size := 0;
function Convert is new Ada.Unchecked_Conversion
(Source => GL.Types.Int, Target => Pixels.Data_Type);
begin
API.Get_Internal_Format.Ref (Kind, Format, Texture_Image_Type, 1, Result);
if Result = 0 then
raise Constraint_Error with "Invalid internal format for uploading to texture";
end if;
return Convert (GL.Types.Int (Result));
end Texture_Type;
function Get_Texture_Format
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Pixels.Format
is
Result : Size := 0;
function Convert is new Ada.Unchecked_Conversion
(Source => GL.Types.Int, Target => Pixels.Format);
begin
API.Get_Internal_Format.Ref (Kind, Format, Get_Texture_Image_Format, 1, Result);
if Result = 0 then
raise Constraint_Error with "Invalid internal format for downloading to texture";
end if;
return Convert (GL.Types.Int (Result));
end Get_Texture_Format;
function Get_Texture_Type
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Pixels.Data_Type
is
Result : Size := 0;
function Convert is new Ada.Unchecked_Conversion
(Source => GL.Types.Int, Target => Pixels.Data_Type);
begin
API.Get_Internal_Format.Ref (Kind, Format, Get_Texture_Image_Type, 1, Result);
if Result = 0 then
raise Constraint_Error with "Invalid internal format for downloading to texture";
end if;
return Convert (GL.Types.Int (Result));
end Get_Texture_Type;
-----------------------------------------------------------------------------
function Mipmap
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Boolean
is (Get_Boolean (Format, Kind, Mipmap));
function Manual_Generate_Mipmap
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Manual_Generate_Mipmap));
function Auto_Generate_Mipmap
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Auto_Generate_Mipmap));
-----------------------------------------------------------------------------
function Color_Encoding
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Encoding
is
Result : Size := 0;
function Convert is new Ada.Unchecked_Conversion
(Source => GL.Types.Int, Target => Encoding);
begin
API.Get_Internal_Format.Ref (Kind, Format, Color_Encoding, 1, Result);
if Result = 0 then
raise Constraint_Error with "Invalid internal format for color encoding";
end if;
return Convert (GL.Types.Int (Result));
end Color_Encoding;
function sRGB_Read
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, sRGB_Read));
function sRGB_Write
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, sRGB_Write));
function sRGB_Decode_Sampling_Time
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, sRGB_Decode_ARB));
-----------------------------------------------------------------------------
function Filter
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Filter));
function Vertex_Texture
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Vertex_Texture));
function Tess_Control_Texture
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Tess_Control_Texture));
function Tess_Evaluation_Texture
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Tess_Evaluation_Texture));
function Geometry_Texture
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Geometry_Texture));
function Fragment_Texture
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Fragment_Texture));
function Compute_Texture
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Compute_Texture));
function Texture_Shadow
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Texture_Shadow));
function Texture_Gather
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Texture_Gather));
function Texture_Gather_Shadow
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Texture_Gather_Shadow));
-----------------------------------------------------------------------------
function Shader_Image_Load
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Shader_Image_Load));
function Shader_Image_Store
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Shader_Image_Store));
function Shader_Image_Atomic
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Shader_Image_Atomic));
-----------------------------------------------------------------------------
function Image_Texel_Size
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Size
is (Get_Size (Format, Kind, Image_Texel_Size));
function Image_Pixel_Format
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Pixels.Format
is
Result : Size := 0;
function Convert is new Ada.Unchecked_Conversion
(Source => GL.Types.Int, Target => Pixels.Format);
begin
API.Get_Internal_Format.Ref (Kind, Format, Image_Pixel_Format, 1, Result);
if Result = 0 then
raise Constraint_Error with "Invalid internal format for image texture";
end if;
return Convert (GL.Types.Int (Result));
end Image_Pixel_Format;
function Image_Pixel_Type
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Pixels.Data_Type
is
Result : Size := 0;
function Convert is new Ada.Unchecked_Conversion
(Source => GL.Types.Int, Target => Pixels.Data_Type);
begin
API.Get_Internal_Format.Ref (Kind, Format, Image_Pixel_Type, 1, Result);
if Result = 0 then
raise Constraint_Error with "Invalid internal format for image texture";
end if;
return Convert (GL.Types.Int (Result));
end Image_Pixel_Type;
function Image_Format_Compatibility
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Image_Format_Compatibility_Type
is
Result : Size := 0;
function Convert is new Ada.Unchecked_Conversion
(Source => GL.Types.Int, Target => Image_Format_Compatibility_Type);
begin
API.Get_Internal_Format.Ref (Kind, Format,
Enums.Internalformat.Image_Format_Compatibility_Type, 1, Result);
if Result = 0 then
raise Constraint_Error with "Invalid internal format for image texture";
end if;
return Convert (GL.Types.Int (Result));
end Image_Format_Compatibility;
function Simultaneous_Texture_And_Depth_Test
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Simultaneous_Texture_And_Depth_Test));
function Simultaneous_Texture_And_Stencil_Test
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Simultaneous_Texture_And_Stencil_Test));
function Simultaneous_Texture_And_Depth_Write
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Simultaneous_Texture_And_Depth_Write));
function Simultaneous_Texture_And_Stencil_Write
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Simultaneous_Texture_And_Stencil_Write));
-----------------------------------------------------------------------------
function Texture_Compressed_Block_Width
(Format : Compressed_Format;
Kind : LE.Texture_Kind) return Size
is (Get_Size (Format, Kind, Texture_Compressed_Block_Width));
function Texture_Compressed_Block_Height
(Format : Compressed_Format;
Kind : LE.Texture_Kind) return Size
is (Get_Size (Format, Kind, Texture_Compressed_Block_Height));
function Texture_Compressed_Block_Size
(Format : Compressed_Format;
Kind : LE.Texture_Kind) return Size
is (Get_Size (Format, Kind, Texture_Compressed_Block_Size));
-----------------------------------------------------------------------------
function Clear_Buffer
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Clear_Buffer));
function Texture_View
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Support
is (Get_Support (Format, Kind, Texture_View));
function Image_Compatibility_Class
(Format : Internal_Format;
Kind : LE.Texture_Kind) return Image_Class
is
Result : Size := 0;
function Convert is new Ada.Unchecked_Conversion
(Source => GL.Types.Int, Target => Image_Class);
begin
API.Get_Internal_Format.Ref (Kind, Format,
Enums.Internalformat.Image_Compatibility_Class, 1, Result);
if Result = 0 then
raise Constraint_Error with "Invalid internal format for image texture";
end if;
return Convert (GL.Types.Int (Result));
end Image_Compatibility_Class;
function View_Compatibility_Class
(Format : Internal_Format;
Kind : LE.Texture_Kind) return View_Class
is
Result : Size := 0;
function Convert is new Ada.Unchecked_Conversion
(Source => GL.Types.Int, Target => View_Class);
begin
API.Get_Internal_Format.Ref (Kind, Format,
Enums.Internalformat.View_Compatibility_Class, 1, Result);
if Result = 0 then
raise Constraint_Error with "Invalid internal format for texture view";
end if;
return Convert (GL.Types.Int (Result));
end View_Compatibility_Class;
end GL.Pixels.Queries;
|
-- Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Interfaces;
with Pck; use Pck;
procedure P is
subtype Double is Interfaces.IEEE_Float_64;
D1 : Double := 123.0;
D2 : Double;
pragma Import (Ada, D2);
for D2'Address use D1'Address;
begin
Do_Nothing (D1'Address); -- START
Do_Nothing (D2'Address);
end P;
|
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with Zstandard.Thin_Binding;
package Zstandard.Functions is
package Thin renames Zstandard.Thin_Binding;
------------------
-- Data Types --
------------------
type Compression_Level is range 1 .. 22;
type File_Size is mod 2 ** 64;
subtype Compression_Dictionary is Thin.ZSTD_CDict_ptr;
subtype Decompression_Dictionary is Thin.ZSTD_DDict_ptr;
-----------------
-- Constants --
-----------------
Fastest_Compression : constant Compression_Level := Compression_Level'First;
Highest_Compression : constant Compression_Level := Compression_Level'Last;
Default_Compression : constant Compression_Level := 3;
--------------------
-- Identification --
--------------------
-- Returns the library version in the format "X.Y.Z", no leading zeros
function Zstd_Version return String;
------------------
-- Compression --
------------------
-- This function returns the compressed version of "source_data". Should the operation fail,
-- "successful" variable will be set to False and the resulting string will contain the
-- related error message.
function Compress
(source_data : String;
successful : out Boolean;
quality : Compression_Level := Default_Compression) return String;
-- This function creates an output file that is a compressed version of the "source_file".
-- It returns a blank string if successful and "successful" is set to True. Should the
-- operation fail, "successful" is set to False and an error message is returned.
-- For convenience, the size of the source and output files are also provided.
function Compress_File
(source_file : String;
output_file : String;
source_size : out File_Size;
output_size : out File_Size;
successful : out Boolean;
quality : Compression_Level := Default_Compression) return String;
--------------------
-- Decompression --
--------------------
-- This function returns the decompressed version of "source_data". Should the operation fail,
-- "successful" variable will be set to False and the resulting string will contain the
-- related error message.
function Decompress
(source_data : String;
successful : out Boolean) return String;
-- This function creates an output file that is a decompressed version of the "source_file".
-- It returns a blank string if successful and "successful" is set to True. Should the
-- operation fail, "successful" is set to False and an error message is returned.
-- For convenience, the size of the source and output files are also provided.
function Decompress_File
(source_file : String;
output_file : String;
source_size : out File_Size;
output_size : out File_Size;
successful : out Boolean) return String;
-- Helper function to dump contents of a file into a string
-- Potentially useful when desirable to have a compressed copy of the file in memory
function File_Contents (filename : String;
filesize : Natural;
nominal : out Boolean) return String;
-- Helper function to create a new file with the exact value of "contents" string
-- Potentially useful for writing compressed or plain text from memory
function Write_Entire_File (filename : String; contents : String) return Boolean;
---------------------------
-- Dictionary Handling --
---------------------------
-- Dictionaries are meant to be used to compress multiple similar files. Before compression,
-- the dictionary is created by giving it a sample of the types to be compressed.
function Create_Compression_Dictionary
(sample : String;
quality : Compression_Level := Default_Compression) return Compression_Dictionary;
-- Similar to "Create_Compression_Dictionary" but the sample comes from a file
-- Normally this is created by "zstd --train" command
function Create_Compression_Dictionary_From_File
(sample_file : String;
successful : out Boolean;
quality : Compression_Level := Default_Compression) return Compression_Dictionary;
-- Release the compression dictionary after use.
procedure Destroy_Compression_Dictionary (digest : Compression_Dictionary);
-- Files compressed with dictionaries have to be decompressed using the same dictionaries
-- created from the same sample data used to create the compression dictionaries.
function Create_Decompression_Dictionary (sample : String) return Decompression_Dictionary;
-- Similar to "Create_Decompression_Dictionary" but the sample comes from a file
-- Normally this is created by "zstd --train" command
function Create_Decompression_Dictionary_From_File
(sample_file : String;
successful : out Boolean) return Decompression_Dictionary;
-- Release the decompression dictionary after use.
procedure Destroy_Decompression_Dictionary (digest : Decompression_Dictionary);
--------------------------------------------
-- Dictionary De/Compression Operations --
--------------------------------------------
-- This function returns the dictionary-biased compressed version of "source_data".
-- Should the operation fail, "successful" variable will be set to False and the resulting
-- string will contain the related error message. The compression level is pre-set during
-- the creation of the "digest" dictionary.
function Compress
(source_data : String;
digest : Compression_Dictionary;
successful : out Boolean) return String;
-- This function creates an output file that is a dictionary-biased compressed version of the
-- "source_file". It returns a blank string if successful and "successful" is set to True.
-- Should the operation fail, "successful" is set to False and an error message is returned.
-- For convenience, the size of the source and output files are also provided.
-- The compression level is pre-set during the creation of the "digest" dictionary.
function Compress_File
(source_file : String;
output_file : String;
digest : Compression_Dictionary;
source_size : out File_Size;
output_size : out File_Size;
successful : out Boolean) return String;
-- This function returns the decompressed version of "source_data" compressed using a
-- dictionary. Should the operation fail, the "successful" variable will be set to False
-- and the resulting string will contain the related error message.
function Decompress
(source_data : String;
digest : Decompression_Dictionary;
successful : out Boolean) return String;
-- This function creates an output file that is a decompressed version of the "source_file"
-- that was compressed using a dictionary. It returns a blank string if successful and
-- "successful" is set to True. Should the operation fail, "successful" is set to False and
-- an error message is returned. For convenience, the size of the source and output files
-- are also provided.
function Decompress_File
(source_file : String;
output_file : String;
digest : Decompression_Dictionary;
source_size : out File_Size;
output_size : out File_Size;
successful : out Boolean) return String;
private
Warn_src_file_DNE : constant String := "ERROR: Source file does not exist";
Warn_src_read_fail : constant String := "ERROR: Failed to read source file";
Warn_dst_write_fail : constant String := "ERROR: Failed to write to open output file";
Warn_compress_fail : constant String := "ERROR: Failed to compress data after reading " &
"source file";
Warn_decompress_fail : constant String := "ERROR: Failed to decompress data after reading " &
"source file";
Warn_way_too_big : constant String := "ERROR: Hit size limit imposed by this architecture";
Warn_orig_size_fail : constant String := "ERROR: Original size unknown";
function convert (data : Thin.IC.char_array) return String;
function convert (data : String) return Thin.IC.char_array;
end Zstandard.Functions;
|
---------------------------------------------------------------------------
-- package QR_Symmetric_Eigen, QR based eigen-decomposition
-- Copyright (C) 2018 Jonathan S. Parker
--
-- 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.
---------------------------------------------------------------------------
-- package QR_Symmetric_Eigen
--
-- Eigen-decomposition of symmetric real-valued matrices.
--
-- The matrix is tri-diagonalized with Givens rotations, then diagonalized
-- using QR iterations.
--
-- procedure Eigen_Decompose
--
-- Works on arbitrary diagonal blocks of input matrix. For other blocks just
-- copy the matrix to desired position; copy overhead is small compared
-- to the O(N^3) running time of the decomposition.
generic
type Real is digits <>;
type Index is range <>;
type Matrix is array (Index, Index) of Real;
package QR_Symmetric_Eigen is
type Col_Vector is array(Index) of Real;
-- procedure Eigen_Decompose
--
-- The routine returns eigenvectors and eigenvalues of arbitrary diagonal
-- blocks of any real-valued square symmetric matrix.
--
-- The orthonormal (unordered) eigenvectors are the Columns of Q.
-- The orthonormal (unordered) eigenvectors are returned as the Rows of Q'=Q_tr.
-- Eigenvals (returned in array Eigenvals) are ordered the same as Eigvecs in Q.
-- So A = Q * E * Q'. The diagonal elements of diagonal matrix E are the
-- eigvals. The routine performs the eigen-decomposition on arbitrary square
-- diagonal blocks of matrix A.
-- It is assumed that the blocks are symmetric matrices.
-- The upper left corner of the square matrix is (Start_Col, Start_Col).
-- The lower rgt corner of the square matrix is (Final_Col, Final_Col).
-- Matrix A doesn't need to be positive definite, or semi-definite.
-- If Eigenvectors_Desired = False, then Q is not calculated.
--
-- Input matrix A is destroyed. Save a copy of A if you need it.
--
procedure Eigen_Decompose
(A : in out Matrix; -- destroyed
Q : out Matrix; -- columns of Q are the eigvecs
Eigenvals : out Col_Vector;
Start_Col : in Index := Index'First;
Final_Col : in Index := Index'Last;
Eigenvectors_Desired : in Boolean := False);
procedure Sort_Eigs
(Eigenvals : in out Col_Vector;
Q : in out Matrix; -- columns of Q are the eigvecs
Start_Col : in Index := Index'First;
Final_Col : in Index := Index'Last;
Sort_Eigvecs_Also : in Boolean := False);
function Norm
(Q : in Col_Vector;
Starting_Col : in Index := Index'First;
Final_Col : in Index := Index'Last)
return Real;
end QR_Symmetric_Eigen;
|
-- F defines a differential equation whose solution is Exp (i*t).
-- dY/dt = F(Y).
-- For testing.
generic
type Real is digits <>;
package Sinu_2 is
type Dyn_Index is range 0..1; -- the 2nd component is just ignored in the tests.
type Dynamical_Variable is array(Dyn_Index) of Real;
DynZero : constant Dynamical_Variable := (others => 0.0);
function F
(Time : Real;
Y : Dynamical_Variable)
return Dynamical_Variable;
-- Defines the equation to be integrated,
-- dY/dt = F (t, Y). Even if the equation is t or Y
-- independent, it must be entered in this form.
function "*"
(Left : Real;
Right : Dynamical_Variable)
return Dynamical_Variable;
function "+"
(Left : Dynamical_Variable;
Right : Dynamical_Variable)
return Dynamical_Variable;
function "-"
(Left : Dynamical_Variable;
Right : Dynamical_Variable)
return Dynamical_Variable;
function Norm (Y : Dynamical_Variable) return Real;
pragma Inline (F, "*", "+", "-", Norm);
end Sinu_2;
|
package GL.Materials is
-- Material. Doc from the VRML 1.0 spec (refers to OpenGL):
-- * The ambient color reflects ambient light evenly from all parts of
-- an object regardless of viewing and lighting angles.
--
-- * The diffuse color reflects all VRML light sources depending on the
-- angle of the surface with respect to the light source.
-- The more directly the surface faces the light, the more
-- diffuse light reflects.
--
-- * The specular color and shininess determine the specular highlights,
-- e.g., the shiny spots on an apple. When the angle from the light
-- to the surface is close to the angle from the surface to the viewer,
-- the specular color is added to the diffuse and ambient color
-- calculations.
-- Lower shininess values produce soft glows, while higher values
-- result in sharper, smaller highlights.
--
-- * Emissive color models "glowing" objects. This can be useful for
-- displaying radiosity - based models (where the light energy of the
-- room is computed explicitly), or for displaying scientific data.
type Material_type is record
ambient,
diffuse,
specular,
emission : GL.Material_Float_vector;
shininess : GL.C_Float; -- 0.0 .. 128.0
end record;
function is_Transparent (Self : Material_type) return Boolean;
neutral_material :
constant Material_type := (ambient => (0.2, 0.2, 0.2, 1.0),
diffuse => (0.8, 0.8, 0.8, 1.0),
specular => (0.0, 0.0, 0.0, 1.0),
emission => (0.0, 0.0, 0.0, 1.0),
shininess => 0.0);
-- ^ the values are GL defaults.
-- A few colour - dominant materials:
Red : constant Material_type := (
ambient => (0.0, 0.0, 0.0, 1.0),
diffuse => (1.0, 0.0, 0.0, 1.0),
specular => (0.0225, 0.0225, 0.0225, 1.0),
emission => (0.0, 0.0, 0.0, 1.0),
shininess => 12.8
);
Orange : constant Material_type := (
ambient => (0.0, 0.0, 0.0, 1.0),
diffuse => (0.992157, 0.513726, 0.0, 1.0),
specular => (0.0225, 0.0225, 0.0225, 1.0),
emission => (0.0, 0.0, 0.0, 1.0),
shininess => 12.8
);
Yellow : constant Material_type := (
ambient => (0.0, 0.0, 0.0, 1.0),
diffuse => (1.0, 0.964706, 0.0, 1.0),
specular => (0.0225, 0.0225, 0.0225, 1.0),
emission => (0.0, 0.0, 0.0, 1.0),
shininess => 12.8
);
Green : constant Material_type := (
ambient => (0.0, 0.0, 0.0, 1.0),
diffuse => (0.0, 1.0, 0.0, 1.0),
specular => (0.0225, 0.0225, 0.0225, 1.0),
emission => (0.0, 0.0, 0.0, 1.0),
shininess => 12.8
);
Indigo : constant Material_type := (
ambient => (0.0, 0.0, 0.0, 1.0),
diffuse => (0.0980392, 0.0, 0.458824, 1.0),
specular => (0.0225, 0.0225, 0.0225, 1.0),
emission => (0.0, 0.0, 0.0, 1.0),
shininess => 12.8
);
Blue : constant Material_type := (
ambient => (0.0, 0.0, 0.0, 1.0),
diffuse => (0.0, 0.0, 1.0, 1.0),
specular => (0.0225, 0.0225, 0.0225, 1.0),
emission => (0.0, 0.0, 0.0, 1.0),
shininess => 12.8
);
Violet : constant Material_type := (
ambient => (0.0, 0.0, 0.0, 1.0),
diffuse => (0.635294, 0.0, 1.0, 1.0),
specular => (0.0225, 0.0225, 0.0225, 1.0),
emission => (0.0, 0.0, 0.0, 1.0),
shininess => 12.8
);
White : constant Material_type := (
ambient => (0.0, 0.0, 0.0, 1.0),
diffuse => (0.992157, 0.992157, 0.992157, 1.0),
specular => (0.0225, 0.0225, 0.0225, 1.0),
emission => (0.0, 0.0, 0.0, 1.0),
shininess => 12.8
);
Black : constant Material_type := (
ambient => (0.0, 0.0, 0.0, 1.0),
diffuse => (0.0, 0.0, 0.0, 1.0),
specular => (0.0225, 0.0225, 0.0225, 1.0),
emission => (0.0, 0.0, 0.0, 1.0),
shininess => 12.8
);
Medium_Gray : constant Material_type := (
ambient => (0.0, 0.0, 0.0, 1.0),
diffuse => (0.454902, 0.454902, 0.454902, 1.0),
specular => (0.0225, 0.0225, 0.0225, 1.0),
emission => (0.0, 0.0, 0.0, 1.0),
shininess => 12.8
);
Light_Gray : constant Material_type := (
ambient => (0.0, 0.0, 0.0, 1.0),
diffuse => (0.682353, 0.682353, 0.682353, 1.0),
specular => (0.0225, 0.0225, 0.0225, 1.0),
emission => (0.0, 0.0, 0.0, 1.0),
shininess => 12.8
);
-- A few "material" materials:
Glass : constant Material_type := (
ambient => (0.0, 0.0, 0.0, 1.0),
diffuse => (0.588235, 0.670588, 0.729412, 1.0),
specular => (0.9, 0.9, 0.9, 1.0),
emission => (0.0, 0.0, 0.0, 1.0),
shininess => 96.0
);
Brass : constant Material_type := (
ambient => (0.329412, 0.223529, 0.027451, 1.0),
diffuse => (0.780392, 0.568627, 0.113725, 1.0),
specular => (0.992157, 0.941176, 0.807843, 1.0),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 27.8974);
Bronze : constant Material_type := (
ambient => (0.2125, 0.1275, 0.054, 1.0),
diffuse => (0.714, 0.4284, 0.18144, 1.0),
specular => (0.393548, 0.271906, 0.166721, 1.0),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 25.6);
Polished_Bronze : constant Material_type := (
ambient => (0.25, 0.148, 0.06475, 1.0),
diffuse => (0.4, 0.2368, 0.1036, 1.0),
specular => (0.774597, 0.458561, 0.200621, 1.0),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 76.8);
Chrome : constant Material_type := (
ambient => (0.25, 0.25, 0.25, 1.0),
diffuse => (0.4, 0.4, 0.4, 1.0),
specular => (0.774597, 0.774597, 0.774597, 1.0),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 76.8);
Copper : constant Material_type := (
ambient => (0.19125, 0.0735, 0.0225, 1.0),
diffuse => (0.7038, 0.27048, 0.0828, 1.0),
specular => (0.256777, 0.137622, 0.086014, 1.0),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 12.8);
Polished_Copper : constant Material_type := (
ambient => (0.2295, 0.08825, 0.0275, 1.0),
diffuse => (0.5508, 0.2118, 0.066, 1.0),
specular => (0.580594, 0.223257, 0.0695701, 1.0),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 51.2);
Gold : constant Material_type := (
ambient => (0.24725, 0.1995, 0.0745, 1.0),
diffuse => (0.75164, 0.60648, 0.22648, 1.0),
specular => (0.628281, 0.555802, 0.366065, 1.0),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 51.2);
Polished_Gold : constant Material_type := (
ambient => (0.24725, 0.2245, 0.0645, 1.0),
diffuse => (0.34615, 0.3143, 0.0903, 1.0),
specular => (0.797357, 0.723991, 0.208006, 1.0),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 83.2);
Pewter : constant Material_type := (
ambient => (0.105882, 0.058824, 0.113725, 1.0),
diffuse => (0.427451, 0.470588, 0.541176, 1.0),
specular => (0.333333, 0.333333, 0.521569, 1.0),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 9.84615);
Silver : constant Material_type := (
ambient => (0.19225, 0.19225, 0.19225, 1.0),
diffuse => (0.50754, 0.50754, 0.50754, 1.0),
specular => (0.508273, 0.508273, 0.508273, 1.0),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 51.2);
Polished_Silver : constant Material_type := (
ambient => (0.23125, 0.23125, 0.23125, 1.0),
diffuse => (0.2775, 0.2775, 0.2775, 1.0),
specular => (0.773911, 0.773911, 0.773911, 1.0),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 89.6);
Emerald : constant Material_type := (
ambient => (0.0215, 0.1745, 0.0215, 0.55),
diffuse => (0.07568, 0.61424, 0.07568, 0.55),
specular => (0.633, 0.727811, 0.633, 0.55),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 76.8);
Jade : constant Material_type := (
ambient => (0.135, 0.2225, 0.1575, 0.95),
diffuse => (0.54, 0.89, 0.63, 0.95),
specular => (0.316228, 0.316228, 0.316228, 0.95),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 12.8);
Obsidian : constant Material_type := (
ambient => (0.05375, 0.05, 0.06625, 0.82),
diffuse => (0.18275, 0.17, 0.22525, 0.82),
specular => (0.332741, 0.328634, 0.346435, 0.82),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 38.4);
Pearl : constant Material_type := (
ambient => (0.25, 0.20725, 0.20725, 0.922),
diffuse => (1.0, 0.829, 0.829, 0.922),
specular => (0.296648, 0.296648, 0.296648, 0.922),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 11.264);
Ruby : constant Material_type := (
ambient => (0.1745, 0.01175, 0.01175, 0.55),
diffuse => (0.61424, 0.04136, 0.04136, 0.55),
specular => (0.727811, 0.626959, 0.626959, 0.55),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 76.8);
Turquoise : constant Material_type := (
ambient => (0.1, 0.18725, 0.1745, 0.8),
diffuse => (0.396, 0.74151, 0.69102, 0.8),
specular => (0.297254, 0.30829, 0.306678, 0.8),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 12.8);
Black_Plastic : constant Material_type := (
ambient => (0.0, 0.0, 0.0, 1.0),
diffuse => (0.01, 0.01, 0.01, 1.0),
specular => (0.50, 0.50, 0.50, 1.0),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 32.0);
Black_Rubber : constant Material_type := (
ambient => (0.02, 0.02, 0.02, 1.0),
diffuse => (0.01, 0.01, 0.01, 1.0),
specular => (0.4, 0.4, 0.4, 1.0),
emission => (0.0, 0.0, 0.0, 0.0),
shininess => 10.0);
VRML_Defaults : constant Material_type := (
ambient => (0.2, 0.2, 0.2, 1.0),
diffuse => (0.8, 0.8, 0.8, 1.0),
specular => (0.0, 0.0, 0.0, 1.0),
emission => (0.0, 0.0, 0.0, 1.0),
shininess => 25.6);
end GL.Materials;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . C R T L --
-- --
-- S p e c --
-- --
-- Copyright (C) 2003-2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides the low level interface to the C runtime library
pragma Compiler_Unit_Warning;
with System.Parameters;
package System.CRTL is
pragma Preelaborate;
subtype chars is System.Address;
-- Pointer to null-terminated array of characters
-- Should use Interfaces.C.Strings types instead, but this causes bootstrap
-- issues as i-c contains Ada 2005 specific features, not compatible with
-- older, Ada 95-only base compilers???
subtype DIRs is System.Address;
-- Corresponds to the C type DIR*
subtype FILEs is System.Address;
-- Corresponds to the C type FILE*
subtype int is Integer;
type long is range -(2 ** (System.Parameters.long_bits - 1))
.. +(2 ** (System.Parameters.long_bits - 1)) - 1;
subtype off_t is Long_Integer;
type size_t is mod 2 ** Standard'Address_Size;
type ssize_t is range -(2 ** (Standard'Address_Size - 1))
.. +(2 ** (Standard'Address_Size - 1)) - 1;
type int64 is new Long_Long_Integer;
-- Note: we use Long_Long_Integer'First instead of -2 ** 63 to allow this
-- unit to compile when using custom target configuration files where the
-- maximum integer is 32 bits. This is useful for static analysis tools
-- such as SPARK or CodePeer. In the normal case, Long_Long_Integer is
-- always 64-bits so there is no difference.
type Filename_Encoding is (UTF8, ASCII_8bits, Unspecified);
for Filename_Encoding use (UTF8 => 0, ASCII_8bits => 1, Unspecified => 2);
pragma Convention (C, Filename_Encoding);
-- Describes the filename's encoding
--------------------
-- GCC intrinsics --
--------------------
-- The following functions are imported with convention Intrinsic so that
-- we take advantage of back-end builtins if present (else we fall back
-- to C library functions by the same names).
function strlen (A : System.Address) return size_t;
pragma Import (Intrinsic, strlen, "strlen");
procedure strncpy (dest, src : System.Address; n : size_t);
pragma Import (Intrinsic, strncpy, "strncpy");
-------------------------------
-- Other C runtime functions --
-------------------------------
function atoi (A : System.Address) return Integer;
pragma Import (C, atoi, "atoi");
procedure clearerr (stream : FILEs);
pragma Import (C, clearerr, "clearerr");
function dup (handle : int) return int;
pragma Import (C, dup, "dup");
function dup2 (from, to : int) return int;
pragma Import (C, dup2, "dup2");
function fclose (stream : FILEs) return int;
pragma Import (C, fclose, "fclose");
function fdopen (handle : int; mode : chars) return FILEs;
pragma Import (C, fdopen, "fdopen");
function fflush (stream : FILEs) return int;
pragma Import (C, fflush, "fflush");
function fgetc (stream : FILEs) return int;
pragma Import (C, fgetc, "fgetc");
function fgets (strng : chars; n : int; stream : FILEs) return chars;
pragma Import (C, fgets, "fgets");
function fopen
(filename : chars;
mode : chars;
encoding : Filename_Encoding := Unspecified) return FILEs;
pragma Import (C, fopen, "__gnat_fopen");
function fputc (C : int; stream : FILEs) return int;
pragma Import (C, fputc, "fputc");
function fputwc (C : int; stream : FILEs) return int;
pragma Import (C, fputwc, "__gnat_fputwc");
function fputs (Strng : chars; Stream : FILEs) return int;
pragma Import (C, fputs, "fputs");
procedure free (Ptr : System.Address);
pragma Import (C, free, "free");
function freopen
(filename : chars;
mode : chars;
stream : FILEs;
encoding : Filename_Encoding := Unspecified) return FILEs;
pragma Import (C, freopen, "__gnat_freopen");
function fseek
(stream : FILEs;
offset : long;
origin : int) return int;
pragma Import (C, fseek, "fseek");
function fseek64
(stream : FILEs;
offset : int64;
origin : int) return int;
pragma Import (C, fseek64, "__gnat_fseek64");
function ftell (stream : FILEs) return long;
pragma Import (C, ftell, "ftell");
function ftell64 (stream : FILEs) return int64;
pragma Import (C, ftell64, "__gnat_ftell64");
function getenv (S : String) return System.Address;
pragma Import (C, getenv, "getenv");
function isatty (handle : int) return int;
pragma Import (C, isatty, "isatty");
function lseek (fd : int; offset : off_t; direction : int) return off_t;
pragma Import (C, lseek, "lseek");
function malloc (Size : size_t) return System.Address;
pragma Import (C, malloc, "malloc");
procedure memcpy (S1 : System.Address; S2 : System.Address; N : size_t);
pragma Import (C, memcpy, "memcpy");
procedure memmove (S1 : System.Address; S2 : System.Address; N : size_t);
pragma Import (C, memmove, "memmove");
procedure mktemp (template : chars);
pragma Import (C, mktemp, "mktemp");
function pclose (stream : System.Address) return int;
pragma Import (C, pclose, "pclose");
function popen (command, mode : System.Address) return System.Address;
pragma Import (C, popen, "popen");
function realloc
(Ptr : System.Address; Size : size_t) return System.Address;
pragma Import (C, realloc, "realloc");
procedure rewind (stream : FILEs);
pragma Import (C, rewind, "rewind");
function rmdir (dir_name : String) return int;
pragma Import (C, rmdir, "__gnat_rmdir");
function chdir (dir_name : String) return int;
pragma Import (C, chdir, "__gnat_chdir");
function mkdir
(dir_name : String;
encoding : Filename_Encoding := Unspecified) return int;
pragma Import (C, mkdir, "__gnat_mkdir");
function setvbuf
(stream : FILEs;
buffer : chars;
mode : int;
size : size_t) return int;
pragma Import (C, setvbuf, "setvbuf");
procedure tmpnam (str : chars);
pragma Import (C, tmpnam, "tmpnam");
function tmpfile return FILEs;
pragma Import (C, tmpfile, "tmpfile");
function ungetc (c : int; stream : FILEs) return int;
pragma Import (C, ungetc, "ungetc");
function unlink (filename : chars) return int;
pragma Import (C, unlink, "__gnat_unlink");
function open (filename : chars; oflag : int) return int;
pragma Import (C, open, "__gnat_open");
function close (fd : int) return int;
pragma Import (C, close, "close");
function read (fd : int; buffer : chars; count : size_t) return ssize_t;
pragma Import (C, read, "read");
function write (fd : int; buffer : chars; count : size_t) return ssize_t;
pragma Import (C, write, "write");
end System.CRTL;
|
-- This spec has been automatically generated from FE310.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
-- E31 CPU Coreplex, high-performance, 32-bit RV32IMAC core
--
package FE310_SVD is
pragma Preelaborate;
--------------------
-- Base addresses --
--------------------
GPIO0_Base : constant System.Address :=
System'To_Address (16#10012000#);
UART0_Base : constant System.Address :=
System'To_Address (16#10013000#);
UART1_Base : constant System.Address :=
System'To_Address (16#10023000#);
PWM0_Base : constant System.Address :=
System'To_Address (16#10015000#);
PWM1_Base : constant System.Address :=
System'To_Address (16#10025000#);
PWM2_Base : constant System.Address :=
System'To_Address (16#10035000#);
end FE310_SVD;
|
with Ada.Text_Io; use Ada.Text_Io;
procedure Subprogram_As_Argument is
type Proc_Access is access procedure;
procedure Second is
begin
Put_Line("Second Procedure");
end Second;
procedure First(Proc : Proc_Access) is
begin
Proc.all;
end First;
begin
First(Second'Access);
end Subprogram_As_Argument;
|
------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- A D A . C O N T A I N E R S . --
-- R E S R I C T E D _ D O U B L Y _ L I N K E D _ L I S T S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2004-2006, 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 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. --
-- --
--
--
--
--
--
--
--
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
generic
type Element_Type is private;
with function "=" (Left, Right : Element_Type)
return Boolean is <>;
package Ada.Containers.Restricted_Doubly_Linked_Lists is
pragma Pure;
type List (Capacity : Count_Type) is tagged limited private;
pragma Preelaborable_Initialization (List);
type Cursor is private;
pragma Preelaborable_Initialization (Cursor);
Empty_List : constant List;
No_Element : constant Cursor;
function "=" (Left, Right : List) return Boolean;
procedure Assign (Target : in out List; Source : List);
function Length (Container : List) return Count_Type;
function Is_Empty (Container : List) return Boolean;
procedure Clear (Container : in out List);
function Element (Position : Cursor) return Element_Type;
procedure Replace_Element
(Container : in out List;
Position : Cursor;
New_Item : Element_Type);
procedure Query_Element
(Position : Cursor;
Process : not null access procedure (Element : Element_Type));
procedure Update_Element
(Container : in out List;
Position : Cursor;
Process : not null access procedure (Element : in out Element_Type));
procedure Insert
(Container : in out List;
Before : Cursor;
New_Item : Element_Type;
Count : Count_Type := 1);
procedure Insert
(Container : in out List;
Before : Cursor;
New_Item : Element_Type;
Position : out Cursor;
Count : Count_Type := 1);
procedure Insert
(Container : in out List;
Before : Cursor;
Position : out Cursor;
Count : Count_Type := 1);
procedure Prepend
(Container : in out List;
New_Item : Element_Type;
Count : Count_Type := 1);
procedure Append
(Container : in out List;
New_Item : Element_Type;
Count : Count_Type := 1);
procedure Delete
(Container : in out List;
Position : in out Cursor;
Count : Count_Type := 1);
procedure Delete_First
(Container : in out List;
Count : Count_Type := 1);
procedure Delete_Last
(Container : in out List;
Count : Count_Type := 1);
procedure Reverse_Elements (Container : in out List);
procedure Swap
(Container : in out List;
I, J : Cursor);
procedure Swap_Links
(Container : in out List;
I, J : Cursor);
procedure Splice
(Container : in out List;
Before : Cursor;
Position : in out Cursor);
function First (Container : List) return Cursor;
function First_Element (Container : List) return Element_Type;
function Last (Container : List) return Cursor;
function Last_Element (Container : List) return Element_Type;
function Next (Position : Cursor) return Cursor;
procedure Next (Position : in out Cursor);
function Previous (Position : Cursor) return Cursor;
procedure Previous (Position : in out Cursor);
function Find
(Container : List;
Item : Element_Type;
Position : Cursor := No_Element) return Cursor;
function Reverse_Find
(Container : List;
Item : Element_Type;
Position : Cursor := No_Element) return Cursor;
function Contains
(Container : List;
Item : Element_Type) return Boolean;
function Has_Element (Position : Cursor) return Boolean;
procedure Iterate
(Container : List;
Process : not null access procedure (Position : Cursor));
procedure Reverse_Iterate
(Container : List;
Process : not null access procedure (Position : Cursor));
generic
with function "<" (Left, Right : Element_Type) return Boolean is <>;
package Generic_Sorting is
function Is_Sorted (Container : List) return Boolean;
procedure Sort (Container : in out List);
end Generic_Sorting;
private
type Node_Type is limited record
Prev : Count_Type'Base;
Next : Count_Type;
Element : Element_Type;
end record;
type Node_Array is array (Count_Type range <>) of Node_Type;
type List (Capacity : Count_Type) is tagged limited record
Nodes : Node_Array (1 .. Capacity) := (others => <>);
Free : Count_Type'Base := -1;
First : Count_Type := 0;
Last : Count_Type := 0;
Length : Count_Type := 0;
end record;
Empty_List : constant List := (0, others => <>);
type List_Access is access all List;
for List_Access'Storage_Size use 0;
type Cursor is
record
Container : List_Access;
Node : Count_Type := 0;
end record;
No_Element : constant Cursor := (null, 0);
end Ada.Containers.Restricted_Doubly_Linked_Lists;
|
pragma License (Unrestricted);
-- implementation unit specialized for Windows
with System.Synchronous_Objects;
with C.winbase;
with C.windef;
with C.winnt;
package System.Native_Tasks is
pragma Preelaborate;
-- thread
subtype Handle_Type is C.winnt.HANDLE;
function Current return Handle_Type
renames C.winbase.GetCurrentThread;
subtype Parameter_Type is C.windef.LPVOID;
subtype Result_Type is C.windef.DWORD;
subtype Thread_Body_Type is C.winbase.PTHREAD_START_ROUTINE;
pragma Convention_Identifier (Thread_Body_CC, WINAPI);
-- WINAPI is stdcall convention on 32bit, or C convention on 64bit.
procedure Create (
Handle : aliased out Handle_Type;
Parameter : Parameter_Type;
Thread_Body : Thread_Body_Type;
Error : out Boolean);
procedure Join (
Handle : Handle_Type; -- of target thread
Current_Abort_Event : access Synchronous_Objects.Event;
Result : aliased out Result_Type;
Error : out Boolean);
procedure Detach (
Handle : in out Handle_Type;
Error : out Boolean);
-- stack
function Info_Block (Handle : Handle_Type) return C.winnt.struct_TEB_ptr;
-- signals
type Abort_Handler is access procedure;
pragma Favor_Top_Level (Abort_Handler);
procedure Install_Abort_Handler (Handler : Abort_Handler);
procedure Uninstall_Abort_Handler;
pragma Inline (Install_Abort_Handler);
pragma Inline (Uninstall_Abort_Handler);
procedure Send_Abort_Signal (
Handle : Handle_Type;
Abort_Event : in out Synchronous_Objects.Event;
Error : out Boolean);
procedure Resend_Abort_Signal (Handle : Handle_Type; Error : out Boolean) is
null;
pragma Inline (Resend_Abort_Signal);
-- [gcc-7] can not skip calling null procedure
procedure Block_Abort_Signal (Abort_Event : Synchronous_Objects.Event);
procedure Unblock_Abort_Signal is null;
pragma Inline (Unblock_Abort_Signal);
-- [gcc-7] can not skip calling null procedure
-- scheduling
procedure Yield;
end System.Native_Tasks;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . D E B U G _ P O O L S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
--
--
--
--
--
--
--
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This packages provides a special implementation of the Ada95 storage pools
-- The goal of this debug pool is to detect incorrect uses of memory
-- (multiple deallocations, access to invalid memory,...). Errors are reported
-- in one of two ways: either by immediately raising an exception, or by
-- printing a message on standard output.
-- You need to instrument your code to use this package: for each access type
-- you want to monitor, you need to add a clause similar to:
-- type Integer_Access is access Integer;
-- for Integer_Access'Storage_Pool use Pool;
-- where Pool is a tagged object declared with
--
-- Pool : GNAT.Debug_Pools.Debug_Pool;
-- This package was designed to be as efficient as possible, but still has an
-- impact on the performance of your code, which depends on the number of
-- allocations, deallocations and, somewhat less, dereferences that your
-- application performs.
-- For each faulty memory use, this debug pool will print several lines
-- of information, including things like the location where the memory
-- was initially allocated, the location where it was freed etc.
-- Physical allocations and deallocations are done through the usual system
-- calls. However, in order to provide proper checks, the debug pool will not
-- release the memory immediately. It keeps released memory around (the amount
-- kept around is configurable) so that it can distinguish between memory that
-- has not been allocated and memory that has been allocated but freed. This
-- also means that this memory cannot be reallocated, preventing what would
-- otherwise be a false indication that freed memory is now allocated.
-- In addition, this package presents several subprograms that help analyze
-- the behavior of your program, by reporting memory leaks, the total amount
-- of memory that was allocated. The pool is also designed to work correctly
-- in conjunction with gnatmem.
-- Finally, a subprogram Print_Pool is provided for use from the debugger
-- Limitations
-- ===========
-- Current limitation of this debug pool: if you use this debug pool for a
-- general access type ("access all"), the pool might report invalid
-- dereferences if the access object is pointing to another object on the
-- stack which was not allocated through a call to "new".
-- This debug pool will respect all alignments specified in your code, but
-- it does that by aligning all objects using Standard'Maximum_Alignment.
-- This allows faster checks, and limits the performance impact of using
-- this pool.
with System; use System;
with System.Storage_Elements; use System.Storage_Elements;
with System.Checked_Pools;
package GNAT.Debug_Pools is
type Debug_Pool is new System.Checked_Pools.Checked_Pool with private;
-- The new debug pool
subtype SSC is System.Storage_Elements.Storage_Count;
Default_Max_Freed : constant SSC := 50_000_000;
Default_Stack_Trace_Depth : constant Natural := 20;
Default_Reset_Content : constant Boolean := False;
Default_Raise_Exceptions : constant Boolean := True;
Default_Advanced_Scanning : constant Boolean := False;
Default_Min_Freed : constant SSC := 0;
-- The above values are constants used for the parameters to Configure
-- if not overridden in the call. See description of Configure for full
-- details on these parameters. If these defaults are not satisfactory,
-- then you need to call Configure to change the default values.
procedure Configure
(Pool : in out Debug_Pool;
Stack_Trace_Depth : Natural := Default_Stack_Trace_Depth;
Maximum_Logically_Freed_Memory : SSC := Default_Max_Freed;
Minimum_To_Free : SSC := Default_Min_Freed;
Reset_Content_On_Free : Boolean := Default_Reset_Content;
Raise_Exceptions : Boolean := Default_Raise_Exceptions;
Advanced_Scanning : Boolean := Default_Advanced_Scanning);
-- Subprogram used to configure the debug pool.
--
-- Stack_Trace_Depth. This parameter controls the maximum depth of stack
-- traces that are output to indicate locations of actions for error
-- conditions such as bad allocations. If set to zero, the debug pool
-- will not try to compute backtraces. This is more efficient but gives
-- less information on problem locations
--
-- Maximum_Logically_Freed_Memory: maximum amount of memory (bytes)
-- that should be kept before starting to physically deallocate some.
-- This value should be non-zero, since having memory that is logically
-- but not physically freed helps to detect invalid memory accesses.
--
-- Minimum_To_Free is the minimum amount of memory that should be freed
-- every time the pool starts physically releasing memory. The algorithm
-- to compute which block should be physically released needs some
-- expensive initialization (see Advanced_Scanning below), and this
-- parameter can be used to limit the performance impact by ensuring
-- that a reasonable amount of memory is freed each time. Even in the
-- advanced scanning mode, marked blocks may be released to match this
-- Minimum_To_Free parameter.
--
-- Reset_Content_On_Free: If true, then the contents of the freed memory
-- is reset to the pattern 16#DEADBEEF#, following an old IBM convention.
-- This helps in detecting invalid memory references from the debugger.
--
-- Raise_Exceptions: If true, the exceptions below will be raised every
-- time an error is detected. If you set this to False, then the action
-- is to generate output on standard error, noting the errors, but to
-- keep running if possible (of course if storage is badly damaged, this
-- attempt may fail. This helps to detect more than one error in a run.
--
-- Advanced_Scanning: If true, the pool will check the contents of all
-- allocated blocks before physically releasing memory. Any possible
-- reference to a logically free block will prevent its deallocation.
-- Note that this algorithm is approximate, and it is recommended
-- that you set Minimum_To_Free to a non-zero value to save time.
--
-- All instantiations of this pool use the same internal tables. However,
-- they do not store the same amount of information for the tracebacks,
-- and they have different counters for maximum logically freed memory.
Accessing_Not_Allocated_Storage : exception;
-- Exception raised if Raise_Exception is True, and an attempt is made
-- to access storage that was never allocated.
Accessing_Deallocated_Storage : exception;
-- Exception raised if Raise_Exception is True, and an attempt is made
-- to access storage that was allocated but has been deallocated.
Freeing_Not_Allocated_Storage : exception;
-- Exception raised if Raise_Exception is True, and an attempt is made
-- to free storage that had not been previously allocated.
Freeing_Deallocated_Storage : exception;
-- Exception raised if Raise_Exception is True, and an attempt is made
-- to free storage that had already been freed.
-- Note on the above exceptions. The distinction between not allocated
-- and deallocated storage is not guaranteed to be accurate in the case
-- where storage is allocated, and then physically freed. Larger values
-- of the parameter Maximum_Logically_Freed_Memory will help to guarantee
-- that this distinction is made more accurately.
generic
with procedure Put_Line (S : String) is <>;
with procedure Put (S : String) is <>;
procedure Print_Info
(Pool : Debug_Pool;
Cumulate : Boolean := False;
Display_Slots : Boolean := False;
Display_Leaks : Boolean := False);
-- Print out information about the High Water Mark, the current and
-- total number of bytes allocated and the total number of bytes
-- deallocated.
--
-- If Display_Slots is true, this subprogram prints a list of all the
-- locations in the application that have done at least one allocation or
-- deallocation. The result might be used to detect places in the program
-- where lots of allocations are taking place. This output is not in any
-- defined order.
--
-- If Cumulate if True, then each stack trace will display the number of
-- allocations that were done either directly, or by the subprograms called
-- at that location (e.g: if there were two physical allocations at a->b->c
-- and a->b->d, then a->b would be reported as performing two allocations).
--
-- If Display_Leaks is true, then each block that has not been deallocated
-- (often called a "memory leak") will be listed, along with the traceback
-- showing where it was allocated. Not that no grouping of the blocks is
-- done, you should use the Dump_Gnatmem procedure below in conjunction
-- with the gnatmem utility.
procedure Print_Info_Stdout
(Pool : Debug_Pool;
Cumulate : Boolean := False;
Display_Slots : Boolean := False;
Display_Leaks : Boolean := False);
-- Standard instantiation of Print_Info to print on standard_output. More
-- convenient to use where this is the intended location, and in particular
-- easier to use from the debugger.
procedure Dump_Gnatmem (Pool : Debug_Pool; File_Name : String);
-- Create an external file on the disk, which can be processed by gnatmem
-- to display the location of memory leaks.
--
-- This provides a nicer output that Print_Info above, and groups similar
-- stack traces together. This also provides an easy way to save the memory
-- status of your program for post-mortem analysis.
--
-- To use this file, use the following command line:
-- gnatmem 5 -i <File_Name> <Executable_Name>
-- If you want all the stack traces to be displayed with 5 levels.
procedure Print_Pool (A : System.Address);
pragma Export (C, Print_Pool, "print_pool");
-- This subprogram is meant to be used from a debugger. Given an address in
-- memory, it will print on standard output the known information about
-- this address (provided, of course, the matching pointer is handled by
-- the Debug_Pool).
--
-- The information includes the stacktrace for the allocation or
-- deallocation of that memory chunck, its current status (allocated or
-- logically freed), etc.
private
-- The following are the standard primitive subprograms for a pool
procedure Allocate
(Pool : in out Debug_Pool;
Storage_Address : out Address;
Size_In_Storage_Elements : Storage_Count;
Alignment : Storage_Count);
-- Allocate a new chunk of memory, and set it up so that the debug pool
-- can check accesses to its data, and report incorrect access later on.
-- The parameters have the same semantics as defined in the ARM95.
procedure Deallocate
(Pool : in out Debug_Pool;
Storage_Address : Address;
Size_In_Storage_Elements : Storage_Count;
Alignment : Storage_Count);
-- Mark a block of memory as invalid. It might not be physically removed
-- immediately, depending on the setup of the debug pool, so that checks
-- are still possible. The parameters have the same semantics as defined
-- in the RM.
function Storage_Size (Pool : Debug_Pool) return SSC;
-- Return the maximal size of data that can be allocated through Pool.
-- Since Pool uses the malloc() system call, all the memory is accessible
-- through the pool
procedure Dereference
(Pool : in out Debug_Pool;
Storage_Address : System.Address;
Size_In_Storage_Elements : Storage_Count;
Alignment : Storage_Count);
-- Check whether a derefence statement is valid, ie whether the pointer
-- was allocated through Pool. As documented above, errors will be
-- reported either by a special error message or an exception, depending
-- on the setup of the storage pool.
-- The parameters have the same semantics as defined in the ARM95.
type Byte_Count is mod System.Max_Binary_Modulus;
-- Type used for maintaining byte counts, needs to be large enough
-- to accomodate counts allowing for repeated use of the same memory.
type Debug_Pool is new System.Checked_Pools.Checked_Pool with record
Stack_Trace_Depth : Natural := Default_Stack_Trace_Depth;
Maximum_Logically_Freed_Memory : SSC := Default_Max_Freed;
Reset_Content_On_Free : Boolean := Default_Reset_Content;
Raise_Exceptions : Boolean := Default_Raise_Exceptions;
Minimum_To_Free : SSC := Default_Min_Freed;
Advanced_Scanning : Boolean := Default_Advanced_Scanning;
Allocated : Byte_Count := 0;
-- Total number of bytes allocated in this pool
Logically_Deallocated : Byte_Count := 0;
-- Total number of bytes logically deallocated in this pool. This is the
-- memory that the application has released, but that the pool has not
-- yet physically released through a call to free(), to detect later
-- accesed to deallocated memory.
Physically_Deallocated : Byte_Count := 0;
-- Total number of bytes that were free()-ed
Marked_Blocks_Deallocated : Boolean := False;
-- Set to true if some mark blocks had to be deallocated in the advanced
-- scanning scheme. Since this is potentially dangereous, this is
-- reported to the user, who might want to rerun his program with a
-- lower Minimum_To_Free value.
High_Water : Byte_Count := 0;
-- Maximum of Allocated - Logically_Deallocated - Physically_Deallocated
First_Free_Block : System.Address := System.Null_Address;
Last_Free_Block : System.Address := System.Null_Address;
-- Pointers to the first and last logically freed blocks
First_Used_Block : System.Address := System.Null_Address;
-- Pointer to the list of currently allocated blocks. This list is
-- used to list the memory leaks in the application on exit, as well as
-- for the advanced freeing algorithms that needs to traverse all these
-- blocks to find possible references to the block being physically
-- freed.
end record;
end GNAT.Debug_Pools;
|
-- { dg-do compile }
pragma Restrictions(No_Elaboration_Code);
with Elab4_Proc;
package Elab4 is
procedure My_G is new Elab4_Proc;
end Elab4;
-- { dg-final { scan-assembler-not "elabs" } }
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . B B . B O A R D _ S U P P O R T --
-- --
-- B o d y --
-- --
-- Copyright (C) 1999-2002 Universidad Politecnica de Madrid --
-- Copyright (C) 2003-2006 The European Space Agency --
-- Copyright (C) 2003-2021, AdaCore --
-- --
-- GNARL 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. GNARL is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
-- The port of GNARL to bare board targets was initially developed by the --
-- Real-Time Systems Group at the Technical University of Madrid. --
-- --
------------------------------------------------------------------------------
with Interfaces; use Interfaces;
with System.ARM_GIC;
with System.Machine_Code;
with System.BB.CPU_Primitives.Multiprocessors;
with System.BB.Parameters; use System.BB.Parameters;
package body System.BB.Board_Support is
use BB.Interrupts;
----------------
-- Interrupts --
----------------
package GIC renames System.ARM_GIC;
procedure IRQ_Handler is new GIC.IRQ_Handler (Interrupt_Wrapper);
pragma Export (Ada, IRQ_Handler, "__gnat_irq_handler");
procedure FIQ_Handler;
pragma Export (Ada, FIQ_Handler, "__gnat_fiq_handler");
-- Low-level interrupt handler
procedure Initialize_CPU_Devices;
pragma Export (C, Initialize_CPU_Devices, "__gnat_initialize_cpu_devices");
-- Per CPU device initialization
-----------
-- Timer --
-----------
Global_Timer_Base : constant := MPCore_Base + 16#200#;
Global_Timer_Counter0 : Unsigned_32
with Import, Volatile, Address => Global_Timer_Base + 16#00#;
Global_Timer_Counter1 : Unsigned_32
with Import, Volatile, Address => Global_Timer_Base + 16#04#;
Global_Timer_Control : Unsigned_32
with Import, Volatile, Address => Global_Timer_Base + 16#08#;
Global_Timer_Interrupt_Status : Unsigned_32
with Import, Volatile, Address => Global_Timer_Base + 16#0C#;
Global_Timer_Comparator0 : Unsigned_32
with Import, Volatile, Address => Global_Timer_Base + 16#10#;
Global_Timer_Comparator1 : Unsigned_32
with Import, Volatile, Address => Global_Timer_Base + 16#14#;
----------------------------
-- Initialize_CPU_Devices --
----------------------------
procedure Initialize_CPU_Devices is
begin
-- Make sure the Global timer IRQ is cleared
Global_Timer_Interrupt_Status := 1;
-- Then enable (prescaler = 0).
-- Bits 1-3 are bancked per core
Global_Timer_Control := 16#00_0_1#;
GIC.Initialize_GICC;
end Initialize_CPU_Devices;
----------------------
-- Initialize_Board --
----------------------
procedure Initialize_Board is
begin
-- Setup global timer
-- First stop and clear
Global_Timer_Control := 0;
Global_Timer_Counter0 := 0;
Global_Timer_Counter1 := 0;
GIC.Initialize_GICD;
-- Level: 01: high level, 11: rising-edge
-- See ug585 table 7.4 for the values.
GIC.Define_IRQ_Triggers
((
-- IRQs 32 - 47
2 => 2#01_01_01_01_01_01_11_01_01_01_01_00_01_01_11_11#,
-- IRQs 63 - 48
3 => 2#01_01_01_01_01_01_01_01_11_01_01_01_01_01_01_01#,
-- IRQs 79 - 64
4 => 2#01_11_01_01_01_01_01_01_01_01_01_01_01_01_01_01#,
-- IRQs 95 - 80
5 => 2#00_00_00_01_01_01_01_01_01_01_01_01_01_01_01_01#));
Initialize_CPU_Devices;
end Initialize_Board;
package body Time is
Alarm_Interrupt_ID : constant BB.Interrupts.Interrupt_ID := 27;
-- Use the global timer interrupt
---------------
-- Set_Alarm --
---------------
procedure Set_Alarm (Ticks : BB.Time.Time)
is
use BB.Time;
Lo : constant Unsigned_32 := Unsigned_32 (Ticks and 16#FFFF_FFFF#);
Hi : constant Unsigned_32 :=
Unsigned_32 (Shift_Right (Unsigned_64 (Ticks), 32));
begin
if Ticks = BB.Time.Time'Last then
Clear_Alarm_Interrupt;
else
-- Set comparator using the 64-bit private timer comparator.
-- See Cortex-A9 Technical Reference Manual 4.3.
-- Requires revision >= r2p0, otherwise no exception is raised for
-- past counter values.
-- Clear the comp_enable bit
Global_Timer_Control := Global_Timer_Control and not 2#010#;
-- Write Lo/Hi comparator values
Global_Timer_Comparator0 := Lo;
Global_Timer_Comparator1 := Hi;
-- Enable timer and IRQ
Global_Timer_Control := 2#111#;
end if;
end Set_Alarm;
----------------
-- Read_Clock --
----------------
function Read_Clock return BB.Time.Time is
use BB.Time;
Lo : Unsigned_32;
Hi : Unsigned_32;
Hi1 : Unsigned_32;
begin
-- We can't atomically read the 64-bits counter. So check that the
-- 32 MSB don't change.
Hi := Global_Timer_Counter1;
loop
Lo := Global_Timer_Counter0;
Hi1 := Global_Timer_Counter1;
exit when Hi = Hi1;
Hi := Hi1;
end loop;
return (BB.Time.Time (Hi) * 2 ** 32) + BB.Time.Time (Lo);
end Read_Clock;
---------------------------
-- Install_Alarm_Handler --
---------------------------
procedure Install_Alarm_Handler (Handler : Interrupt_Handler) is
begin
-- Attach interrupt handler
BB.Interrupts.Attach_Handler
(Handler,
Alarm_Interrupt_ID,
Interrupt_Priority'Last);
end Install_Alarm_Handler;
---------------------------
-- Clear_Alarm_Interrupt --
---------------------------
procedure Clear_Alarm_Interrupt is
begin
Global_Timer_Control := 2#001#;
Global_Timer_Interrupt_Status := 1;
end Clear_Alarm_Interrupt;
end Time;
-----------------
-- FIQ_Handler --
-----------------
procedure FIQ_Handler is
begin
-- Not supported
raise Program_Error;
end FIQ_Handler;
package body Interrupts is
procedure Install_Interrupt_Handler
(Interrupt : BB.Interrupts.Interrupt_ID;
Prio : Interrupt_Priority)
renames GIC.Install_Interrupt_Handler;
function Priority_Of_Interrupt
(Interrupt : System.BB.Interrupts.Interrupt_ID)
return System.Any_Priority
renames GIC.Priority_Of_Interrupt;
procedure Set_Current_Priority (Priority : Integer)
renames GIC.Set_Current_Priority;
procedure Power_Down renames GIC.Power_Down;
end Interrupts;
package body Multiprocessors is
use System.Machine_Code;
use System.Multiprocessors;
Poke_Interrupt : constant Interrupt_ID := 0;
-- Use SGI #0
procedure Poke_Handler (Interrupt : BB.Interrupts.Interrupt_ID);
-- Handler for the Poke interrupt
function MPIDR return Unsigned_32;
-- Return current value of the MPIDR register
procedure Start_CPU (CPU_Id : CPU);
-- Start one cpu
-- SCU configuration register
SCU_Configuration : Unsigned_32
with Address => 16#F8F0_0004#, Volatile, Import;
--------------------
-- Number_Of_CPUs --
--------------------
function Number_Of_CPUs return CPU is
NCPUs : CPU;
begin
NCPUs := CPU (1 + (SCU_Configuration and 3));
return NCPUs;
end Number_Of_CPUs;
-----------
-- MPIDR --
-----------
function MPIDR return Unsigned_32 is
R : Unsigned_32;
begin
Asm ("mrc p15,0,%0,c0,c0,5",
Outputs => Unsigned_32'Asm_Output ("=r", R),
Volatile => True);
return R;
end MPIDR;
-----------------
-- Current_CPU --
-----------------
function Current_CPU return CPU is
-- Get CPU Id from bits 1:0 from the MPIDR register
(if CPU'Last = 1 then 1 else CPU ((MPIDR and 3) + 1));
--------------
-- Poke_CPU --
--------------
procedure Poke_CPU (CPU_Id : CPU) is
begin
-- There is no need to protect access to the register since the only
-- operation applied to it is this assignment and it's always with
-- the same value (Poke_Interrupt).
-- No race condition possible here.
GIC.Poke_CPU (CPU_Id, Poke_Interrupt);
end Poke_CPU;
---------------
-- Start_CPU --
---------------
procedure Start_CPU (CPU_Id : CPU) is
procedure Kick_Cpu1;
pragma Import (C, Kick_Cpu1, "__kick_cpu1");
-- Start processor #1
begin
-- Cannot be true on one processor configuration
pragma Warnings (Off, "condition*");
if CPU_Id = 2 then
Kick_Cpu1;
end if;
pragma Warnings (On, "condition*");
end Start_CPU;
--------------------
-- Start_All_CPUs --
--------------------
procedure Start_All_CPUs is
begin
BB.Interrupts.Attach_Handler
(Poke_Handler'Access, Poke_Interrupt, Interrupt_Priority'Last);
-- Disable warnings for non-SMP case
pragma Warnings (Off, "loop range is null*");
for CPU_Id in CPU'First + 1 .. CPU'Last loop
Start_CPU (CPU_Id);
end loop;
pragma Warnings (On, "loop range is null*");
end Start_All_CPUs;
------------------
-- Poke_Handler --
------------------
procedure Poke_Handler (Interrupt : BB.Interrupts.Interrupt_ID) is
begin
-- Make sure we are handling the right interrupt
pragma Assert (Interrupt = Poke_Interrupt);
System.BB.CPU_Primitives.Multiprocessors.Poke_Handler;
end Poke_Handler;
end Multiprocessors;
end System.BB.Board_Support;
|
pragma License (GPL);
------------------------------------------------------------------------------
-- EMAIL: <darkestkhan@gmail.com> --
-- License: GNU GPLv3 or any later as published by Free Software Foundation --
-- (see README file) --
-- Copyright © 2013 darkestkhan --
------------------------------------------------------------------------------
-- This Program is Free Software: You can redistribute it and/or modify --
-- it under the terms of The GNU General Public License as published by --
-- the Free Software Foundation, either version 3 of the license, or --
-- (at Your option) any later version. --
-- --
-- This Program is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS for A PARTICULAR PURPOSE. See the --
-- GNU General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public License --
-- along with this program. If not, see <http://www.gnu.org/licenses/>. --
------------------------------------------------------------------------------
--------------------------------------------------------------------------
-- Test parameterized Data_Home, Config_Home and Cache_Home functions. --
--------------------------------------------------------------------------
with Ada.Environment_Variables;
with Ada.Command_Line;
with Ada.Text_IO;
with XDG;
procedure XDG_Home_Paths is
package EV renames Ada.Environment_Variables;
package CLI renames Ada.Command_Line;
package TIO renames Ada.Text_IO;
type String_Access is access String;
type XDG_Paths is (Data_Home, Config_Home, Cache_Home);
-- Error count;
Errors: Natural := 0;
Home_Path: constant String := EV.Value ("HOME");
-- NOTE: '/' at the end of Dir is added in order to ease up testing.
Dir: constant String := "XDG?/";
function Get_Path (To: in XDG_Paths) return String
is
begin
case To is
when Data_Home => return XDG.Data_Home (Dir);
when Config_Home => return XDG.Config_Home (Dir);
when Cache_Home => return XDG.Cache_Home (Dir);
end case;
end Get_Path;
Var_Names: constant array (XDG_Paths) of String_Access :=
( new String'("XDG_DATA_HOME"),
new String'("XDG_CONFIG_HOME"),
new String'("XDG_CACHE_HOME")
);
Paths: constant array (XDG_Paths) of String_Access :=
( new String'(Home_Path & "data/"),
new String'(Home_Path & "config/"),
new String'(Home_Path & "cache/")
);
Error_Message: constant String := "Test error when testing: ";
Error_Message_At_Exit: constant String :=
"xdg_home_paths: Total number of unexpected failures triggered: ";
begin
for I in XDG_Paths loop
EV.Clear (Var_Names (I).all);
EV.Set (Var_Names (I).all, Paths (I).all);
if Get_Path (I) /= Paths (I).all & Dir then
Errors := Errors + 1;
TIO.Put_Line
( File => TIO.Standard_Error,
Item => Error_Message & " " & XDG_Paths'Image (I)
);
TIO.Put_Line
( File => TIO.Standard_Error,
Item => " Expected value: " & Paths (I).all & Dir
);
TIO.Put_Line
( File => TIO.Standard_Error,
Item => " Received value: " & Get_Path (I)
);
end if;
end loop;
if Errors /= 0 then
TIO.Put_Line
( File => TIO.Standard_Error,
Item => Error_Message_At_Exit & Natural'Image (Errors)
);
CLI.Set_Exit_Status (CLI.Failure);
end if;
end XDG_Home_Paths;
|
with Ada.IO_Exceptions;
with Ada.Streams;
private with C.openssl.md5;
package Crypto.MD5 is
pragma Preelaborate;
subtype Fingerprint is Ada.Streams.Stream_Element_Array (0 .. 15);
subtype Message_Digest is String (1 .. 32);
type Context (<>) is private;
function Initial return Context;
procedure Update (
Context : in out MD5.Context;
Data : in Ada.Streams.Stream_Element_Array);
procedure Update (Context : in out MD5.Context; Data : in String);
procedure Final (Context : in out MD5.Context; Digest : out Fingerprint);
function Value (S : Message_Digest) return Fingerprint;
function Image (Digest : Fingerprint) return Message_Digest;
-- exceptions
Use_Error : exception
renames Ada.IO_Exceptions.Use_Error;
private
type Context is record
MD5 : aliased C.openssl.md5.MD5_CTX;
end record;
pragma Suppress_Initialization (Context);
pragma Compile_Time_Error (
Fingerprint'Length /= C.openssl.md5.MD5_DIGEST_LENGTH,
"Fingerprint'Length is mismatch.");
end Crypto.MD5;
|
--
-- See protect.adb
--
-- This test proves that multiple readers on a protected
-- object are possible when using function: in the example
-- protect.adb the problem was the delay.
--
-- (Hence the name One_A_Time must refer to the writers)
--
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
procedure Protect2 is
procedure Put_Time_Diff (D : in Time) is
T : Duration := Clock - D;
begin
Put (Duration'Image (T));
end Put_Time_Diff;
protected One_A_Time is
function Read (Id : String) return Integer;
procedure Write (X : Integer);
private
V : Integer := 2;
T : Time := Clock;
end One_A_Time;
protected body One_A_Time is
function Read (Id : String) return Integer is
begin
Put_Time_Diff (T); Put_Line (" OAT reads for " & Id);
return V;
end Read;
procedure Write (X : Integer) is
begin
Put_Time_Diff (T); Put_Line (" OAT starts writing...");
delay 5.0;
V := X;
Put_Time_Diff (T); Put_Line (" OAT ended writing...");
end Write;
end One_A_Time;
task Reader1;
task Reader2;
task body Reader1 is
I : Integer := One_A_Time.Read ("R1");
begin
loop
exit when I = 0;
I := One_A_Time.Read ("R1");
delay 0.5;
end loop;
end Reader1;
task body Reader2 is
I : Integer := One_A_Time.Read ("R2");
begin
loop
exit when I = 0;
I := One_A_Time.Read ("R2");
delay 0.5;
end loop;
end Reader2;
T : Time := Clock;
begin
-- The main writes
Put_Time_Diff (T); Put_Line (" ET writes 1...");
One_A_Time.Write (1);
Put_Time_Diff (T); Put_Line (" ET has written 1");
delay 5.0;
Put_Time_Diff (T); Put_Line (" ET writes 0...");
One_A_Time.Write (0);
Put_Time_Diff (T); Put_Line (" ET has written 0");
end;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Thick_Hello is
package Counter is
type C_Type is mod 17;
procedure Increment;
procedure Increment (I : Integer);
procedure Decrement;
function Value return C_Type;
private
Cnt : C_Type := 0;
end Counter;
package body Counter is
procedure Increment is
begin
Cnt := Cnt + 1;
end Increment;
procedure Increment (I : Integer) is
begin
Cnt := Cnt + C_Type (I mod C_Type'Modulus);
end Increment;
procedure Decrement is
begin
Cnt := Cnt - 1;
end Decrement;
function Value return C_Type is (Cnt);
end Counter;
package M is new Ada.Text_IO.Modular_IO (Counter.C_Type);
use type Counter.C_Type;
T : Counter.C_Type := 0;
begin
for I in Integer range 1 .. 120
loop
if I rem 7 = 0 then
Counter.Decrement;
elsif I rem 12 = 0 then
Counter.Decrement;
elsif I rem 17 = 0 then
Counter.Increment;
elsif I rem 25 = 0 then
Counter.Increment (I);
end if;
if T = Counter.Value then
Counter.Increment;
end if;
M.Put (Counter.Value); New_Line;
T := Counter.Value;
end loop;
end Thick_Hello;
|
package body Symbex.Walk is
procedure Walk_Tree
(Tree : in Parse.Tree_t;
Status : out Walk_Status_t)
is
Finish_Tree : exception;
Finish_Error : exception;
Depth : Natural := 0;
-- Recursive list walking procedure.
procedure Walk_List
(Tree : in Parse.Tree_t;
List_ID : in Parse.List_ID_t)
is
use type Parse.List_Position_t;
procedure Process_List (List : in Parse.List_t) is
Current_Status : Walk_Status_t;
Length : Parse.List_Length_t;
Position : Parse.List_Position_t;
-- Process node, call handler based on node type.
procedure Process_Node (Node : in Parse.Node_t) is
begin
case Parse.Node_Kind (Node) is
when Parse.Node_Symbol =>
Handle_Symbol
(Name => Parse.Internal.Get_Data (Node),
List_ID => List_ID,
List_Position => Position,
List_Length => Length,
Status => Current_Status);
when Parse.Node_String =>
Handle_String
(Data => Parse.Internal.Get_Data (Node),
List_ID => List_ID,
List_Position => Position,
List_Length => Length,
Status => Current_Status);
when Parse.Node_List =>
Walk_List
(Tree => Tree,
List_ID => Parse.Internal.Get_List_ID (Node));
end case;
Position := Position + 1;
end Process_Node;
begin
Length := Parse.List_Length (List);
Position := Parse.List_Position_t'First;
-- Open list callback.
Handle_List_Open
(List_ID => List_ID,
Depth => Parse.List_Depth_t (Depth),
Status => Current_Status);
case Current_Status is
when Walk_Continue => null;
when Walk_Finish_List => return;
when Walk_Finish_Tree => raise Finish_Tree;
when Walk_Error => raise Finish_Error;
end case;
-- Iterate over all nodes in list.
Parse.Internal.List_Iterate
(List => List,
Process => Process_Node'Access);
case Current_Status is
when Walk_Continue => null;
when Walk_Finish_List => return;
when Walk_Finish_Tree => raise Finish_Tree;
when Walk_Error => raise Finish_Error;
end case;
-- Close list callback.
Handle_List_Close
(List_ID => List_ID,
Depth => Parse.List_Depth_t (Depth),
Status => Current_Status);
case Current_Status is
when Walk_Continue => null;
when Walk_Finish_List => return;
when Walk_Finish_Tree => raise Finish_Tree;
when Walk_Error => raise Finish_Error;
end case;
end Process_List;
begin
Depth := Depth + 1;
Process_List
(Parse.Internal.Get_List
(Tree => Tree,
List_ID => List_ID));
Depth := Depth - 1;
end Walk_List;
begin
Walk_List
(Tree => Tree,
List_ID => Parse.List_ID_t'First);
exception
when Finish_Tree => Status := Walk_Finish_Tree;
when Finish_Error => Status := Walk_Error;
end Walk_Tree;
end Symbex.Walk;
|
with base_iface; use base_iface;
package oop_mixin is
type Derived is limited new The_Interface with null record;
overriding procedure simple (Self : Derived);
overriding procedure compound (Self : Derived);
overriding procedure redispatching(Self : Derived);
end oop_mixin;
|
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
with Apsepp.Generic_Shared_Instance.Access_Setter,
Apsepp.Test_Node_Class.Private_Test_Reporter;
package body Apsepp.Test_Node_Class.Runner_Sequential is
----------------------------------------------------------------------------
overriding
function Child (Obj : Test_Runner_Sequential;
K : Test_Node_Index) return Test_Node_Access
is (Obj.Child_Access);
----------------------------------------------------------------------------
overriding
function Routine (Obj : Test_Runner_Sequential;
K : Test_Routine_Index) return Test_Routine
is (Null_Test_Routine'Access);
----------------------------------------------------------------------------
overriding
procedure Run
(Obj : in out Test_Runner_Sequential;
Outcome : out Test_Outcome;
Kind : Run_Kind := Assert_Cond_And_Run_Test) is
use Private_Test_Reporter;
R_A : constant Shared_Instance.Instance_Type_Access
:= Shared_Instance.Instance_Type_Access (Obj.Reporter_Access);
procedure CB is new SB_Lock_CB_procedure (SBLCB_Access => Obj.R_A_S_CB);
package Test_Reporter_Access_Setter is new Shared_Instance.Access_Setter
(Inst_Access => R_A,
CB => CB);
pragma Unreferenced (Test_Reporter_Access_Setter);
begin
Outcome := Passed;
case Kind is
when Assert_Cond_And_Run_Test =>
Test_Suite_Stub (Obj).Run (Outcome, Check_Cond); -- Inherited
-- procedure call.
when Check_Cond =>
null;
end case;
case Outcome is
when Passed =>
Test_Suite_Stub (Obj).Run (Outcome, Kind); -- Inherited procedure
-- call.
when Failed =>
null;
end case;
end Run;
----------------------------------------------------------------------------
end Apsepp.Test_Node_Class.Runner_Sequential;
|
-- This spec has been automatically generated from STM32F303xE.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.EXTI is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- IMR1_MR array element
subtype IMR1_MR_Element is STM32_SVD.Bit;
-- IMR1_MR array
type IMR1_MR_Field_Array is array (0 .. 31) of IMR1_MR_Element
with Component_Size => 1, Size => 32;
-- Interrupt mask register
type IMR1_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- MR as a value
Val : STM32_SVD.UInt32;
when True =>
-- MR as an array
Arr : IMR1_MR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for IMR1_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- EMR1_MR array element
subtype EMR1_MR_Element is STM32_SVD.Bit;
-- EMR1_MR array
type EMR1_MR_Field_Array is array (0 .. 31) of EMR1_MR_Element
with Component_Size => 1, Size => 32;
-- Event mask register
type EMR1_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- MR as a value
Val : STM32_SVD.UInt32;
when True =>
-- MR as an array
Arr : EMR1_MR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for EMR1_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- RTSR1_TR array element
subtype RTSR1_TR_Element is STM32_SVD.Bit;
-- RTSR1_TR array
type RTSR1_TR_Field_Array is array (0 .. 22) of RTSR1_TR_Element
with Component_Size => 1, Size => 23;
-- Type definition for RTSR1_TR
type RTSR1_TR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TR as a value
Val : STM32_SVD.UInt23;
when True =>
-- TR as an array
Arr : RTSR1_TR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 23;
for RTSR1_TR_Field use record
Val at 0 range 0 .. 22;
Arr at 0 range 0 .. 22;
end record;
-- RTSR1_TR array
type RTSR1_TR_Field_Array_1 is array (29 .. 31) of RTSR1_TR_Element
with Component_Size => 1, Size => 3;
-- Type definition for RTSR1_TR
type RTSR1_TR_Field_1
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TR as a value
Val : STM32_SVD.UInt3;
when True =>
-- TR as an array
Arr : RTSR1_TR_Field_Array_1;
end case;
end record
with Unchecked_Union, Size => 3;
for RTSR1_TR_Field_1 use record
Val at 0 range 0 .. 2;
Arr at 0 range 0 .. 2;
end record;
-- Rising Trigger selection register
type RTSR1_Register is record
-- Rising trigger event configuration of line 0
TR : RTSR1_TR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_23_28 : STM32_SVD.UInt6 := 16#0#;
-- Rising trigger event configuration of line 29
TR_1 : RTSR1_TR_Field_1 := (As_Array => False, Val => 16#0#);
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTSR1_Register use record
TR at 0 range 0 .. 22;
Reserved_23_28 at 0 range 23 .. 28;
TR_1 at 0 range 29 .. 31;
end record;
-- FTSR1_TR array element
subtype FTSR1_TR_Element is STM32_SVD.Bit;
-- FTSR1_TR array
type FTSR1_TR_Field_Array is array (0 .. 22) of FTSR1_TR_Element
with Component_Size => 1, Size => 23;
-- Type definition for FTSR1_TR
type FTSR1_TR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TR as a value
Val : STM32_SVD.UInt23;
when True =>
-- TR as an array
Arr : FTSR1_TR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 23;
for FTSR1_TR_Field use record
Val at 0 range 0 .. 22;
Arr at 0 range 0 .. 22;
end record;
-- FTSR1_TR array
type FTSR1_TR_Field_Array_1 is array (29 .. 31) of FTSR1_TR_Element
with Component_Size => 1, Size => 3;
-- Type definition for FTSR1_TR
type FTSR1_TR_Field_1
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TR as a value
Val : STM32_SVD.UInt3;
when True =>
-- TR as an array
Arr : FTSR1_TR_Field_Array_1;
end case;
end record
with Unchecked_Union, Size => 3;
for FTSR1_TR_Field_1 use record
Val at 0 range 0 .. 2;
Arr at 0 range 0 .. 2;
end record;
-- Falling Trigger selection register
type FTSR1_Register is record
-- Falling trigger event configuration of line 0
TR : FTSR1_TR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_23_28 : STM32_SVD.UInt6 := 16#0#;
-- Falling trigger event configuration of line 29
TR_1 : FTSR1_TR_Field_1 := (As_Array => False, Val => 16#0#);
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FTSR1_Register use record
TR at 0 range 0 .. 22;
Reserved_23_28 at 0 range 23 .. 28;
TR_1 at 0 range 29 .. 31;
end record;
-- SWIER1_SWIER array element
subtype SWIER1_SWIER_Element is STM32_SVD.Bit;
-- SWIER1_SWIER array
type SWIER1_SWIER_Field_Array is array (0 .. 22) of SWIER1_SWIER_Element
with Component_Size => 1, Size => 23;
-- Type definition for SWIER1_SWIER
type SWIER1_SWIER_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SWIER as a value
Val : STM32_SVD.UInt23;
when True =>
-- SWIER as an array
Arr : SWIER1_SWIER_Field_Array;
end case;
end record
with Unchecked_Union, Size => 23;
for SWIER1_SWIER_Field use record
Val at 0 range 0 .. 22;
Arr at 0 range 0 .. 22;
end record;
-- SWIER1_SWIER array
type SWIER1_SWIER_Field_Array_1 is array (29 .. 31)
of SWIER1_SWIER_Element
with Component_Size => 1, Size => 3;
-- Type definition for SWIER1_SWIER
type SWIER1_SWIER_Field_1
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SWIER as a value
Val : STM32_SVD.UInt3;
when True =>
-- SWIER as an array
Arr : SWIER1_SWIER_Field_Array_1;
end case;
end record
with Unchecked_Union, Size => 3;
for SWIER1_SWIER_Field_1 use record
Val at 0 range 0 .. 2;
Arr at 0 range 0 .. 2;
end record;
-- Software interrupt event register
type SWIER1_Register is record
-- Software Interrupt on line 0
SWIER : SWIER1_SWIER_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_23_28 : STM32_SVD.UInt6 := 16#0#;
-- Software Interrupt on line 29
SWIER_1 : SWIER1_SWIER_Field_1 :=
(As_Array => False, Val => 16#0#);
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SWIER1_Register use record
SWIER at 0 range 0 .. 22;
Reserved_23_28 at 0 range 23 .. 28;
SWIER_1 at 0 range 29 .. 31;
end record;
-- PR1_PR array element
subtype PR1_PR_Element is STM32_SVD.Bit;
-- PR1_PR array
type PR1_PR_Field_Array is array (0 .. 22) of PR1_PR_Element
with Component_Size => 1, Size => 23;
-- Type definition for PR1_PR
type PR1_PR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PR as a value
Val : STM32_SVD.UInt23;
when True =>
-- PR as an array
Arr : PR1_PR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 23;
for PR1_PR_Field use record
Val at 0 range 0 .. 22;
Arr at 0 range 0 .. 22;
end record;
-- PR1_PR array
type PR1_PR_Field_Array_1 is array (29 .. 31) of PR1_PR_Element
with Component_Size => 1, Size => 3;
-- Type definition for PR1_PR
type PR1_PR_Field_1
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PR as a value
Val : STM32_SVD.UInt3;
when True =>
-- PR as an array
Arr : PR1_PR_Field_Array_1;
end case;
end record
with Unchecked_Union, Size => 3;
for PR1_PR_Field_1 use record
Val at 0 range 0 .. 2;
Arr at 0 range 0 .. 2;
end record;
-- Pending register
type PR1_Register is record
-- Pending bit 0
PR : PR1_PR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_23_28 : STM32_SVD.UInt6 := 16#0#;
-- Pending bit 29
PR_1 : PR1_PR_Field_1 := (As_Array => False, Val => 16#0#);
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PR1_Register use record
PR at 0 range 0 .. 22;
Reserved_23_28 at 0 range 23 .. 28;
PR_1 at 0 range 29 .. 31;
end record;
-- IMR2_MR array element
subtype IMR2_MR_Element is STM32_SVD.Bit;
-- IMR2_MR array
type IMR2_MR_Field_Array is array (32 .. 35) of IMR2_MR_Element
with Component_Size => 1, Size => 4;
-- Type definition for IMR2_MR
type IMR2_MR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- MR as a value
Val : STM32_SVD.UInt4;
when True =>
-- MR as an array
Arr : IMR2_MR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 4;
for IMR2_MR_Field use record
Val at 0 range 0 .. 3;
Arr at 0 range 0 .. 3;
end record;
-- Interrupt mask register
type IMR2_Register is record
-- Interrupt Mask on external/internal line 32
MR : IMR2_MR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_4_31 : STM32_SVD.UInt28 := 16#FFFFFFF#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IMR2_Register use record
MR at 0 range 0 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- EMR2_MR array element
subtype EMR2_MR_Element is STM32_SVD.Bit;
-- EMR2_MR array
type EMR2_MR_Field_Array is array (32 .. 35) of EMR2_MR_Element
with Component_Size => 1, Size => 4;
-- Type definition for EMR2_MR
type EMR2_MR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- MR as a value
Val : STM32_SVD.UInt4;
when True =>
-- MR as an array
Arr : EMR2_MR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 4;
for EMR2_MR_Field use record
Val at 0 range 0 .. 3;
Arr at 0 range 0 .. 3;
end record;
-- Event mask register
type EMR2_Register is record
-- Event mask on external/internal line 32
MR : EMR2_MR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_4_31 : STM32_SVD.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EMR2_Register use record
MR at 0 range 0 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- RTSR2_TR array element
subtype RTSR2_TR_Element is STM32_SVD.Bit;
-- RTSR2_TR array
type RTSR2_TR_Field_Array is array (32 .. 33) of RTSR2_TR_Element
with Component_Size => 1, Size => 2;
-- Type definition for RTSR2_TR
type RTSR2_TR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TR as a value
Val : STM32_SVD.UInt2;
when True =>
-- TR as an array
Arr : RTSR2_TR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for RTSR2_TR_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Rising Trigger selection register
type RTSR2_Register is record
-- Rising trigger event configuration bit of line 32
TR : RTSR2_TR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_2_31 : STM32_SVD.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTSR2_Register use record
TR at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- FTSR2_TR array element
subtype FTSR2_TR_Element is STM32_SVD.Bit;
-- FTSR2_TR array
type FTSR2_TR_Field_Array is array (32 .. 33) of FTSR2_TR_Element
with Component_Size => 1, Size => 2;
-- Type definition for FTSR2_TR
type FTSR2_TR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TR as a value
Val : STM32_SVD.UInt2;
when True =>
-- TR as an array
Arr : FTSR2_TR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for FTSR2_TR_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Falling Trigger selection register
type FTSR2_Register is record
-- Falling trigger event configuration bit of line 32
TR : FTSR2_TR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_2_31 : STM32_SVD.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FTSR2_Register use record
TR at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- SWIER2_SWIER array element
subtype SWIER2_SWIER_Element is STM32_SVD.Bit;
-- SWIER2_SWIER array
type SWIER2_SWIER_Field_Array is array (32 .. 33) of SWIER2_SWIER_Element
with Component_Size => 1, Size => 2;
-- Type definition for SWIER2_SWIER
type SWIER2_SWIER_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SWIER as a value
Val : STM32_SVD.UInt2;
when True =>
-- SWIER as an array
Arr : SWIER2_SWIER_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for SWIER2_SWIER_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Software interrupt event register
type SWIER2_Register is record
-- Software interrupt on line 32
SWIER : SWIER2_SWIER_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_2_31 : STM32_SVD.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SWIER2_Register use record
SWIER at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- PR2_PR array element
subtype PR2_PR_Element is STM32_SVD.Bit;
-- PR2_PR array
type PR2_PR_Field_Array is array (32 .. 33) of PR2_PR_Element
with Component_Size => 1, Size => 2;
-- Type definition for PR2_PR
type PR2_PR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PR as a value
Val : STM32_SVD.UInt2;
when True =>
-- PR as an array
Arr : PR2_PR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for PR2_PR_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Pending register
type PR2_Register is record
-- Pending bit on line 32
PR : PR2_PR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_2_31 : STM32_SVD.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PR2_Register use record
PR at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- External interrupt/event controller
type EXTI_Peripheral is record
-- Interrupt mask register
IMR1 : aliased IMR1_Register;
-- Event mask register
EMR1 : aliased EMR1_Register;
-- Rising Trigger selection register
RTSR1 : aliased RTSR1_Register;
-- Falling Trigger selection register
FTSR1 : aliased FTSR1_Register;
-- Software interrupt event register
SWIER1 : aliased SWIER1_Register;
-- Pending register
PR1 : aliased PR1_Register;
-- Interrupt mask register
IMR2 : aliased IMR2_Register;
-- Event mask register
EMR2 : aliased EMR2_Register;
-- Rising Trigger selection register
RTSR2 : aliased RTSR2_Register;
-- Falling Trigger selection register
FTSR2 : aliased FTSR2_Register;
-- Software interrupt event register
SWIER2 : aliased SWIER2_Register;
-- Pending register
PR2 : aliased PR2_Register;
end record
with Volatile;
for EXTI_Peripheral use record
IMR1 at 16#0# range 0 .. 31;
EMR1 at 16#4# range 0 .. 31;
RTSR1 at 16#8# range 0 .. 31;
FTSR1 at 16#C# range 0 .. 31;
SWIER1 at 16#10# range 0 .. 31;
PR1 at 16#14# range 0 .. 31;
IMR2 at 16#18# range 0 .. 31;
EMR2 at 16#1C# range 0 .. 31;
RTSR2 at 16#20# range 0 .. 31;
FTSR2 at 16#24# range 0 .. 31;
SWIER2 at 16#28# range 0 .. 31;
PR2 at 16#2C# range 0 .. 31;
end record;
-- External interrupt/event controller
EXTI_Periph : aliased EXTI_Peripheral
with Import, Address => System'To_Address (16#40010400#);
end STM32_SVD.EXTI;
|
generic
-- Generic parameter to convert list element to string
package Generic_List.Output is
procedure Print (List : List_T);
end Generic_List.Output;
|
with
lace.Observer,
lace.Subject,
lace.Response;
private
with
ada.Text_IO,
ada.Containers.indefinite_hashed_Sets;
package lace.event.Logger.text
--
-- Provides a logger which logs to a text file.
--
is
type Item is limited new Logger.item with private;
type View is access all Item'Class;
-- Forge
--
function to_Logger (Name : in String) return Item;
overriding
procedure destruct (Self : in out Item);
-- Operations
--
-- Logging of event consfiguration.
--
overriding
procedure log_Connection (Self : in out Item; From : in Observer.view;
To : in Subject .view;
for_Kind : in Event.Kind);
overriding
procedure log_Disconnection (Self : in out Item; From : in Observer.view;
To : in Subject .view;
for_Kind : in Event.Kind);
overriding
procedure log_new_Response (Self : in out Item; the_Response : in Response.view;
of_Observer : in Observer.item'Class;
to_Kind : in Event.Kind;
from_Subject : in subject_Name);
overriding
procedure log_rid_Response (Self : in out Item; the_Response : in Response.view;
of_Observer : in Observer.item'Class;
to_Kind : in Event.Kind;
from_Subject : in subject_Name);
-- Logging of event transmission.
--
overriding
procedure log_Emit (Self : in out Item; From : in Subject .view;
To : in Observer.view;
the_Event : in Event.item'Class);
overriding
procedure log_Relay (Self : in out Item; From : in Observer.view;
To : in Observer.view;
the_Event : in Event.item'Class);
overriding
procedure log_Response (Self : in out Item; the_Response : in Response.view;
of_Observer : in Observer.view;
to_Event : in Event.item'Class;
from_Subject : in subject_Name);
-- Logging of miscellaneous messages.
--
overriding
procedure log (Self : in out Item; Message : in String);
-- Log filtering
--
overriding
procedure ignore (Self : in out Item; Kind : in Event.Kind);
private
package event_kind_Sets is new ada.Containers.indefinite_hashed_Sets (Event.Kind,
Event.Hash,
"=");
subtype event_kind_Set is event_kind_Sets.Set;
type Item is limited new Logger.item with
record
File : ada.Text_IO.File_type;
Ignored : event_kind_Set;
end record;
end lace.event.Logger.text;
|
pragma SPARK_Mode;
with Interfaces.C; use Interfaces.C;
package Proc_Types is
type Register is mod 2 ** 32
with Size => 32;
subtype Pin_Type is unsigned;
end Proc_Types;
|
-----------------------------------------------------------------------
-- Util.Streams.Files -- File Stream utilities
-- Copyright (C) 2010, 2011, 2012 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Util.Streams.Buffered;
with Util.Texts.Transforms;
with Ada.Characters.Handling;
with Ada.Calendar;
with GNAT.Calendar.Time_IO;
package Util.Streams.Texts is
-- -----------------------
-- Print stream
-- -----------------------
-- The <b>Print_Stream</b> is an output stream which provides helper methods
-- for writing text streams.
type Print_Stream is new Buffered.Buffered_Stream with private;
type Print_Stream_Access is access all Print_Stream'Class;
procedure Initialize (Stream : in out Print_Stream;
To : in Output_Stream_Access);
-- Write an integer on the stream.
procedure Write (Stream : in out Print_Stream;
Item : in Integer);
-- Write an integer on the stream.
procedure Write (Stream : in out Print_Stream;
Item : in Long_Long_Integer);
-- Write a string on the stream.
procedure Write (Stream : in out Print_Stream;
Item : in Ada.Strings.Unbounded.Unbounded_String);
-- Write a date on the stream.
procedure Write (Stream : in out Print_Stream;
Item : in Ada.Calendar.Time;
Format : in GNAT.Calendar.Time_IO.Picture_String
:= GNAT.Calendar.Time_IO.ISO_Date);
-- Get the output stream content as a string.
function To_String (Stream : in Buffered.Buffered_Stream) return String;
package TR is
new Util.Texts.Transforms (Stream => Buffered.Buffered_Stream,
Char => Character,
Input => String,
Put => Buffered.Write,
To_Upper => Ada.Characters.Handling.To_Upper,
To_Lower => Ada.Characters.Handling.To_Lower,
To_Input => To_String);
-- -----------------------
-- Reader stream
-- -----------------------
-- The <b>Reader_Stream</b> is an input stream which provides helper methods
-- for reading text streams.
type Reader_Stream is new Buffered.Buffered_Stream with private;
type Reader_Stream_Access is access all Reader_Stream'Class;
-- Initialize the reader to read the input from the input stream given in <b>From</b>.
procedure Initialize (Stream : in out Reader_Stream;
From : in Input_Stream_Access);
-- Read an input line from the input stream. The line is terminated by ASCII.LF.
-- When <b>Strip</b> is set, the line terminators (ASCII.CR, ASCII.LF) are removed.
procedure Read_Line (Stream : in out Reader_Stream;
Into : out Ada.Strings.Unbounded.Unbounded_String;
Strip : in Boolean := False);
private
type Print_Stream is new Buffered.Buffered_Stream with null record;
type Reader_Stream is new Buffered.Buffered_Stream with null record;
end Util.Streams.Texts;
|
with ACO.Utils.DS.Generic_Protected_Queue;
with ACO.Configuration;
package ACO.Messages.Buffer is new ACO.Utils.DS.Generic_Protected_Queue
(Item_Type => Message,
Maximum_Nof_Items => ACO.Configuration.Messages_Buffer_Size);
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- P R J . P P --
-- --
-- S p e c --
-- --
-- Copyright (C) 2001-2010, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package is the Project File Pretty Printer
-- Used to output a project file from a project file tree.
-- Used by gnatname to update or create project files.
-- Also used GPS to display project file trees.
-- Also be used for debugging tools that create project file trees.
with Prj.Tree;
package Prj.PP is
-- The following access to procedure types are used to redirect output when
-- calling Pretty_Print.
type Write_Char_Ap is access procedure (C : Character);
type Write_Eol_Ap is access procedure;
type Write_Str_Ap is access procedure (S : String);
subtype Max_Length_Of_Line is Positive range 50 .. 255;
procedure Pretty_Print
(Project : Prj.Tree.Project_Node_Id;
In_Tree : Prj.Tree.Project_Node_Tree_Ref;
Increment : Positive := 3;
Eliminate_Empty_Case_Constructions : Boolean := False;
Minimize_Empty_Lines : Boolean := False;
W_Char : Write_Char_Ap := null;
W_Eol : Write_Eol_Ap := null;
W_Str : Write_Str_Ap := null;
Backward_Compatibility : Boolean;
Id : Prj.Project_Id := Prj.No_Project;
Max_Line_Length : Max_Length_Of_Line :=
Max_Length_Of_Line'Last);
-- Output a project file, using either the default output routines, or the
-- ones specified by W_Char, W_Eol and W_Str.
--
-- Increment is the number of spaces for each indentation level
--
-- W_Char, W_Eol and W_Str can be used to change the default output
-- procedures. The default values force the output to Standard_Output.
--
-- If Eliminate_Empty_Case_Constructions is True, then case constructions
-- and case items that do not include any declarations will not be output.
--
-- If Minimize_Empty_Lines is True, empty lines will be output only after
-- the last with clause, after the line declaring the project name, after
-- the last declarative item of the project and before each package
-- declaration. Otherwise, more empty lines are output.
--
-- If Backward_Compatibility is True, then new attributes (Spec,
-- Spec_Suffix, Body, Body_Suffix) will be replaced by obsolete ones
-- (Specification, Specification_Suffix, Implementation,
-- Implementation_Suffix).
--
-- Id is used to compute the display name of the project including its
-- proper casing.
--
-- Max_Line_Length is the maximum line length in the project file
private
procedure Output_Statistics;
-- This procedure can be used after one or more calls to Pretty_Print to
-- display what Project_Node_Kinds have not been exercised by the call(s)
-- to Pretty_Print. It is used only for testing purposes.
end Prj.PP;
|
------------------------------------------------------------------------------
-- 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) $:
with Asis.Elements;
with Asis.Gela.Errors;
with Asis.Statements;
with Asis.Expressions;
with Asis.Definitions;
with Asis.Declarations;
with Asis.Gela.Classes;
with Asis.Gela.Visibility;
with XASIS.Utils;
with XASIS.Types;
with Ada.Wide_Text_IO;
package body Asis.Gela.Overloads.Walk.Up is
use Asis.Elements;
use Asis.Gela.Classes;
function Check_Array_Aggregate
(Params : Asis.Association_List) return Boolean;
function Check_Type_Conversion (Name : Up_Interpretation) return Boolean;
function Get_Array_Element_Type
(Tipe : Type_Info) return Up_Interpretation;
function Find_Task_Visible_Item
(Definition : Asis.Definition;
Name : Program_Text) return Asis.Declaration;
procedure Attribute_Reference_Value
(Resolver : in out Up_Resolver;
Element : in Asis.Element;
Tipe : in Asis.Declaration);
procedure Attribute_Reference_Value
(Resolver : in out Up_Resolver;
Element : in Asis.Element;
Tipe : in Asis.Declaration;
Store : in out Stored_Set);
procedure Attribute_Reference_Function
(Resolver : in out Up_Resolver;
Element : in Asis.Element);
procedure Access_Attribute_Reference
(Resolver : in out Up_Resolver;
Element : in Asis.Element;
Unchecked : in Boolean := False);
procedure Class_Attribute
(Resolver : in out Up_Resolver;
Element : in Asis.Element);
procedure Identity_Attribute_Reference
(Resolver : in out Up_Resolver;
Element : in Asis.Element);
procedure First_Attribute_Reference
(Resolver : in out Up_Resolver;
Element : in Asis.Element;
Store : in out Stored_Set;
Is_Range : in Boolean := False);
function Allow_Implicit_Dereference (Element : Asis.Element) return Boolean;
function Allow_Parameterless_Call (Element : Asis.Element) return Boolean;
function Get_Call_Prefix (Element : Asis.Element )
return Asis.Element;
function Subprograms_Of_Ancestor
(Tipe : Type_Info;
Target : Type_Info;
Ident : Asis.Identifier) return Asis.Defining_Name_List;
function Subprograms_Of_Ancestors
(Ancestors : Asis.Name_List;
Target : Type_Info;
Ident : Asis.Identifier) return Asis.Defining_Name_List;
--------------------------------
-- Access_Attribute_Reference --
--------------------------------
procedure Access_Attribute_Reference
(Resolver : in out Up_Resolver;
Element : in Asis.Element;
Unchecked : in Boolean := False)
is
Prefix : Up_Interpretation_Set;
Item : Up_Interpretation;
Result : Up_Interpretation_Set := Create;
Store : Stored_Set := Create;
Stored : Stored_Interpretation;
begin
U.Pop (Resolver.Stack, Prefix);
Resolve_Identifier (Prefix);
if Length (Prefix) > 0 then
Get (Prefix, 1, Item);
end if;
if Length (Prefix) > 0 and then
not Unchecked and then
Item.Kind = A_Declaration and then
Is_Subprogram (Item.Declaration)
then -- Subprogram access
for I in 1 .. Length (Prefix) loop
Get (Prefix, I, Item);
if Item.Kind = A_Declaration and then
Is_Subprogram (Item.Declaration)
then
Stored.Down := Item;
Add (Store, Stored);
Item := (Kind => A_Subprogram_Access,
Profile => Item.Declaration);
Add (Result, Item);
end if;
end loop;
elsif Has_Interpretation (Prefix, Element) then
Stored.Down := Item;
Add (Store, Stored);
Item := (Kind => A_General_Access);
Add (Result, Item);
end if;
Destroy (Prefix);
U.Push (Resolver.Stack, Result);
Put (Resolver.Store, Element, Store);
end Access_Attribute_Reference;
---------------
-- Aggregate --
---------------
procedure Aggregate
(Resolver : in out Up_Resolver;
Element : in Asis.Element;
Extension : in Boolean := False)
is
use Asis.Expressions;
Set : Up_Interpretation_Set;
Store : Stored_Set;
Stored : Stored_Interpretation;
Result : Up_Interpretation_Set := Create;
Item : Up_Interpretation;
Expr : Asis.Element;
List : constant Asis.Association_List
:= Record_Component_Associations (Element);
begin
for I in reverse List'Range loop
U.Pop (Resolver.Stack, Set);
Expand_Expression (Set, Resolver.Implicit,
Component_Expression (List (I)));
Destroy (Set);
end loop;
if Could_Be_Record_Aggregate (Element, Extension) then
if Extension then
Expr := Extension_Aggregate_Expression (Element);
Store := Create;
U.Pop (Resolver.Stack, Set);
if Is_Subtype_Mark (Expr) then
Resolve_Identifier (Set);
if Has_Interpretation (Set, Expr) then
Get (Set, 1, Stored.Down);
Add (Store, Stored);
end if;
else
Constrain_To_Tagged_Non_Limited_Types
(Set, Resolver.Implicit, Expr);
if Has_Interpretation (Set, Element) then
Get (Set, 1, Stored.Down);
Add (Store, Stored);
end if;
end if;
Put (Resolver.Store, Element, Store);
Destroy (Set);
Item := (Kind => An_Extension_Aggregate);
else
Item := (Kind => A_Record_Aggregate);
end if;
Add (Result, Item);
end if;
if not Extension and then
(Could_Be_Positional_Array_Aggregate (Element) or else
Could_Be_Named_Array_Aggregate (Element))
then
Item := (Kind => An_Array_Aggregate);
Add (Result, Item);
end if;
U.Push (Resolver.Stack, Result);
end Aggregate;
----------------
-- Allocation --
----------------
procedure Allocation
(Resolver : in out Up_Resolver;
Element : in Asis.Element;
From_Expr : in Boolean := False)
is
Set : Up_Interpretation_Set;
Result : Up_Interpretation_Set := Create;
Item : Up_Interpretation;
Next : Up_Interpretation;
Ind : Asis.Subtype_Indication;
begin
if From_Expr then
U.Pop (Resolver.Stack, Set);
Expand_Expression (Set, Resolver.Implicit, Element);
if Has_Interpretation (Set, Element) then
Get (Set, 1, Item);
if Item.Kind = An_Expression then
Next := (Kind => An_Object_Access,
Object_Type => Item.Expression_Type);
Add (Result, Next);
end if;
end if;
Destroy (Set);
else
Ind := Asis.Expressions.Allocator_Subtype_Indication (Element);
Item := (Kind => An_Object_Access,
Object_Type => Type_From_Indication (Ind, Element));
Add (Result, Item);
end if;
U.Push (Resolver.Stack, Result);
end Allocation;
--------------------------------
-- Allow_Implicit_Dereference --
--------------------------------
function Allow_Implicit_Dereference (Element : Asis.Element) return Boolean
is
begin
case Attribute_Kind (Element) is
when
A_Callable_Attribute |
A_Component_Size_Attribute |
A_Constrained_Attribute |
A_First_Attribute |
An_Identity_Attribute |
A_Last_Attribute |
A_Length_Attribute |
A_Range_Attribute |
A_Storage_Size_Attribute |
A_Tag_Attribute |
A_Terminated_Attribute |
A_Valid_Attribute =>
return True;
when others =>
return False;
end case;
end Allow_Implicit_Dereference;
------------------------------
-- Allow_Parameterless_Call --
------------------------------
function Allow_Parameterless_Call (Element : Asis.Element) return Boolean
is
begin
case Attribute_Kind (Element) is
when An_Access_Attribute |
An_Address_Attribute |
A_Body_Version_Attribute |
A_Partition_ID_Attribute |
A_Version_Attribute =>
return False;
when others =>
return True;
end case;
end Allow_Parameterless_Call;
----------------
-- Assignment --
----------------
procedure Assignment
(Resolver : in out Up_Resolver;
Element : in Asis.Element)
is
use Asis.Statements;
Result : Up_Interpretation_Set := Create;
Left : Up_Interpretation_Set;
Right : Up_Interpretation_Set;
Left_Item : Up_Interpretation;
begin
U.Pop (Resolver.Stack, Right);
U.Pop (Resolver.Stack, Left);
Expand_Expression (Right, Resolver.Implicit,
Assignment_Expression (Element));
Constrain_To_Non_Limited_Types (Left, Resolver.Implicit,
Assignment_Variable_Name (Element));
for I in 1 .. Length (Left) loop
Get (Left, I, Left_Item);
if Left_Item.Kind = An_Expression and then
Has_Type (Right, Left_Item.Expression_Type) then
Add (Result, Left_Item);
end if;
end loop;
U.Push (Resolver.Stack, Result);
Destroy (Right);
Destroy (Left);
end Assignment;
-------------------------
-- Attribute_Reference --
-------------------------
procedure Attribute_Reference
(Resolver : in out Up_Resolver;
Element : in Asis.Element)
is
use Asis.Expressions;
Kind : constant Attribute_Kinds := Attribute_Kind (Element);
Set : Up_Interpretation_Set;
Store : Stored_Set;
Stored : Stored_Interpretation;
begin
-- Attribute expressions
if Kind = A_First_Attribute or
Kind = A_Last_Attribute or
Kind = A_Length_Attribute or
Kind = A_Range_Attribute
then
declare
List : constant Asis.Element_List :=
Attribute_Designator_Expressions (Element);
begin
Store := Create;
for I in List'Range loop
U.Pop (Resolver.Stack, Set);
Constrain_To_Integer_Types (Set, Resolver.Implicit, List (I));
if Has_Interpretation (Set, Element) then
Get (Set, 1, Stored.Down);
else
Stored.Down := (Kind => A_Skip);
end if;
Add (Store, Stored);
Destroy (Set);
end loop;
end;
end if;
-- Attribute identificator
U.Pop (Resolver.Stack, Set);
Destroy (Set);
case Kind is
when Not_An_Attribute =>
raise Internal_Error;
when An_Access_Attribute =>
Access_Attribute_Reference (Resolver, Element);
when An_Address_Attribute =>
Attribute_Reference_Value
(Resolver, Element, XASIS.Types.System_Address);
when An_Adjacent_Attribute |
A_Ceiling_Attribute |
A_Compose_Attribute |
A_Copy_Sign_Attribute |
An_Exponent_Attribute |
A_Floor_Attribute |
A_Fraction_Attribute |
An_Image_Attribute |
An_Input_Attribute |
A_Leading_Part_Attribute |
A_Machine_Attribute |
A_Machine_Rounding_Attribute |
A_Max_Attribute |
A_Min_Attribute |
A_Mod_Attribute |
A_Model_Attribute |
A_Pos_Attribute |
A_Pred_Attribute |
A_Remainder_Attribute |
A_Round_Attribute |
A_Rounding_Attribute |
A_Scaling_Attribute |
A_Succ_Attribute |
A_Truncation_Attribute |
An_Unbiased_Rounding_Attribute |
A_Val_Attribute |
A_Value_Attribute |
A_Wide_Image_Attribute |
A_Wide_Value_Attribute |
A_Wide_Wide_Image_Attribute |
A_Wide_Wide_Value_Attribute |
An_Output_Attribute |
A_Read_Attribute |
A_Write_Attribute =>
Attribute_Reference_Function (Resolver, Element);
when An_Aft_Attribute |
An_Alignment_Attribute |
A_Component_Size_Attribute |
A_Count_Attribute |
A_Digits_Attribute |
A_First_Bit_Attribute |
A_Fore_Attribute |
A_Last_Bit_Attribute |
A_Machine_Emax_Attribute |
A_Machine_Emin_Attribute |
A_Machine_Mantissa_Attribute |
A_Machine_Radix_Attribute |
A_Max_Size_In_Storage_Elements_Attribute |
A_Model_Emin_Attribute |
A_Model_Mantissa_Attribute |
A_Modulus_Attribute |
A_Partition_ID_Attribute |
A_Position_Attribute |
A_Scale_Attribute |
A_Size_Attribute |
A_Storage_Size_Attribute |
A_Stream_Size_Attribute |
A_Wide_Wide_Width_Attribute |
A_Wide_Width_Attribute |
A_Width_Attribute =>
Attribute_Reference_Value
(Resolver, Element, XASIS.Types.Universal_Integer);
when A_Bit_Order_Attribute =>
Attribute_Reference_Value
(Resolver, Element, XASIS.Types.System_Bit_Order);
when A_Body_Version_Attribute |
An_External_Tag_Attribute |
A_Version_Attribute =>
Attribute_Reference_Value
(Resolver, Element, XASIS.Types.String);
when A_Callable_Attribute |
A_Constrained_Attribute |
A_Definite_Attribute |
A_Denorm_Attribute |
A_Machine_Overflows_Attribute |
A_Machine_Rounds_Attribute |
A_Signed_Zeros_Attribute |
A_Terminated_Attribute |
A_Valid_Attribute =>
Attribute_Reference_Value
(Resolver, Element, XASIS.Types.Boolean);
when A_Caller_Attribute =>
Attribute_Reference_Value
(Resolver, Element, XASIS.Types.Task_Id);
when A_Delta_Attribute |
A_Model_Epsilon_Attribute |
A_Model_Small_Attribute |
A_Safe_First_Attribute |
A_Safe_Last_Attribute |
A_Small_Attribute =>
Attribute_Reference_Value
(Resolver, Element, XASIS.Types.Universal_Real);
when A_Storage_Pool_Attribute =>
Attribute_Reference_Value
(Resolver, Element, XASIS.Types.Root_Storage_Pool);
when A_Tag_Attribute =>
Attribute_Reference_Value
(Resolver, Element, XASIS.Types.Tag);
when A_Class_Attribute =>
Class_Attribute (Resolver, Element);
when A_Base_Attribute =>
null; -- Ignore 'Base for overload resolution
when An_Unchecked_Access_Attribute =>
Access_Attribute_Reference (Resolver, Element, True);
when An_Identity_Attribute =>
Identity_Attribute_Reference (Resolver, Element);
when A_Length_Attribute =>
Attribute_Reference_Value
(Resolver, Element, XASIS.Types.Universal_Integer, Store);
when A_First_Attribute |
A_Last_Attribute =>
First_Attribute_Reference (Resolver, Element, Store);
when A_Range_Attribute =>
First_Attribute_Reference (Resolver, Element, Store, True);
when A_Priority_Attribute =>
Attribute_Reference_Value (Resolver, Element, XASIS.Types.Integer);
when others =>
raise Unimplemented;
end case;
end Attribute_Reference;
----------------------------------
-- Attribute_Reference_Function --
----------------------------------
procedure Attribute_Reference_Function
(Resolver : in out Up_Resolver;
Element : in Asis.Element)
is
Kind : constant Attribute_Kinds := Attribute_Kind (Element);
Set : Up_Interpretation_Set;
Result : Up_Interpretation_Set := Create;
Store : Stored_Set := Create;
Stored : Stored_Interpretation;
begin
-- Attribute prefix
U.Pop (Resolver.Stack, Set);
Resolve_Identifier (Set);
if Has_Interpretation (Set, Element) then
Get (Set, 1, Stored.Down);
if Stored.Down.Kind = A_Declaration then
Add (Result, (Kind => An_Attribute_Function,
Prefix => Stored.Down.Declaration,
Attr_Kind => Kind,
Class_Wide => False));
Add (Store, Stored);
elsif Stored.Down.Kind = A_Type then
Add (Result,
(Kind => An_Attribute_Function,
Prefix => Get_Declaration (Stored.Down.Type_Info),
Attr_Kind => Kind,
Class_Wide => Is_Class_Wide (Stored.Down.Type_Info)));
Add (Store, Stored);
end if;
end if;
Destroy (Set);
U.Push (Resolver.Stack, Result);
Put (Resolver.Store, Element, Store);
end Attribute_Reference_Function;
-------------------------------
-- Attribute_Reference_Value --
-------------------------------
procedure Attribute_Reference_Value
(Resolver : in out Up_Resolver;
Element : in Asis.Element;
Tipe : in Asis.Declaration)
is
Store : Stored_Set := Create;
begin
Attribute_Reference_Value (Resolver, Element, Tipe, Store);
end Attribute_Reference_Value;
-------------------------------
-- Attribute_Reference_Value --
-------------------------------
procedure Attribute_Reference_Value
(Resolver : in out Up_Resolver;
Element : in Asis.Element;
Tipe : in Asis.Declaration;
Store : in out Stored_Set)
is
Set : Up_Interpretation_Set;
Result : Up_Interpretation_Set := Create;
Stored : Stored_Interpretation;
begin
-- Attribute prefix
U.Pop (Resolver.Stack, Set);
if not Allow_Parameterless_Call (Element) then
Resolve_Identifier (Set);
else
Expand_Attribute_Prefix (Set, Resolver.Implicit,
Asis.Expressions.Prefix (Element),
Allow_Implicit_Dereference (Element));
end if;
if Has_Interpretation (Set, Element) then
Get (Set, 1, Stored.Down);
Add (Result, Up_Expression (Tipe, Element));
Add (Store, Stored);
end if;
Destroy (Set);
U.Push (Resolver.Stack, Result);
Put (Resolver.Store, Element, Store);
end Attribute_Reference_Value;
---------------------------
-- Check_Array_Aggregate --
---------------------------
function Check_Array_Aggregate
(Params : Asis.Association_List) return Boolean is
begin
for I in Params'Range loop
if not Is_Nil (Get_Formal_Parameter (Params, I)) then
return False;
end if;
end loop;
return Params'Length > 0;
end Check_Array_Aggregate;
------------------
-- Check_Family --
------------------
function Check_Family (Name : Up_Interpretation) return Boolean is
begin
return Name.Kind = A_Declaration and then
XASIS.Utils.Is_Entry_Family (Name.Declaration);
end Check_Family;
---------------------------
-- Check_Type_Conversion --
---------------------------
function Check_Type_Conversion (Name : Up_Interpretation) return Boolean is
begin
if Name.Kind = A_Type then
return True;
elsif Name.Kind /= A_Declaration or else
not Is_Type_Declaration (Name.Declaration)
then
return False;
end if;
return True;
end Check_Type_Conversion;
---------------------
-- Class_Attribute --
---------------------
procedure Class_Attribute
(Resolver : in out Up_Resolver;
Element : in Asis.Element)
is
Set : Up_Interpretation_Set;
Item : Up_Interpretation;
Result : Up_Interpretation_Set := Create;
Store : Stored_Set := Create;
Stored : Stored_Interpretation;
Tipe : Type_Info;
begin
-- Attribute prefix
U.Pop (Resolver.Stack, Set);
Resolve_Identifier (Set);
for I in 1 .. Length (Set) loop
Get (Set, I, Item);
if Item.Kind = A_Declaration then
Tipe := Type_From_Declaration (Item.Declaration, Element);
Set_Class_Wide (Tipe);
Add (Result, (A_Type, Tipe));
Stored.Down := Item;
Stored.Result_Type := Tipe;
Add (Store, Stored);
end if;
end loop;
U.Push (Resolver.Stack, Result);
Put (Resolver.Store, Element, Store);
Destroy (Set);
end Class_Attribute;
--------------------------
-- Explicit_Dereference --
--------------------------
procedure Explicit_Dereference
(Resolver : in out Up_Resolver;
Element : in Asis.Element)
is
Set : Up_Interpretation_Set;
Store : Stored_Set := Create;
Stored : Stored_Interpretation;
Result : Up_Interpretation_Set := Create;
Item : Up_Interpretation;
begin
U.Pop (Resolver.Stack, Set);
Constrain_To_Access_Types (Set, Resolver.Implicit,
Asis.Expressions.Prefix (Element));
for I in 1 .. Length (Set) loop
Get (Set, I, Item);
Stored.Down := Item;
if Item.Kind /= An_Expression then
raise Internal_Error;
end if;
Item := Dereference (Item.Expression_Type);
case Item.Kind is
when A_Subprogram_Reference =>
Stored.Kind := A_Subprogram_Reference;
Stored.Result_Type := Item.Access_Type;
when An_Expression =>
Stored.Kind := A_Function_Call;
Stored.Result_Type := Item.Expression_Type;
when others =>
raise Internal_Error;
end case;
Add (Store, Stored);
Add (Result, Item);
end loop;
U.Push (Resolver.Stack, Result);
Put (Resolver.Store, Element, Store);
Destroy (Set);
end Explicit_Dereference;
----------------------------
-- Find_Task_Visible_Item --
----------------------------
function Find_Task_Visible_Item
(Definition : Asis.Definition;
Name : Program_Text) return Asis.Declaration
is
use Asis.Definitions;
List : constant Asis.Declarative_Item_List :=
Visible_Part_Items (Definition);
Def_Name : Asis.Defining_Name;
begin
for I in List'Range loop
Def_Name := XASIS.Utils.Get_Defining_Name (List (I), Name);
if Assigned (Def_Name) then
return List (I);
end if;
end loop;
return Nil_Element;
end Find_Task_Visible_Item;
-------------------------------
-- First_Attribute_Reference --
-------------------------------
procedure First_Attribute_Reference
(Resolver : in out Up_Resolver;
Element : in Asis.Element;
Store : in out Stored_Set;
Is_Range : in Boolean := False)
is
use Asis.Gela.Errors;
use Asis.Expressions;
N : constant List_Index := 1;
Tipe : Type_Info;
Set : Up_Interpretation_Set;
Item : Up_Interpretation;
Result : Up_Interpretation_Set := Create;
Stored : Stored_Interpretation;
List : constant Asis.Element_List :=
Attribute_Designator_Expressions (Element);
begin
-- Attribute prefix
U.Pop (Resolver.Stack, Set);
Expand_Attribute_Prefix (Set, Resolver.Implicit,
Asis.Expressions.Prefix (Element));
Stored.Down := (Kind => A_Skip);
for I in 1 .. Length (Set) loop
Get (Set, I, Item);
if Item.Kind = A_Declaration then
Tipe := Type_From_Declaration (Item.Declaration, Element);
end if;
if (Item.Kind = An_Expression and then
Is_Array (Item.Expression_Type)) or
(Item.Kind = A_Declaration and then Is_Array (Tipe))
then
if List'Length = 1 then
null; -- FIXME N := Calculate (List (1));
end if;
if Item.Kind = An_Expression then
Tipe := Get_Array_Index_Type (Item.Expression_Type, N);
else
Tipe := Get_Array_Index_Type (Tipe, N);
end if;
if Is_Range then
Add (Result, (A_Range, Tipe));
else
Add (Result, Up_Expression (Tipe));
end if;
Stored.Down := Item;
elsif Item.Kind = A_Declaration and then Is_Scalar (Tipe) then
if List'Length /= 0 then
Report (Element, Error_Syntax_Index_Exists);
end if;
if Is_Range then
Add (Result, (A_Range, Tipe));
else
Add (Result, Up_Expression (Tipe));
end if;
Stored.Down := Item;
end if;
end loop;
Add (Store, Stored);
Destroy (Set);
U.Push (Resolver.Stack, Result);
Put (Resolver.Store, Element, Store);
end First_Attribute_Reference;
-------------------
-- Function_Call --
-------------------
procedure Function_Call
(Resolver : in out Up_Resolver;
Element : in Asis.Element)
is
function Check_Parameter
(Profile : Asis.Parameter_Specification_List;
Index : List_Index := 1;
Set : Up_Interpretation_Set)
return Boolean;
function Check_Parameters
(Profile : in Asis.Parameter_Specification_List;
Index : in List_Index := 1) return Boolean;
function Check_Defaults
(Profile : in Asis.Parameter_Specification_List) return Boolean;
Result : Up_Interpretation_Set := Create;
Store : Stored_Set := Create;
Stored : Stored_Interpretation;
Name : Up_Interpretation;
Tipe : Up_Interpretation;
Names : Up_Interpretation_Set;
Params : constant Asis.Association_List :=
Get_Call_Parameters (Element);
Sets : Up_Interpretation_Set_Array (1 .. Params'Length);
--------------------
-- Check_Defaults --
--------------------
function Check_Defaults
(Profile : in Asis.Parameter_Specification_List)
return Boolean
is
use Asis.Declarations;
Formal : List_Index;
Found : Boolean;
Set : array (Profile'Range) of Natural := (others => 0);
Fake_Profile : Boolean := False;
begin
if Profile'Length >= 1
and then not XASIS.Utils.Is_Parameter_Specification (Profile (1))
then
Fake_Profile := True;
end if;
for I in Params'Range loop
Find_Formal_Index (Params, I, Profile, Formal, Found);
if not Found then
return False;
end if;
Set (Formal) := Set (Formal) + 1;
end loop;
for I in Set'Range loop
if Set (I) < Asis.Declarations.Names (Profile (I))'Length
and then (Fake_Profile
or else Is_Nil (Initialization_Expression
(Profile (I))))
then
return False;
end if;
end loop;
return True;
end Check_Defaults;
-----------------
-- Check_Array --
-----------------
function Check_Array (Name : Up_Interpretation) return Boolean is
begin
if Name.Kind = An_Expression then
return Is_Array (Name.Expression_Type, Params'Length);
end if;
return False;
end Check_Array;
---------------------
-- Check_Parameter --
---------------------
function Check_Parameter
(Profile : Asis.Parameter_Specification_List;
Index : List_Index := 1;
Set : Up_Interpretation_Set)
return Boolean
is
Item : Up_Interpretation;
Info : constant Type_Info :=
Get_Parameter_Type (Name, Profile, Index, Element);
begin
if Has_Type (Set, Info) then
if Is_Universal (Info) or Is_Class_Wide (Info) then
Item := Get_Type (Set, Info);
if Item.Kind = An_Expression then
if Stored.Real_Types = null then
Stored.Real_Types := new Type_Infos (Profile'Range);
end if;
Stored.Real_Types (Index) := Item.Expression_Type;
end if;
end if;
return True;
end if;
return False;
end Check_Parameter;
----------------------
-- Check_Parameters --
----------------------
function Check_Parameters
(Profile : Asis.Parameter_Specification_List;
Index : List_Index := 1) return Boolean
is
Found : Boolean;
Formal : List_Index;
begin
if Index = 1 and then not Check_Defaults (Profile) then
return False;
end if;
if Index > Params'Last then
return True;
end if;
Find_Formal_Index (Params, Index, Profile, Formal, Found);
if not Found then
return False;
end if;
if Check_Parameter (Profile, Formal, Sets (Positive (Index))) then
if Check_Parameters (Profile, Index + 1) then
return True;
end if;
end if;
return False;
end Check_Parameters;
-------------------------
-- Check_Array_Indexes --
-------------------------
function Check_Array_Indexes return Boolean is
Item : Up_Interpretation;
Tipe : Type_Info;
Found : Boolean;
begin
for J in Sets'Range loop
Tipe := Get_Array_Index_Type
(Name.Expression_Type, Asis.List_Index (J));
Found := False;
for I in 1 .. Length (Sets (J)) loop
Get (Sets (J), I, Item);
if Item.Kind = An_Expression and then
Is_Expected_Type (Item.Expression_Type, Tipe)
then
Found := True;
exit;
end if;
end loop;
if not Found then
return False;
end if;
end loop;
return True;
end Check_Array_Indexes;
------------------------
-- Check_Family_Index --
------------------------
function Check_Family_Index return Boolean is
use Asis.Declarations;
Tipe : constant Type_Info := Type_From_Discrete_Def
(Entry_Family_Definition (Name.Declaration), Element);
Item : Up_Interpretation;
begin
for I in 1 .. Length (Sets (1)) loop
Get (Sets (1), I, Item);
if Item.Kind = An_Expression
and then Is_Expected_Type (Item.Expression_Type, Tipe)
then
return True;
end if;
end loop;
return False;
end Check_Family_Index;
------------------------
-- Compare_Preference --
------------------------
procedure Compare_Preference
(New_Decl : in Asis.Declaration;
Old_Decl : in Asis.Declaration;
New_Pref : in out Boolean;
Old_Pref : in out Boolean)
is
use XASIS.Types;
New_Param : constant Asis.Parameter_Specification_List
:= XASIS.Utils.Get_Profile (New_Decl);
Old_Param : constant Asis.Parameter_Specification_List
:= XASIS.Utils.Get_Profile (Old_Decl);
New_Type : constant Type_Info :=
Type_Of_Declaration (New_Param (1), Element);
Old_Type : constant Type_Info :=
Type_Of_Declaration (Old_Param (1), Element);
begin
if Is_Integer (New_Type) and then Is_Integer (New_Type) then
if Is_Equal (Get_Declaration (Old_Type), Root_Integer) then
Old_Pref := True;
elsif Is_Equal (Get_Declaration (New_Type), Root_Integer) then
New_Pref := True;
end if;
elsif Is_Real (New_Type) and then Is_Real (New_Type) then
if Is_Equal (Get_Declaration (Old_Type), Root_Real) then
Old_Pref := True;
elsif Is_Equal (Get_Declaration (New_Type), Root_Real) then
New_Pref := True;
end if;
end if;
end Compare_Preference;
----------------------------
-- Check_Prefered_And_Add --
----------------------------
procedure Check_Prefered_And_Add
(Result : in out Up_Interpretation_Set;
Tipe : in Up_Interpretation;
Store : in out Stored_Set;
Stored : in Stored_Interpretation)
is
Count : Natural := 0;
Item : Stored_Interpretation;
Next : Up_Interpretation;
Info : constant Type_Info := Tipe.Expression_Type;
New_Is_Prefered : Boolean := False;
Old_Is_Prefered : Boolean := False;
Fixed_Result : Up_Interpretation_Set;
Fixed_Store : Stored_Set;
begin
if not Has_Type (Result, Info) then
Add (Result, Tipe);
Add (Store, Stored);
return;
end if;
for I in 1 .. Length (Store) loop
Get (Store, I, Item);
if Item.Kind = A_Function_Call
and then Item.Down.Kind = A_Declaration
and then Is_Equal (Item.Result_Type, Info)
then
Compare_Preference
(Stored.Down.Declaration,
Item.Down.Declaration,
New_Is_Prefered,
Old_Is_Prefered);
end if;
end loop;
if not (New_Is_Prefered or Old_Is_Prefered) then
Add (Result, Tipe);
Add (Store, Stored);
return;
elsif New_Is_Prefered and Old_Is_Prefered then
raise Internal_Error;
elsif Old_Is_Prefered then
return;
end if;
Fixed_Result := Create;
Fixed_Store := Create;
for I in 1 .. Length (Store) loop
Get (Store, I, Item);
if Item.Kind = A_Function_Call
and then Item.Down.Kind = A_Declaration
and then Is_Equal (Item.Result_Type, Info)
then
New_Is_Prefered := False;
Compare_Preference
(Stored.Down.Declaration,
Item.Down.Declaration,
New_Is_Prefered,
Old_Is_Prefered);
if New_Is_Prefered then
Count := Count + 1;
else
Add (Fixed_Store, Item);
end if;
else
Add (Fixed_Store, Item);
end if;
end loop;
for I in 1 .. Length (Result) loop
Get (Result, I, Next);
if Count > 0
and then Next.Kind = An_Expression
and then Is_Equal (Next.Expression_Type, Info)
then
Count := Count - 1;
else
Add (Fixed_Result, Next);
end if;
end loop;
Destroy (Result);
Destroy (Store);
Result := Fixed_Result;
Store := Fixed_Store;
Add (Result, Tipe);
Add (Store, Stored);
end Check_Prefered_And_Add;
-----------------------
-- Check_Slice_Index --
-----------------------
function Check_Slice_Index return Boolean is
Item : Up_Interpretation;
Tipe : constant Type_Info :=
Get_Array_Index_Type (Name.Expression_Type);
begin
for I in 1 .. Length (Sets (1)) loop
Get (Sets (1), I, Item);
if Item.Kind = A_Range and then
Is_Expected_Type (Item.Range_Type, Tipe)
then
return True;
end if;
end loop;
return False;
end Check_Slice_Index;
----------------------------
-- Is_Universal_Access_Eq --
----------------------------
function Is_Universal_Access_Eq (Op : Asis.Declaration) return Boolean is
Name : constant Asis.Defining_Name := Asis.Declarations.Names (Op)(1);
Tipe : Asis.Definition;
Decl : Asis.Declaration;
begin
if Defining_Name_Kind (Name) = A_Defining_Operator_Symbol and then
Is_Part_Of_Implicit (Op)
then
Tipe := Asis.Declarations.Corresponding_Type (Op);
if Assigned (Tipe) then
Decl := Enclosing_Element (Tipe);
return Is_Equal (Decl, XASIS.Types.Universal_Access);
end if;
end if;
return False;
end Is_Universal_Access_Eq;
function Check_Universal_Access_Eq -- ARM 4.5.2 (9.1/2)
(Name : Up_Interpretation) return Boolean
is
Prefix : Asis.Expression;
begin
if Name.Kind /= A_Declaration or else
not Is_Universal_Access_Eq (Name.Declaration)
then
return True;
end if;
if not Is_Anonymous_Access (Stored.Real_Types (1))
and then not Is_Anonymous_Access (Stored.Real_Types (2))
then
return False;
end if;
Prefix := Asis.Expressions.Prefix (Element);
if Expression_Kind (Prefix) = A_Selected_Component and then
Is_Expanded_Name (Prefix)
then
return True;
end if;
-- TODO rest of rule
return True;
end Check_Universal_Access_Eq;
begin -- Up_Function_Call
for I in reverse Sets'Range loop
U.Pop (Resolver.Stack, Sets (I));
Expand_Expression (Sets (I), Resolver.Implicit,
Get_Actual_Parameter (Params, Asis.List_Index (I)));
end loop;
U.Pop (Resolver.Stack, Names);
Expand_Prefix (Names, Resolver.Implicit,
Get_Call_Prefix (Element));
for I in 1 .. Length (Names) loop
Get (Names, I, Name);
if Check_Name (Name)
and then Check_Parameters (Get_Profile (Name))
and then Check_Universal_Access_Eq (Name)
then
Tipe := Get_Result_Profile (Name, Element);
Stored.Down := Name;
case Tipe.Kind is
when A_Procedure_Call =>
Stored.Kind := A_Procedure_Call;
Add (Result, Tipe);
Add (Store, Stored);
when An_Expression =>
Stored.Kind := A_Function_Call;
Stored.Result_Type := Tipe.Expression_Type;
if Is_Boolean (Tipe.Expression_Type) then
Check_Prefered_And_Add (Result, Tipe, Store, Stored);
else
Add (Result, Tipe);
Add (Store, Stored);
end if;
when others =>
raise Internal_Error;
end case;
Stored.Real_Types := null;
elsif Check_Array_Aggregate (Params) then
if Check_Array (Name) then
if Params'Length = 1 and then Check_Slice_Index then
Tipe := Name;
Add (Result, Tipe);
Stored.Kind := A_Slice;
Stored.Down := Name;
Stored.Result_Type := Tipe.Expression_Type;
Add (Store, Stored);
elsif Check_Array_Indexes then
Tipe := Get_Array_Element_Type (Name.Expression_Type);
Add (Result, Tipe);
Stored.Kind := An_Array;
Stored.Down := Name;
Stored.Result_Type := Tipe.Expression_Type;
Add (Store, Stored);
end if;
elsif Params'Length = 1 and then Check_Family (Name)
and then Check_Family_Index
then
Add (Result, (A_Family_Member, Name.Declaration));
elsif Params'Length = 1 and then Check_Type_Conversion (Name) then
declare
use Asis.Gela.Errors;
Found : Natural := 0;
Item : Up_Interpretation;
begin
Select_Prefered (Sets (1)); -- Hope Names'length=1
for J in 1 .. Length (Sets (1)) loop
Get (Sets (1), J, Item);
if Item.Kind = An_Expression then
Found := Found + 1;
Stored.Down := Item;
end if;
end loop;
if Found /= 0 then
if Found > 1 then
Report (Element, Error_Ambiguous_Interprentation);
end if;
Stored.Kind := A_Type_Conversion;
if Name.Kind = A_Declaration then
Stored.Result_Type :=
Type_From_Declaration (Name.Declaration, Element);
else
Stored.Result_Type := Name.Type_Info;
end if;
Add (Result, Up_Expression (Stored.Result_Type));
Add (Store, Stored);
end if;
end;
end if;
end if;
end loop;
for I in Sets'Range loop
Destroy (Sets (I));
end loop;
Destroy (Names);
U.Push (Resolver.Stack, Result);
Put (Resolver.Store, Element, Store);
end Function_Call;
----------------------------
-- Get_Array_Element_Type --
----------------------------
function Get_Array_Element_Type
(Tipe : Type_Info) return Up_Interpretation
is
begin
return Up_Expression (Get_Array_Element_Type (Tipe));
end Get_Array_Element_Type;
---------------------
-- Get_Call_Prefix --
---------------------
function Get_Call_Prefix (Element : Asis.Element )
return Asis.Element
is
begin
if Expression_Kind (Element) = A_Function_Call then
return Asis.Expressions.Prefix (Element);
elsif Statement_Kind (Element) = A_Procedure_Call_Statement then
return Asis.Statements.Called_Name (Element);
else
raise Internal_Error;
end if;
end Get_Call_Prefix;
----------------------------------
-- Identity_Attribute_Reference --
----------------------------------
procedure Identity_Attribute_Reference
(Resolver : in out Up_Resolver;
Element : in Asis.Element)
is
function Is_Exception (Item : Asis.Declaration) return Boolean is
Kind : constant Asis.Declaration_Kinds := Declaration_Kind (Item);
begin
return Kind = An_Exception_Declaration or else
Kind = An_Exception_Renaming_Declaration;
end Is_Exception;
Set : Up_Interpretation_Set;
Item : Up_Interpretation;
Result : Up_Interpretation_Set := Create;
Store : Stored_Set := Create;
Stored : Stored_Interpretation;
Tipe : Asis.Declaration;
begin
-- Attribute prefix
U.Pop (Resolver.Stack, Set);
Expand_Attribute_Prefix (Set, Resolver.Implicit,
Asis.Expressions.Prefix (Element));
if Has_Interpretation (Set, Element) then
Get (Set, 1, Item);
Stored.Down := Item;
if Item.Kind = A_Declaration and then
Is_Exception (Item.Declaration)
then
Tipe := XASIS.Types.Exception_Id;
else
Tipe := XASIS.Types.Task_Id;
end if;
Add (Result, Up_Expression (Tipe, Element));
else
Stored.Down := (Kind => A_Skip);
end if;
Add (Store, Stored);
Destroy (Set);
U.Push (Resolver.Stack, Result);
Put (Resolver.Store, Element, Store);
end Identity_Attribute_Reference;
----------------
-- Membership --
----------------
procedure Membership
(Resolver : in out Up_Resolver;
Element : in Asis.Element)
is
use Asis.Gela.Errors;
Left : Up_Interpretation_Set;
Right : Up_Interpretation_Set;
Tipe : Type_Info;
Kind : constant Asis.Expression_Kinds := Expression_Kind (Element);
Item : Up_Interpretation;
Store : Stored_Set := Create;
Stored : Stored_Interpretation;
Found : Boolean := False;
Failed : Boolean := False;
begin
U.Pop (Resolver.Stack, Right);
U.Pop (Resolver.Stack, Left);
Expand_Expression (Left, Resolver.Implicit,
Asis.Expressions.Membership_Test_Expression (Element));
Resolve_Identifier (Right);
if Kind in An_In_Range_Membership_Test .. A_Not_In_Range_Membership_Test
then
for I in 1 .. Length (Right) loop
Get (Right, I, Item);
if Item.Kind /= A_Range then
raise Internal_Error;
end if;
Tipe := Item.Range_Type;
Stored.Down := Item;
for J in 1 .. Length (Left) loop
Get (Left, J, Item);
if Item.Kind = An_Expression and then
Is_Expected_Type (Item.Expression_Type, Tipe)
then
if Found then
Report (Element, Error_Ambiguous_Interprentation);
else
Stored.Result_Type := Item.Expression_Type;
Add (Store, Stored);
Found := True;
end if;
end if;
end loop;
end loop;
else
if Length (Right) = 1 then
Get (Right, 1, Item);
if Item.Kind = A_Declaration then
Tipe := Type_From_Declaration (Item.Declaration, Element);
Failed := Is_Not_Type (Tipe);
Stored.Down := Item;
elsif Item.Kind = A_Type then
Tipe := Item.Type_Info;
Failed := Is_Not_Type (Tipe);
Stored.Down := Item;
else
Failed := True;
end if;
else
Failed := True;
end if;
if Failed then
Report (Element, Error_No_Interprentation);
elsif Is_Tagged (Tipe) then
for J in 1 .. Length (Left) loop
Get (Left, J, Item);
if Item.Kind = An_Expression and then
(Is_Covered (Item.Expression_Type, Tipe) or else
Is_Covered (Tipe, Item.Expression_Type))
then
if Found then
Report (Element, Error_Ambiguous_Interprentation);
else
Stored.Result_Type := Item.Expression_Type;
Add (Store, Stored);
Found := True;
end if;
end if;
end loop;
else
for J in 1 .. Length (Left) loop
Get (Left, J, Item);
if Item.Kind = An_Expression and then
Is_Expected_Type (Item.Expression_Type, Tipe)
then
if Found then
Report (Element, Error_Ambiguous_Interprentation);
else
Stored.Result_Type := Item.Expression_Type;
Add (Store, Stored);
Found := True;
end if;
end if;
end loop;
end if;
end if;
Destroy (Left);
Destroy (Right);
if Failed or not Found then
Left := Create;
U.Push (Resolver.Stack, Left);
else
Push_Single (Resolver, Up_Expression (XASIS.Types.Boolean, Element));
end if;
Put (Resolver.Store, Element, Store);
end Membership;
-------------------------------
-- Operator_Symbol_Or_String --
-------------------------------
procedure Operator_Symbol_Or_String
(Resolver : in out Up_Resolver;
Element : in Asis.Element)
is
Set : Up_Interpretation_Set;
Kind : constant Asis.Operator_Kinds :=
XASIS.Utils.Operator_Kind (Asis.Expressions.Name_Image (Element));
begin
if Kind = Not_An_Operator then
Push_Single (Resolver, (Kind => A_String_Type));
else
Push_Single (Resolver, (An_Identifier, Element), Resolve => True);
U.Pop (Resolver.Stack, Set);
Add (Set, (Kind => A_String_Type));
U.Push (Resolver.Stack, Set);
end if;
end Operator_Symbol_Or_String;
-----------------
-- Push_Single --
-----------------
procedure Push_Single
(Resolver : in out Up_Resolver;
Item : in Up_Interpretation;
Resolve : in Boolean := False)
is
Set : Up_Interpretation_Set := Create;
begin
Add (Set, Item);
if Resolve then
Resolve_Identifier (Set);
end if;
U.Push (Resolver.Stack, Set);
end Push_Single;
--------------------------
-- Qualified_Expression --
--------------------------
procedure Qualified_Expression
(Resolver : in out Up_Resolver;
Element : in Asis.Element)
is
Set : Up_Interpretation_Set;
Prefix : Up_Interpretation_Set;
Tipe : Type_Info;
Store : Stored_Set := Create;
Stored : Stored_Interpretation;
Result : Up_Interpretation_Set := Create;
Item : Up_Interpretation;
begin
U.Pop (Resolver.Stack, Set);
U.Pop (Resolver.Stack, Prefix);
Resolve_Identifier (Prefix);
if Has_Interpretation (Prefix, Element) then
Get (Prefix, 1, Item);
if Item.Kind = A_Declaration and then
Is_Type_Declaration (Item.Declaration)
then
Tipe := Type_From_Declaration (Item.Declaration, Element);
Constrain_To_Type
(Set,
Resolver.Implicit,
Asis.Expressions.Converted_Or_Qualified_Expression (Element),
Tipe);
if Has_Interpretation (Set, Element) then
Get (Set, 1, Item);
if Item.Kind = An_Expression then
Stored.Kind := A_Function_Call;
Stored.Result_Type := Tipe;
Stored.Down := Item;
Add (Store, Stored);
Add (Result, Up_Expression (Tipe));
elsif Item.Kind = A_Record_Aggregate
or Item.Kind = An_Array_Aggregate
or Item.Kind = A_String_Type
then
Stored.Kind := An_Array;
Stored.Result_Type := Tipe;
Add (Store, Stored);
Add (Result, Up_Expression (Tipe));
end if;
end if;
end if;
end if;
U.Push (Resolver.Stack, Result);
Put (Resolver.Store, Element, Store);
Destroy (Set);
Destroy (Prefix);
end Qualified_Expression;
------------------------
-- Selected_Component --
------------------------
procedure Selected_Component
(Resolver : in out Up_Resolver;
Element : in Asis.Element)
is
use XASIS.Utils;
use Asis.Declarations;
Set : Up_Interpretation_Set;
Prefix : Up_Interpretation_Set;
Result : Up_Interpretation_Set;
Item : Up_Interpretation;
Ident : Asis.Identifier;
Store : Stored_Set;
Stored : Stored_Interpretation;
Decl : Asis.Declaration;
Def : Asis.Definition;
Found : Boolean;
begin
if Is_Expanded_Name (Element) then
Drop_One (Resolver);
return;
end if;
U.Pop (Resolver.Stack, Set);
if Length (Set) /= 1 then
raise Internal_Error;
else
Get (Set, 1, Item);
if Item.Kind /= An_Identifier then
raise Internal_Error;
end if;
end if;
Ident := Item.Identifier;
U.Pop (Resolver.Stack, Prefix);
Expand_Prefix (Prefix, Resolver.Implicit,
Asis.Expressions.Prefix (Element));
Result := Create;
Store := Create;
for I in 1 .. Length (Prefix) loop
Get (Prefix, I, Item);
case Item.Kind is
when An_Expression =>
Found := False;
if Is_Composite (Item.Expression_Type) and then
not Is_Array (Item.Expression_Type) then
Decl := Find_Component
(Item.Expression_Type, Name_Image (Ident));
if not Is_Nil (Decl) then
Stored.Kind := A_Component;
Stored.Down := Item;
Stored.Result_Type := Type_Of_Declaration (Decl, Element);
Stored.Component := Decl;
Add (Result, Up_Expression (Stored.Result_Type));
Add (Store, Stored);
Found := True;
elsif Is_Task (Item.Expression_Type)
or Is_Protected (Item.Expression_Type)
then
Def := Get_Type_Def (Item.Expression_Type);
Decl := Find_Task_Visible_Item (Def, Name_Image (Ident));
if not Is_Nil (Decl) then
Add (Result, (A_Declaration, Decl));
Stored.Kind := A_Function_Call;
Stored.Down := Item;
Add (Store, Stored);
Found := True;
end if;
end if;
end if;
if not Found and then
(Is_Tagged (Item.Expression_Type) or
Is_Class_Wide (Item.Expression_Type))
then
declare
Not_Wide : constant Type_Info :=
Drop_Class (Item.Expression_Type);
List : constant Asis.Defining_Name_List :=
XASIS.Utils.Unique
(Subprograms_Of_Ancestor (Tipe => Not_Wide,
Target => Not_Wide,
Ident => Ident));
Decl : Asis.Declaration;
begin
for J in List'Range loop
Decl := Enclosing_Element (List (J));
Add (Result, (A_Prefixed_View, Decl));
Stored.Kind := A_Subprogram_Reference;
Stored.Down := Item;
Stored.Component := Decl;
Add (Store, Stored);
end loop;
end;
end if;
when A_Declaration =>
case Declaration_Kind (Item.Declaration) is
when A_Single_Task_Declaration |
A_Single_Protected_Declaration |
A_Protected_Body_Declaration |
A_Task_Body_Declaration =>
Decl := Item.Declaration;
if Declaration_Kind (Decl) = A_Protected_Body_Declaration
or Declaration_Kind (Decl) = A_Task_Body_Declaration
then
Decl := Corresponding_Declaration (Decl);
end if;
Def := Object_Declaration_View (Decl);
Decl := Find_Task_Visible_Item (Def, Name_Image (Ident));
if not Is_Nil (Decl) then
Add (Result, (A_Declaration, Decl));
Stored.Kind := A_Function_Call;
Stored.Down := Item;
Add (Store, Stored);
end if;
when others =>
null;
end case;
when others =>
raise Internal_Error;
end case;
end loop;
U.Push (Resolver.Stack, Result);
Destroy (Prefix);
Destroy (Set);
Put (Resolver.Store, Element, Store);
end Selected_Component;
-------------------
-- Short_Circuit --
-------------------
procedure Short_Circuit
(Resolver : in out Up_Resolver;
Element : in Asis.Element)
is
use Asis.Expressions;
Result : Up_Interpretation_Set := Create;
Left : Up_Interpretation_Set;
Right : Up_Interpretation_Set;
Left_Item : Up_Interpretation;
begin
U.Pop (Resolver.Stack, Right);
U.Pop (Resolver.Stack, Left);
Expand_Expression (Right, Resolver.Implicit,
Short_Circuit_Operation_Right_Expression (Element));
Constrain_To_Boolean_Types (Left, Resolver.Implicit,
Short_Circuit_Operation_Left_Expression (Element));
for I in 1 .. Length (Left) loop
Get (Left, I, Left_Item);
if Left_Item.Kind = An_Expression and then
Has_Type (Right, Left_Item.Expression_Type) then
Add (Result, Left_Item);
end if;
end loop;
U.Push (Resolver.Stack, Result);
Destroy (Right);
Destroy (Left);
end Short_Circuit;
------------------
-- Simple_Range --
------------------
procedure Simple_Range
(Resolver : in out Up_Resolver;
Element : in Asis.Element)
is
Result : Up_Interpretation_Set := Create;
Left : Up_Interpretation_Set;
Right : Up_Interpretation_Set;
Left_Item : Up_Interpretation;
Right_Item : Up_Interpretation;
Tipe : Type_Info;
begin
U.Pop (Resolver.Stack, Right);
U.Pop (Resolver.Stack, Left);
Expand_Expression (Right, Resolver.Implicit,
Asis.Definitions.Upper_Bound (Element));
Expand_Expression (Left, Resolver.Implicit,
Asis.Definitions.Lower_Bound (Element));
for I in 1 .. Length (Left) loop
Get (Left, I, Left_Item);
for J in 1 .. Length (Right) loop
Get (Right, J, Right_Item);
if Right_Item.Kind = An_Expression and then
Left_Item.Kind = An_Expression
then
Tipe := Type_Of_Range (Left_Item.Expression_Type,
Right_Item.Expression_Type);
if not Is_Not_Type (Tipe) then
Add (Result, (A_Range, Tipe));
end if;
end if;
end loop;
end loop;
U.Push (Resolver.Stack, Result);
Destroy (Right);
Destroy (Left);
end Simple_Range;
-----------------------------
-- Subprograms_Of_Ancestor --
-----------------------------
function Subprograms_Of_Ancestor
(Tipe : Type_Info;
Target : Type_Info;
Ident : Asis.Identifier) return Asis.Defining_Name_List
is
use Asis.Gela.Visibility;
function Fit (Name : Defining_Name) return Boolean is
Decl : constant Asis.Declaration := Enclosing_Element (Name);
List : constant Asis.Parameter_Specification_List :=
XASIS.Utils.Get_Profile (Decl);
begin
if List'Length = 0 then
return False;
end if;
declare
Info : Type_Info := Type_Of_Declaration (List (1), Ident);
begin
if Is_Anonymous_Access (Info) then
Info := Destination_Type (Info);
end if;
return Is_Equal (Target, Info) or else
(Is_Class_Wide (Info) and then
Is_Covered (Target, Class_Wide => Info));
end;
end Fit;
Decl : constant Asis.Declaration := Get_Declaration (Tipe);
Parents : constant Asis.Name_List := XASIS.Utils.Get_Ancestors (Decl);
List : constant Asis.Element_List :=
Subprograms_Of_Ancestors (Parents, Target, Ident);
Found : Asis.Element_List := Lookup_In_Parent_Region (Ident, Decl);
Index : Asis.ASIS_Natural := 0;
begin
for J in Found'Range loop
if Fit (Found (J)) then
Index := Index + 1;
Found (Index) := Found (J);
end if;
end loop;
return Found (1 .. Index) & List;
end Subprograms_Of_Ancestor;
------------------------------
-- Subprograms_Of_Ancestors --
------------------------------
function Subprograms_Of_Ancestors
(Ancestors : Asis.Name_List;
Target : Type_Info;
Ident : Asis.Identifier) return Asis.Defining_Name_List
is
begin
if Ancestors'Length = 0 then
return Asis.Nil_Element_List;
else
declare
Tipe : constant Type_Info := Type_From_Subtype_Mark
(Ancestors (Ancestors'Last), Ident);
List : constant Asis.Element_List :=
Subprograms_Of_Ancestor (Tipe, Target, Ident);
begin
if Ancestors'First = Ancestors'Last then
return List;
else
return Subprograms_Of_Ancestors
(Ancestors (Ancestors'First .. Ancestors'Last - 1),
Target,
Ident) & List;
end if;
end;
end if;
end Subprograms_Of_Ancestors;
end Asis.Gela.Overloads.Walk.Up;
------------------------------------------------------------------------------
-- 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.
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A 4 G . K N D _ C O N V --
-- --
-- B o d y --
-- --
-- Copyright (C) 1995-2012, Free Software Foundation, Inc. --
-- --
-- ASIS-for-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 --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY 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 ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by AdaCore --
-- (http://www.adacore.com). --
-- --
------------------------------------------------------------------------------
package body A4G.Knd_Conv is
use Asis;
--------------------------------------
-- Element Classification Functions --
--------------------------------------
-- Most of the Conversion Functions use the table-driven switching to
-- define the result of the conversion. Switches are implemented as
-- one-dimension arrays indexed by the corresponding Internal_Element_Kinds
-- subtype and having components of the target type of the conversion
-------------------------------------------------------
-- Conversion Switches Definition and Initialization --
-------------------------------------------------------
Pragma_Kind_Switch : constant array (Internal_Pragma_Kinds) of Pragma_Kinds
:=
(An_All_Calls_Remote_Pragma => An_All_Calls_Remote_Pragma,
An_Asynchronous_Pragma => An_Asynchronous_Pragma,
An_Atomic_Pragma => An_Atomic_Pragma,
An_Atomic_Components_Pragma => An_Atomic_Components_Pragma,
An_Attach_Handler_Pragma => An_Attach_Handler_Pragma,
A_Controlled_Pragma => A_Controlled_Pragma,
A_Convention_Pragma => A_Convention_Pragma,
A_Discard_Names_Pragma => A_Discard_Names_Pragma, -- added
An_Elaborate_Pragma => An_Elaborate_Pragma, -- added
An_Elaborate_All_Pragma => An_Elaborate_All_Pragma,
An_Elaborate_Body_Pragma => An_Elaborate_Body_Pragma,
An_Export_Pragma => An_Export_Pragma,
An_Import_Pragma => An_Import_Pragma,
An_Inline_Pragma => An_Inline_Pragma,
An_Inspection_Point_Pragma => An_Inspection_Point_Pragma,
An_Interrupt_Handler_Pragma => An_Interrupt_Handler_Pragma,
An_Interrupt_Priority_Pragma => An_Interrupt_Priority_Pragma,
A_Linker_Options_Pragma => A_Linker_Options_Pragma, -- added
A_List_Pragma => A_List_Pragma,
A_Locking_Policy_Pragma => A_Locking_Policy_Pragma,
A_Normalize_Scalars_Pragma => A_Normalize_Scalars_Pragma,
An_Optimize_Pragma => An_Optimize_Pragma,
A_Pack_Pragma => A_Pack_Pragma,
A_Page_Pragma => A_Page_Pragma,
A_Preelaborate_Pragma => A_Preelaborate_Pragma,
A_Priority_Pragma => A_Priority_Pragma,
A_Pure_Pragma => A_Pure_Pragma,
A_Queuing_Policy_Pragma => A_Queuing_Policy_Pragma,
A_Remote_Call_Interface_Pragma => A_Remote_Call_Interface_Pragma,
A_Remote_Types_Pragma => A_Remote_Types_Pragma,
A_Restrictions_Pragma => A_Restrictions_Pragma,
A_Reviewable_Pragma => A_Reviewable_Pragma,
A_Shared_Passive_Pragma => A_Shared_Passive_Pragma,
A_Storage_Size_Pragma => A_Storage_Size_Pragma, -- added
A_Suppress_Pragma => A_Suppress_Pragma,
A_Task_Dispatching_Policy_Pragma => A_Task_Dispatching_Policy_Pragma,
A_Volatile_Pragma => A_Volatile_Pragma,
A_Volatile_Components_Pragma => A_Volatile_Components_Pragma,
-- --|A2005 start
-- New Ada 2005 pragmas. To be alphabetically ordered later:
An_Assert_Pragma => An_Assert_Pragma,
An_Assertion_Policy_Pragma => An_Assertion_Policy_Pragma,
A_Detect_Blocking_Pragma => A_Detect_Blocking_Pragma,
A_No_Return_Pragma => A_No_Return_Pragma,
A_Partition_Elaboration_Policy_Pragma =>
A_Partition_Elaboration_Policy_Pragma,
A_Preelaborable_Initialization_Pragma =>
A_Preelaborable_Initialization_Pragma,
A_Priority_Specific_Dispatching_Pragma =>
A_Priority_Specific_Dispatching_Pragma,
A_Profile_Pragma => A_Profile_Pragma,
A_Relative_Deadline_Pragma => A_Relative_Deadline_Pragma,
An_Unchecked_Union_Pragma => An_Unchecked_Union_Pragma,
An_Unsuppress_Pragma => An_Unsuppress_Pragma,
-- --|A2005 end
-- --|A2012 start
-- New Ada 2012 pragmas. To be alphabetically ordered later
A_Default_Storage_Pool_Pragma => A_Default_Storage_Pool_Pragma,
A_Dispatching_Domain_Pragma => A_Dispatching_Domain_Pragma,
A_CPU_Pragma => A_CPU_Pragma,
An_Independent_Pragma => An_Independent_Pragma,
A_Independent_Components_Pragma => A_Independent_Components_Pragma,
-- To be continued...
-- --|A2012 end
An_Implementation_Defined_Pragma => An_Implementation_Defined_Pragma,
An_Unknown_Pragma => An_Unknown_Pragma);
------------------------------------------------------------------------------
Defining_Name_Kind_Switch : constant array (Internal_Defining_Name_Kinds) of
Defining_Name_Kinds :=
(A_Defining_Identifier => A_Defining_Identifier,
A_Defining_Character_Literal => A_Defining_Character_Literal,
A_Defining_Enumeration_Literal => A_Defining_Enumeration_Literal,
-- A_Defining_Operator_Symbol
A_Defining_And_Operator ..
A_Defining_Not_Operator => A_Defining_Operator_Symbol,
A_Defining_Expanded_Name => A_Defining_Expanded_Name);
------------------------------------------------------------------------------
Declaration_Kind_Switch : constant array (Internal_Declaration_Kinds) of
Declaration_Kinds :=
(An_Ordinary_Type_Declaration => An_Ordinary_Type_Declaration,
A_Task_Type_Declaration => A_Task_Type_Declaration,
A_Protected_Type_Declaration => A_Protected_Type_Declaration,
An_Incomplete_Type_Declaration => An_Incomplete_Type_Declaration,
A_Tagged_Incomplete_Type_Declaration =>
A_Tagged_Incomplete_Type_Declaration,
A_Private_Type_Declaration => A_Private_Type_Declaration,
A_Private_Extension_Declaration => A_Private_Extension_Declaration,
A_Subtype_Declaration => A_Subtype_Declaration,
A_Variable_Declaration => A_Variable_Declaration,
A_Constant_Declaration => A_Constant_Declaration,
A_Deferred_Constant_Declaration => A_Deferred_Constant_Declaration,
A_Single_Task_Declaration => A_Single_Task_Declaration,
A_Single_Protected_Declaration => A_Single_Protected_Declaration,
An_Integer_Number_Declaration => An_Integer_Number_Declaration,
A_Real_Number_Declaration => A_Real_Number_Declaration,
An_Enumeration_Literal_Specification =>
An_Enumeration_Literal_Specification,
A_Discriminant_Specification => A_Discriminant_Specification,
A_Component_Declaration => A_Component_Declaration,
A_Loop_Parameter_Specification => A_Loop_Parameter_Specification,
A_Generalized_Iterator_Specification =>
A_Generalized_Iterator_Specification,
An_Element_Iterator_Specification => An_Element_Iterator_Specification,
A_Procedure_Declaration => A_Procedure_Declaration,
A_Function_Declaration => A_Function_Declaration,
A_Parameter_Specification => A_Parameter_Specification,
A_Procedure_Body_Declaration => A_Procedure_Body_Declaration,
A_Function_Body_Declaration => A_Function_Body_Declaration,
A_Return_Variable_Specification => A_Return_Variable_Specification,
A_Return_Constant_Specification => A_Return_Constant_Specification,
A_Null_Procedure_Declaration => A_Null_Procedure_Declaration,
An_Expression_Function_Declaration =>
An_Expression_Function_Declaration,
A_Package_Declaration => A_Package_Declaration,
A_Package_Body_Declaration => A_Package_Body_Declaration,
An_Object_Renaming_Declaration => An_Object_Renaming_Declaration,
An_Exception_Renaming_Declaration => An_Exception_Renaming_Declaration,
A_Package_Renaming_Declaration => A_Package_Renaming_Declaration,
A_Procedure_Renaming_Declaration => A_Procedure_Renaming_Declaration,
A_Function_Renaming_Declaration => A_Function_Renaming_Declaration,
A_Generic_Package_Renaming_Declaration =>
A_Generic_Package_Renaming_Declaration,
A_Generic_Procedure_Renaming_Declaration =>
A_Generic_Procedure_Renaming_Declaration,
A_Generic_Function_Renaming_Declaration =>
A_Generic_Function_Renaming_Declaration,
A_Task_Body_Declaration => A_Task_Body_Declaration,
A_Protected_Body_Declaration => A_Protected_Body_Declaration,
An_Entry_Declaration => An_Entry_Declaration,
An_Entry_Body_Declaration => An_Entry_Body_Declaration,
An_Entry_Index_Specification => An_Entry_Index_Specification,
A_Procedure_Body_Stub => A_Procedure_Body_Stub,
A_Function_Body_Stub => A_Function_Body_Stub,
A_Package_Body_Stub => A_Package_Body_Stub,
A_Task_Body_Stub => A_Task_Body_Stub,
A_Protected_Body_Stub => A_Protected_Body_Stub,
An_Exception_Declaration => An_Exception_Declaration,
A_Choice_Parameter_Specification => A_Choice_Parameter_Specification,
A_Generic_Procedure_Declaration => A_Generic_Procedure_Declaration,
A_Generic_Function_Declaration => A_Generic_Function_Declaration,
A_Generic_Package_Declaration => A_Generic_Package_Declaration,
A_Package_Instantiation => A_Package_Instantiation,
A_Procedure_Instantiation => A_Procedure_Instantiation,
A_Function_Instantiation => A_Function_Instantiation,
A_Formal_Object_Declaration => A_Formal_Object_Declaration,
A_Formal_Type_Declaration => A_Formal_Type_Declaration,
A_Formal_Incomplete_Type_Declaration =>
A_Formal_Incomplete_Type_Declaration,
A_Formal_Procedure_Declaration => A_Formal_Procedure_Declaration,
A_Formal_Function_Declaration => A_Formal_Function_Declaration,
A_Formal_Package_Declaration => A_Formal_Package_Declaration,
A_Formal_Package_Declaration_With_Box =>
A_Formal_Package_Declaration_With_Box);
------------------------------------------------------------------------------
Definition_Kind_Switch : constant array (Internal_Definition_Kinds) of
Definition_Kinds :=
(A_Derived_Type_Definition ..
An_Access_To_Protected_Function => A_Type_Definition,
A_Subtype_Indication => A_Subtype_Indication,
-- A_Constraint, -- 3.2.2 -> Constraint_Kinds
A_Range_Attribute_Reference ..
A_Discriminant_Constraint => A_Constraint,
A_Component_Definition => A_Component_Definition,
-- A_Discrete_Subtype_Definition, -- 3.6 -> Discrete_Range_Kinds
A_Discrete_Subtype_Indication_As_Subtype_Definition ..
A_Discrete_Simple_Expression_Range_As_Subtype_Definition
=> A_Discrete_Subtype_Definition,
-- A_Discrete_Range, -- 3.6.1 -> Discrete_Range_Kinds
A_Discrete_Subtype_Indication ..
A_Discrete_Simple_Expression_Range => A_Discrete_Range,
An_Unknown_Discriminant_Part => An_Unknown_Discriminant_Part,
A_Known_Discriminant_Part => A_Known_Discriminant_Part,
A_Record_Definition => A_Record_Definition,
A_Null_Record_Definition => A_Null_Record_Definition,
A_Null_Component => A_Null_Component,
A_Variant_Part => A_Variant_Part,
A_Variant => A_Variant,
An_Others_Choice => An_Others_Choice,
-- --|A2005 start
-- An_Access_Definition, -- 3.10(6/2) -> Access_Definition_Kinds
An_Anonymous_Access_To_Variable ..
An_Anonymous_Access_To_Protected_Function => An_Access_Definition,
-- --|A2005 end
A_Private_Type_Definition => A_Private_Type_Definition,
A_Tagged_Private_Type_Definition => A_Tagged_Private_Type_Definition,
A_Private_Extension_Definition => A_Private_Extension_Definition,
A_Task_Definition => A_Task_Definition,
A_Protected_Definition => A_Protected_Definition,
-- A_Formal_Type_Definition, -- 12.5 -> Formal_Type_Kinds
A_Formal_Private_Type_Definition ..
A_Formal_Access_To_Protected_Function => A_Formal_Type_Definition,
An_Aspect_Specification => An_Aspect_Specification);
------------------------------------------------------------------------------
Type_Kind_Switch : constant array (Internal_Type_Kinds) of Type_Kinds :=
(A_Derived_Type_Definition => A_Derived_Type_Definition,
A_Derived_Record_Extension_Definition =>
A_Derived_Record_Extension_Definition,
An_Enumeration_Type_Definition => An_Enumeration_Type_Definition,
A_Signed_Integer_Type_Definition => A_Signed_Integer_Type_Definition,
A_Modular_Type_Definition => A_Modular_Type_Definition,
-- A_Root_Type_Definition, -- 3.5.4(10), 3.5.6(4)
-- -> Root_Type_Kinds
A_Root_Integer_Definition ..
A_Universal_Fixed_Definition => A_Root_Type_Definition,
A_Floating_Point_Definition => A_Floating_Point_Definition,
An_Ordinary_Fixed_Point_Definition => An_Ordinary_Fixed_Point_Definition,
A_Decimal_Fixed_Point_Definition => A_Decimal_Fixed_Point_Definition,
An_Unconstrained_Array_Definition => An_Unconstrained_Array_Definition,
A_Constrained_Array_Definition => A_Constrained_Array_Definition,
A_Record_Type_Definition => A_Record_Type_Definition,
A_Tagged_Record_Type_Definition => A_Tagged_Record_Type_Definition,
-- --|A2005 start
-- An_Interface_Type_Definition, -- 3.9.4 -> Interface_Kinds
-- --|A2005 end
An_Ordinary_Interface .. A_Synchronized_Interface =>
An_Interface_Type_Definition,
-- An_Access_Type_Definition, -- 3.10 -> Access_Type_Kinds
A_Pool_Specific_Access_To_Variable ..
An_Access_To_Protected_Function => An_Access_Type_Definition);
------------------------------------------------------------------------------
Formal_Type_Kind_Switch : constant array (Internal_Formal_Type_Kinds) of
Formal_Type_Kinds :=
(A_Formal_Private_Type_Definition => A_Formal_Private_Type_Definition,
A_Formal_Tagged_Private_Type_Definition =>
A_Formal_Tagged_Private_Type_Definition,
A_Formal_Derived_Type_Definition => A_Formal_Derived_Type_Definition,
A_Formal_Discrete_Type_Definition => A_Formal_Discrete_Type_Definition,
A_Formal_Signed_Integer_Type_Definition =>
A_Formal_Signed_Integer_Type_Definition,
A_Formal_Modular_Type_Definition => A_Formal_Modular_Type_Definition,
A_Formal_Floating_Point_Definition =>
A_Formal_Floating_Point_Definition,
A_Formal_Ordinary_Fixed_Point_Definition =>
A_Formal_Ordinary_Fixed_Point_Definition,
A_Formal_Decimal_Fixed_Point_Definition =>
A_Formal_Decimal_Fixed_Point_Definition,
-- --|A2005 start
-- A_Formal_Interface_Type_Definition, -- 12.5.5(2) -> Interface_Kinds
A_Formal_Ordinary_Interface .. A_Formal_Synchronized_Interface =>
A_Formal_Interface_Type_Definition,
-- --|A2005 end
A_Formal_Unconstrained_Array_Definition =>
A_Formal_Unconstrained_Array_Definition,
A_Formal_Constrained_Array_Definition =>
A_Formal_Constrained_Array_Definition,
-- A_Formal_Access_Type_Definition, -- 12.5.4 -> Access_Type_Kinds
A_Formal_Pool_Specific_Access_To_Variable ..
A_Formal_Access_To_Protected_Function => A_Formal_Access_Type_Definition);
------------------------------------------------------------------------------
Access_Type_Kind_Switch : constant array (Internal_Access_Type_Kinds) of
Access_Type_Kinds :=
(A_Pool_Specific_Access_To_Variable => A_Pool_Specific_Access_To_Variable,
An_Access_To_Variable => An_Access_To_Variable,
An_Access_To_Constant => An_Access_To_Constant,
An_Access_To_Procedure => An_Access_To_Procedure,
An_Access_To_Protected_Procedure => An_Access_To_Protected_Procedure,
An_Access_To_Function => An_Access_To_Function,
An_Access_To_Protected_Function => An_Access_To_Protected_Function);
------------------------------------------------------------------------------
-- --|A2005 start
Access_Definition_Kind_Switch : constant
array (Internal_Access_Definition_Kinds) of Access_Definition_Kinds :=
(An_Anonymous_Access_To_Variable => An_Anonymous_Access_To_Variable,
An_Anonymous_Access_To_Constant => An_Anonymous_Access_To_Constant,
An_Anonymous_Access_To_Procedure => An_Anonymous_Access_To_Procedure,
An_Anonymous_Access_To_Protected_Procedure =>
An_Anonymous_Access_To_Protected_Procedure,
An_Anonymous_Access_To_Function => An_Anonymous_Access_To_Function,
An_Anonymous_Access_To_Protected_Function =>
An_Anonymous_Access_To_Protected_Function);
Interface_Kind_Switch : constant array (Internal_Interface_Kinds) of
Interface_Kinds :=
(An_Ordinary_Interface => An_Ordinary_Interface,
A_Limited_Interface => A_Limited_Interface,
A_Task_Interface => A_Task_Interface,
A_Protected_Interface => A_Protected_Interface,
A_Synchronized_Interface => A_Synchronized_Interface);
Formal_Interface_Kind_Switch : constant
array (Internal_Formal_Interface_Kinds) of Interface_Kinds :=
(A_Formal_Ordinary_Interface => An_Ordinary_Interface,
A_Formal_Limited_Interface => A_Limited_Interface,
A_Formal_Task_Interface => A_Task_Interface,
A_Formal_Protected_Interface => A_Protected_Interface,
A_Formal_Synchronized_Interface => A_Synchronized_Interface);
-- --|A2005 end
------------------------------------------------------------------------------
Formal_Access_Type_Kind_Switch : constant
array (Internal_Formal_Access_Type_Kinds) of Access_Type_Kinds :=
(A_Formal_Pool_Specific_Access_To_Variable =>
A_Pool_Specific_Access_To_Variable,
A_Formal_Access_To_Variable => An_Access_To_Variable,
A_Formal_Access_To_Constant => An_Access_To_Constant,
A_Formal_Access_To_Procedure => An_Access_To_Procedure,
A_Formal_Access_To_Protected_Procedure => An_Access_To_Protected_Procedure,
A_Formal_Access_To_Function => An_Access_To_Function,
A_Formal_Access_To_Protected_Function => An_Access_To_Protected_Function);
------------------------------------------------------------------------------
Root_Type_Kind_Switch : constant array (Internal_Root_Type_Kinds) of
Root_Type_Kinds :=
(A_Root_Integer_Definition => A_Root_Integer_Definition,
A_Root_Real_Definition => A_Root_Real_Definition,
A_Universal_Integer_Definition => A_Universal_Integer_Definition,
A_Universal_Real_Definition => A_Universal_Real_Definition,
A_Universal_Fixed_Definition => A_Universal_Fixed_Definition);
------------------------------------------------------------------------------
Constraint_Kind_Switch : constant array (Internal_Constraint_Kinds) of
Constraint_Kinds :=
(A_Range_Attribute_Reference => A_Range_Attribute_Reference,
A_Simple_Expression_Range => A_Simple_Expression_Range,
A_Digits_Constraint => A_Digits_Constraint,
A_Delta_Constraint => A_Delta_Constraint,
An_Index_Constraint => An_Index_Constraint,
A_Discriminant_Constraint => A_Discriminant_Constraint);
------------------------------------------------------------------------------
Discrete_Range_Kind_Switch : constant array (Internal_Element_Kinds) of
Discrete_Range_Kinds :=
-- This switch array (as well as Operator_Kind_Switch) differs from all
-- the others, because it is to be used for two different internal
-- classification subtypes:
-- Internal_Discrete_Subtype_Definition_Kinds and
-- Internal_Discrete_Range_Kinds
(A_Discrete_Subtype_Indication_As_Subtype_Definition
| A_Discrete_Subtype_Indication
=> A_Discrete_Subtype_Indication,
A_Discrete_Range_Attribute_Reference_As_Subtype_Definition
| A_Discrete_Range_Attribute_Reference
=> A_Discrete_Range_Attribute_Reference,
A_Discrete_Simple_Expression_Range_As_Subtype_Definition
| A_Discrete_Simple_Expression_Range
=> A_Discrete_Simple_Expression_Range,
others => Not_A_Discrete_Range);
------------------------------------------------------------------------------
Expression_Kind_Switch : constant array (Internal_Expression_Kinds) of
Expression_Kinds :=
(An_Integer_Literal => An_Integer_Literal,
A_Real_Literal => A_Real_Literal,
A_String_Literal => A_String_Literal,
An_Identifier => An_Identifier,
-- An_Operator_Symbol
An_And_Operator ..
A_Not_Operator => An_Operator_Symbol,
A_Character_Literal => A_Character_Literal,
An_Enumeration_Literal => An_Enumeration_Literal,
An_Explicit_Dereference => An_Explicit_Dereference,
A_Function_Call => A_Function_Call,
An_Indexed_Component => An_Indexed_Component,
A_Slice => A_Slice,
A_Selected_Component => A_Selected_Component,
An_Access_Attribute ..
An_Unknown_Attribute => An_Attribute_Reference,
A_Record_Aggregate => A_Record_Aggregate,
An_Extension_Aggregate => An_Extension_Aggregate,
A_Positional_Array_Aggregate => A_Positional_Array_Aggregate,
A_Named_Array_Aggregate => A_Named_Array_Aggregate,
An_And_Then_Short_Circuit => An_And_Then_Short_Circuit,
An_Or_Else_Short_Circuit => An_Or_Else_Short_Circuit,
An_In_Membership_Test => An_In_Membership_Test,
A_Not_In_Membership_Test => A_Not_In_Membership_Test,
A_Null_Literal => A_Null_Literal,
A_Parenthesized_Expression => A_Parenthesized_Expression,
A_Type_Conversion => A_Type_Conversion,
A_Qualified_Expression => A_Qualified_Expression,
An_Allocation_From_Subtype => An_Allocation_From_Subtype,
An_Allocation_From_Qualified_Expression =>
An_Allocation_From_Qualified_Expression,
A_Case_Expression => A_Case_Expression,
An_If_Expression => An_If_Expression,
A_For_All_Quantified_Expression => A_For_All_Quantified_Expression,
A_For_Some_Quantified_Expression => A_For_Some_Quantified_Expression);
------------------------------------------------------------------------------
Operator_Kind_Switch : constant array (Internal_Element_Kinds) of
Operator_Kinds :=
-- This switch array (as well as Discrete_Range_Kind_Switch) differs from
-- all the others, because it is to be used for two different internal
-- classification subtypes:
-- Internal_Defining_Operator_Kinds and Internal_Operator_Symbol_Kinds
(A_Defining_And_Operator
| An_And_Operator => An_And_Operator,
A_Defining_Or_Operator
| An_Or_Operator => An_Or_Operator,
A_Defining_Xor_Operator
| An_Xor_Operator => An_Xor_Operator,
A_Defining_Equal_Operator
| An_Equal_Operator => An_Equal_Operator,
A_Defining_Not_Equal_Operator
| A_Not_Equal_Operator => A_Not_Equal_Operator,
A_Defining_Less_Than_Operator
| A_Less_Than_Operator => A_Less_Than_Operator,
A_Defining_Less_Than_Or_Equal_Operator
| A_Less_Than_Or_Equal_Operator => A_Less_Than_Or_Equal_Operator,
A_Defining_Greater_Than_Operator
| A_Greater_Than_Operator => A_Greater_Than_Operator,
A_Defining_Greater_Than_Or_Equal_Operator
| A_Greater_Than_Or_Equal_Operator => A_Greater_Than_Or_Equal_Operator,
A_Defining_Plus_Operator
| A_Plus_Operator => A_Plus_Operator,
A_Defining_Minus_Operator
| A_Minus_Operator => A_Minus_Operator,
A_Defining_Concatenate_Operator
| A_Concatenate_Operator => A_Concatenate_Operator,
A_Defining_Unary_Plus_Operator
| A_Unary_Plus_Operator => A_Unary_Plus_Operator,
A_Defining_Unary_Minus_Operator
| A_Unary_Minus_Operator => A_Unary_Minus_Operator,
A_Defining_Multiply_Operator
| A_Multiply_Operator => A_Multiply_Operator,
A_Defining_Divide_Operator
| A_Divide_Operator => A_Divide_Operator,
A_Defining_Mod_Operator
| A_Mod_Operator => A_Mod_Operator,
A_Defining_Rem_Operator
| A_Rem_Operator => A_Rem_Operator,
A_Defining_Exponentiate_Operator
| An_Exponentiate_Operator => An_Exponentiate_Operator,
A_Defining_Abs_Operator
| An_Abs_Operator => An_Abs_Operator,
A_Defining_Not_Operator
| A_Not_Operator => A_Not_Operator,
others => Not_An_Operator);
------------------------------------------------------------------------------
Attribute_Kind_Switch : constant array (Internal_Attribute_Reference_Kinds)
of Attribute_Kinds :=
(
An_Access_Attribute => An_Access_Attribute,
An_Address_Attribute => An_Address_Attribute,
An_Adjacent_Attribute => An_Adjacent_Attribute,
An_Aft_Attribute => An_Aft_Attribute,
An_Alignment_Attribute => An_Alignment_Attribute,
A_Base_Attribute => A_Base_Attribute,
A_Bit_Order_Attribute => A_Bit_Order_Attribute,
A_Body_Version_Attribute => A_Body_Version_Attribute,
A_Callable_Attribute => A_Callable_Attribute,
A_Caller_Attribute => A_Caller_Attribute,
A_Ceiling_Attribute => A_Ceiling_Attribute,
A_Class_Attribute => A_Class_Attribute,
A_Component_Size_Attribute => A_Component_Size_Attribute,
A_Compose_Attribute => A_Compose_Attribute,
A_Constrained_Attribute => A_Constrained_Attribute,
A_Copy_Sign_Attribute => A_Copy_Sign_Attribute,
A_Count_Attribute => A_Count_Attribute,
A_Definite_Attribute => A_Definite_Attribute,
A_Delta_Attribute => A_Delta_Attribute,
A_Denorm_Attribute => A_Denorm_Attribute,
A_Digits_Attribute => A_Digits_Attribute,
An_Exponent_Attribute => An_Exponent_Attribute,
An_External_Tag_Attribute => An_External_Tag_Attribute,
A_First_Attribute => A_First_Attribute,
A_First_Bit_Attribute => A_First_Bit_Attribute,
A_Floor_Attribute => A_Floor_Attribute,
A_Fore_Attribute => A_Fore_Attribute,
A_Fraction_Attribute => A_Fraction_Attribute,
An_Identity_Attribute => An_Identity_Attribute,
An_Image_Attribute => An_Image_Attribute,
An_Input_Attribute => An_Input_Attribute,
A_Last_Attribute => A_Last_Attribute,
A_Last_Bit_Attribute => A_Last_Bit_Attribute,
A_Leading_Part_Attribute => A_Leading_Part_Attribute,
A_Length_Attribute => A_Length_Attribute,
A_Machine_Attribute => A_Machine_Attribute,
A_Machine_Emax_Attribute => A_Machine_Emax_Attribute,
A_Machine_Emin_Attribute => A_Machine_Emin_Attribute,
A_Machine_Mantissa_Attribute => A_Machine_Mantissa_Attribute,
A_Machine_Overflows_Attribute => A_Machine_Overflows_Attribute,
A_Machine_Radix_Attribute => A_Machine_Radix_Attribute,
A_Machine_Rounds_Attribute => A_Machine_Rounds_Attribute,
A_Max_Attribute => A_Max_Attribute,
A_Max_Size_In_Storage_Elements_Attribute =>
A_Max_Size_In_Storage_Elements_Attribute,
A_Min_Attribute => A_Min_Attribute,
A_Model_Attribute => A_Model_Attribute,
A_Model_Emin_Attribute => A_Model_Emin_Attribute,
A_Model_Epsilon_Attribute => A_Model_Epsilon_Attribute,
A_Model_Mantissa_Attribute => A_Model_Mantissa_Attribute,
A_Model_Small_Attribute => A_Model_Small_Attribute,
A_Modulus_Attribute => A_Modulus_Attribute,
An_Output_Attribute => An_Output_Attribute,
A_Partition_ID_Attribute => A_Partition_ID_Attribute,
A_Pos_Attribute => A_Pos_Attribute,
A_Position_Attribute => A_Position_Attribute,
A_Pred_Attribute => A_Pred_Attribute,
A_Range_Attribute => A_Range_Attribute,
A_Read_Attribute => A_Read_Attribute,
A_Remainder_Attribute => A_Remainder_Attribute,
A_Round_Attribute => A_Round_Attribute,
A_Rounding_Attribute => A_Rounding_Attribute,
A_Safe_First_Attribute => A_Safe_First_Attribute,
A_Safe_Last_Attribute => A_Safe_Last_Attribute,
A_Scale_Attribute => A_Scale_Attribute,
A_Scaling_Attribute => A_Scaling_Attribute,
A_Signed_Zeros_Attribute => A_Signed_Zeros_Attribute,
A_Size_Attribute => A_Size_Attribute,
A_Small_Attribute => A_Small_Attribute,
A_Storage_Pool_Attribute => A_Storage_Pool_Attribute,
A_Storage_Size_Attribute => A_Storage_Size_Attribute,
A_Succ_Attribute => A_Succ_Attribute,
A_Tag_Attribute => A_Tag_Attribute,
A_Terminated_Attribute => A_Terminated_Attribute,
A_Truncation_Attribute => A_Truncation_Attribute,
An_Unbiased_Rounding_Attribute => An_Unbiased_Rounding_Attribute,
An_Unchecked_Access_Attribute => An_Unchecked_Access_Attribute,
A_Val_Attribute => A_Val_Attribute,
A_Valid_Attribute => A_Valid_Attribute,
A_Value_Attribute => A_Value_Attribute,
A_Version_Attribute => A_Version_Attribute,
A_Wide_Image_Attribute => A_Wide_Image_Attribute,
A_Wide_Value_Attribute => A_Wide_Value_Attribute,
A_Wide_Width_Attribute => A_Wide_Width_Attribute,
A_Width_Attribute => A_Width_Attribute,
A_Write_Attribute => A_Write_Attribute,
-- |A2005/2012 start
-- New Ada 2005/2012 attributes. To be alphabetically ordered later
A_Machine_Rounding_Attribute => A_Machine_Rounding_Attribute,
A_Mod_Attribute => A_Mod_Attribute,
A_Priority_Attribute => A_Priority_Attribute,
A_Stream_Size_Attribute => A_Stream_Size_Attribute,
A_Wide_Wide_Image_Attribute => A_Wide_Wide_Image_Attribute,
A_Wide_Wide_Value_Attribute => A_Wide_Wide_Value_Attribute,
A_Wide_Wide_Width_Attribute => A_Wide_Wide_Width_Attribute,
A_Max_Alignment_For_Allocation_Attribute =>
A_Max_Alignment_For_Allocation_Attribute,
An_Overlaps_Storage_Attribute => An_Overlaps_Storage_Attribute,
-- |A2005/2012 end
An_Implementation_Defined_Attribute =>
An_Implementation_Defined_Attribute,
An_Unknown_Attribute => An_Unknown_Attribute);
------------------------------------------------------------------------------
Association_Kind_Switch : constant array (Internal_Association_Kinds) of
Association_Kinds :=
(
A_Pragma_Argument_Association => A_Pragma_Argument_Association,
A_Discriminant_Association => A_Discriminant_Association,
A_Record_Component_Association => A_Record_Component_Association,
An_Array_Component_Association => An_Array_Component_Association,
A_Parameter_Association => A_Parameter_Association,
A_Generic_Association => A_Generic_Association);
------------------------------------------------------------------------------
Statement_Kind_Switch : constant array (Internal_Statement_Kinds) of
Statement_Kinds :=
(A_Null_Statement => A_Null_Statement,
An_Assignment_Statement => An_Assignment_Statement,
An_If_Statement => An_If_Statement,
A_Case_Statement => A_Case_Statement,
A_Loop_Statement => A_Loop_Statement,
A_While_Loop_Statement => A_While_Loop_Statement,
A_For_Loop_Statement => A_For_Loop_Statement,
A_Block_Statement => A_Block_Statement,
An_Exit_Statement => An_Exit_Statement,
A_Goto_Statement => A_Goto_Statement,
A_Procedure_Call_Statement => A_Procedure_Call_Statement,
A_Return_Statement => A_Return_Statement,
-- --|A2005 start
An_Extended_Return_Statement => An_Extended_Return_Statement,
-- --|A2005 end
An_Accept_Statement => An_Accept_Statement,
An_Entry_Call_Statement => An_Entry_Call_Statement,
A_Requeue_Statement => A_Requeue_Statement,
A_Requeue_Statement_With_Abort => A_Requeue_Statement_With_Abort,
A_Delay_Until_Statement => A_Delay_Until_Statement,
A_Delay_Relative_Statement => A_Delay_Relative_Statement,
A_Terminate_Alternative_Statement => A_Terminate_Alternative_Statement,
A_Selective_Accept_Statement => A_Selective_Accept_Statement,
A_Timed_Entry_Call_Statement => A_Timed_Entry_Call_Statement,
A_Conditional_Entry_Call_Statement => A_Conditional_Entry_Call_Statement,
An_Asynchronous_Select_Statement => An_Asynchronous_Select_Statement,
An_Abort_Statement => An_Abort_Statement,
A_Raise_Statement => A_Raise_Statement,
A_Code_Statement => A_Code_Statement);
------------------------------------------------------------------------------
Path_Kind_Switch : constant array (Internal_Path_Kinds) of
Path_Kinds :=
(An_If_Path => An_If_Path,
An_Elsif_Path => An_Elsif_Path,
An_Else_Path => An_Else_Path,
A_Case_Path => A_Case_Path,
A_Select_Path => A_Select_Path,
An_Or_Path => An_Or_Path,
A_Then_Abort_Path => A_Then_Abort_Path,
A_Case_Expression_Path => A_Case_Expression_Path,
An_If_Expression_Path => An_If_Expression_Path,
An_Elsif_Expression_Path => An_Elsif_Expression_Path,
An_Else_Expression_Path => An_Else_Expression_Path);
------------------------------------------------------------------------------
Clause_Kind_Switch : constant array (Internal_Clause_Kinds) of Clause_Kinds
:=
(A_Use_Package_Clause => A_Use_Package_Clause,
A_Use_Type_Clause => A_Use_Type_Clause,
A_Use_All_Type_Clause => A_Use_All_Type_Clause, -- Ada 2012
A_With_Clause => A_With_Clause,
-- A_Representation_Clause, -- 13.1 -> Representation_Clause_Kinds
An_Attribute_Definition_Clause ..
An_At_Clause => A_Representation_Clause,
A_Component_Clause => A_Component_Clause);
------------------------------------------------------------------------------
Representation_Clause_Kind_Switch :
constant array (Internal_Representation_Clause_Kinds) of
Representation_Clause_Kinds :=
(An_Attribute_Definition_Clause => An_Attribute_Definition_Clause,
An_Enumeration_Representation_Clause => An_Enumeration_Representation_Clause,
A_Record_Representation_Clause => A_Record_Representation_Clause,
An_At_Clause => An_At_Clause);
------------------------------------------------------------------------------
Def_Op_Switch : constant array (Internal_Operator_Symbol_Kinds) of
Internal_Defining_Operator_Kinds :=
(An_And_Operator => A_Defining_And_Operator,
An_Or_Operator => A_Defining_Or_Operator,
An_Xor_Operator => A_Defining_Xor_Operator,
An_Equal_Operator => A_Defining_Equal_Operator,
A_Not_Equal_Operator => A_Defining_Not_Equal_Operator,
A_Less_Than_Operator => A_Defining_Less_Than_Operator,
A_Less_Than_Or_Equal_Operator => A_Defining_Less_Than_Or_Equal_Operator,
A_Greater_Than_Operator => A_Defining_Greater_Than_Operator,
A_Greater_Than_Or_Equal_Operator => A_Defining_Greater_Than_Or_Equal_Operator,
A_Plus_Operator => A_Defining_Plus_Operator,
A_Minus_Operator => A_Defining_Minus_Operator,
A_Concatenate_Operator => A_Defining_Concatenate_Operator,
A_Unary_Plus_Operator => A_Defining_Unary_Plus_Operator,
A_Unary_Minus_Operator => A_Defining_Unary_Minus_Operator,
A_Multiply_Operator => A_Defining_Multiply_Operator,
A_Divide_Operator => A_Defining_Divide_Operator,
A_Mod_Operator => A_Defining_Mod_Operator,
A_Rem_Operator => A_Defining_Rem_Operator,
An_Exponentiate_Operator => A_Defining_Exponentiate_Operator,
An_Abs_Operator => A_Defining_Abs_Operator,
A_Not_Operator => A_Defining_Not_Operator);
------------------------------------------------------------------------------
-------------------------------------------------
-- Internal Element Kinds Conversion Functions --
-------------------------------------------------
------------------------------------
-- Access_Type_Kind_From_Internal --
------------------------------------
function Access_Type_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Access_Type_Kinds is
begin
if Internal_Kind in Internal_Access_Type_Kinds then
return Access_Type_Kind_Switch (Internal_Kind);
elsif Internal_Kind in Internal_Formal_Access_Type_Kinds then
return Formal_Access_Type_Kind_Switch (Internal_Kind);
else
return Not_An_Access_Type_Definition;
end if;
end Access_Type_Kind_From_Internal;
-----------------------------
-- Asis_From_Internal_Kind --
-----------------------------
function Asis_From_Internal_Kind
(Internal_Kind : Internal_Element_Kinds)
return Asis.Element_Kinds
is
begin
case Internal_Kind is
when Internal_Pragma_Kinds =>
return A_Pragma;
when Internal_Defining_Name_Kinds =>
return A_Defining_Name;
when Internal_Declaration_Kinds =>
return A_Declaration;
when Internal_Definition_Kinds =>
return A_Definition;
when Internal_Expression_Kinds =>
return An_Expression;
when Internal_Association_Kinds =>
return An_Association;
when Internal_Statement_Kinds =>
return A_Statement;
when Internal_Path_Kinds =>
return A_Path;
when Internal_Clause_Kinds =>
return A_Clause;
when An_Exception_Handler =>
return An_Exception_Handler;
when others => -- Not_An_Element and Not_A_XXX values
return Not_An_Element;
end case;
end Asis_From_Internal_Kind;
------------------------------------
-- Association_Kind_From_Internal --
------------------------------------
function Association_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Association_Kinds is
begin
if Internal_Kind not in Internal_Association_Kinds then
return Not_An_Association;
else
return Association_Kind_Switch (Internal_Kind);
end if;
end Association_Kind_From_Internal;
----------------------------------
-- Attribute_Kind_From_Internal --
----------------------------------
function Attribute_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Attribute_Kinds is
begin
if Internal_Kind not in Internal_Attribute_Reference_Kinds then
return Not_An_Attribute;
else
return Attribute_Kind_Switch (Internal_Kind);
end if;
end Attribute_Kind_From_Internal;
-------------------------------
-- Clause_Kind_From_Internal --
-------------------------------
function Clause_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Clause_Kinds is
begin
if Internal_Kind not in Internal_Clause_Kinds then
return Not_A_Clause;
else
return Clause_Kind_Switch (Internal_Kind);
end if;
end Clause_Kind_From_Internal;
-----------------------------------
-- Constraint_Kind_From_Internal --
-----------------------------------
function Constraint_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Constraint_Kinds is
begin
if Internal_Kind not in Internal_Constraint_Kinds then
return Not_A_Constraint;
else
return Constraint_Kind_Switch (Internal_Kind);
end if;
end Constraint_Kind_From_Internal;
------------------------------------
-- Declaration_Kind_From_Internal --
------------------------------------
function Declaration_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Declaration_Kinds is
begin
if Internal_Kind not in Internal_Declaration_Kinds then
return Not_A_Declaration;
else
return Declaration_Kind_Switch (Internal_Kind);
end if;
end Declaration_Kind_From_Internal;
-------------------------------------
-- Defining_Name_Kind_From_Internal--
-------------------------------------
function Defining_Name_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Defining_Name_Kinds is
begin
if Internal_Kind not in Internal_Defining_Name_Kinds then
return Not_A_Defining_Name;
else
return Defining_Name_Kind_Switch (Internal_Kind);
end if;
end Defining_Name_Kind_From_Internal;
-----------------------------------
-- Definition_Kind_From_Internal --
-----------------------------------
function Definition_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Definition_Kinds is
begin
if Internal_Kind not in Internal_Definition_Kinds then
return Not_A_Definition;
else
return Definition_Kind_Switch (Internal_Kind);
end if;
end Definition_Kind_From_Internal;
---------------------------------------
-- Discrete_Range_Kind_From_Internal --
---------------------------------------
function Discrete_Range_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Discrete_Range_Kinds is
begin
return Discrete_Range_Kind_Switch (Internal_Kind);
end Discrete_Range_Kind_From_Internal;
-----------------------------------
-- Expression_Kind_From_Internal --
-----------------------------------
function Expression_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Expression_Kinds is
begin
if Internal_Kind not in Internal_Expression_Kinds then
return Not_An_Expression;
else
return Expression_Kind_Switch (Internal_Kind);
end if;
end Expression_Kind_From_Internal;
------------------------------------
-- Formal_Type_Kind_From_Internal --
------------------------------------
function Formal_Type_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Formal_Type_Kinds is
begin
if Internal_Kind not in Internal_Formal_Type_Kinds then
return Not_A_Formal_Type_Definition;
else
return Formal_Type_Kind_Switch (Internal_Kind);
end if;
end Formal_Type_Kind_From_Internal;
-- --|A2005 start
------------------------------------------
-- Access_Definition_Kind_From_Internal --
------------------------------------------
function Access_Definition_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Access_Definition_Kinds
is
begin
if Internal_Kind not in Internal_Access_Definition_Kinds then
return Not_An_Access_Definition;
else
return Access_Definition_Kind_Switch (Internal_Kind);
end if;
end Access_Definition_Kind_From_Internal;
----------------------------------
-- Interface_Kind_From_Internal --
----------------------------------
function Interface_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Interface_Kinds
is
begin
if Internal_Kind in Internal_Interface_Kinds then
return Interface_Kind_Switch (Internal_Kind);
elsif Internal_Kind in Internal_Formal_Interface_Kinds then
return Formal_Interface_Kind_Switch (Internal_Kind);
else
return Not_An_Interface;
end if;
end Interface_Kind_From_Internal;
-- --|A2005 end
---------------------------------
-- Operator_Kind_From_Internal --
---------------------------------
function Operator_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Operator_Kinds is
begin
return Operator_Kind_Switch (Internal_Kind);
end Operator_Kind_From_Internal;
-----------------------------
-- Path_Kind_From_Internal --
-----------------------------
function Path_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Path_Kinds is
begin
if Internal_Kind not in Internal_Path_Kinds then
return Not_A_Path;
else
return Path_Kind_Switch (Internal_Kind);
end if;
end Path_Kind_From_Internal;
-------------------------------
-- Pragma_Kind_From_Internal --
-------------------------------
function Pragma_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds)
return Asis.Pragma_Kinds is
begin
if Internal_Kind not in Internal_Pragma_Kinds then
return Not_A_Pragma;
else
return Pragma_Kind_Switch (Internal_Kind);
end if;
end Pragma_Kind_From_Internal;
----------------------------------------------
-- Representation_Clause_Kind_From_Internal --
-----------------------------------------------
function Representation_Clause_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Representation_Clause_Kinds is
begin
if Internal_Kind not in Internal_Representation_Clause_Kinds then
return Not_A_Representation_Clause;
else
return Representation_Clause_Kind_Switch (Internal_Kind);
end if;
end Representation_Clause_Kind_From_Internal;
----------------------------------
-- Root_Type_Kind_From_Internal --
----------------------------------
function Root_Type_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Root_Type_Kinds is
begin
if Internal_Kind not in Internal_Root_Type_Kinds then
return Not_A_Root_Type_Definition;
else
return Root_Type_Kind_Switch (Internal_Kind);
end if;
end Root_Type_Kind_From_Internal;
----------------------------------
-- Statement_Kind_From_Internal --
----------------------------------
function Statement_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Statement_Kinds is
begin
if Internal_Kind not in Internal_Statement_Kinds then
return Not_A_Statement;
else
return Statement_Kind_Switch (Internal_Kind);
end if;
end Statement_Kind_From_Internal;
-----------------------------
-- Type_Kind_From_Internal --
-----------------------------
function Type_Kind_From_Internal
(Internal_Kind : Internal_Element_Kinds)
return Asis.Type_Kinds is
begin
if Internal_Kind not in Internal_Type_Kinds then
return Not_A_Type_Definition;
else
return Type_Kind_Switch (Internal_Kind);
end if;
end Type_Kind_From_Internal;
-------------------------------------
-- Additional Classification items --
-------------------------------------
-----------------------
-- Def_Operator_Kind --
-----------------------
function Def_Operator_Kind
(Op_Kind : Internal_Element_Kinds)
return Internal_Element_Kinds is
begin
return Def_Op_Switch (Op_Kind);
end Def_Operator_Kind;
------------------------------------------------------------------------------
end A4G.Knd_Conv;
|
with Sessions;
with Symbol_Sets;
package Symbols.IO is
procedure Put_Named (Session : in Sessions.Session_Type;
Set : in Symbol_Sets.Set_Type);
-- Debug
procedure JQ_Dump_Symbols (Session : in Sessions.Session_Type;
Mode : in Integer);
end Symbols.IO;
|
-----------------------------------------------------------------------
-- package body Extended_Real.E_Rand, extended precision random numbers.
-- Copyright (C) 2008-2018 Jonathan S. Parker
--
-- 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.
---------------------------------------------------------------------------
package body Extended_Real.E_Rand is
State : Random_Int := 701;
----------------
-- Get_Random --
----------------
-- 61 bit rands:
function Next_Random_Int
return Random_Int
is
X2 : Random_Int;
S8 : constant := 6; S7 : constant := 20; S6 : constant := 32;
S5 : constant := 30; S4 : constant := 15; S3 : constant := 7;
S2 : constant := 3; S1 : constant := 1;
-- Error detection is by assertion:
pragma Assert
(S8=6 and S7=20 and S6=32 and S5=30 and S4=15 and S3=7 and S2=3 and S1=1);
-- Error correction is by inspection:
-- (if mutated parameters are detected, use data given below to correct).
-- 1 3 7 15 30 32 20 6
-- 1 3 7 15 30 32 20 6
-- 1 3 7 15 30 32 20 6
begin
X2 := State;
X2 := X2 XOR (X2 / 2**S8);
X2 := (X2 XOR (X2 * 2**S7))mod 2**61;
X2 := X2 XOR (X2 / 2**S6);
X2 := (X2 XOR (X2 * 2**S5))mod 2**61;
X2 := X2 XOR (X2 / 2**S4);
X2 := (X2 XOR (X2 * 2**S3))mod 2**61;
X2 := X2 XOR (X2 / 2**S2);
X2 := (X2 XOR (X2 * 2**S1))mod 2**61;
State := X2;
return X2;
end Next_Random_Int;
-----------
-- Reset --
-----------
-- Initiator and state must never be negative or 0!
procedure Reset
(Initiator : in Positive := 7777777)
is
X : Integer := Initiator mod 2**30;
-- if Ints are 64 bit, keep it under 61 bit, while still portable to 32 bit int.
begin
if X = 0 then X := 1; end if;
State := Random_Int (X);
end Reset;
------------
-- Random --
------------
function Random
return E_Real
is
Result : E_Real;
begin
for I in Digit_Index loop
Result.Digit(I) := Digit_Type (Next_Random_Int mod 2**No_Of_Bits_in_Radix);
end loop;
if Result.Digit(Digit_Index'First) = Digit_Zero then
Result.Digit(Digit_Index'First) := Digit_One;
end if;
Result.Is_Zero := False;
Result.Is_Positive := True;
Result.Is_Infinite := False;
Result.Exp := -1;
return Result;
end Random;
end Extended_Real.E_Rand;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Escape_Loop is
package IO is new Integer_IO (Integer);
begin
Reverse_Loop:
for I in reverse 1 .. 100 loop
for J in 2*I .. 4*I loop
IO.Put (I);
exit reverse_loop when I*J mod 300 = 0;
IO.Put (J); New_Line;
end loop;
end loop Reverse_Loop;
end Escape_Loop;
|
------------------------------------------------------------------------------
-- --
-- Unicode Utilities --
-- --
-- Unicode Character Database (UCD) Utilities --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2019, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Exceptions; use Ada;
with Ada.IO_Exceptions;
with Ada.Characters.Conversions;
with Ada.Characters.Latin_1;
with Ada.Strings;
with Hex;
with Hex.Unsigned_24;
with Unicode.UTF8_Stream_Decoder;
package body Unicode.UCD is
use type Hex.Hex_Character;
----------------
-- Next_Entry --
----------------
function Next_Entry
(Stream: not null access Ada.Streams.Root_Stream_Type'Class)
return UCD_Entry
is
use type Ada.Streams.Root_Stream_Type;
subtype Root_Stream_Type is Ada.Streams.Root_Stream_Type;
function Next_Character
(UTF8_Stream: not null access Root_Stream_Type'Class
:= Stream)
return Wide_Wide_Character
renames Unicode.UTF8_Stream_Decoder.Decode_Next;
function Next_Character
(UTF8_Stream: not null access Root_Stream_Type'Class
:= Stream)
return Character
renames Unicode.UTF8_Stream_Decoder.Decode_Next;
CR: Character renames Ada.Characters.Latin_1.CR;
LF: Character renames Ada.Characters.Latin_1.LF;
WW_CR: constant Wide_Wide_Character
:= Wide_Wide_Character'Val (Character'Pos (CR));
WW_LF: constant Wide_Wide_Character
:= Wide_Wide_Character'Val (Character'Pos (LF));
WWC: Wide_Wide_Character;
C : Character;
-- Seek_Entry_Start --
----------------------
-- Attempts to seek to the first digit of the initial codepoint of the
-- next entry. If successful, C contains the first hex digit of the
-- entry, otherwise Bad_Data is raised.
procedure Seek_Entry_Start with Inline is
begin
-- We should be positioned at the start of a line.
-- The first thing we want to find is the value of the first
-- codepoint of a poential range. We expect to find spaces,
-- '#' or a hexidecimal digit, anything else and we bail.
-- if it's a '#', we then look for a single LF character before
-- trying again (on the next line).
loop
begin
C := Next_Character;
exception
-- Check for an end of file condition - this can happen when
-- the very last lines are comments. If we have an end error
-- here, we'll just propegate it
when IO_Exceptions.End_Error => raise;
-- Otherwise, it's probably a wide-wide character or bad utf-8,
-- either case, this shouldn't happen. yet
when e: others =>
raise Bad_Data with
"Exception while looking for codepoint range: " &
Ada.Exceptions.Exception_Information (e);
end;
exit when C in Hex.Hex_Character;
case C is
when '#' =>
-- Comment. Comments can be any UTF-8 character,
-- and we should discard those until we find a
-- single Line-feed or a Carriage-return followed
-- by a line-feed (why not, we'll place nice)
begin
loop
WWC := Next_Character;
exit when WWC = WW_LF;
if WWC = WW_CR then
WWC := Next_Character;
if WWC /= WW_LF then
raise Bad_Data with
"CR not followed by LF.";
end if;
end if;
end loop;
exception
when Bad_Data => raise;
when e: others =>
raise Bad_Data with
"Exception while looking for end of comment - " &
"where comment is before the first entry " &
" of the file: " &
Ada.Exceptions.Exception_Information (e);
end;
-- Leading whitespace is ignored
when CR =>
C := Next_Character;
if C /= LF then
raise Bad_Data with "CR not followed by LF.";
end if;
when LF | ' ' =>
-- This is fine, skip
null;
when others =>
-- We already left the loop if it was a valid hexadecimal
-- digit, so this must be something else entirely.
-- a ';' would definately be illegal since we really need to
-- know at least the first codepoint!
raise Bad_Data with
"Unexpected '" & C
& "' while looking for first codepoint.";
end case;
end loop;
exception
when Bad_Data | IO_Exceptions.End_Error => raise;
when e: others =>
raise Bad_Data with "Unexpected exception while seeking "
& "first codepoint: "
& Ada.Exceptions.Exception_Information (e);
end Seek_Entry_Start;
-- Parse_Codepoints --
----------------------
-- Following a call to Seek_Entry_Start, C is expected to cointain
-- a single Hex digit. This procedure attempts to parse the codepoint
-- range or singleton
procedure Parse_Codepoints (First, Last: out Wide_Wide_Character)
with Inline
is
use Hex.Unsigned_24;
Codepoint_Hex: String (1 .. 6);
Last_Digit: Natural;
Is_Range : Boolean;
procedure Load_Codepoint_String with Inline is
begin
-- First (most significant) digit is loaded "manually",
-- we are here to fill-out the rest
Is_Range := False;
for I in 2 .. Codepoint_Hex'Last + 1 loop
C := Next_Character;
case C is
when Hex.Hex_Character =>
if I > Codepoint_Hex'Last then
raise Bad_Data with
"Codepoint is longer than the allowed maximum";
else
Codepoint_Hex(I) := C;
end if;
when '.' =>
-- Next character *must* be '.' also.
if Next_Character /= Wide_Wide_Character'('.') then
raise Bad_Data
with "First codepoint incorrectly terminated.";
else
-- Nice, we're done with this one, and we have a
-- range!
Last_Digit := I - 1;
Is_Range := True;
exit;
end if;
when ';' =>
-- Singleton value
Last_Digit := I - 1;
exit;
when ' ' =>
-- Shall be a singleton value ("ABCD .. DEF0" is not
-- valid, only "ABCD..DEF0" is legal according to
-- Unicode. So spaces shall only exist when trailing a
-- property - and that means it needs to end with ';'
-- CR/LF is not legal - as the line is not complete
-- (same with comments)
while C = ' ' loop
C := Next_Character;
end loop;
if C /= ';' then
raise Bad_Data with "Invalid termination of first "
& "codepoint.";
end if;
Last_Digit := I - 1;
exit;
when others =>
-- Invalid!
raise Bad_Data with "Invalid character in "
& "first codepoint";
end case;
end loop;
end Load_Codepoint_String;
begin
Codepoint_Hex(1) := C;
Load_Codepoint_String;
-- If we made it here, we should have a proper string to convert
First := Wide_Wide_Character'Val
(Decode (Codepoint_Hex (1 .. Last_Digit)));
-- Next we check if it is a range, in which case we then need to
-- try to get the last character of that range.
if Is_Range then
-- A valid range means that there is no space or LF after the
-- "..", and therefore the next character had better be a
-- hex digit
C := Next_Character;
if C not in Hex.Hex_Character then
raise Bad_Data with "Invalid codepoint range";
end if;
Codepoint_Hex(1) := C;
Load_Codepoint_String;
-- This should not report another range!
if Is_Range then
raise Bad_Data with "Invalid codepoint range";
end if;
Last
:= Wide_Wide_Character'Val
(Decode (Codepoint_Hex (1 .. Last_Digit)));
else
-- Singleton codepoint
Last := First;
end if;
exception
when Bad_Data => raise;
when e: others =>
raise Bad_Data
with "Unexpected exception when parsing codepoint: "
& Ada.Exceptions.Exception_Information (e);
end Parse_Codepoints;
-- Parse_Properties --
----------------------
-- We've consumed the ';' delimiting the beginning of property 1.
-- Parse_Properties then loads each property until the end of the line,
-- except for any final comment
-- 1. Leading spaces (following the last ';') are insignificant
-- 2. Empty properties are signficiant
-- 3. Trailing spaces are insignificant (read: should be trimed)
-- 4. Every property must _begin_ with ';', but can end with either
-- LF (or CRLF), or '#' for a comment.
--
-- WWC will be left containing whichever character ended the sequence,
-- which will always be either LF (WW_LF) or '#'
procedure Parse_Properties (Properties: in out Property_Vector)
with Inline is
procedure Skip_Leading_Spaces with Inline is
begin
loop
WWC := Next_Character;
exit when WWC /= ' ';
end loop;
end Skip_Leading_Spaces;
procedure Load_Property with Inline is
use WWU;
use Ada.Strings;
Chunk: Wide_Wide_String (1 .. 80) := (others => ' ');
Chunk_Last: Natural := Chunk'First - 1;
-- Most properties will fit into a single chunk! This method makes
-- adding each bit to the unbounded string more efficient than if
-- we did it one character at a time!
Property: Unbounded_Wide_Wide_String;
begin
loop
if Chunk_Last = Chunk'Last then
-- Time to purge
Append (Source => Property,
New_Item => Chunk);
Chunk_Last := Chunk'First - 1;
end if;
case WWC is
when ';' | '#' | WW_LF =>
-- End of the road
exit;
when WW_CR =>
WWC := Next_Character;
if WWC /= WW_LF then
raise Bad_Data with "CR not followed with LF";
end if;
exit;
when others =>
Chunk_Last := Chunk_Last + 1;
Chunk(Chunk_Last) := WWC;
end case;
-- Skip_Leading_Spaces would have the first character
-- already loaded
WWC := Next_Character;
end loop;
-- Last purge
if Chunk_Last >= Chunk'First then
Append (Source => Property,
New_Item => Chunk(Chunk'First .. Chunk_Last));
end if;
-- Trim trailing spaces
Trim (Source => Property,
Side => Right);
-- Slap it on the end of the vector
Properties.Append (Property);
end Load_Property;
begin
loop
Skip_Leading_Spaces;
Load_Property;
exit when WWC /= ';';
end loop;
exception
when e: others =>
raise Bad_Data with "Properties malformed: " &
Ada.Exceptions.Exception_Information (e);
end Parse_Properties;
-- Load_Comment --
------------------
-- To be called only after reaching '#'. Loads everything following up
-- until LF or CRLF.
function Load_Comment return Unbounded_Wide_Wide_String
with Inline is
use WWU;
Chunk: Wide_Wide_String (1 .. 80) := (others => ' ');
Chunk_Last: Natural := Chunk'First - 1;
begin
return Comment: Unbounded_Wide_Wide_String do
loop
if Chunk_Last = Chunk'Last then
-- purge
Append (Source => Comment,
New_Item => Chunk);
Chunk_Last := Chunk'First - 1;
end if;
WWC := Next_Character;
exit when WWC in WW_CR | WW_LF;
Chunk_Last := Chunk_Last + 1;
Chunk(Chunk_Last) := WWC;
end loop;
if WWC = WW_CR then
WWC := Next_Character;
if WWC /= WW_LF then
raise Bad_Data with "CR not followed with LF";
end if;
end if;
-- Load last chunk
if Chunk_Last >= Chunk'First then
Append (Source => Comment,
New_Item => Chunk(Chunk'First .. Chunk_Last));
end if;
end return;
end Load_Comment;
-- Next_Entry Body ---------------------------------------------------------
begin
return E: UCD_Entry do
-- Initial conditions - reserving some space in the vector
-- prevents undue memory copying every time the vector is
-- expanded (as can be expected in some implementations)
E.Properties.Reserve_Capacity (20);
Seek_Entry_Start;
Parse_Codepoints (E.First, E.Last);
Parse_Properties (E.Properties);
-- WWC should now have either LF or '#'
case WWC is
when '#' =>
-- We also have a comment to load!
E.Comment := Load_Comment;
when WW_LF =>
-- That's it
null;
when others =>
raise Program_Error with
"Parse_Properties failed inappropriately.";
end case;
end return;
end Next_Entry;
end Unicode.UCD;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.