content stringlengths 23 1.05M |
|---|
-- This package has been generated automatically by GNATtest.
-- Do not edit any part of it, see GNATtest documentation for more details.
-- begin read only
with GNATtest_Generated;
package Tk.Labelframe.Label_Frame_Create_Options_Test_Data
.Label_Frame_Create_Options_Tests
is
type Test_Label_Frame_Create_Options is new GNATtest_Generated
.GNATtest_Standard
.Tk
.Labelframe
.Label_Frame_Create_Options_Test_Data
.Test_Label_Frame_Create_Options with
null record;
procedure Test_Create_32e405_0563f1
(Gnattest_T: in out Test_Label_Frame_Create_Options);
-- tk-labelframe.ads:138:4:Create:Test_Create_Label_Frame1
procedure Test_Create_ebbdc1_776696
(Gnattest_T: in out Test_Label_Frame_Create_Options);
-- tk-labelframe.ads:172:4:Create:Test_Create_Label_Frame2
procedure Test_Get_Options_ded36e_6d2dd5
(Gnattest_T: in out Test_Label_Frame_Create_Options);
-- tk-labelframe.ads:196:4:Get_Options:Test_Get_Options_Label_Frame
end Tk.Labelframe.Label_Frame_Create_Options_Test_Data
.Label_Frame_Create_Options_Tests;
-- end read only
|
pragma License (Unrestricted);
-- implementation unit
package System.Long_Long_Integer_Types is
pragma Pure;
-- Word size types
type Word_Integer is range
-(2 ** (Standard'Word_Size - 1)) .. 2 ** (Standard'Word_Size - 1) - 1;
for Word_Integer'Size use Standard'Word_Size;
subtype Word_Natural is Word_Integer range 0 .. Word_Integer'Last;
subtype Word_Positive is Word_Integer range 1 .. Word_Integer'Last;
type Word_Unsigned is mod 2 ** Standard'Word_Size;
for Word_Unsigned'Size use Standard'Word_Size;
pragma Provide_Shift_Operators (Word_Unsigned);
-- Largest types
pragma Compile_Time_Error (
Max_Binary_Modulus /= 2 ** Long_Long_Integer'Size,
"Long_Long_Integer is not largest type.");
type Long_Long_Unsigned is mod 2 ** Long_Long_Integer'Size;
for Long_Long_Unsigned'Size use Long_Long_Integer'Size;
pragma Provide_Shift_Operators (Long_Long_Unsigned);
procedure Divide (
Left, Right : Long_Long_Unsigned;
Quotient, Remainder : out Long_Long_Unsigned);
pragma Inline (Divide);
end System.Long_Long_Integer_Types;
|
--
-- Copyright (C) 2021 Jeremy Grosser <jeremy@synack.me>
--
-- SPDX-License-Identifier: BSD-3-Clause
--
package Str is
pragma Pure;
function Find
(S : String;
C : Character)
return Natural;
function Contains
(Haystack, Needle : String)
return Boolean;
function Find_Number
(S : String)
return Natural;
function To_Natural
(S : String;
Base : Positive := 10)
return Natural;
function Split
(S : String;
Delimiter : Character;
Skip : Natural)
return String;
function Strip
(S : String;
C : Character)
return String;
function Strip_Leading
(S : String;
C : Character)
return String;
function Trim
(S : String;
Chars : String)
return String;
function Starts_With
(S : String;
Prefix : String)
return Boolean;
end Str;
|
with Interfaces.C;
with System;
package OpenAL.Types is
package C renames Interfaces.C;
-- ALfloat
type Float_t is new C.C_float;
-- ALdouble
type Double_t is new C.double;
-- ALsizeiptr
type Size_Pointer_t is mod 2 ** System.Word_Size;
for Size_Pointer_t'Size use System.Word_Size;
pragma Convention (C, Size_Pointer_t);
-- ALintptr
type Integer_Pointer_t is mod 2 ** System.Word_Size;
for Integer_Pointer_t'Size use System.Word_Size;
pragma Convention (C, Integer_Pointer_t);
-- ALbitfield
type Bitfield_t is mod 2 ** 32;
for Bitfield_t'Size use 32;
pragma Convention (C, Bitfield_t);
-- ALboolean
type Boolean_t is new Boolean;
for Boolean_t'Size use 8;
pragma Convention (C, Boolean_t);
-- ALbyte
type Byte_t is range -127 .. 127;
for Byte_t'Size use 8;
pragma Convention (C, Byte_t);
-- ALclampd
subtype Clamped_Double_t is Double_t range 0.0 .. 1.0;
-- ALclampf
subtype Clamped_Float_t is Float_t range 0.0 .. 1.0;
-- ALenum
type Enumeration_t is mod 2 ** 32;
for Enumeration_t'Size use 32;
pragma Convention (C, Enumeration_t);
-- ALint
type Integer_t is range -2147483647 .. 2147483647;
for Integer_t'Size use 32;
pragma Convention (C, Integer_t);
-- ALshort
type Short_t is range -32767 .. 32767;
for Short_t'Size use 16;
pragma Convention (C, Short_t);
-- ALsizei
type Size_t is range -2147483647 .. 2147483647;
for Size_t'Size use 32;
pragma Convention (C, Size_t);
-- ALubyte
type Unsigned_Byte_t is mod 2 ** 8;
for Unsigned_Byte_t'Size use 8;
pragma Convention (C, Unsigned_Byte_t);
-- ALuint
type Unsigned_Integer_t is mod 2 ** 32;
for Unsigned_Integer_t'Size use 32;
pragma Convention (C, Unsigned_Integer_t);
-- ALushort
type Unsigned_Short_t is mod 2 ** 16;
for Unsigned_Short_t'Size use 16;
pragma Convention (C, Unsigned_Short_t);
-- ALvoid *
subtype Void_Pointer_t is System.Address;
-- ALvoid **
type Void_Pointer_Access_t is access all Void_Pointer_t;
pragma Convention (C, Void_Pointer_Access_t);
-- const ALvoid **
type Void_Pointer_Access_Constant_t is access constant System.Address;
pragma Convention (C, Void_Pointer_Access_Constant_t);
type String_t is new System.Address;
subtype Natural_Float_t is Float_t range 0.0 .. Float_t'Last;
subtype Positive_Float_t is Float_t range 1.0 .. Float_t'Last;
type Vector_i_t is array (Positive range <>) of aliased Integer_t;
type Vector_2i_t is new Vector_i_t (1 .. 2);
type Vector_3i_t is new Vector_i_t (1 .. 3);
type Vector_4i_t is new Vector_i_t (1 .. 4);
type Vector_f_t is array (Positive range <>) of aliased Float_t;
type Vector_2f_t is new Vector_f_t (1 .. 2);
type Vector_3f_t is new Vector_f_t (1 .. 3);
type Vector_4f_t is new Vector_f_t (1 .. 4);
--
-- Frequency in hz.
--
type Frequency_t is new Size_t range 1 .. Size_t'Last;
end OpenAL.Types;
|
pragma Ada_2012;
-- with Readable_Sequences.String_Sequences;
-- use Readable_Sequences.String_Sequences;
-- with Protypo.Scanning;
-- with Protypo.Parsing;
-- with Protypo.Code_Trees.Interpreter.Expressions;
pragma Warnings (Off, "no entities of ""Ada.Text_IO"" are referenced");
with Ada.Text_IO; use Ada.Text_IO;
-- with Protypo.Api.Interpreters;
package body Protypo.Code_Trees.Interpreter.Consumer_Handlers is
function To_String (X : Engine_Value) return String
is (case X.Class is
when Int => Get_Integer (X)'Image,
when Real => Get_Float (X)'Image,
when Text => Get_String (X),
when others => raise Constraint_Error);
overriding function Process (Fun : Consumer_Callback;
Parameter : Engine_Value_vectors.Vector)
return Engine_Value_vectors.Vector
is
begin
for P of Parameter loop
declare
To_Be_Consumed : constant String :=
(if Fun.With_Escape
then
Do_Escape (Fun.Status, To_String (P))
else
To_String (P));
begin
Fun.Consumer.Process (To_Be_Consumed & To_String (Fun.End_Of_Line));
end;
end loop;
return Engine_Value_Vectors.Empty_Vector;
end Process;
function Signature (Fun : Consumer_Callback)
return Api.Engine_Values.Parameter_Lists.Parameter_Signature
is (1 => Parameter_Lists.Mandatory);
end Protypo.Code_Trees.Interpreter.Consumer_Handlers;
|
-- { dg-do compile }
package body Ancestor_Type is
package body B is
function make return T is
begin
return (T with n => 0); -- { dg-error "expect ancestor" }
end make;
end B;
end Ancestor_Type;
|
package openGL.Model.box
--
-- Provides an abstract model of a box.
--
is
type Item is abstract new openGL.Model.item with private;
type Side is (Front, Rear,
Upper, Lower,
Left, Right);
function Size (Self : in Item) return Vector_3;
private
type Item is abstract new openGL.Model.item with
record
Size : Vector_3;
end record;
type site_Id is ( Left_Lower_Front, Right_Lower_Front,
Right_Upper_Front, Left_Upper_Front,
Right_Lower_Rear, Left_Lower_Rear,
Left_Upper_Rear, Right_Upper_Rear);
type Sites is array (site_Id) of Vector_3;
front_Normal : constant Vector_3 := ( 0.0, 0.0, 1.0);
rear_Normal : constant Vector_3 := ( 0.0, 0.0, -1.0);
upper_Normal : constant Vector_3 := ( 0.0, 1.0, 0.0);
lower_Normal : constant Vector_3 := ( 0.0, -1.0, 0.0);
left_Normal : constant Vector_3 := (-1.0, 0.0, 0.0);
right_Normal : constant Vector_3 := ( 1.0, 0.0, 0.0);
function vertex_Sites (Self : in Item'Class) return Sites;
end openGL.Model.box;
|
-- Collection of square matrices. Most are ill conditioned, singular
-- or badly scaled.
-- Several matrices are from John Burkardt's fortran 90 Test_Mat.
generic
type real is digits <>;
type Index is range <>;
type Matrix is array(Index, Index) of Real;
package Test_Matrices is
-- In notes below, N is the Order of the Matrix.
type Matrix_Id is
(Laguerre, -- eig vec calc fails w/ balancing for lower tri version.
Ding_Dong, -- eigs clustered very near (18+ sig. figs) +/- pi, symmetric
Lesp,
-- Sensitive eigs., tridiag, not symmetric, transpo hard, triggers underflows,
-- Balancing v. bad., hessenberg pivoting solves difficult eigen calc.
Vandermonde, -- non-symmetric
Combin, -- solutions with maximally high error for given condition num?
Kahan,
Kahan_2,
Kahan_Col_Scaled,
Kahan_Row_Scaled,
Sampling, -- ill conditioned eigs, eigs = 0..N-1, ok up to ~ 21x21
Sampling_1, -- well behaved, eigs = 0..N-1
Companion_2, -- Eigs are roots of companion polynomial.
Companion_1, -- Badly scaled, difficult eigs, balancing essential for eigs.
Companion_0, -- Balancing important.
Companion, -- Eigs are roots of companion polynomial
Lower_Integers, -- almost triangular, eigs = 1, 2, 3 ...
Pas_Fib, -- ill-cond N > 9; rescaled if big
Pascal_Symmetric,
Pascal,
-- ill-cond N > 9; sing. vals ~ x, 1/x, all>0, rescaled if big, balancing bad
-- if lower triangular
Pascal_Row_Scaled,
Pascal_Col_Scaled,
Frank_0, -- upper Hess, ill cond eigs, eig prod = 1, balance bad, 17x17max
Frank_1, -- upper Hess, ill cond eigs, eig prod = N, balance bad
Frank_2, -- symmetric, easy, product of eigs = 1
Fiedler_0, -- symm, non singular
Fiedler_1, -- non symm, poor-cond eigs
Fibonacci, -- non symm, non singular, tri diag, max defective
Wilkinson_Minus, -- symm. W- only if odd N: then just one 0.0 eigval
Hilbert, -- exactly represented in 15 digit Real only up to ~ 20x20
Lotkin, -- like Hilbert, but not symmetric
Clustered, -- eigs clustered, poorly scaled
Zielke_0, -- symmetric, clustered eigs, ill conditioned
Zielke_1, -- symmetric, clustered eigs, singular
Zielke_2, -- symmetric, clustered eigs, singular
Gear_0, -- non symm, non singular, one small sing val
Gear_1, -- non symm, singular
Diag_Test, -- one small singular val.
Moler, -- 1 small eig, prod. of eigs = 1, eig sum = N(N+1)/2
Peters, -- 1 small eig, like Givens_Moler, lower triangular
Peters_0, -- 1 small eig, like Givens_Moler, upper triangular
Peters_1, -- ok w. row pivoting, LU
Peters_2, -- bad w/ row pivoting, LU
Gregory, -- symmetric, all but 2 of the eigs = 1.
Anti_Hadamard_Upper_Tri, -- 1 small sing.val, non singular
Anti_Hadamard_Lower_Tri, -- 1 small sing.val, non singular
Wilkinson_Plus, -- strictly it's W+ only for odd N.
Wilkinson_Plus_2I,
U_Hard, -- slow convergence on Golub SVD, all 1's but 1st col=0
Zero_Cols_and_Rows, -- 1st 3 rows and cols all 0; else it's 1.
Easy_Matrix,
Symmetric_Banded, -- not diagonally dominant, moderately ill-conditioned
Small_Diagonal, -- but not symmetric
Trench,
Trench_1,
Forsythe_0, -- eigs on circle of radius 1, center=A=0.
Forsythe_1, -- eigs on circle of radius 1, center=A=1.
Forsythe_Symmetric,
Zero_Diagonal, -- if odd then N singular, eg N X N = 13x13
QR_Test, -- 4x4 hard on QR
Ring_Adjacency_0, -- Symm.
Ring_Adjacency_1, -- Non-Symm.
Upper_Tri_K,
Lower_Tri_K, -- lower tri, non-singular, v high condition num
Upper_Ones, -- triangular
Lower_Ones, -- triangular
All_Ones,
Redheff, -- sensitive eigs, hard tst - slow convergence on Peters_Eigen.
Chow, -- ill-conditioned eigs, N / 2 eigs = 0, balancing bad, lower hess.
Chow1, -- chow w/ alpha=-1.05
Chow2, -- chow w/ alpha=gamma
Chow3, -- non-sym, full
Lehmer, -- easy
Random_1_bit_anti, -- anti-sym, singular, on [0,1] new seed each run, hard tst
Random_1_bit, -- new seed each run.
Random_32_bit, -- on [0,1), new seed each run.
All_Zeros);
procedure Init_Matrix
(M : out Matrix;
Desired_Matrix : in Matrix_Id := Easy_Matrix;
Starting_Index : in Index := Index'First;
Max_Index : in Index := Index'Last);
-- Can optionally add constant Matrix_Addend to some of the Matrices.
-- Increases the variety of tests, and usually makes them harder to
-- decompose. The matrices are:
--
-- Anti_Hadamard_Lower_Tri, Anti_Hadamard_Upper_Tri, Lower_Tri_K, Upper_Tri_K
-- Pascal_Col_Scaled, Pascal_Row_Scaled, Pascal
-- Lower_Ones, Upper_Ones, Lower_Integers
-- Frank_0, Frank_1, Fibonacci, Peters, Peters_0
-- Kahan_Row_Scaled, Kahan_Col_Scaled, Kahan_Col_Scaled_2, Kahan
--Matrix_Addend : constant Real := +1.0e-5;
Matrix_Addend : constant Real := +0.0;
procedure Transpose
(A : in out Matrix;
Starting_Index : in Index := Index'First;
Max_Index : in Index := Index'Last);
procedure Symmetrize
(A : in out Matrix);
end Test_Matrices;
|
-- Demonstration of the extended units: Ada.Fixed
with Ada.Float;
procedure floats is
subtype T is Long_Long_Float;
begin
declare -- Infinity and Is_Infinity
function Infinity is new Ada.Float.Infinity (T);
function Is_Infinity is new Ada.Float.Is_Infinity (T);
begin
pragma Assert (T'Image (Infinity) = " INF");
pragma Assert (T'Image (-Infinity) = "-INF");
pragma Assert (Is_Infinity (Infinity));
null;
end;
declare -- NaN and Is_NaN
function NaN is new Ada.Float.NaN (T);
function Is_NaN is new Ada.Float.Is_NaN (T);
begin
pragma Assert (T'Image (NaN) = " NAN");
pragma Assert (T'Image (-NaN) = "-NAN");
pragma Assert (not (-NaN < 0.0)); -- comparison of NaN is always False
pragma Assert (Is_NaN (NaN));
null;
end;
declare -- Is_Negative
function Is_Negative is new Ada.Float.Is_Negative (T);
begin
pragma Assert (Is_Negative (-1.0));
pragma Assert (not Is_Negative (0.0));
pragma Assert (not Is_Negative (+1.0));
null;
end;
declare -- Divide
procedure Divide is new Ada.Float.Divide (T, T, T, T);
Q, R : T;
begin
Divide (4.5, 2.0, Q, R);
pragma Assert (Q = 2.0 and then R = 0.5);
Divide (5.0, 0.5, Q, R);
pragma Assert (Q = 10.0 and then R = 0.0);
Divide (0.9, 1.0, Q, R);
pragma Assert (Q = 0.0 and then R = 0.9);
Divide (-0.9, 1.0, Q, R);
pragma Assert (Q = 0.0 and then R = -0.9);
end;
pragma Debug (Ada.Debug.Put ("OK"));
end floats;
|
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.FDCAN is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CREL_DAY_Field is HAL.UInt8;
subtype CREL_MON_Field is HAL.UInt8;
subtype CREL_YEAR_Field is HAL.UInt4;
subtype CREL_SUBSTEP_Field is HAL.UInt4;
subtype CREL_STEP_Field is HAL.UInt4;
subtype CREL_REL_Field is HAL.UInt4;
-- Clock Calibration Unit Core Release Register
type CREL_Register is record
-- Time Stamp Day
DAY : CREL_DAY_Field := 16#0#;
-- Time Stamp Month
MON : CREL_MON_Field := 16#0#;
-- Time Stamp Year
YEAR : CREL_YEAR_Field := 16#0#;
-- Sub-step of Core Release
SUBSTEP : CREL_SUBSTEP_Field := 16#0#;
-- Step of Core Release
STEP : CREL_STEP_Field := 16#0#;
-- Core Release
REL : CREL_REL_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CREL_Register use record
DAY at 0 range 0 .. 7;
MON at 0 range 8 .. 15;
YEAR at 0 range 16 .. 19;
SUBSTEP at 0 range 20 .. 23;
STEP at 0 range 24 .. 27;
REL at 0 range 28 .. 31;
end record;
subtype CCFG_TQBT_Field is HAL.UInt5;
subtype CCFG_OCPM_Field is HAL.UInt8;
subtype CCFG_CDIV_Field is HAL.UInt4;
-- Calibration Configuration Register
type CCFG_Register is record
-- Time Quanta per Bit Time
TQBT : CCFG_TQBT_Field := 16#0#;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- Bypass Clock Calibration
BCC : Boolean := False;
-- Calibration Field Length
CFL : Boolean := False;
-- Oscillator Clock Periods Minimum
OCPM : CCFG_OCPM_Field := 16#0#;
-- Clock Divider
CDIV : CCFG_CDIV_Field := 16#0#;
-- unspecified
Reserved_20_30 : HAL.UInt11 := 16#0#;
-- Software Reset
SWR : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CCFG_Register use record
TQBT at 0 range 0 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
BCC at 0 range 6 .. 6;
CFL at 0 range 7 .. 7;
OCPM at 0 range 8 .. 15;
CDIV at 0 range 16 .. 19;
Reserved_20_30 at 0 range 20 .. 30;
SWR at 0 range 31 .. 31;
end record;
subtype CSTAT_OCPC_Field is HAL.UInt18;
subtype CSTAT_TQC_Field is HAL.UInt11;
subtype CSTAT_CALS_Field is HAL.UInt2;
-- Calibration Status Register
type CSTAT_Register is record
-- Oscillator Clock Period Counter
OCPC : CSTAT_OCPC_Field := 16#0#;
-- Time Quanta Counter
TQC : CSTAT_TQC_Field := 16#0#;
-- unspecified
Reserved_29_29 : HAL.Bit := 16#0#;
-- Calibration State
CALS : CSTAT_CALS_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CSTAT_Register use record
OCPC at 0 range 0 .. 17;
TQC at 0 range 18 .. 28;
Reserved_29_29 at 0 range 29 .. 29;
CALS at 0 range 30 .. 31;
end record;
subtype CWD_WDC_Field is HAL.UInt16;
subtype CWD_WDV_Field is HAL.UInt16;
-- Calibration Watchdog Register
type CWD_Register is record
-- WDC
WDC : CWD_WDC_Field := 16#0#;
-- WDV
WDV : CWD_WDV_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CWD_Register use record
WDC at 0 range 0 .. 15;
WDV at 0 range 16 .. 31;
end record;
-- Clock Calibration Unit Interrupt Register
type IR_Register is record
-- Calibration Watchdog Event
CWE : Boolean := False;
-- Calibration State Changed
CSC : Boolean := False;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for IR_Register use record
CWE at 0 range 0 .. 0;
CSC at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- Clock Calibration Unit Interrupt Enable Register
type IE_Register is record
-- Calibration Watchdog Event Enable
CWEE : Boolean := False;
-- Calibration State Changed Enable
CSCE : Boolean := False;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for IE_Register use record
CWEE at 0 range 0 .. 0;
CSCE at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
subtype FDCAN_CREL_DAY_Field is HAL.UInt8;
subtype FDCAN_CREL_MON_Field is HAL.UInt8;
subtype FDCAN_CREL_YEAR_Field is HAL.UInt4;
subtype FDCAN_CREL_SUBSTEP_Field is HAL.UInt4;
subtype FDCAN_CREL_STEP_Field is HAL.UInt4;
subtype FDCAN_CREL_REL_Field is HAL.UInt4;
-- FDCAN Core Release Register
type FDCAN_CREL_Register is record
-- Read-only. Timestamp Day
DAY : FDCAN_CREL_DAY_Field;
-- Read-only. Timestamp Month
MON : FDCAN_CREL_MON_Field;
-- Read-only. Timestamp Year
YEAR : FDCAN_CREL_YEAR_Field;
-- Read-only. Sub-step of Core release
SUBSTEP : FDCAN_CREL_SUBSTEP_Field;
-- Read-only. Step of Core release
STEP : FDCAN_CREL_STEP_Field;
-- Read-only. Core release
REL : FDCAN_CREL_REL_Field;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_CREL_Register use record
DAY at 0 range 0 .. 7;
MON at 0 range 8 .. 15;
YEAR at 0 range 16 .. 19;
SUBSTEP at 0 range 20 .. 23;
STEP at 0 range 24 .. 27;
REL at 0 range 28 .. 31;
end record;
subtype FDCAN_DBTP_DSJW_Field is HAL.UInt4;
subtype FDCAN_DBTP_DTSEG2_Field is HAL.UInt4;
subtype FDCAN_DBTP_DTSEG1_Field is HAL.UInt5;
subtype FDCAN_DBTP_DBRP_Field is HAL.UInt5;
-- FDCAN Data Bit Timing and Prescaler Register
type FDCAN_DBTP_Register is record
-- Read-only. Synchronization Jump Width
DSJW : FDCAN_DBTP_DSJW_Field;
-- Read-only. Data time segment after sample point
DTSEG2 : FDCAN_DBTP_DTSEG2_Field;
-- Read-only. Data time segment after sample point
DTSEG1 : FDCAN_DBTP_DTSEG1_Field;
-- unspecified
Reserved_13_15 : HAL.UInt3;
-- Read-only. Data BIt Rate Prescaler
DBRP : FDCAN_DBTP_DBRP_Field;
-- unspecified
Reserved_21_22 : HAL.UInt2;
-- Read-only. Transceiver Delay Compensation
TDC : Boolean;
-- unspecified
Reserved_24_31 : HAL.UInt8;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_DBTP_Register use record
DSJW at 0 range 0 .. 3;
DTSEG2 at 0 range 4 .. 7;
DTSEG1 at 0 range 8 .. 12;
Reserved_13_15 at 0 range 13 .. 15;
DBRP at 0 range 16 .. 20;
Reserved_21_22 at 0 range 21 .. 22;
TDC at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype FDCAN_TEST_TX_Field is HAL.UInt2;
-- FDCAN Test Register
type FDCAN_TEST_Register is record
-- unspecified
Reserved_0_3 : HAL.UInt4;
-- Read-only. Loop Back mode
LBCK : Boolean;
-- Read-only. Loop Back mode
TX : FDCAN_TEST_TX_Field;
-- Read-only. Control of Transmit Pin
RX : Boolean;
-- unspecified
Reserved_8_31 : HAL.UInt24;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TEST_Register use record
Reserved_0_3 at 0 range 0 .. 3;
LBCK at 0 range 4 .. 4;
TX at 0 range 5 .. 6;
RX at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype FDCAN_RWD_WDC_Field is HAL.UInt8;
subtype FDCAN_RWD_WDV_Field is HAL.UInt8;
-- FDCAN RAM Watchdog Register
type FDCAN_RWD_Register is record
-- Read-only. Watchdog configuration
WDC : FDCAN_RWD_WDC_Field;
-- Read-only. Watchdog value
WDV : FDCAN_RWD_WDV_Field;
-- unspecified
Reserved_16_31 : HAL.UInt16;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_RWD_Register use record
WDC at 0 range 0 .. 7;
WDV at 0 range 8 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- FDCAN CC Control Register
type FDCAN_CCCR_Register is record
-- Initialization
INIT : Boolean := False;
-- Configuration Change Enable
CCE : Boolean := False;
-- ASM Restricted Operation Mode
ASM : Boolean := False;
-- Clock Stop Acknowledge
CSA : Boolean := False;
-- Clock Stop Request
CSR : Boolean := False;
-- Bus Monitoring Mode
MON : Boolean := False;
-- Disable Automatic Retransmission
DAR : Boolean := False;
-- Test Mode Enable
TEST : Boolean := False;
-- FD Operation Enable
FDOE : Boolean := False;
-- FDCAN Bit Rate Switching
BSE : Boolean := False;
-- unspecified
Reserved_10_11 : HAL.UInt2 := 16#0#;
-- Protocol Exception Handling Disable
PXHD : Boolean := False;
-- Edge Filtering during Bus Integration
EFBI : Boolean := False;
-- TXP
TXP : Boolean := False;
-- Non ISO Operation
NISO : Boolean := False;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_CCCR_Register use record
INIT at 0 range 0 .. 0;
CCE at 0 range 1 .. 1;
ASM at 0 range 2 .. 2;
CSA at 0 range 3 .. 3;
CSR at 0 range 4 .. 4;
MON at 0 range 5 .. 5;
DAR at 0 range 6 .. 6;
TEST at 0 range 7 .. 7;
FDOE at 0 range 8 .. 8;
BSE at 0 range 9 .. 9;
Reserved_10_11 at 0 range 10 .. 11;
PXHD at 0 range 12 .. 12;
EFBI at 0 range 13 .. 13;
TXP at 0 range 14 .. 14;
NISO at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype FDCAN_NBTP_TSEG2_Field is HAL.UInt7;
subtype FDCAN_NBTP_NTSEG1_Field is HAL.UInt8;
subtype FDCAN_NBTP_NBRP_Field is HAL.UInt9;
subtype FDCAN_NBTP_NSJW_Field is HAL.UInt7;
-- FDCAN Nominal Bit Timing and Prescaler Register
type FDCAN_NBTP_Register is record
-- Nominal Time segment after sample point
TSEG2 : FDCAN_NBTP_TSEG2_Field := 16#0#;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- Nominal Time segment before sample point
NTSEG1 : FDCAN_NBTP_NTSEG1_Field := 16#0#;
-- Bit Rate Prescaler
NBRP : FDCAN_NBTP_NBRP_Field := 16#0#;
-- NSJW: Nominal (Re)Synchronization Jump Width
NSJW : FDCAN_NBTP_NSJW_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_NBTP_Register use record
TSEG2 at 0 range 0 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
NTSEG1 at 0 range 8 .. 15;
NBRP at 0 range 16 .. 24;
NSJW at 0 range 25 .. 31;
end record;
subtype FDCAN_TSCC_TSS_Field is HAL.UInt2;
subtype FDCAN_TSCC_TCP_Field is HAL.UInt4;
-- FDCAN Timestamp Counter Configuration Register
type FDCAN_TSCC_Register is record
-- Timestamp Select
TSS : FDCAN_TSCC_TSS_Field := 16#0#;
-- unspecified
Reserved_2_15 : HAL.UInt14 := 16#0#;
-- Timestamp Counter Prescaler
TCP : FDCAN_TSCC_TCP_Field := 16#0#;
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TSCC_Register use record
TSS at 0 range 0 .. 1;
Reserved_2_15 at 0 range 2 .. 15;
TCP at 0 range 16 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
subtype FDCAN_TSCV_TSC_Field is HAL.UInt16;
-- FDCAN Timestamp Counter Value Register
type FDCAN_TSCV_Register is record
-- Timestamp Counter
TSC : FDCAN_TSCV_TSC_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TSCV_Register use record
TSC at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype FDCAN_TOCC_TOS_Field is HAL.UInt2;
subtype FDCAN_TOCC_TOP_Field is HAL.UInt16;
-- FDCAN Timeout Counter Configuration Register
type FDCAN_TOCC_Register is record
-- Enable Timeout Counter
ETOC : Boolean := False;
-- Timeout Select
TOS : FDCAN_TOCC_TOS_Field := 16#0#;
-- unspecified
Reserved_3_15 : HAL.UInt13 := 16#0#;
-- Timeout Period
TOP : FDCAN_TOCC_TOP_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TOCC_Register use record
ETOC at 0 range 0 .. 0;
TOS at 0 range 1 .. 2;
Reserved_3_15 at 0 range 3 .. 15;
TOP at 0 range 16 .. 31;
end record;
subtype FDCAN_TOCV_TOC_Field is HAL.UInt16;
-- FDCAN Timeout Counter Value Register
type FDCAN_TOCV_Register is record
-- Timeout Counter
TOC : FDCAN_TOCV_TOC_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TOCV_Register use record
TOC at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype FDCAN_ECR_TEC_Field is HAL.UInt8;
subtype FDCAN_ECR_TREC_Field is HAL.UInt7;
subtype FDCAN_ECR_CEL_Field is HAL.UInt8;
-- FDCAN Error Counter Register
type FDCAN_ECR_Register is record
-- Transmit Error Counter
TEC : FDCAN_ECR_TEC_Field := 16#0#;
-- Receive Error Counter
TREC : FDCAN_ECR_TREC_Field := 16#0#;
-- Receive Error Passive
RP : Boolean := False;
-- AN Error Logging
CEL : FDCAN_ECR_CEL_Field := 16#0#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_ECR_Register use record
TEC at 0 range 0 .. 7;
TREC at 0 range 8 .. 14;
RP at 0 range 15 .. 15;
CEL at 0 range 16 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype FDCAN_PSR_LEC_Field is HAL.UInt3;
subtype FDCAN_PSR_ACT_Field is HAL.UInt2;
subtype FDCAN_PSR_DLEC_Field is HAL.UInt3;
subtype FDCAN_PSR_TDCV_Field is HAL.UInt7;
-- FDCAN Protocol Status Register
type FDCAN_PSR_Register is record
-- Last Error Code
LEC : FDCAN_PSR_LEC_Field := 16#0#;
-- Activity
ACT : FDCAN_PSR_ACT_Field := 16#0#;
-- Error Passive
EP : Boolean := False;
-- Warning Status
EW : Boolean := False;
-- Bus_Off Status
BO : Boolean := False;
-- Data Last Error Code
DLEC : FDCAN_PSR_DLEC_Field := 16#0#;
-- ESI flag of last received FDCAN Message
RESI : Boolean := False;
-- BRS flag of last received FDCAN Message
RBRS : Boolean := False;
-- Received FDCAN Message
REDL : Boolean := False;
-- Protocol Exception Event
PXE : Boolean := False;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#0#;
-- Transmitter Delay Compensation Value
TDCV : FDCAN_PSR_TDCV_Field := 16#0#;
-- unspecified
Reserved_23_31 : HAL.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_PSR_Register use record
LEC at 0 range 0 .. 2;
ACT at 0 range 3 .. 4;
EP at 0 range 5 .. 5;
EW at 0 range 6 .. 6;
BO at 0 range 7 .. 7;
DLEC at 0 range 8 .. 10;
RESI at 0 range 11 .. 11;
RBRS at 0 range 12 .. 12;
REDL at 0 range 13 .. 13;
PXE at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
TDCV at 0 range 16 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
subtype FDCAN_TDCR_TDCF_Field is HAL.UInt7;
subtype FDCAN_TDCR_TDCO_Field is HAL.UInt7;
-- FDCAN Transmitter Delay Compensation Register
type FDCAN_TDCR_Register is record
-- Read-only. Transmitter Delay Compensation Filter Window Length
TDCF : FDCAN_TDCR_TDCF_Field;
-- unspecified
Reserved_7_7 : HAL.Bit;
-- Read-only. Transmitter Delay Compensation Offset
TDCO : FDCAN_TDCR_TDCO_Field;
-- unspecified
Reserved_15_31 : HAL.UInt17;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TDCR_Register use record
TDCF at 0 range 0 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
TDCO at 0 range 8 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
-- FDCAN Interrupt Register
type FDCAN_IR_Register is record
-- Read-only. Rx FIFO 0 New Message
RF0N : Boolean;
-- Read-only. Rx FIFO 0 Full
RF0W : Boolean;
-- Read-only. Rx FIFO 0 Full
RF0F : Boolean;
-- Read-only. Rx FIFO 0 Message Lost
RF0L : Boolean;
-- Read-only. Rx FIFO 1 New Message
RF1N : Boolean;
-- Read-only. Rx FIFO 1 Watermark Reached
RF1W : Boolean;
-- Read-only. Rx FIFO 1 Watermark Reached
RF1F : Boolean;
-- Read-only. Rx FIFO 1 Message Lost
RF1L : Boolean;
-- Read-only. High Priority Message
HPM : Boolean;
-- Read-only. Transmission Completed
TC : Boolean;
-- Read-only. Transmission Cancellation Finished
TCF : Boolean;
-- Read-only. Tx FIFO Empty
TEF : Boolean;
-- Read-only. Tx Event FIFO New Entry
TEFN : Boolean;
-- Read-only. Tx Event FIFO Watermark Reached
TEFW : Boolean;
-- Read-only. Tx Event FIFO Full
TEFF : Boolean;
-- Read-only. Tx Event FIFO Element Lost
TEFL : Boolean;
-- Read-only. Timestamp Wraparound
TSW : Boolean;
-- Read-only. Message RAM Access Failure
MRAF : Boolean;
-- Read-only. Timeout Occurred
TOO : Boolean;
-- Read-only. Message stored to Dedicated Rx Buffer
DRX : Boolean;
-- unspecified
Reserved_20_21 : HAL.UInt2;
-- Read-only. Error Logging Overflow
ELO : Boolean;
-- Read-only. Error Passive
EP : Boolean;
-- Read-only. Warning Status
EW : Boolean;
-- Read-only. Bus_Off Status
BO : Boolean;
-- Read-only. Watchdog Interrupt
WDI : Boolean;
-- Read-only. Protocol Error in Arbitration Phase (Nominal Bit Time is
-- used)
PEA : Boolean;
-- Read-only. Protocol Error in Data Phase (Data Bit Time is used)
PED : Boolean;
-- Read-only. Access to Reserved Address
ARA : Boolean;
-- unspecified
Reserved_30_31 : HAL.UInt2;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_IR_Register use record
RF0N at 0 range 0 .. 0;
RF0W at 0 range 1 .. 1;
RF0F at 0 range 2 .. 2;
RF0L at 0 range 3 .. 3;
RF1N at 0 range 4 .. 4;
RF1W at 0 range 5 .. 5;
RF1F at 0 range 6 .. 6;
RF1L at 0 range 7 .. 7;
HPM at 0 range 8 .. 8;
TC at 0 range 9 .. 9;
TCF at 0 range 10 .. 10;
TEF at 0 range 11 .. 11;
TEFN at 0 range 12 .. 12;
TEFW at 0 range 13 .. 13;
TEFF at 0 range 14 .. 14;
TEFL at 0 range 15 .. 15;
TSW at 0 range 16 .. 16;
MRAF at 0 range 17 .. 17;
TOO at 0 range 18 .. 18;
DRX at 0 range 19 .. 19;
Reserved_20_21 at 0 range 20 .. 21;
ELO at 0 range 22 .. 22;
EP at 0 range 23 .. 23;
EW at 0 range 24 .. 24;
BO at 0 range 25 .. 25;
WDI at 0 range 26 .. 26;
PEA at 0 range 27 .. 27;
PED at 0 range 28 .. 28;
ARA at 0 range 29 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- FDCAN Interrupt Enable Register
type FDCAN_IE_Register is record
-- Read-only. Rx FIFO 0 New Message Enable
RF0NE : Boolean;
-- Read-only. Rx FIFO 0 Full Enable
RF0WE : Boolean;
-- Read-only. Rx FIFO 0 Full Enable
RF0FE : Boolean;
-- Read-only. Rx FIFO 0 Message Lost Enable
RF0LE : Boolean;
-- Read-only. Rx FIFO 1 New Message Enable
RF1NE : Boolean;
-- Read-only. Rx FIFO 1 Watermark Reached Enable
RF1WE : Boolean;
-- Read-only. Rx FIFO 1 Watermark Reached Enable
RF1FE : Boolean;
-- Read-only. Rx FIFO 1 Message Lost Enable
RF1LE : Boolean;
-- Read-only. High Priority Message Enable
HPME : Boolean;
-- Read-only. Transmission Completed Enable
TCE : Boolean;
-- Read-only. Transmission Cancellation Finished Enable
TCFE : Boolean;
-- Read-only. Tx FIFO Empty Enable
TEFE : Boolean;
-- Read-only. Tx Event FIFO New Entry Enable
TEFNE : Boolean;
-- Read-only. Tx Event FIFO Watermark Reached Enable
TEFWE : Boolean;
-- Read-only. Tx Event FIFO Full Enable
TEFFE : Boolean;
-- Read-only. Tx Event FIFO Element Lost Enable
TEFLE : Boolean;
-- Read-only. Timestamp Wraparound Enable
TSWE : Boolean;
-- Read-only. Message RAM Access Failure Enable
MRAFE : Boolean;
-- Read-only. Timeout Occurred Enable
TOOE : Boolean;
-- Read-only. Message stored to Dedicated Rx Buffer Enable
DRXE : Boolean;
-- Read-only. Bit Error Corrected Interrupt Enable
BECE : Boolean;
-- Read-only. Bit Error Uncorrected Interrupt Enable
BEUE : Boolean;
-- Read-only. Error Logging Overflow Enable
ELOE : Boolean;
-- Read-only. Error Passive Enable
EPE : Boolean;
-- Read-only. Warning Status Enable
EWE : Boolean;
-- Read-only. Bus_Off Status Enable
BOE : Boolean;
-- Read-only. Watchdog Interrupt Enable
WDIE : Boolean;
-- Read-only. Protocol Error in Arbitration Phase Enable
PEAE : Boolean;
-- Read-only. Protocol Error in Data Phase Enable
PEDE : Boolean;
-- Read-only. Access to Reserved Address Enable
ARAE : Boolean;
-- unspecified
Reserved_30_31 : HAL.UInt2;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_IE_Register use record
RF0NE at 0 range 0 .. 0;
RF0WE at 0 range 1 .. 1;
RF0FE at 0 range 2 .. 2;
RF0LE at 0 range 3 .. 3;
RF1NE at 0 range 4 .. 4;
RF1WE at 0 range 5 .. 5;
RF1FE at 0 range 6 .. 6;
RF1LE at 0 range 7 .. 7;
HPME at 0 range 8 .. 8;
TCE at 0 range 9 .. 9;
TCFE at 0 range 10 .. 10;
TEFE at 0 range 11 .. 11;
TEFNE at 0 range 12 .. 12;
TEFWE at 0 range 13 .. 13;
TEFFE at 0 range 14 .. 14;
TEFLE at 0 range 15 .. 15;
TSWE at 0 range 16 .. 16;
MRAFE at 0 range 17 .. 17;
TOOE at 0 range 18 .. 18;
DRXE at 0 range 19 .. 19;
BECE at 0 range 20 .. 20;
BEUE at 0 range 21 .. 21;
ELOE at 0 range 22 .. 22;
EPE at 0 range 23 .. 23;
EWE at 0 range 24 .. 24;
BOE at 0 range 25 .. 25;
WDIE at 0 range 26 .. 26;
PEAE at 0 range 27 .. 27;
PEDE at 0 range 28 .. 28;
ARAE at 0 range 29 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- FDCAN Interrupt Line Select Register
type FDCAN_ILS_Register is record
-- Read-only. Rx FIFO 0 New Message Interrupt Line
RF0NL : Boolean;
-- Read-only. Rx FIFO 0 Watermark Reached Interrupt Line
RF0WL : Boolean;
-- Read-only. Rx FIFO 0 Full Interrupt Line
RF0FL : Boolean;
-- Read-only. Rx FIFO 0 Message Lost Interrupt Line
RF0LL : Boolean;
-- Read-only. Rx FIFO 1 New Message Interrupt Line
RF1NL : Boolean;
-- Read-only. Rx FIFO 1 Watermark Reached Interrupt Line
RF1WL : Boolean;
-- Read-only. Rx FIFO 1 Full Interrupt Line
RF1FL : Boolean;
-- Read-only. Rx FIFO 1 Message Lost Interrupt Line
RF1LL : Boolean;
-- Read-only. High Priority Message Interrupt Line
HPML : Boolean;
-- Read-only. Transmission Completed Interrupt Line
TCL : Boolean;
-- Read-only. Transmission Cancellation Finished Interrupt Line
TCFL : Boolean;
-- Read-only. Tx FIFO Empty Interrupt Line
TEFL : Boolean;
-- Read-only. Tx Event FIFO New Entry Interrupt Line
TEFNL : Boolean;
-- Read-only. Tx Event FIFO Watermark Reached Interrupt Line
TEFWL : Boolean;
-- Read-only. Tx Event FIFO Full Interrupt Line
TEFFL : Boolean;
-- Read-only. Tx Event FIFO Element Lost Interrupt Line
TEFLL : Boolean;
-- Read-only. Timestamp Wraparound Interrupt Line
TSWL : Boolean;
-- Read-only. Message RAM Access Failure Interrupt Line
MRAFL : Boolean;
-- Read-only. Timeout Occurred Interrupt Line
TOOL : Boolean;
-- Read-only. Message stored to Dedicated Rx Buffer Interrupt Line
DRXL : Boolean;
-- Read-only. Bit Error Corrected Interrupt Line
BECL : Boolean;
-- Read-only. Bit Error Uncorrected Interrupt Line
BEUL : Boolean;
-- Read-only. Error Logging Overflow Interrupt Line
ELOL : Boolean;
-- Read-only. Error Passive Interrupt Line
EPL : Boolean;
-- Read-only. Warning Status Interrupt Line
EWL : Boolean;
-- Read-only. Bus_Off Status
BOL : Boolean;
-- Read-only. Watchdog Interrupt Line
WDIL : Boolean;
-- Read-only. Protocol Error in Arbitration Phase Line
PEAL : Boolean;
-- Read-only. Protocol Error in Data Phase Line
PEDL : Boolean;
-- Read-only. Access to Reserved Address Line
ARAL : Boolean;
-- unspecified
Reserved_30_31 : HAL.UInt2;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_ILS_Register use record
RF0NL at 0 range 0 .. 0;
RF0WL at 0 range 1 .. 1;
RF0FL at 0 range 2 .. 2;
RF0LL at 0 range 3 .. 3;
RF1NL at 0 range 4 .. 4;
RF1WL at 0 range 5 .. 5;
RF1FL at 0 range 6 .. 6;
RF1LL at 0 range 7 .. 7;
HPML at 0 range 8 .. 8;
TCL at 0 range 9 .. 9;
TCFL at 0 range 10 .. 10;
TEFL at 0 range 11 .. 11;
TEFNL at 0 range 12 .. 12;
TEFWL at 0 range 13 .. 13;
TEFFL at 0 range 14 .. 14;
TEFLL at 0 range 15 .. 15;
TSWL at 0 range 16 .. 16;
MRAFL at 0 range 17 .. 17;
TOOL at 0 range 18 .. 18;
DRXL at 0 range 19 .. 19;
BECL at 0 range 20 .. 20;
BEUL at 0 range 21 .. 21;
ELOL at 0 range 22 .. 22;
EPL at 0 range 23 .. 23;
EWL at 0 range 24 .. 24;
BOL at 0 range 25 .. 25;
WDIL at 0 range 26 .. 26;
PEAL at 0 range 27 .. 27;
PEDL at 0 range 28 .. 28;
ARAL at 0 range 29 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- FDCAN_ILE_EINT array
type FDCAN_ILE_EINT_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for FDCAN_ILE_EINT
type FDCAN_ILE_EINT_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EINT as a value
Val : HAL.UInt2;
when True =>
-- EINT as an array
Arr : FDCAN_ILE_EINT_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for FDCAN_ILE_EINT_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- FDCAN Interrupt Line Enable Register
type FDCAN_ILE_Register is record
-- Enable Interrupt Line 0
EINT : FDCAN_ILE_EINT_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_ILE_Register use record
EINT at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
subtype FDCAN_GFC_ANFE_Field is HAL.UInt2;
subtype FDCAN_GFC_ANFS_Field is HAL.UInt2;
-- FDCAN Global Filter Configuration Register
type FDCAN_GFC_Register is record
-- Reject Remote Frames Extended
RRFE : Boolean := False;
-- Reject Remote Frames Standard
RRFS : Boolean := False;
-- Accept Non-matching Frames Extended
ANFE : FDCAN_GFC_ANFE_Field := 16#0#;
-- Accept Non-matching Frames Standard
ANFS : FDCAN_GFC_ANFS_Field := 16#0#;
-- unspecified
Reserved_6_31 : HAL.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_GFC_Register use record
RRFE at 0 range 0 .. 0;
RRFS at 0 range 1 .. 1;
ANFE at 0 range 2 .. 3;
ANFS at 0 range 4 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
subtype FDCAN_SIDFC_FLSSA_Field is HAL.UInt14;
subtype FDCAN_SIDFC_LSS_Field is HAL.UInt8;
-- FDCAN Standard ID Filter Configuration Register
type FDCAN_SIDFC_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- Filter List Standard Start Address
FLSSA : FDCAN_SIDFC_FLSSA_Field := 16#0#;
-- List Size Standard
LSS : FDCAN_SIDFC_LSS_Field := 16#0#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_SIDFC_Register use record
Reserved_0_1 at 0 range 0 .. 1;
FLSSA at 0 range 2 .. 15;
LSS at 0 range 16 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype FDCAN_XIDFC_FLESA_Field is HAL.UInt14;
subtype FDCAN_XIDFC_LSE_Field is HAL.UInt8;
-- FDCAN Extended ID Filter Configuration Register
type FDCAN_XIDFC_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- Filter List Standard Start Address
FLESA : FDCAN_XIDFC_FLESA_Field := 16#0#;
-- List Size Extended
LSE : FDCAN_XIDFC_LSE_Field := 16#0#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_XIDFC_Register use record
Reserved_0_1 at 0 range 0 .. 1;
FLESA at 0 range 2 .. 15;
LSE at 0 range 16 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype FDCAN_XIDAM_EIDM_Field is HAL.UInt29;
-- FDCAN Extended ID and Mask Register
type FDCAN_XIDAM_Register is record
-- Extended ID Mask
EIDM : FDCAN_XIDAM_EIDM_Field := 16#0#;
-- unspecified
Reserved_29_31 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_XIDAM_Register use record
EIDM at 0 range 0 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
subtype FDCAN_HPMS_BIDX_Field is HAL.UInt6;
subtype FDCAN_HPMS_MSI_Field is HAL.UInt2;
subtype FDCAN_HPMS_FIDX_Field is HAL.UInt7;
-- FDCAN High Priority Message Status Register
type FDCAN_HPMS_Register is record
-- Read-only. Buffer Index
BIDX : FDCAN_HPMS_BIDX_Field;
-- Read-only. Message Storage Indicator
MSI : FDCAN_HPMS_MSI_Field;
-- Read-only. Filter Index
FIDX : FDCAN_HPMS_FIDX_Field;
-- Read-only. Filter List
FLST : Boolean;
-- unspecified
Reserved_16_31 : HAL.UInt16;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_HPMS_Register use record
BIDX at 0 range 0 .. 5;
MSI at 0 range 6 .. 7;
FIDX at 0 range 8 .. 14;
FLST at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- FDCAN_NDAT1_ND array
type FDCAN_NDAT1_ND_Field_Array is array (0 .. 31) of Boolean
with Component_Size => 1, Size => 32;
-- FDCAN New Data 1 Register
type FDCAN_NDAT1_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- ND as a value
Val : HAL.UInt32;
when True =>
-- ND as an array
Arr : FDCAN_NDAT1_ND_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_NDAT1_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- FDCAN_NDAT2_ND array
type FDCAN_NDAT2_ND_Field_Array is array (32 .. 63) of Boolean
with Component_Size => 1, Size => 32;
-- FDCAN New Data 2 Register
type FDCAN_NDAT2_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- ND as a value
Val : HAL.UInt32;
when True =>
-- ND as an array
Arr : FDCAN_NDAT2_ND_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_NDAT2_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
subtype FDCAN_RXF0C_F0SA_Field is HAL.UInt14;
subtype FDCAN_RXF0C_F0S_Field is HAL.UInt8;
subtype FDCAN_RXF0C_F0WM_Field is HAL.UInt8;
-- FDCAN Rx FIFO 0 Configuration Register
type FDCAN_RXF0C_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- Rx FIFO 0 Start Address
F0SA : FDCAN_RXF0C_F0SA_Field := 16#0#;
-- Rx FIFO 0 Size
F0S : FDCAN_RXF0C_F0S_Field := 16#0#;
-- FIFO 0 Watermark
F0WM : FDCAN_RXF0C_F0WM_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_RXF0C_Register use record
Reserved_0_1 at 0 range 0 .. 1;
F0SA at 0 range 2 .. 15;
F0S at 0 range 16 .. 23;
F0WM at 0 range 24 .. 31;
end record;
subtype FDCAN_RXF0S_F0FL_Field is HAL.UInt7;
subtype FDCAN_RXF0S_F0G_Field is HAL.UInt6;
subtype FDCAN_RXF0S_F0P_Field is HAL.UInt6;
-- FDCAN Rx FIFO 0 Status Register
type FDCAN_RXF0S_Register is record
-- Rx FIFO 0 Fill Level
F0FL : FDCAN_RXF0S_F0FL_Field := 16#0#;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- Rx FIFO 0 Get Index
F0G : FDCAN_RXF0S_F0G_Field := 16#0#;
-- unspecified
Reserved_14_15 : HAL.UInt2 := 16#0#;
-- Rx FIFO 0 Put Index
F0P : FDCAN_RXF0S_F0P_Field := 16#0#;
-- unspecified
Reserved_22_23 : HAL.UInt2 := 16#0#;
-- Rx FIFO 0 Full
F0F : Boolean := False;
-- Rx FIFO 0 Message Lost
RF0L : Boolean := False;
-- unspecified
Reserved_26_31 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_RXF0S_Register use record
F0FL at 0 range 0 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
F0G at 0 range 8 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
F0P at 0 range 16 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
F0F at 0 range 24 .. 24;
RF0L at 0 range 25 .. 25;
Reserved_26_31 at 0 range 26 .. 31;
end record;
subtype FDCAN_RXF0A_FA01_Field is HAL.UInt6;
-- CAN Rx FIFO 0 Acknowledge Register
type FDCAN_RXF0A_Register is record
-- Rx FIFO 0 Acknowledge Index
FA01 : FDCAN_RXF0A_FA01_Field := 16#0#;
-- unspecified
Reserved_6_31 : HAL.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_RXF0A_Register use record
FA01 at 0 range 0 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
subtype FDCAN_RXBC_RBSA_Field is HAL.UInt14;
-- FDCAN Rx Buffer Configuration Register
type FDCAN_RXBC_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- Rx Buffer Start Address
RBSA : FDCAN_RXBC_RBSA_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_RXBC_Register use record
Reserved_0_1 at 0 range 0 .. 1;
RBSA at 0 range 2 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype FDCAN_RXF1C_F1SA_Field is HAL.UInt14;
subtype FDCAN_RXF1C_F1S_Field is HAL.UInt7;
subtype FDCAN_RXF1C_F1WM_Field is HAL.UInt7;
-- FDCAN Rx FIFO 1 Configuration Register
type FDCAN_RXF1C_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- Rx FIFO 1 Start Address
F1SA : FDCAN_RXF1C_F1SA_Field := 16#0#;
-- Rx FIFO 1 Size
F1S : FDCAN_RXF1C_F1S_Field := 16#0#;
-- unspecified
Reserved_23_23 : HAL.Bit := 16#0#;
-- Rx FIFO 1 Watermark
F1WM : FDCAN_RXF1C_F1WM_Field := 16#0#;
-- unspecified
Reserved_31_31 : HAL.Bit := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_RXF1C_Register use record
Reserved_0_1 at 0 range 0 .. 1;
F1SA at 0 range 2 .. 15;
F1S at 0 range 16 .. 22;
Reserved_23_23 at 0 range 23 .. 23;
F1WM at 0 range 24 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
subtype FDCAN_RXF1S_F1FL_Field is HAL.UInt7;
subtype FDCAN_RXF1S_F1GI_Field is HAL.UInt7;
subtype FDCAN_RXF1S_F1PI_Field is HAL.UInt7;
subtype FDCAN_RXF1S_DMS_Field is HAL.UInt2;
-- FDCAN Rx FIFO 1 Status Register
type FDCAN_RXF1S_Register is record
-- Rx FIFO 1 Fill Level
F1FL : FDCAN_RXF1S_F1FL_Field := 16#0#;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- Rx FIFO 1 Get Index
F1GI : FDCAN_RXF1S_F1GI_Field := 16#0#;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#0#;
-- Rx FIFO 1 Put Index
F1PI : FDCAN_RXF1S_F1PI_Field := 16#0#;
-- unspecified
Reserved_23_23 : HAL.Bit := 16#0#;
-- Rx FIFO 1 Full
F1F : Boolean := False;
-- Rx FIFO 1 Message Lost
RF1L : Boolean := False;
-- unspecified
Reserved_26_29 : HAL.UInt4 := 16#0#;
-- Debug Message Status
DMS : FDCAN_RXF1S_DMS_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_RXF1S_Register use record
F1FL at 0 range 0 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
F1GI at 0 range 8 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
F1PI at 0 range 16 .. 22;
Reserved_23_23 at 0 range 23 .. 23;
F1F at 0 range 24 .. 24;
RF1L at 0 range 25 .. 25;
Reserved_26_29 at 0 range 26 .. 29;
DMS at 0 range 30 .. 31;
end record;
subtype FDCAN_RXF1A_F1AI_Field is HAL.UInt6;
-- FDCAN Rx FIFO 1 Acknowledge Register
type FDCAN_RXF1A_Register is record
-- Rx FIFO 1 Acknowledge Index
F1AI : FDCAN_RXF1A_F1AI_Field := 16#0#;
-- unspecified
Reserved_6_31 : HAL.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_RXF1A_Register use record
F1AI at 0 range 0 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
subtype FDCAN_RXESC_F0DS_Field is HAL.UInt3;
subtype FDCAN_RXESC_F1DS_Field is HAL.UInt3;
subtype FDCAN_RXESC_RBDS_Field is HAL.UInt3;
-- FDCAN Rx Buffer Element Size Configuration Register
type FDCAN_RXESC_Register is record
-- Rx FIFO 1 Data Field Size:
F0DS : FDCAN_RXESC_F0DS_Field := 16#0#;
-- unspecified
Reserved_3_3 : HAL.Bit := 16#0#;
-- Rx FIFO 0 Data Field Size:
F1DS : FDCAN_RXESC_F1DS_Field := 16#0#;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- Rx Buffer Data Field Size:
RBDS : FDCAN_RXESC_RBDS_Field := 16#0#;
-- unspecified
Reserved_11_31 : HAL.UInt21 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_RXESC_Register use record
F0DS at 0 range 0 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
F1DS at 0 range 4 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
RBDS at 0 range 8 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
subtype FDCAN_TXBC_TBSA_Field is HAL.UInt14;
subtype FDCAN_TXBC_NDTB_Field is HAL.UInt6;
subtype FDCAN_TXBC_TFQS_Field is HAL.UInt6;
-- FDCAN Tx Buffer Configuration Register
type FDCAN_TXBC_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- Tx Buffers Start Address
TBSA : FDCAN_TXBC_TBSA_Field := 16#0#;
-- Number of Dedicated Transmit Buffers
NDTB : FDCAN_TXBC_NDTB_Field := 16#0#;
-- unspecified
Reserved_22_23 : HAL.UInt2 := 16#0#;
-- Transmit FIFO/Queue Size
TFQS : FDCAN_TXBC_TFQS_Field := 16#0#;
-- Tx FIFO/Queue Mode
TFQM : Boolean := False;
-- unspecified
Reserved_31_31 : HAL.Bit := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TXBC_Register use record
Reserved_0_1 at 0 range 0 .. 1;
TBSA at 0 range 2 .. 15;
NDTB at 0 range 16 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
TFQS at 0 range 24 .. 29;
TFQM at 0 range 30 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
subtype FDCAN_TXFQS_TFFL_Field is HAL.UInt6;
subtype FDCAN_TXFQS_TFGI_Field is HAL.UInt5;
subtype FDCAN_TXFQS_TFQPI_Field is HAL.UInt5;
-- FDCAN Tx FIFO/Queue Status Register
type FDCAN_TXFQS_Register is record
-- Read-only. Tx FIFO Free Level
TFFL : FDCAN_TXFQS_TFFL_Field;
-- unspecified
Reserved_6_7 : HAL.UInt2;
-- Read-only. TFGI
TFGI : FDCAN_TXFQS_TFGI_Field;
-- unspecified
Reserved_13_15 : HAL.UInt3;
-- Read-only. Tx FIFO/Queue Put Index
TFQPI : FDCAN_TXFQS_TFQPI_Field;
-- Read-only. Tx FIFO/Queue Full
TFQF : Boolean;
-- unspecified
Reserved_22_31 : HAL.UInt10;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TXFQS_Register use record
TFFL at 0 range 0 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
TFGI at 0 range 8 .. 12;
Reserved_13_15 at 0 range 13 .. 15;
TFQPI at 0 range 16 .. 20;
TFQF at 0 range 21 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
subtype FDCAN_TXESC_TBDS_Field is HAL.UInt3;
-- FDCAN Tx Buffer Element Size Configuration Register
type FDCAN_TXESC_Register is record
-- Tx Buffer Data Field Size:
TBDS : FDCAN_TXESC_TBDS_Field := 16#0#;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TXESC_Register use record
TBDS at 0 range 0 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
subtype FDCAN_TXEFC_EFSA_Field is HAL.UInt14;
subtype FDCAN_TXEFC_EFS_Field is HAL.UInt6;
subtype FDCAN_TXEFC_EFWM_Field is HAL.UInt6;
-- FDCAN Tx Event FIFO Configuration Register
type FDCAN_TXEFC_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- Event FIFO Start Address
EFSA : FDCAN_TXEFC_EFSA_Field := 16#0#;
-- Event FIFO Size
EFS : FDCAN_TXEFC_EFS_Field := 16#0#;
-- unspecified
Reserved_22_23 : HAL.UInt2 := 16#0#;
-- Event FIFO Watermark
EFWM : FDCAN_TXEFC_EFWM_Field := 16#0#;
-- unspecified
Reserved_30_31 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TXEFC_Register use record
Reserved_0_1 at 0 range 0 .. 1;
EFSA at 0 range 2 .. 15;
EFS at 0 range 16 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
EFWM at 0 range 24 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
subtype FDCAN_TXEFS_EFFL_Field is HAL.UInt6;
subtype FDCAN_TXEFS_EFGI_Field is HAL.UInt5;
-- FDCAN Tx Event FIFO Status Register
type FDCAN_TXEFS_Register is record
-- Event FIFO Fill Level
EFFL : FDCAN_TXEFS_EFFL_Field := 16#0#;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- Event FIFO Get Index.
EFGI : FDCAN_TXEFS_EFGI_Field := 16#0#;
-- unspecified
Reserved_13_23 : HAL.UInt11 := 16#0#;
-- Event FIFO Full.
EFF : Boolean := False;
-- Tx Event FIFO Element Lost.
TEFL : Boolean := False;
-- unspecified
Reserved_26_31 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TXEFS_Register use record
EFFL at 0 range 0 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
EFGI at 0 range 8 .. 12;
Reserved_13_23 at 0 range 13 .. 23;
EFF at 0 range 24 .. 24;
TEFL at 0 range 25 .. 25;
Reserved_26_31 at 0 range 26 .. 31;
end record;
subtype FDCAN_TXEFA_EFAI_Field is HAL.UInt5;
-- FDCAN Tx Event FIFO Acknowledge Register
type FDCAN_TXEFA_Register is record
-- Event FIFO Acknowledge Index
EFAI : FDCAN_TXEFA_EFAI_Field := 16#0#;
-- unspecified
Reserved_5_31 : HAL.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TXEFA_Register use record
EFAI at 0 range 0 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
subtype FDCAN_TTTMC_TMSA_Field is HAL.UInt14;
subtype FDCAN_TTTMC_TME_Field is HAL.UInt7;
-- FDCAN TT Trigger Memory Configuration Register
type FDCAN_TTTMC_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- Trigger Memory Start Address
TMSA : FDCAN_TTTMC_TMSA_Field := 16#0#;
-- Trigger Memory Elements
TME : FDCAN_TTTMC_TME_Field := 16#0#;
-- unspecified
Reserved_23_31 : HAL.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TTTMC_Register use record
Reserved_0_1 at 0 range 0 .. 1;
TMSA at 0 range 2 .. 15;
TME at 0 range 16 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
subtype FDCAN_TTRMC_RID_Field is HAL.UInt29;
-- FDCAN TT Reference Message Configuration Register
type FDCAN_TTRMC_Register is record
-- Reference Identifier.
RID : FDCAN_TTRMC_RID_Field := 16#0#;
-- unspecified
Reserved_29_29 : HAL.Bit := 16#0#;
-- Extended Identifier
XTD : Boolean := False;
-- Reference Message Payload Select
RMPS : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TTRMC_Register use record
RID at 0 range 0 .. 28;
Reserved_29_29 at 0 range 29 .. 29;
XTD at 0 range 30 .. 30;
RMPS at 0 range 31 .. 31;
end record;
subtype FDCAN_TTOCF_OM_Field is HAL.UInt2;
subtype FDCAN_TTOCF_LDSDL_Field is HAL.UInt3;
subtype FDCAN_TTOCF_IRTO_Field is HAL.UInt7;
subtype FDCAN_TTOCF_AWL_Field is HAL.UInt8;
-- FDCAN TT Operation Configuration Register
type FDCAN_TTOCF_Register is record
-- Operation Mode
OM : FDCAN_TTOCF_OM_Field := 16#0#;
-- unspecified
Reserved_2_2 : HAL.Bit := 16#0#;
-- Gap Enable
GEN : Boolean := False;
-- Time Master
TM : Boolean := False;
-- LD of Synchronization Deviation Limit
LDSDL : FDCAN_TTOCF_LDSDL_Field := 16#0#;
-- Initial Reference Trigger Offset
IRTO : FDCAN_TTOCF_IRTO_Field := 16#0#;
-- Enable External Clock Synchronization
EECS : Boolean := False;
-- Application Watchdog Limit
AWL : FDCAN_TTOCF_AWL_Field := 16#0#;
-- Enable Global Time Filtering
EGTF : Boolean := False;
-- Enable Clock Calibration
ECC : Boolean := False;
-- Event Trigger Polarity
EVTP : Boolean := False;
-- unspecified
Reserved_27_31 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TTOCF_Register use record
OM at 0 range 0 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
GEN at 0 range 3 .. 3;
TM at 0 range 4 .. 4;
LDSDL at 0 range 5 .. 7;
IRTO at 0 range 8 .. 14;
EECS at 0 range 15 .. 15;
AWL at 0 range 16 .. 23;
EGTF at 0 range 24 .. 24;
ECC at 0 range 25 .. 25;
EVTP at 0 range 26 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
subtype FDCAN_TTMLM_CCM_Field is HAL.UInt6;
subtype FDCAN_TTMLM_CSS_Field is HAL.UInt2;
subtype FDCAN_TTMLM_TXEW_Field is HAL.UInt4;
subtype FDCAN_TTMLM_ENTT_Field is HAL.UInt12;
-- FDCAN TT Matrix Limits Register
type FDCAN_TTMLM_Register is record
-- Cycle Count Max
CCM : FDCAN_TTMLM_CCM_Field := 16#0#;
-- Cycle Start Synchronization
CSS : FDCAN_TTMLM_CSS_Field := 16#0#;
-- Tx Enable Window
TXEW : FDCAN_TTMLM_TXEW_Field := 16#0#;
-- unspecified
Reserved_12_15 : HAL.UInt4 := 16#0#;
-- Expected Number of Tx Triggers
ENTT : FDCAN_TTMLM_ENTT_Field := 16#0#;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TTMLM_Register use record
CCM at 0 range 0 .. 5;
CSS at 0 range 6 .. 7;
TXEW at 0 range 8 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
ENTT at 0 range 16 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
subtype FDCAN_TURCF_NCL_Field is HAL.UInt16;
subtype FDCAN_TURCF_DC_Field is HAL.UInt14;
-- FDCAN TUR Configuration Register
type FDCAN_TURCF_Register is record
-- Numerator Configuration Low.
NCL : FDCAN_TURCF_NCL_Field := 16#0#;
-- Denominator Configuration.
DC : FDCAN_TURCF_DC_Field := 16#0#;
-- unspecified
Reserved_30_30 : HAL.Bit := 16#0#;
-- Enable Local Time
ELT : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TURCF_Register use record
NCL at 0 range 0 .. 15;
DC at 0 range 16 .. 29;
Reserved_30_30 at 0 range 30 .. 30;
ELT at 0 range 31 .. 31;
end record;
subtype FDCAN_TTOCN_SWS_Field is HAL.UInt2;
subtype FDCAN_TTOCN_TMC_Field is HAL.UInt2;
-- FDCAN TT Operation Control Register
type FDCAN_TTOCN_Register is record
-- Set Global time
SGT : Boolean := False;
-- External Clock Synchronization
ECS : Boolean := False;
-- Stop Watch Polarity
SWP : Boolean := False;
-- Stop Watch Source.
SWS : FDCAN_TTOCN_SWS_Field := 16#0#;
-- Register Time Mark Interrupt Pulse Enable
RTIE : Boolean := False;
-- Register Time Mark Compare
TMC : FDCAN_TTOCN_TMC_Field := 16#0#;
-- Trigger Time Mark Interrupt Pulse Enable
TTIE : Boolean := False;
-- Gap Control Select
GCS : Boolean := False;
-- Finish Gap.
FGP : Boolean := False;
-- Time Mark Gap
TMG : Boolean := False;
-- Next is Gap
NIG : Boolean := False;
-- External Synchronization Control
ESCN : Boolean := False;
-- unspecified
Reserved_14_14 : HAL.Bit := 16#0#;
-- TT Operation Control Register Locked
LCKC : Boolean := False;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TTOCN_Register use record
SGT at 0 range 0 .. 0;
ECS at 0 range 1 .. 1;
SWP at 0 range 2 .. 2;
SWS at 0 range 3 .. 4;
RTIE at 0 range 5 .. 5;
TMC at 0 range 6 .. 7;
TTIE at 0 range 8 .. 8;
GCS at 0 range 9 .. 9;
FGP at 0 range 10 .. 10;
TMG at 0 range 11 .. 11;
NIG at 0 range 12 .. 12;
ESCN at 0 range 13 .. 13;
Reserved_14_14 at 0 range 14 .. 14;
LCKC at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype CAN_TTGTP_NCL_Field is HAL.UInt16;
subtype CAN_TTGTP_CTP_Field is HAL.UInt16;
-- FDCAN TT Global Time Preset Register
type CAN_TTGTP_Register is record
-- Time Preset
NCL : CAN_TTGTP_NCL_Field := 16#0#;
-- Cycle Time Target Phase
CTP : CAN_TTGTP_CTP_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_TTGTP_Register use record
NCL at 0 range 0 .. 15;
CTP at 0 range 16 .. 31;
end record;
subtype FDCAN_TTTMK_TM_Field is HAL.UInt16;
subtype FDCAN_TTTMK_TICC_Field is HAL.UInt7;
-- FDCAN TT Time Mark Register
type FDCAN_TTTMK_Register is record
-- Time Mark
TM : FDCAN_TTTMK_TM_Field := 16#0#;
-- Time Mark Cycle Code
TICC : FDCAN_TTTMK_TICC_Field := 16#0#;
-- unspecified
Reserved_23_30 : HAL.UInt8 := 16#0#;
-- TT Time Mark Register Locked
LCKM : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TTTMK_Register use record
TM at 0 range 0 .. 15;
TICC at 0 range 16 .. 22;
Reserved_23_30 at 0 range 23 .. 30;
LCKM at 0 range 31 .. 31;
end record;
-- FDCAN_TTIR_SE array
type FDCAN_TTIR_SE_Field_Array is array (1 .. 2) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for FDCAN_TTIR_SE
type FDCAN_TTIR_SE_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SE as a value
Val : HAL.UInt2;
when True =>
-- SE as an array
Arr : FDCAN_TTIR_SE_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for FDCAN_TTIR_SE_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- FDCAN TT Interrupt Register
type FDCAN_TTIR_Register is record
-- Start of Basic Cycle
SBC : Boolean := False;
-- Start of Matrix Cycle
SMC : Boolean := False;
-- Change of Synchronization Mode
CSM : Boolean := False;
-- Start of Gap
SOG : Boolean := False;
-- Register Time Mark Interrupt.
RTMI : Boolean := False;
-- Trigger Time Mark Event Internal
TTMI : Boolean := False;
-- Stop Watch Event
SWE : Boolean := False;
-- Global Time Wrap
GTW : Boolean := False;
-- Global Time Discontinuity
GTD : Boolean := False;
-- Global Time Error
GTE : Boolean := False;
-- Tx Count Underflow
TXU : Boolean := False;
-- Tx Count Overflow
TXO : Boolean := False;
-- Scheduling Error 1
SE : FDCAN_TTIR_SE_Field :=
(As_Array => False, Val => 16#0#);
-- Error Level Changed.
ELC : Boolean := False;
-- Initialization Watch Trigger
IWTG : Boolean := False;
-- Watch Trigger
WT : Boolean := False;
-- Application Watchdog
AW : Boolean := False;
-- Configuration Error
CER : Boolean := False;
-- unspecified
Reserved_19_31 : HAL.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TTIR_Register use record
SBC at 0 range 0 .. 0;
SMC at 0 range 1 .. 1;
CSM at 0 range 2 .. 2;
SOG at 0 range 3 .. 3;
RTMI at 0 range 4 .. 4;
TTMI at 0 range 5 .. 5;
SWE at 0 range 6 .. 6;
GTW at 0 range 7 .. 7;
GTD at 0 range 8 .. 8;
GTE at 0 range 9 .. 9;
TXU at 0 range 10 .. 10;
TXO at 0 range 11 .. 11;
SE at 0 range 12 .. 13;
ELC at 0 range 14 .. 14;
IWTG at 0 range 15 .. 15;
WT at 0 range 16 .. 16;
AW at 0 range 17 .. 17;
CER at 0 range 18 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
-- FDCAN TT Interrupt Enable Register
type FDCAN_TTIE_Register is record
-- Start of Basic Cycle Interrupt Enable
SBCE : Boolean := False;
-- Start of Matrix Cycle Interrupt Enable
SMCE : Boolean := False;
-- Change of Synchronization Mode Interrupt Enable
CSME : Boolean := False;
-- Start of Gap Interrupt Enable
SOGE : Boolean := False;
-- Register Time Mark Interrupt Enable
RTMIE : Boolean := False;
-- Trigger Time Mark Event Internal Interrupt Enable
TTMIE : Boolean := False;
-- Stop Watch Event Interrupt Enable
SWEE : Boolean := False;
-- Global Time Wrap Interrupt Enable
GTWE : Boolean := False;
-- Global Time Discontinuity Interrupt Enable
GTDE : Boolean := False;
-- Global Time Error Interrupt Enable
GTEE : Boolean := False;
-- Tx Count Underflow Interrupt Enable
TXUE : Boolean := False;
-- Tx Count Overflow Interrupt Enable
TXOE : Boolean := False;
-- Scheduling Error 1 Interrupt Enable
SE1E : Boolean := False;
-- Scheduling Error 2 Interrupt Enable
SE2E : Boolean := False;
-- Change Error Level Interrupt Enable
ELCE : Boolean := False;
-- Initialization Watch Trigger Interrupt Enable
IWTGE : Boolean := False;
-- Watch Trigger Interrupt Enable
WTE : Boolean := False;
-- Application Watchdog Interrupt Enable
AWE : Boolean := False;
-- Configuration Error Interrupt Enable
CERE : Boolean := False;
-- unspecified
Reserved_19_31 : HAL.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TTIE_Register use record
SBCE at 0 range 0 .. 0;
SMCE at 0 range 1 .. 1;
CSME at 0 range 2 .. 2;
SOGE at 0 range 3 .. 3;
RTMIE at 0 range 4 .. 4;
TTMIE at 0 range 5 .. 5;
SWEE at 0 range 6 .. 6;
GTWE at 0 range 7 .. 7;
GTDE at 0 range 8 .. 8;
GTEE at 0 range 9 .. 9;
TXUE at 0 range 10 .. 10;
TXOE at 0 range 11 .. 11;
SE1E at 0 range 12 .. 12;
SE2E at 0 range 13 .. 13;
ELCE at 0 range 14 .. 14;
IWTGE at 0 range 15 .. 15;
WTE at 0 range 16 .. 16;
AWE at 0 range 17 .. 17;
CERE at 0 range 18 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
-- FDCAN TT Interrupt Line Select Register
type FDCAN_TTILS_Register is record
-- Start of Basic Cycle Interrupt Line
SBCL : Boolean := False;
-- Start of Matrix Cycle Interrupt Line
SMCL : Boolean := False;
-- Change of Synchronization Mode Interrupt Line
CSML : Boolean := False;
-- Start of Gap Interrupt Line
SOGL : Boolean := False;
-- Register Time Mark Interrupt Line
RTMIL : Boolean := False;
-- Trigger Time Mark Event Internal Interrupt Line
TTMIL : Boolean := False;
-- Stop Watch Event Interrupt Line
SWEL : Boolean := False;
-- Global Time Wrap Interrupt Line
GTWL : Boolean := False;
-- Global Time Discontinuity Interrupt Line
GTDL : Boolean := False;
-- Global Time Error Interrupt Line
GTEL : Boolean := False;
-- Tx Count Underflow Interrupt Line
TXUL : Boolean := False;
-- Tx Count Overflow Interrupt Line
TXOL : Boolean := False;
-- Scheduling Error 1 Interrupt Line
SE1L : Boolean := False;
-- Scheduling Error 2 Interrupt Line
SE2L : Boolean := False;
-- Change Error Level Interrupt Line
ELCL : Boolean := False;
-- Initialization Watch Trigger Interrupt Line
IWTGL : Boolean := False;
-- Watch Trigger Interrupt Line
WTL : Boolean := False;
-- Application Watchdog Interrupt Line
AWL : Boolean := False;
-- Configuration Error Interrupt Line
CERL : Boolean := False;
-- unspecified
Reserved_19_31 : HAL.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TTILS_Register use record
SBCL at 0 range 0 .. 0;
SMCL at 0 range 1 .. 1;
CSML at 0 range 2 .. 2;
SOGL at 0 range 3 .. 3;
RTMIL at 0 range 4 .. 4;
TTMIL at 0 range 5 .. 5;
SWEL at 0 range 6 .. 6;
GTWL at 0 range 7 .. 7;
GTDL at 0 range 8 .. 8;
GTEL at 0 range 9 .. 9;
TXUL at 0 range 10 .. 10;
TXOL at 0 range 11 .. 11;
SE1L at 0 range 12 .. 12;
SE2L at 0 range 13 .. 13;
ELCL at 0 range 14 .. 14;
IWTGL at 0 range 15 .. 15;
WTL at 0 range 16 .. 16;
AWL at 0 range 17 .. 17;
CERL at 0 range 18 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
subtype FDCAN_TTOST_EL_Field is HAL.UInt2;
subtype FDCAN_TTOST_MS_Field is HAL.UInt2;
subtype FDCAN_TTOST_SYS_Field is HAL.UInt2;
subtype FDCAN_TTOST_RTO_Field is HAL.UInt8;
subtype FDCAN_TTOST_TMP_Field is HAL.UInt3;
-- FDCAN TT Operation Status Register
type FDCAN_TTOST_Register is record
-- Error Level
EL : FDCAN_TTOST_EL_Field := 16#0#;
-- Master State.
MS : FDCAN_TTOST_MS_Field := 16#0#;
-- Synchronization State
SYS : FDCAN_TTOST_SYS_Field := 16#0#;
-- Quality of Global Time Phase
GTP : Boolean := False;
-- Quality of Clock Speed
QCS : Boolean := False;
-- Reference Trigger Offset
RTO : FDCAN_TTOST_RTO_Field := 16#0#;
-- unspecified
Reserved_16_21 : HAL.UInt6 := 16#0#;
-- Wait for Global Time Discontinuity
WGTD : Boolean := False;
-- Gap Finished Indicator.
GFI : Boolean := False;
-- Time Master Priority
TMP : FDCAN_TTOST_TMP_Field := 16#0#;
-- Gap Started Indicator.
GSI : Boolean := False;
-- Wait for Event
WFE : Boolean := False;
-- Application Watchdog Event
AWE : Boolean := False;
-- Wait for External Clock Synchronization
WECS : Boolean := False;
-- Schedule Phase Lock
SPL : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TTOST_Register use record
EL at 0 range 0 .. 1;
MS at 0 range 2 .. 3;
SYS at 0 range 4 .. 5;
GTP at 0 range 6 .. 6;
QCS at 0 range 7 .. 7;
RTO at 0 range 8 .. 15;
Reserved_16_21 at 0 range 16 .. 21;
WGTD at 0 range 22 .. 22;
GFI at 0 range 23 .. 23;
TMP at 0 range 24 .. 26;
GSI at 0 range 27 .. 27;
WFE at 0 range 28 .. 28;
AWE at 0 range 29 .. 29;
WECS at 0 range 30 .. 30;
SPL at 0 range 31 .. 31;
end record;
subtype FDCAN_TURNA_NAV_Field is HAL.UInt18;
-- FDCAN TUR Numerator Actual Register
type FDCAN_TURNA_Register is record
-- Read-only. Numerator Actual Value
NAV : FDCAN_TURNA_NAV_Field;
-- unspecified
Reserved_18_31 : HAL.UInt14;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TURNA_Register use record
NAV at 0 range 0 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
subtype FDCAN_TTLGT_LT_Field is HAL.UInt16;
subtype FDCAN_TTLGT_GT_Field is HAL.UInt16;
-- FDCAN TT Local and Global Time Register
type FDCAN_TTLGT_Register is record
-- Read-only. Local Time
LT : FDCAN_TTLGT_LT_Field;
-- Read-only. Global Time
GT : FDCAN_TTLGT_GT_Field;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TTLGT_Register use record
LT at 0 range 0 .. 15;
GT at 0 range 16 .. 31;
end record;
subtype FDCAN_TTCTC_CT_Field is HAL.UInt16;
subtype FDCAN_TTCTC_CC_Field is HAL.UInt6;
-- FDCAN TT Cycle Time and Count Register
type FDCAN_TTCTC_Register is record
-- Read-only. Cycle Time
CT : FDCAN_TTCTC_CT_Field;
-- Read-only. Cycle Count
CC : FDCAN_TTCTC_CC_Field;
-- unspecified
Reserved_22_31 : HAL.UInt10;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TTCTC_Register use record
CT at 0 range 0 .. 15;
CC at 0 range 16 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
subtype FDCAN_TTCPT_CT_Field is HAL.UInt6;
subtype FDCAN_TTCPT_SWV_Field is HAL.UInt16;
-- FDCAN TT Capture Time Register
type FDCAN_TTCPT_Register is record
-- Read-only. Cycle Count Value
CT : FDCAN_TTCPT_CT_Field;
-- unspecified
Reserved_6_15 : HAL.UInt10;
-- Read-only. Stop Watch Value
SWV : FDCAN_TTCPT_SWV_Field;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TTCPT_Register use record
CT at 0 range 0 .. 5;
Reserved_6_15 at 0 range 6 .. 15;
SWV at 0 range 16 .. 31;
end record;
subtype FDCAN_TTCSM_CSM_Field is HAL.UInt16;
-- FDCAN TT Cycle Sync Mark Register
type FDCAN_TTCSM_Register is record
-- Read-only. Cycle Sync Mark
CSM : FDCAN_TTCSM_CSM_Field;
-- unspecified
Reserved_16_31 : HAL.UInt16;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TTCSM_Register use record
CSM at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype FDCAN_TTTS_SWTDEL_Field is HAL.UInt2;
subtype FDCAN_TTTS_EVTSEL_Field is HAL.UInt2;
-- FDCAN TT Trigger Select Register
type FDCAN_TTTS_Register is record
-- Stop watch trigger input selection
SWTDEL : FDCAN_TTTS_SWTDEL_Field := 16#0#;
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- Event trigger input selection
EVTSEL : FDCAN_TTTS_EVTSEL_Field := 16#0#;
-- unspecified
Reserved_6_31 : HAL.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FDCAN_TTTS_Register use record
SWTDEL at 0 range 0 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
EVTSEL at 0 range 4 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- CCU registers
type CAN_CCU_Peripheral is record
-- Clock Calibration Unit Core Release Register
CREL : aliased CREL_Register;
-- Calibration Configuration Register
CCFG : aliased CCFG_Register;
-- Calibration Status Register
CSTAT : aliased CSTAT_Register;
-- Calibration Watchdog Register
CWD : aliased CWD_Register;
-- Clock Calibration Unit Interrupt Register
IR : aliased IR_Register;
-- Clock Calibration Unit Interrupt Enable Register
IE : aliased IE_Register;
end record
with Volatile;
for CAN_CCU_Peripheral use record
CREL at 16#0# range 0 .. 31;
CCFG at 16#4# range 0 .. 31;
CSTAT at 16#8# range 0 .. 31;
CWD at 16#C# range 0 .. 31;
IR at 16#10# range 0 .. 31;
IE at 16#14# range 0 .. 31;
end record;
-- CCU registers
CAN_CCU_Periph : aliased CAN_CCU_Peripheral
with Import, Address => CAN_CCU_Base;
-- FDCAN1
type FDCAN_Peripheral is record
-- FDCAN Core Release Register
FDCAN_CREL : aliased FDCAN_CREL_Register;
-- FDCAN Core Release Register
FDCAN_ENDN : aliased HAL.UInt32;
-- FDCAN Data Bit Timing and Prescaler Register
FDCAN_DBTP : aliased FDCAN_DBTP_Register;
-- FDCAN Test Register
FDCAN_TEST : aliased FDCAN_TEST_Register;
-- FDCAN RAM Watchdog Register
FDCAN_RWD : aliased FDCAN_RWD_Register;
-- FDCAN CC Control Register
FDCAN_CCCR : aliased FDCAN_CCCR_Register;
-- FDCAN Nominal Bit Timing and Prescaler Register
FDCAN_NBTP : aliased FDCAN_NBTP_Register;
-- FDCAN Timestamp Counter Configuration Register
FDCAN_TSCC : aliased FDCAN_TSCC_Register;
-- FDCAN Timestamp Counter Value Register
FDCAN_TSCV : aliased FDCAN_TSCV_Register;
-- FDCAN Timeout Counter Configuration Register
FDCAN_TOCC : aliased FDCAN_TOCC_Register;
-- FDCAN Timeout Counter Value Register
FDCAN_TOCV : aliased FDCAN_TOCV_Register;
-- FDCAN Error Counter Register
FDCAN_ECR : aliased FDCAN_ECR_Register;
-- FDCAN Protocol Status Register
FDCAN_PSR : aliased FDCAN_PSR_Register;
-- FDCAN Transmitter Delay Compensation Register
FDCAN_TDCR : aliased FDCAN_TDCR_Register;
-- FDCAN Interrupt Register
FDCAN_IR : aliased FDCAN_IR_Register;
-- FDCAN Interrupt Enable Register
FDCAN_IE : aliased FDCAN_IE_Register;
-- FDCAN Interrupt Line Select Register
FDCAN_ILS : aliased FDCAN_ILS_Register;
-- FDCAN Interrupt Line Enable Register
FDCAN_ILE : aliased FDCAN_ILE_Register;
-- FDCAN Global Filter Configuration Register
FDCAN_GFC : aliased FDCAN_GFC_Register;
-- FDCAN Standard ID Filter Configuration Register
FDCAN_SIDFC : aliased FDCAN_SIDFC_Register;
-- FDCAN Extended ID Filter Configuration Register
FDCAN_XIDFC : aliased FDCAN_XIDFC_Register;
-- FDCAN Extended ID and Mask Register
FDCAN_XIDAM : aliased FDCAN_XIDAM_Register;
-- FDCAN High Priority Message Status Register
FDCAN_HPMS : aliased FDCAN_HPMS_Register;
-- FDCAN New Data 1 Register
FDCAN_NDAT1 : aliased FDCAN_NDAT1_Register;
-- FDCAN New Data 2 Register
FDCAN_NDAT2 : aliased FDCAN_NDAT2_Register;
-- FDCAN Rx FIFO 0 Configuration Register
FDCAN_RXF0C : aliased FDCAN_RXF0C_Register;
-- FDCAN Rx FIFO 0 Status Register
FDCAN_RXF0S : aliased FDCAN_RXF0S_Register;
-- CAN Rx FIFO 0 Acknowledge Register
FDCAN_RXF0A : aliased FDCAN_RXF0A_Register;
-- FDCAN Rx Buffer Configuration Register
FDCAN_RXBC : aliased FDCAN_RXBC_Register;
-- FDCAN Rx FIFO 1 Configuration Register
FDCAN_RXF1C : aliased FDCAN_RXF1C_Register;
-- FDCAN Rx FIFO 1 Status Register
FDCAN_RXF1S : aliased FDCAN_RXF1S_Register;
-- FDCAN Rx FIFO 1 Acknowledge Register
FDCAN_RXF1A : aliased FDCAN_RXF1A_Register;
-- FDCAN Rx Buffer Element Size Configuration Register
FDCAN_RXESC : aliased FDCAN_RXESC_Register;
-- FDCAN Tx Buffer Configuration Register
FDCAN_TXBC : aliased FDCAN_TXBC_Register;
-- FDCAN Tx FIFO/Queue Status Register
FDCAN_TXFQS : aliased FDCAN_TXFQS_Register;
-- FDCAN Tx Buffer Element Size Configuration Register
FDCAN_TXESC : aliased FDCAN_TXESC_Register;
-- FDCAN Tx Buffer Request Pending Register
FDCAN_TXBRP : aliased HAL.UInt32;
-- FDCAN Tx Buffer Add Request Register
FDCAN_TXBAR : aliased HAL.UInt32;
-- FDCAN Tx Buffer Cancellation Request Register
FDCAN_TXBCR : aliased HAL.UInt32;
-- FDCAN Tx Buffer Transmission Occurred Register
FDCAN_TXBTO : aliased HAL.UInt32;
-- FDCAN Tx Buffer Cancellation Finished Register
FDCAN_TXBCF : aliased HAL.UInt32;
-- FDCAN Tx Buffer Transmission Interrupt Enable Register
FDCAN_TXBTIE : aliased HAL.UInt32;
-- FDCAN Tx Buffer Cancellation Finished Interrupt Enable Register
FDCAN_TXBCIE : aliased HAL.UInt32;
-- FDCAN Tx Event FIFO Configuration Register
FDCAN_TXEFC : aliased FDCAN_TXEFC_Register;
-- FDCAN Tx Event FIFO Status Register
FDCAN_TXEFS : aliased FDCAN_TXEFS_Register;
-- FDCAN Tx Event FIFO Acknowledge Register
FDCAN_TXEFA : aliased FDCAN_TXEFA_Register;
-- FDCAN TT Trigger Memory Configuration Register
FDCAN_TTTMC : aliased FDCAN_TTTMC_Register;
-- FDCAN TT Reference Message Configuration Register
FDCAN_TTRMC : aliased FDCAN_TTRMC_Register;
-- FDCAN TT Operation Configuration Register
FDCAN_TTOCF : aliased FDCAN_TTOCF_Register;
-- FDCAN TT Matrix Limits Register
FDCAN_TTMLM : aliased FDCAN_TTMLM_Register;
-- FDCAN TUR Configuration Register
FDCAN_TURCF : aliased FDCAN_TURCF_Register;
-- FDCAN TT Operation Control Register
FDCAN_TTOCN : aliased FDCAN_TTOCN_Register;
-- FDCAN TT Global Time Preset Register
CAN_TTGTP : aliased CAN_TTGTP_Register;
-- FDCAN TT Time Mark Register
FDCAN_TTTMK : aliased FDCAN_TTTMK_Register;
-- FDCAN TT Interrupt Register
FDCAN_TTIR : aliased FDCAN_TTIR_Register;
-- FDCAN TT Interrupt Enable Register
FDCAN_TTIE : aliased FDCAN_TTIE_Register;
-- FDCAN TT Interrupt Line Select Register
FDCAN_TTILS : aliased FDCAN_TTILS_Register;
-- FDCAN TT Operation Status Register
FDCAN_TTOST : aliased FDCAN_TTOST_Register;
-- FDCAN TUR Numerator Actual Register
FDCAN_TURNA : aliased FDCAN_TURNA_Register;
-- FDCAN TT Local and Global Time Register
FDCAN_TTLGT : aliased FDCAN_TTLGT_Register;
-- FDCAN TT Cycle Time and Count Register
FDCAN_TTCTC : aliased FDCAN_TTCTC_Register;
-- FDCAN TT Capture Time Register
FDCAN_TTCPT : aliased FDCAN_TTCPT_Register;
-- FDCAN TT Cycle Sync Mark Register
FDCAN_TTCSM : aliased FDCAN_TTCSM_Register;
-- FDCAN TT Trigger Select Register
FDCAN_TTTS : aliased FDCAN_TTTS_Register;
end record
with Volatile;
for FDCAN_Peripheral use record
FDCAN_CREL at 16#0# range 0 .. 31;
FDCAN_ENDN at 16#4# range 0 .. 31;
FDCAN_DBTP at 16#C# range 0 .. 31;
FDCAN_TEST at 16#10# range 0 .. 31;
FDCAN_RWD at 16#14# range 0 .. 31;
FDCAN_CCCR at 16#18# range 0 .. 31;
FDCAN_NBTP at 16#1C# range 0 .. 31;
FDCAN_TSCC at 16#20# range 0 .. 31;
FDCAN_TSCV at 16#24# range 0 .. 31;
FDCAN_TOCC at 16#28# range 0 .. 31;
FDCAN_TOCV at 16#2C# range 0 .. 31;
FDCAN_ECR at 16#40# range 0 .. 31;
FDCAN_PSR at 16#44# range 0 .. 31;
FDCAN_TDCR at 16#48# range 0 .. 31;
FDCAN_IR at 16#50# range 0 .. 31;
FDCAN_IE at 16#54# range 0 .. 31;
FDCAN_ILS at 16#58# range 0 .. 31;
FDCAN_ILE at 16#5C# range 0 .. 31;
FDCAN_GFC at 16#80# range 0 .. 31;
FDCAN_SIDFC at 16#84# range 0 .. 31;
FDCAN_XIDFC at 16#88# range 0 .. 31;
FDCAN_XIDAM at 16#90# range 0 .. 31;
FDCAN_HPMS at 16#94# range 0 .. 31;
FDCAN_NDAT1 at 16#98# range 0 .. 31;
FDCAN_NDAT2 at 16#9C# range 0 .. 31;
FDCAN_RXF0C at 16#A0# range 0 .. 31;
FDCAN_RXF0S at 16#A4# range 0 .. 31;
FDCAN_RXF0A at 16#A8# range 0 .. 31;
FDCAN_RXBC at 16#AC# range 0 .. 31;
FDCAN_RXF1C at 16#B0# range 0 .. 31;
FDCAN_RXF1S at 16#B4# range 0 .. 31;
FDCAN_RXF1A at 16#B8# range 0 .. 31;
FDCAN_RXESC at 16#BC# range 0 .. 31;
FDCAN_TXBC at 16#C0# range 0 .. 31;
FDCAN_TXFQS at 16#C4# range 0 .. 31;
FDCAN_TXESC at 16#C8# range 0 .. 31;
FDCAN_TXBRP at 16#CC# range 0 .. 31;
FDCAN_TXBAR at 16#D0# range 0 .. 31;
FDCAN_TXBCR at 16#D4# range 0 .. 31;
FDCAN_TXBTO at 16#D8# range 0 .. 31;
FDCAN_TXBCF at 16#DC# range 0 .. 31;
FDCAN_TXBTIE at 16#E0# range 0 .. 31;
FDCAN_TXBCIE at 16#E4# range 0 .. 31;
FDCAN_TXEFC at 16#F0# range 0 .. 31;
FDCAN_TXEFS at 16#F4# range 0 .. 31;
FDCAN_TXEFA at 16#F8# range 0 .. 31;
FDCAN_TTTMC at 16#100# range 0 .. 31;
FDCAN_TTRMC at 16#104# range 0 .. 31;
FDCAN_TTOCF at 16#108# range 0 .. 31;
FDCAN_TTMLM at 16#10C# range 0 .. 31;
FDCAN_TURCF at 16#110# range 0 .. 31;
FDCAN_TTOCN at 16#114# range 0 .. 31;
CAN_TTGTP at 16#118# range 0 .. 31;
FDCAN_TTTMK at 16#11C# range 0 .. 31;
FDCAN_TTIR at 16#120# range 0 .. 31;
FDCAN_TTIE at 16#124# range 0 .. 31;
FDCAN_TTILS at 16#128# range 0 .. 31;
FDCAN_TTOST at 16#12C# range 0 .. 31;
FDCAN_TURNA at 16#130# range 0 .. 31;
FDCAN_TTLGT at 16#134# range 0 .. 31;
FDCAN_TTCTC at 16#138# range 0 .. 31;
FDCAN_TTCPT at 16#13C# range 0 .. 31;
FDCAN_TTCSM at 16#140# range 0 .. 31;
FDCAN_TTTS at 16#300# range 0 .. 31;
end record;
-- FDCAN1
FDCAN1_Periph : aliased FDCAN_Peripheral
with Import, Address => FDCAN1_Base;
-- FDCAN1
FDCAN2_Periph : aliased FDCAN_Peripheral
with Import, Address => FDCAN2_Base;
end STM32_SVD.FDCAN;
|
-- { dg-do compile }
-- { dg-options "-g" }
procedure Addr4 is
function F return String is begin return ""; end F;
S1 : String renames F;
subtype ST is String (1 .. S1'Length);
S2 : ST;
for S2'Address use S1'Address;
begin
null;
end;
|
package body Util is
function "+"(a, b : Cost_Type) return Cost_Type is
begin
if a > Cost_Type'Last - b then
return Cost_Type'Last;
else
return Cost_Type(Long_Integer(a) + Long_Integer(b));
end if;
end "+";
function Log2(n : Natural) return Natural is
i : Natural := n;
r : Natural := 0;
begin
while i > 0 loop
r := r + 1;
i := i / 2;
end loop;
return r;
end Log2;
function Log2(n : Long_Integer) return Natural is
i : Long_Integer := n;
r : Natural := 0;
begin
while i > 0 loop
r := r + 1;
i := i / 2;
end loop;
return r;
end Log2;
function Round_Power2(n : Natural) return Natural is
begin
return 2 ** Log2(n);
end Round_Power2;
function To_String(i : Integer) return String is
str : constant String := Integer'Image(i);
begin
if str(str'First) = ' ' then
return str(str'First + 1 .. str'Last);
else
return str;
end if;
end To_String;
function To_String(i : Long_Integer) return String is
str : constant String := Long_Integer'Image(i);
begin
if str(str'First) = ' ' then
return str(str'First + 1 .. str'Last);
else
return str;
end if;
end To_String;
function To_String(f : Long_Float) return String is
str : constant String := Long_Float'Image(f);
begin
if str(str'First) = ' ' then
return str(str'First + 1 .. str'Last);
else
return str;
end if;
end To_String;
end Util;
|
------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. (gh+spat@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.Containers.Bounded_Vectors;
package body SPAT.Entity.Tree is
package body Generic_Sorting is
package Cursor_Lists is new
Ada.Containers.Bounded_Vectors (Index_Type => Positive,
Element_Type => Cursor,
"=" => "=");
------------------------------------------------------------------------
-- Sort
--
-- This is a "sort by proxy". The way it works that we first copy the
-- children's cursors into a vector which then gets sorted. After this
-- step, we rearrange the subtree in the order of elements in the
-- vector.
------------------------------------------------------------------------
procedure Sort (Tree : in out T;
Parent : in Cursor) is
Num_Children : constant Ada.Containers.Count_Type :=
Entity.Tree.Child_Count (Parent => Parent);
use type Ada.Containers.Count_Type;
The_List : Cursor_Lists.Vector (Capacity => Num_Children);
begin
if Num_Children < 2 then
-- No elements to sort.
return;
end if;
-- Copy the tree's cursor into The_List.
for C in Tree.Iterate_Children (Parent => Parent) loop
The_List.Append (New_Item => C);
end loop;
-- Sort the list with our tree cursors.
declare
------------------------------------------------------------------
-- Before
--
-- Comparison operator.
------------------------------------------------------------------
function Before (Left : in Cursor;
Right : in Cursor) return Boolean is
(Before -- from the generic instance
(Left => Entity.Tree.Element (Position => Left),
Right => Entity.Tree.Element (Position => Right)));
package Sorting is new
Cursor_Lists.Generic_Sorting ("<" => Before);
begin
Sorting.Sort (Container => The_List);
end;
-- Now rearrange the subtree according to our sorting order.
for C of The_List loop
Tree.Splice_Subtree (Parent => Parent,
Before => Entity.Tree.No_Element,
Position => C);
end loop;
end Sort;
end Generic_Sorting;
end SPAT.Entity.Tree;
|
pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with SDL_SDL_stdinc_h;
with System;
package SDL_SDL_version_h is
SDL_MAJOR_VERSION : constant := 1; -- ../include/SDL/SDL_version.h:42
SDL_MINOR_VERSION : constant := 2; -- ../include/SDL/SDL_version.h:43
SDL_PATCHLEVEL : constant := 15; -- ../include/SDL/SDL_version.h:44
-- arg-macro: procedure SDL_VERSION (X)
-- { (X).major := SDL_MAJOR_VERSION; (X).minor := SDL_MINOR_VERSION; (X).patch := SDL_PATCHLEVEL; }
-- arg-macro: function SDL_VERSIONNUM (X, Y, Z)
-- return (X)*1000 + (Y)*100 + (Z);
-- unsupported macro: SDL_COMPILEDVERSION SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
-- arg-macro: function SDL_VERSION_ATLEAST (X, Y, Z)
-- return SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z);
type SDL_version is record
major : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_version.h:48
minor : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_version.h:49
patch : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_version.h:50
end record;
pragma Convention (C_Pass_By_Copy, SDL_version); -- ../include/SDL/SDL_version.h:47
function SDL_Linked_Version return System.Address; -- ../include/SDL/SDL_version.h:83
pragma Import (C, SDL_Linked_Version, "SDL_Linked_Version");
end SDL_SDL_version_h;
|
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with League.IRIs;
with League.Strings;
package Torrent.Trackers is
type Announcement_Kind is
(Started, Completed, Stopped, Regular);
function Event_URL
(Tracker : League.IRIs.IRI;
Info_Hash : SHA1;
Peer_Id : SHA1;
Port : Positive;
Uploaded : Ada.Streams.Stream_Element_Count;
Downloaded : Ada.Streams.Stream_Element_Count;
Left : Ada.Streams.Stream_Element_Count;
Event : Announcement_Kind) return League.IRIs.IRI;
-- Construct an URL to request a tracker.
type Response (<>) is tagged private;
function Parse (Data : Ada.Streams.Stream_Element_Array) return Response;
-- Decode tracker's response. Constraint_Error is raised if it fails.
function Is_Failure (Self : Response'Class) return Boolean;
-- If the query failed.
function Failure_Reason
(Self : Response'Class) return League.Strings.Universal_String;
-- A human readable string which explains why the query failed.
function Interval (Self : Response'Class) return Duration;
-- The number of seconds the downloader should wait between regular
-- rerequests.
function Peer_Count (Self : Response'Class) return Natural;
-- Length of peer lists.
function Peer_Id
(Self : Response'Class;
Index : Positive) return SHA1;
-- The peer's self-selected ID
function Peer_Address
(Self : Response'Class;
Index : Positive) return League.Strings.Universal_String;
-- The peer's IP address or DNS name.
function Peer_Port
(Self : Response'Class;
Index : Positive) return Natural;
-- The peer's port number.
private
type Peer is record
Id : SHA1;
Address : League.Strings.Universal_String;
Port : Natural;
end record;
type Peer_Array is array (Positive range <>) of Peer;
type Response (Peer_Count : Natural) is tagged record
Is_Failure : Boolean;
Failure_Reason : League.Strings.Universal_String;
Interval : Duration;
Peers : Peer_Array (1 .. Peer_Count);
end record;
end Torrent.Trackers;
|
package body Math_2D.Triangles is
use type Types.Real_Type;
use type Types.Point_t;
function Area
(Triangle : in Types.Triangle_t) return Types.Real_Type'Base
is
Point_A : Types.Point_t renames Triangle (1);
Point_B : Types.Point_t renames Triangle (2);
Point_C : Types.Point_t renames Triangle (3);
A : constant Types.Real_Type'Base := Point_A (1) - Point_C (1);
B : constant Types.Real_Type'Base := Point_A (2) - Point_C (2);
C : constant Types.Real_Type'Base := Point_B (1) - Point_C (1);
D : constant Types.Real_Type'Base := Point_B (2) - Point_C (2);
begin
return abs ((A * D) - (B * C)) / 2.0;
end Area;
function Orthocenter
(Triangle : in Types.Triangle_t) return Types.Point_t is
begin
return (Triangle (1)
+ Triangle (2)
+ Triangle (3)) / 3.0;
end Orthocenter;
function Perimeter
(Triangle : in Types.Triangle_t) return Types.Real_Type'Base
is
Point_A : Types.Point_t renames Triangle (1);
Point_B : Types.Point_t renames Triangle (2);
Point_C : Types.Point_t renames Triangle (3);
Distance_AB : constant Types.Real_Type'Base := Points.Distance (Point_A, Point_B);
Distance_BC : constant Types.Real_Type'Base := Points.Distance (Point_B, Point_C);
Distance_CA : constant Types.Real_Type'Base := Points.Distance (Point_C, Point_A);
begin
return Distance_AB + Distance_BC + Distance_CA;
end Perimeter;
function Point_Is_Inside
(Triangle : in Types.Triangle_t;
Point : in Types.Point_t) return Boolean
is
Point_A : Types.Point_t renames Triangle (1);
Point_B : Types.Point_t renames Triangle (2);
Point_C : Types.Point_t renames Triangle (3);
Sub_Tri_A : constant Types.Triangle_t := (Point, Point_A, Point_B);
Sub_Tri_B : constant Types.Triangle_t := (Point, Point_B, Point_C);
Sub_Tri_C : constant Types.Triangle_t := (Point, Point_A, Point_C);
Base_Area : constant Types.Real_Type'Base := Area (Triangle);
Area_A : constant Types.Real_Type'Base := Area (Sub_Tri_A);
Area_B : constant Types.Real_Type'Base := Area (Sub_Tri_B);
Area_C : constant Types.Real_Type'Base := Area (Sub_Tri_C);
Total_Area : constant Types.Real_Type'Base := Area_A + Area_B + Area_C;
begin
return Total_Area <= Base_Area;
end Point_Is_Inside;
end Math_2D.Triangles;
|
with Ada.Text_IO;
package body Trie is
package IO renames Ada.Text_IO;
procedure Add_Word(node : in out Trie_Node; word, partial : String; node_count : in out Natural) is
first : Character;
begin
if partial'Length = 0 then
node.is_terminal := true;
node.word := BoundedString.To_Bounded_String(word);
else
first := partial(partial'First);
if node.children(first) = null then
node_count := node_count + 1;
node.children(first) := new Trie_Node;
end if;
Add_Word(node.children(first).all, word, partial(partial'First + 1 .. partial'Last), node_count);
end if;
end Add_Word;
function Find_Partial(node : in Trie_Node_Access; word : String) return Trie_Node_Access is
begin
if node = null or else word'Length = 0 then
return node;
else
return Find_Partial(node.all.children(word(word'First)), word(word'First + 1 .. word'Last));
end if;
end Find_Partial;
function Make_Trie(filename : String) return Trie is
input : IO.File_Type;
result : Trie;
word : String (1 .. 32);
last : Natural;
begin
IO.Open(input, IO.In_File, filename);
result.node_count := 0;
result.root := new Trie_Node;
while not IO.End_Of_File(input) loop
IO.Get_Line(input, word, last);
if last = word'Last then
raise Constraint_Error;
elsif last > 3 and last < BoundedString.Max_Length then
Add_Word(result.root.all, word(1 .. last), word(1 .. last), result.node_count);
end if;
end loop;
return result;
end Make_Trie;
procedure Find_Words(words : Trie; fragments: String; endpoints: Fragment_Endpoint_Array) is
taken : Array (fragments'Range) of Boolean := (others => False);
procedure Find_Words_Helper(node : Trie_Node_Access ) is
new_node : Trie_Node_Access;
begin
for index in endpoints'Range loop
if not taken(index) then
new_node := Find_Partial(node, fragments(endpoints(index).first .. endpoints(index).last));
if new_node /= null then
taken(index) := True;
if new_node.all.is_terminal then
IO.Put_Line(BoundedString.To_String(new_node.all.word));
end if;
Find_Words_Helper(new_node);
taken(index) := False;
end if;
end if;
end loop;
end Find_Words_Helper;
begin
IO.Put_Line(fragments);
Find_Words_Helper(words.root);
end Find_Words;
end Trie;
|
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../../License.txt
package body AdaBase.Statement.Base is
------------------
-- successful --
------------------
overriding
function successful (Stmt : Base_Statement) return Boolean
is
begin
return Stmt.successful_execution;
end successful;
----------------------
-- data_discarded --
----------------------
overriding
function data_discarded (Stmt : Base_Statement) return Boolean
is
begin
return Stmt.rows_leftover;
end data_discarded;
---------------------
-- rows_affected --
---------------------
overriding
function rows_affected (Stmt : Base_Statement) return Affected_Rows
is
begin
if not Stmt.successful_execution then
raise PRIOR_EXECUTION_FAILED
with "Has query been executed yet?";
end if;
if Stmt.result_present then
raise INVALID_FOR_RESULT_SET
with "Result set found; use rows_returned";
else
return Stmt.impacted;
end if;
end rows_affected;
---------------------
-- transform_sql --
---------------------
function transform_sql (Stmt : out Base_Statement; sql : String)
return String
is
procedure reserve_marker;
sql_mask : String := CT.redact_quotes (sql);
procedure reserve_marker
is
brec : bindrec;
begin
brec.v00 := False;
Stmt.realmccoy.Append (New_Item => brec);
end reserve_marker;
begin
Stmt.alpha_markers.Clear;
Stmt.realmccoy.Clear;
if CT.IsBlank (sql) then
return "";
end if;
declare
-- This block does two things:
-- 1) finds "?" and increments the replacement index
-- 2) finds ":[A-Za-z0-9_]*", replaces with "?", increments the
-- replacement index, and pushes the string into alpha markers
-- Avoid replacing "::" which is casting on postgresql (in redact)
-- Normally ? and : aren't mixed but we will support it.
procedure replace_alias;
procedure lock_and_advance (symbol : Character);
start : Natural := 0;
final : Natural := 0;
arrow : Positive := 1;
polaris : Natural := 0;
scanning : Boolean := False;
product : String (1 .. sql'Length) := (others => ' ');
adjacent_error : constant String :=
"Bindings are not separated; they are touching: ";
procedure lock_and_advance (symbol : Character) is
begin
polaris := polaris + 1;
product (polaris) := symbol;
end lock_and_advance;
procedure replace_alias is
len : Natural := final - start;
alias : String (1 .. len) := sql_mask (start + 1 .. final);
begin
if Stmt.alpha_markers.Contains (Key => alias) then
raise ILLEGAL_BIND_SQL with "multiple instances of " & alias;
end if;
reserve_marker;
Stmt.alpha_markers.Insert (alias, Stmt.realmccoy.Last_Index);
scanning := False;
end replace_alias;
begin
loop
case sql_mask (arrow) is
when ASCII.Query =>
if scanning then
raise ILLEGAL_BIND_SQL
with adjacent_error & sql_mask (start .. arrow);
end if;
reserve_marker;
lock_and_advance (ASCII.Query);
when ASCII.Colon =>
if scanning then
raise ILLEGAL_BIND_SQL
with adjacent_error & sql_mask (start .. arrow);
end if;
scanning := True;
start := arrow;
when others =>
if scanning then
case sql_mask (arrow) is
when 'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '_' =>
final := arrow;
when others =>
replace_alias;
lock_and_advance (ASCII.Query);
lock_and_advance (sql (arrow));
end case;
else
lock_and_advance (sql (arrow));
end if;
end case;
if scanning and then arrow = sql_mask'Length then
replace_alias;
lock_and_advance (ASCII.Query);
end if;
exit when arrow = sql_mask'Length;
arrow := arrow + 1;
end loop;
return product (1 .. polaris);
end;
end transform_sql;
----------------------------------
-- convert string to textwide --
----------------------------------
function convert (nv : String) return AR.Textwide is
begin
return SUW.To_Unbounded_Wide_String (ACC.To_Wide_String (nv));
end convert;
-----------------------------------
-- convert string to textsuper --
-----------------------------------
function convert (nv : String) return AR.Textsuper is
begin
return SWW.To_Unbounded_Wide_Wide_String (ACC.To_Wide_Wide_String (nv));
end convert;
--------------------
-- Same_Strings --
--------------------
function Same_Strings (S, T : String) return Boolean is
begin
return S = T;
end Same_Strings;
-------------------
-- log_nominal --
-------------------
procedure log_nominal (statement : Base_Statement;
category : Log_Category;
message : String)
is
begin
logger_access.all.log_nominal
(driver => statement.dialect,
category => category,
message => CT.SUS (message));
end log_nominal;
--------------------
-- bind_proceed --
--------------------
function bind_proceed (Stmt : Base_Statement; index : Positive)
return Boolean is
begin
if not Stmt.successful_execution then
raise PRIOR_EXECUTION_FAILED
with "Use bind after 'execute' but before 'fetch_next'";
end if;
if index > Stmt.crate.Last_Index then
raise BINDING_COLUMN_NOT_FOUND
with "Index" & index'Img & " is too high; only" &
Stmt.crate.Last_Index'Img & " columns exist.";
end if;
return True;
end bind_proceed;
------------------
-- bind_index --
------------------
function bind_index (Stmt : Base_Statement; heading : String)
return Positive
is
use type Markers.Cursor;
cursor : Markers.Cursor;
begin
cursor := Stmt.headings_map.Find (Key => heading);
if cursor = Markers.No_Element then
raise BINDING_COLUMN_NOT_FOUND with
"There is no column named '" & heading & "'.";
end if;
return Markers.Element (Position => cursor);
end bind_index;
---------------------------------
-- check_bound_column_access --
---------------------------------
procedure check_bound_column_access (absent : Boolean) is
begin
if absent then
raise ILLEGAL_BIND_SQL with
"Binding column with null access is illegal";
end if;
end check_bound_column_access;
------------------------------------------------------
-- 23 bind functions (impossible to make generic) --
------------------------------------------------------
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte0_Access)
is
use type AR.NByte0_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_nbyte0, a00 => vaxx, v00 => False,
bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte1_Access)
is
use type AR.NByte1_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_nbyte1, a01 => vaxx, v01 => 0,
bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte2_Access)
is
use type AR.NByte2_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_nbyte2, a02 => vaxx, v02 => 0,
bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte3_Access)
is
use type AR.NByte3_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_nbyte3, a03 => vaxx, v03 => 0,
bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte4_Access)
is
use type AR.NByte4_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_nbyte4, a04 => vaxx, v04 => 0,
bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte8_Access)
is
use type AR.NByte8_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_nbyte8, a05 => vaxx, v05 => 0,
bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte1_Access)
is
use type AR.Byte1_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_byte1, a06 => vaxx, v06 => 0,
bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte2_Access)
is
use type AR.Byte2_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_byte2, a07 => vaxx, v07 => 0,
bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte3_Access)
is
use type AR.Byte3_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_byte3, a08 => vaxx, v08 => 0,
bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte4_Access)
is
use type AR.Byte4_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_byte4, a09 => vaxx, v09 => 0,
bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte8_Access)
is
use type AR.Byte8_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_byte8, a10 => vaxx, v10 => 0,
bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Real9_Access)
is
use type AR.Real9_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_real9, a11 => vaxx, v11 => 0.0,
bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Real18_Access)
is
use type AR.Real18_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_real18, a12 => vaxx, v12 => 0.0,
bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Str1_Access)
is
use type AR.Str1_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_textual, a13 => vaxx, v13 => CT.blank,
bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Str2_Access)
is
use type AR.Str2_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_widetext, a14 => vaxx, bound => True,
v14 => AR.Blank_WString, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Str4_Access)
is
use type AR.Str4_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_supertext, a15 => vaxx, bound => True,
v15 => AR.Blank_WWString, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Time_Access)
is
use type AR.Time_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_timestamp, a16 => vaxx,
v16 => CAL.Clock, bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Chain_Access)
is
use type AR.Chain_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_chain, a17 => vaxx,
v17 => CT.blank, bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Enum_Access)
is
use type AR.Enum_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_enumtype, a18 => vaxx, bound => True,
v18 => AR.PARAM_IS_ENUM, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Settype_Access)
is
use type AR.Settype_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_settype, a19 => vaxx,
v19 => CT.blank, bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Bits_Access)
is
use type AR.Bits_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_bits, a20 => vaxx,
v20 => CT.blank, bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.S_UTF8_Access)
is
use type AR.S_UTF8_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_utf8, a21 => vaxx,
v21 => CT.blank, bound => True, null_data => False));
end if;
end bind;
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Geometry_Access)
is
use type AR.Geometry_Access;
absent : Boolean := (vaxx = null);
begin
check_bound_column_access (absent);
if Stmt.bind_proceed (index => index) then
Stmt.crate.Replace_Element
(index, (output_type => ft_geometry, a22 => vaxx,
v22 => CT.blank, bound => True, null_data => False));
end if;
end bind;
------------------------------------------------------------------
-- bind via headings (believe me, generics are not possible) --
------------------------------------------------------------------
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.NByte0_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.NByte1_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.NByte2_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.NByte3_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.NByte4_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.NByte8_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Byte1_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Byte2_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Byte3_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Byte4_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Byte8_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Real9_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Real18_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Str1_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Str2_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Str4_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Time_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Chain_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Enum_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Settype_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Bits_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.S_UTF8_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Geometry_Access) is
begin
Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading));
end bind;
--------------------
-- assign_index --
--------------------
function assign_index (Stmt : Base_Statement; moniker : String)
return Positive
is
use type Markers.Cursor;
cursor : Markers.Cursor;
begin
cursor := Stmt.alpha_markers.Find (Key => moniker);
if cursor = Markers.No_Element then
raise MARKER_NOT_FOUND with
"There is no marker known as '" & moniker & "'.";
end if;
return Markers.Element (Position => cursor);
end assign_index;
------------------------------------------------------------------
-- assign via moniker (Access, 23) --
------------------------------------------------------------------
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte0_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte1_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte2_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte3_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte4_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte8_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte1_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte2_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte3_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte4_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte8_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Real9_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Real18_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Str1_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Str2_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Str4_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Time_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Chain_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Enum_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Settype_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Bits_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.S_UTF8_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Geometry_Access) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
------------------------------------------------------------------
-- assign via moniker (Value, 23) --
------------------------------------------------------------------
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte0) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte1) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte2) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte3) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte4) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte8) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte1) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte2) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte3) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte4) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte8) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Real9) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Real18) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Textual) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Textwide) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Textsuper) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : CAL.Time) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Chain) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Enumtype) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Settype) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Bits) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Text_UTF8) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : Spatial_Data.Geometry) is
begin
Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker));
end assign;
------------------------------------------------------
-- 23 + 23 = 46 assign functions --
------------------------------------------------------
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte0_Access)
is
use type AR.NByte0_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_nbyte0, a00 => vaxx, v00 => False,
bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte0) is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_nbyte0, a00 => null, v00 => vaxx,
bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte1_Access)
is
use type AR.NByte1_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_nbyte1, a01 => vaxx, v01 => 0,
bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte1) is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_nbyte1, a01 => null, v01 => vaxx,
bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte2_Access)
is
use type AR.NByte2_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_nbyte2, a02 => vaxx, v02 => 0,
bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte2) is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_nbyte2, a02 => null, v02 => vaxx,
bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte3_Access)
is
use type AR.NByte3_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_nbyte3, a03 => vaxx, v03 => 0,
bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte3) is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_nbyte3, a03 => null, v03 => vaxx,
bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte4_Access)
is
use type AR.NByte4_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_nbyte4, a04 => vaxx, v04 => 0,
bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte4) is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_nbyte4, a04 => null, v04 => vaxx,
bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte8_Access)
is
use type AR.NByte8_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_nbyte8, a05 => vaxx, v05 => 0,
bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte8) is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_nbyte8, a05 => null, v05 => vaxx,
bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte1_Access)
is
use type AR.Byte1_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_byte1, a06 => vaxx, v06 => 0,
bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte1) is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_byte1, a06 => null, v06 => vaxx,
bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte2_Access)
is
use type AR.Byte2_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_byte2, a07 => vaxx, v07 => 0,
bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte2) is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_byte2, a07 => null, v07 => vaxx,
bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte3_Access)
is
use type AR.Byte3_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_byte3, a08 => vaxx, v08 => 0,
bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte3) is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_byte3, a08 => null, v08 => vaxx,
bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte4_Access)
is
use type AR.Byte4_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_byte4, a09 => vaxx, v09 => 0,
bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte4) is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_byte4, a09 => null, v09 => vaxx,
bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte8_Access)
is
use type AR.Byte8_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_byte8, a10 => vaxx, v10 => 0,
bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte8) is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_byte8, a10 => null, v10 => vaxx,
bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Real9_Access)
is
use type AR.Real9_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_real9, a11 => vaxx, v11 => 0.0,
bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Real9) is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_real9, a11 => null, v11 => vaxx,
bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Real18_Access)
is
use type AR.Real18_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_real18, a12 => vaxx, v12 => 0.0,
bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Real18) is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_real18, a12 => null, v12 => vaxx,
bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Str1_Access)
is
use type AR.Str1_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_textual, a13 => vaxx, v13 => CT.blank,
bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Textual) is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_textual, a13 => null, v13 => vaxx,
bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Str2_Access)
is
use type AR.Str2_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_widetext, a14 => vaxx,
v14 => AR.Blank_WString, bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Textwide) is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_widetext, a14 => null, v14 => vaxx,
bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Str4_Access)
is
use type AR.Str4_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_supertext, a15 => vaxx, bound => True,
v15 => AR.Blank_WWString, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Textsuper) is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_supertext, a15 => null, v15 => vaxx,
bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Time_Access)
is
use type AR.Time_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_timestamp, a16 => vaxx,
v16 => CAL.Clock, bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : CAL.Time) is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_timestamp, a16 => null, v16 => vaxx,
bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Chain_Access)
is
use type AR.Chain_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_chain, a17 => vaxx,
v17 => CT.blank, bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Chain)
is
payload : constant String := ARC.convert (vaxx);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_chain, a17 => null,
v17 => CT.SUS (payload), bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Enum_Access)
is
use type AR.Enum_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_enumtype, a18 => vaxx,
v18 => AR.PARAM_IS_ENUM, bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Enumtype) is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_enumtype, a18 => null, v18 => vaxx,
bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Settype_Access)
is
use type AR.Settype_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_settype, a19 => vaxx,
v19 => CT.blank, bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Settype)
is
payload : AR.Textual := CT.blank;
begin
for x in vaxx'Range loop
if x /= vaxx'First then
CT.SU.Append (payload, ",");
end if;
CT.SU.Append (payload, vaxx (x).enumeration);
end loop;
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_settype, a19 => null,
v19 => payload, bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Bits_Access)
is
use type AR.Bits_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_bits, a20 => vaxx,
v20 => CT.blank, bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Bits)
is
payload : constant String := ARC.convert (vaxx);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_bits, a20 => null,
v20 => CT.SUS (payload), bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.S_UTF8_Access)
is
use type AR.S_UTF8_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_utf8, a21 => vaxx,
v21 => CT.blank, bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Text_UTF8)
is
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_utf8, a21 => null,
v21 => CT.SUS (vaxx), bound => True, null_data => False));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Geometry_Access)
is
use type AR.Geometry_Access;
absent : Boolean := (vaxx = null);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_geometry, a22 => vaxx,
v22 => CT.blank, bound => True, null_data => absent));
end assign;
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : Spatial_Data.Geometry)
is
shape : String := Spatial_Data.Well_Known_Text (vaxx);
begin
Stmt.realmccoy.Replace_Element
(index, (output_type => ft_geometry, a22 => null,
v22 => CT.SUS (shape), bound => True, null_data => False));
end assign;
------------------
-- iterate #1 --
------------------
overriding
procedure iterate (Stmt : out Base_Statement;
process : not null access procedure) is
begin
loop
exit when not fetch_bound (Stmt => Base_Statement'Class (Stmt));
process.all;
end loop;
end iterate;
------------------
-- iterate #2 --
------------------
overriding
procedure iterate (Stmt : out Base_Statement;
process : not null access procedure (row : ARS.Datarow))
is
begin
loop
declare
local_row : ARS.Datarow :=
fetch_next (Stmt => Base_Statement'Class (Stmt));
begin
exit when local_row.data_exhausted;
process.all (row => local_row);
end;
end loop;
end iterate;
-------------------
-- auto_assign --
-------------------
procedure auto_assign (Stmt : out Base_Statement; index : Positive;
value : String)
is
zone : bindrec renames Stmt.realmccoy.Element (index);
ST : AR.Textual;
STW : AR.Textwide;
STS : AR.Textsuper;
hold : ARF.Variant;
begin
case zone.output_type is
when ft_widetext =>
ST := CT.SUS (value);
STW := SUW.To_Unbounded_Wide_String (ARC.convert (ST));
when ft_supertext =>
ST := CT.SUS (value);
STS := SWW.To_Unbounded_Wide_Wide_String (ARC.convert (ST));
when ft_timestamp | ft_settype | ft_chain =>
null;
when others =>
ST := CT.SUS (value);
end case;
case zone.output_type is
when ft_nbyte0 => hold := (ft_nbyte0, ARC.convert (ST));
when ft_nbyte1 => hold := (ft_nbyte1, ARC.convert (ST));
when ft_nbyte2 => hold := (ft_nbyte2, ARC.convert (ST));
when ft_nbyte3 => hold := (ft_nbyte3, ARC.convert (ST));
when ft_nbyte4 => hold := (ft_nbyte4, ARC.convert (ST));
when ft_nbyte8 => hold := (ft_nbyte8, ARC.convert (ST));
when ft_byte1 => hold := (ft_byte1, ARC.convert (ST));
when ft_byte2 => hold := (ft_byte2, ARC.convert (ST));
when ft_byte3 => hold := (ft_byte3, ARC.convert (ST));
when ft_byte4 => hold := (ft_byte4, ARC.convert (ST));
when ft_byte8 => hold := (ft_byte8, ARC.convert (ST));
when ft_real9 => hold := (ft_real9, ARC.convert (ST));
when ft_real18 => hold := (ft_real18, ARC.convert (ST));
when ft_textual => hold := (ft_textual, ST);
when ft_widetext => hold := (ft_widetext, STW);
when ft_supertext => hold := (ft_supertext, STS);
when ft_timestamp => hold := (ft_timestamp, (ARC.convert (value)));
when ft_chain => null;
when ft_enumtype => hold := (ft_enumtype, (ARC.convert (ST)));
when ft_settype => null;
when ft_bits => null;
when ft_utf8 => hold := (ft_utf8, ST);
when ft_geometry => hold := (ft_geometry, ST); -- ST=WKB
end case;
case zone.output_type is
when ft_nbyte0 => Stmt.assign (index, hold.v00);
when ft_nbyte1 => Stmt.assign (index, hold.v01);
when ft_nbyte2 => Stmt.assign (index, hold.v02);
when ft_nbyte3 => Stmt.assign (index, hold.v03);
when ft_nbyte4 => Stmt.assign (index, hold.v04);
when ft_nbyte8 => Stmt.assign (index, hold.v05);
when ft_byte1 => Stmt.assign (index, hold.v06);
when ft_byte2 => Stmt.assign (index, hold.v07);
when ft_byte3 => Stmt.assign (index, hold.v08);
when ft_byte4 => Stmt.assign (index, hold.v09);
when ft_byte8 => Stmt.assign (index, hold.v10);
when ft_real9 => Stmt.assign (index, hold.v11);
when ft_real18 => Stmt.assign (index, hold.v12);
when ft_textual => Stmt.assign (index, hold.v13);
when ft_widetext => Stmt.assign (index, hold.v14);
when ft_supertext => Stmt.assign (index, hold.v15);
when ft_timestamp => Stmt.assign (index, hold.v16);
when ft_enumtype => Stmt.assign (index, hold.v18);
when ft_utf8 => Stmt.assign (index, hold.v21);
when ft_geometry => Stmt.assign (index, hold.v22);
when ft_chain =>
declare
my_chain : AR.Chain := ARC.convert (value);
begin
Stmt.assign (index, my_chain);
end;
when ft_settype =>
declare
set : AR.Settype := ARC.convert (value);
begin
Stmt.assign (index, set);
end;
when ft_bits =>
declare
bitchain : AR.Bits := ARC.convert (value);
begin
Stmt.assign (index, bitchain);
end;
end case;
end auto_assign;
------------------
-- set_as_null --
-------------------
procedure set_as_null (param : bindrec)
is
data_type : field_types := param.output_type;
begin
case data_type is
when ft_nbyte0 => param.a00.all := AR.PARAM_IS_BOOLEAN;
when ft_nbyte1 => param.a01.all := AR.PARAM_IS_NBYTE_1;
when ft_nbyte2 => param.a02.all := AR.PARAM_IS_NBYTE_2;
when ft_nbyte3 => param.a03.all := AR.PARAM_IS_NBYTE_3;
when ft_nbyte4 => param.a04.all := AR.PARAM_IS_NBYTE_4;
when ft_nbyte8 => param.a05.all := AR.PARAM_IS_NBYTE_8;
when ft_byte1 => param.a06.all := AR.PARAM_IS_BYTE_1;
when ft_byte2 => param.a07.all := AR.PARAM_IS_BYTE_2;
when ft_byte3 => param.a08.all := AR.PARAM_IS_BYTE_3;
when ft_byte4 => param.a09.all := AR.PARAM_IS_BYTE_4;
when ft_byte8 => param.a10.all := AR.PARAM_IS_BYTE_8;
when ft_real9 => param.a11.all := AR.PARAM_IS_REAL_9;
when ft_real18 => param.a12.all := AR.PARAM_IS_REAL_18;
when ft_textual => param.a13.all := AR.PARAM_IS_TEXTUAL;
when ft_widetext => param.a14.all := AR.PARAM_IS_TEXTWIDE;
when ft_supertext => param.a15.all := AR.PARAM_IS_TEXTSUPER;
when ft_timestamp => param.a16.all := AR.PARAM_IS_TIMESTAMP;
when ft_enumtype => param.a18.all := AR.PARAM_IS_ENUM;
when ft_chain => param.a17.all :=
ARC.convert ("", param.a17.all'Length);
when ft_settype => param.a19.all :=
ARC.convert ("", param.a19.all'Length);
when ft_bits => param.a20.all :=
ARC.convert ("", param.a20.all'Length);
when ft_utf8 => param.a21.all := AR.PARAM_IS_TEXT_UTF8;
when ft_geometry => param.a22.all := GEO.initialize_as_point
(GEO.Origin_Point);
end case;
end set_as_null;
end AdaBase.Statement.Base;
|
-- Demonstration of the compiler-defined attribute: 'Scalar_Storage_Order
-- The expected output:
-- L: 1000000 0100000 1100000 0010000 1010000 0110000 1110000 0001000
-- B: 0000001 0000010 0000011 0000100 0000101 0000110 0000111 0001000
with Ada.Text_IO;
with System;
procedure bswap is
type Unsigned_7 is mod 2 ** 7;
type NA is array (1 .. 8) of Unsigned_7;
for NA'Component_Size use 7;
for NA'Size use 56;
type LA is new NA; -- little endian
for LA'Scalar_Storage_Order use System.Low_Order_First;
type BA is new NA; -- big endian
for BA'Scalar_Storage_Order use System.High_Order_First;
N_Data : constant NA := (1, 2, 3, 4, 5, 6, 7, 8);
L_Data : aliased LA := LA (N_Data);
B_Data : aliased BA := BA (N_Data);
begin
pragma Assert (LA'Size = 56);
pragma Assert (BA'Size = 56);
for I in NA'Range loop
pragma Assert (L_Data (I) = B_Data (I));
null;
end loop;
declare
type Unsigned_1 is mod 2;
for Unsigned_1'Size use 1;
use Ada.Text_IO;
package Unsigned_1_IO is new Modular_IO (Unsigned_1);
use Unsigned_1_IO;
begin
-- dump L_Data
declare
type LR is array (0 .. NA'Size - 1) of Unsigned_1;
for LR'Component_Size use 1;
for LR'Size use 56;
for LR'Scalar_Storage_Order use System.Low_Order_First;
L_Repr : LR;
for L_Repr'Address use L_Data'Address;
begin
Put ("L:");
for I in LR'Range loop
if I mod 7 = 0 then
Put (' ');
end if;
Put (L_Repr (I), Width => 1);
end loop;
New_Line;
end;
-- dump B_Data
declare
type BR is array (0 .. NA'Size - 1) of Unsigned_1;
for BR'Component_Size use 1;
for BR'Size use 56;
for BR'Scalar_Storage_Order use System.High_Order_First;
B_Repr : BR;
for B_Repr'Address use B_Data'Address;
begin
Put ("B:");
for I in BR'Range loop
if I mod 7 = 0 then
Put (' ');
end if;
Put (B_Repr (I), Width => 1);
end loop;
New_Line;
end;
end;
end bswap;
|
with STM32GD.GPIO; use STM32GD.GPIO;
with STM32GD.GPIO.Pin;
with STM32GD.USART;
with STM32GD.USART.Peripheral;
with STM32GD.SPI;
with STM32GD.SPI.Peripheral;
with STM32GD.RTC;
with STM32GD.Clock;
with STM32GD.Clock.Tree;
with Drivers.Text_IO;
package STM32GD.Board is
package CLOCKS is new STM32GD.Clock.Tree;
package SCLK is new Pin (Pin => Pin_5, Port => Port_A, Mode => Mode_AF);
package MISO is new Pin (Pin => Pin_6, Port => Port_A, Mode => Mode_AF);
package MOSI is new Pin (Pin => Pin_7, Port => Port_A, Mode => Mode_AF);
package CSN is new Pin (Pin => Pin_6, Port => Port_B, Mode => Mode_Out);
package BUTTON is new Pin (Pin => Pin_13, Port => Port_C);
package LED is new Pin (Pin => Pin_5, Port => Port_A, Mode => Mode_Out);
package LED2 is new Pin (Pin => Pin_8, Port => Port_C, Mode => Mode_Out);
package LED3 is new Pin (Pin => Pin_6, Port => Port_C, Mode => Mode_Out);
package TX is new Pin (Pin => Pin_2, Port => Port_A,
Pull_Resistor => Pull_Up,
Mode => Mode_AF, Alternate_Function => 1);
package RX is new Pin (Pin => Pin_3, Port => Port_A,
Pull_Resistor => Pull_Up,
Mode => Mode_AF, Alternate_Function => 1);
package USART is new STM32GD.USART.Peripheral (
USART => STM32GD.USART.USART_2,
Speed => 115200, RX_DMA_Buffer_Size => 64,
Clock_Tree => CLOCKS,
Clock => STM32GD.Clock.PCLK);
package RTC is new STM32GD.RTC (Clock_Tree => STM32GD.Board.Clocks,
Clock => STM32GD.Clock.LSI);
package SPI is new STM32GD.SPI.Peripheral (SPI => STM32GD.SPI.SPI_1);
package Text_IO is new Drivers.Text_IO (USART => STM32GD.Board.USART);
procedure Init;
end STM32GD.Board;
|
with Ada.Streams; use Ada.Streams;
with Interfaces;
package SHA1 with
Pure,
Preelaborate,
SPARK_Mode => On
is
-- @summary
-- Secure Hash Algorithm 1 implementation in Ada/SPARK
--
-- @description
-- This package provides an implementation of SHA1 algorithm
pragma Compile_Time_Error
(Stream_Element'Modulus /= 256,
"'Stream_Element' type must be mod 2**8, i.e. represent a byte");
Digest_Length : constant Stream_Element_Offset := 20;
-- Length (in bytes) of the hash result
Block_Length : constant Stream_Element_Offset := 64;
-- Block length (in bytes), not very useful for the end user
subtype Digest is Stream_Element_Array (0 .. Digest_Length - 1);
-- Type representing the result of a hash function
type Context is private;
-- Algorithm context, holds all of the necessary internal data. Always
-- initialized with correct data, calling Initialize() functions is not
-- required but is strongly advised.
function Initialize return Context;
-- Initialize a Context properly. By default Context is already holding
-- all of the necessary initialization values, this function is provided
-- mainly for compatibility with other implementations.
-- @return An initialized context
procedure Initialize (Ctx : out Context);
-- Ditto, but as a procedure.
procedure Update (Ctx : in out Context; Input : String);
-- Update Ctx with data from Input
procedure Update (Ctx : in out Context; Input : Stream_Element_Array);
-- Update Ctx with data from Input
function Finalize (Ctx : Context) return Digest;
-- Compute hash value and return it.
procedure Finalize (Ctx : Context; Output : out Digest);
-- Ditto, but as a procedure.
function Hash (Input : String) return Digest;
-- Compute hash of Input and return it. Essentially is an equivalent of
-- Initialize, Update(Input) and Finalize.
function Hash (Input : Stream_Element_Array) return Digest;
-- Compute hash of Input and return it. Essentially is an equivalent of
-- Initialize, Update(Input) and Finalize
private
use Interfaces;
subtype Block is Stream_Element_Array (0 .. Block_Length - 1);
type State_Array is array (Natural range 0 .. 4) of Unsigned_32;
type Context is record
State : State_Array :=
(16#6745_2301#, 16#EFCD_AB89#, 16#98BA_DCFE#, 16#1032_5476#,
16#C3D2_E1F0#);
Count : Stream_Element_Offset := 0;
Buffer : Block;
end record;
procedure Transform (Ctx : in out Context);
pragma Inline (Transform);
end SHA1;
|
-- Copyright ©2021,2022 Steve Merrony
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-- THE SOFTWARE.
package body Display_P is
protected body Display is
procedure Set_Dirty is begin Dirty := True; end Set_Dirty;
procedure Clear_Dirty is begin Dirty := False; end Clear_Dirty;
function Is_Dirty return Boolean is (Dirty);
function Get_Visible_Cols return Positive is (Disp.Visible_Cols);
function Get_Visible_Lines return Positive is (Disp.Visible_Lines);
procedure Set_Visible_Cols (Cols : in Positive) is begin Disp.Visible_Cols := Cols; end Set_Visible_Cols;
procedure Set_Visible_Lines (Lines : in Positive) is begin Disp.Visible_Lines := Lines; end Set_Visible_Lines;
function Is_Blink_Enabled return Boolean is (Disp.Blink_Enabled);
procedure Set_Blink_Enabled (Blink : in Boolean) is begin Disp.Blink_Enabled := Blink; end Set_Blink_Enabled;
function Get_Cursor_X return Natural is (Disp.Cursor_X);
function Get_Cursor_Y return Natural is (Disp.Cursor_Y);
procedure Init is
begin
Disp.Visible_Lines := Default_Lines;
Disp.Visible_Cols := Default_Cols;
for Line in 0 .. Total_Lines - 1 loop
for Col in 0 .. Total_Cols - 1 loop
Disp.Cells(Line, Col).Clear_To_Space;
end loop;
end loop;
Disp.Cells(12,39).Set (Value => 'O', Blnk => False, Dm => False, Rv => False, Under => False, Prot => False);
Disp.Cells(12,40).Set (Value => 'K', Blnk => False, Dm => False, Rv => False, Under => False, Prot => False);
Disp.Blink_Enabled := True;
History.First := 0;
History.Last := 0;
for C in Empty_History_Line'Range loop
Empty_History_Line(C).Clear_To_Space;
end loop;
for HL in History.Lines'Range loop
for Col in 0 .. Total_Cols - 1 loop
History.Lines(HL)(Col).Clear_To_Space;
end loop;
end loop;
Set_Scrolled_Back (False);
end Init;
procedure Copy (Src : in out Display_T; Dest : out Display_T) is
begin
for Line in 0 .. Src.Visible_Lines-1 loop
for Col in 0 .. Src.Visible_Cols-1 loop
Cell.Copy (Src => Src.Cells(Line,Col), Dest => Dest.Cells(Line,Col));
end loop;
end loop;
Dest.Blink_Enabled := Src.Blink_Enabled;
Dest.Cursor_X := Src.Cursor_X;
Dest.Cursor_Y := Src.Cursor_Y;
Dest.Visible_Cols := Src.Visible_Cols;
Dest.Visible_Lines := Src.Visible_Lines;
end Copy;
procedure Clear_Cell (Line, Col : in Natural) is
begin
Disp.Cells(Line, Col).Clear_To_Space;
end Clear_Cell;
procedure Clear_Unprotected_Cell (Line, Col : in Natural) is
begin
Disp.Cells(Line, Col).Clear_If_Unprotected;
end Clear_Unprotected_Cell;
procedure Get_Cell (Line, Col : in Natural; Value : out Character; Blnk, Dm, Rv, Under, Prot : out Boolean) is
begin
Disp.Cells(Line,Col).Get (Value => Value, Blnk => Blnk, Dm => Dm, Rv => Rv, Under => Under, Prot => Prot);
end Get_Cell;
procedure Set_Cell (Line, Col : in Natural; Char : in Character;
Blink, Dim, Rev, Under, Prot : in Boolean) is
begin
Disp.Cells(Line,Col).Set (Value => Char, Blnk => Blink, Dm => Dim,
Rv => Rev, Under => Under, Prot => Prot);
end Set_Cell;
procedure Set_Cursor (X, Y : in Natural) is
begin
Disp.Cursor_X := X;
Disp.Cursor_Y := Y;
end Set_Cursor;
procedure Clear_Line (Line : in Integer) is
begin
for Col in 0 .. Total_Cols - 1 loop
Disp.Cells(Line, Col).Clear_To_Space;
end loop;
end Clear_Line;
procedure Copy_Line (Src, Dest : in Integer) is
begin
for Col in 0 .. Total_Cols - 1 loop
Cell.Copy (Src => Disp.Cells(Src,Col), Dest => Disp.Cells(Dest,Col));
end loop;
end Copy_Line;
procedure Copy_Line_To_History (Src : in Integer) is
begin
History.Last := History.Last + 1;
if History.Last = History_Lines then
-- wrap-around
History.Last := 0;
end if;
-- has the tail hit the head?
if History.Last = History.First then
History.First := History.First + 1;
if History.First = History_Lines then
History.First := 0;
end if;
end if;
for C in History.Lines(History.Last)'Range loop
Cell.Copy (Src => Disp.Cells(Src,C), Dest => History.Lines(History.Last)(C));
end loop;
end Copy_Line_To_History;
procedure Copy_Line_From_History (Src, Dest : in Natural) is
HL : History_Line;
Ix : Integer;
begin
if History.First = History.Last then -- no history yet
for C in Empty_History_Line'Range loop
Cell.Copy (Src => Empty_History_Line(C), Dest => HL(C));
end loop;
else
Ix := History.Last - Src;
if Ix < 0 then
Ix := Ix + History_Lines;
end if;
for C in History.Lines(Ix)'Range loop
Cell.Copy (Src => History.Lines(Ix)(C), Dest => HL(C));
end loop;
end if;
for Col in 0 .. Total_Cols - 1 loop
Cell.Copy (Src => HL(Col), Dest => Disp.Cells(Dest,Col));
end loop;
end Copy_Line_From_History;
procedure Scroll_Up (Lines : in Natural) is
begin
for L in 1 .. Lines loop
Copy_Line_To_History (0);
for R in 1 .. Disp.Visible_Lines loop
Copy_Line (Src => R, Dest => R - 1);
Clear_Line (R);
end loop;
Clear_Line (Disp.Visible_Lines - 1);
end loop;
end Scroll_Up;
function Is_Scrolled_Back return Boolean is
(Scrolled_Back);
procedure Set_Scrolled_Back (Back : in Boolean) is
begin
Scrolled_Back := Back;
end Set_Scrolled_Back;
procedure Scroll_Back (Start_Line : in Natural) is
begin
if not Scrolled_Back then
Copy (Src => Disp, Dest => Saved_Disp);
Scrolled_Back := True;
end if;
-- there are two cases: we are already scrolled back beyond the 'live' screen,
-- or we are partially showing it
if Start_Line < Disp.Visible_Lines then
declare
On_Screen_Line, Live_Line : Natural := 0;
begin
for HL in reverse 0 .. Start_Line loop
Copy_Line_From_History (HL, On_Screen_Line);
On_Screen_Line := On_Screen_Line + 1;
end loop;
while On_Screen_Line < Disp.Visible_Lines loop
Copy_Line_From_History (Live_Line, On_Screen_Line);
Live_Line := Live_Line + 1;
On_Screen_Line := On_Screen_Line + 1;
end loop;
end;
else
-- all 'history' - easier
for L in 0 .. Disp.Visible_Lines loop
Copy_Line_From_History (Start_Line - L, L);
end loop;
end if;
Set_Dirty;
end Scroll_Back;
procedure Cancel_Scroll_Back is
begin
Copy (Src => Saved_Disp, Dest => Disp);
Scrolled_Back := False;
Set_Dirty;
end Cancel_Scroll_Back;
end Display;
end Display_P; |
package Aggr21_Pkg is
type Rec is record
A : Integer;
S : String (1 .. 120);
N : Natural;
end record;
procedure Init (R : out Rec);
end Aggr21_Pkg;
|
pragma License (Unrestricted);
-- implementation unit required by compiler
package System.WWd_Enum is
pragma Pure;
-- (s-wchcon.ads)
type WC_Encoding_Method is range 1 .. 6;
-- required for Enum'Wide_Width by compiler (s-wwdenu.ads)
function Wide_Width_Enumeration_8 (
Names : String;
Indexes : Address;
Lo, Hi : Natural;
EM : WC_Encoding_Method := 1)
return Natural;
function Wide_Width_Enumeration_16 (
Names : String;
Indexes : Address;
Lo, Hi : Natural;
EM : WC_Encoding_Method := 1)
return Natural;
function Wide_Width_Enumeration_32 (
Names : String;
Indexes : Address;
Lo, Hi : Natural;
EM : WC_Encoding_Method := 1)
return Natural;
pragma Pure_Function (Wide_Width_Enumeration_8);
pragma Pure_Function (Wide_Width_Enumeration_16);
pragma Pure_Function (Wide_Width_Enumeration_32);
pragma Inline (Wide_Width_Enumeration_8);
pragma Inline (Wide_Width_Enumeration_16);
pragma Inline (Wide_Width_Enumeration_32);
-- required for Enum'Wide_Wide_Width by compiler (s-wwdenu.ads)
function Wide_Wide_Width_Enumeration_8 (
Names : String;
Indexes : Address;
Lo, Hi : Natural;
EM : WC_Encoding_Method := 1)
return Natural;
function Wide_Wide_Width_Enumeration_16 (
Names : String;
Indexes : Address;
Lo, Hi : Natural;
EM : WC_Encoding_Method := 1)
return Natural;
function Wide_Wide_Width_Enumeration_32 (
Names : String;
Indexes : Address;
Lo, Hi : Natural;
EM : WC_Encoding_Method := 1)
return Natural;
pragma Pure_Function (Wide_Wide_Width_Enumeration_8);
pragma Pure_Function (Wide_Wide_Width_Enumeration_16);
pragma Pure_Function (Wide_Wide_Width_Enumeration_32);
pragma Inline (Wide_Wide_Width_Enumeration_8);
pragma Inline (Wide_Wide_Width_Enumeration_16);
pragma Inline (Wide_Wide_Width_Enumeration_32);
-- [gcc 4.5/4.6] it needs default values for EM to avoiding bug of compiler
-- (missing argument for parameter "EM" in call to ...)
end System.WWd_Enum;
|
with
openGL.Errors,
openGL.Tasks,
GL.Pointers;
package body openGL.Buffer.general
is
--------------------------
-- 'vertex buffer' Object
--
package body Forge
is
function to_Buffer (From : access constant Element_Array;
Usage : in Buffer.Usage) return Object
is
use GL.Pointers;
begin
Tasks.check;
return new_Buffer : Object
do
new_Buffer.Usage := Usage;
new_Buffer.Length := From'Length;
new_Buffer.verify_Name;
new_Buffer.enable;
glBufferData (to_GL_Enum (new_Buffer.Kind),
From.all'Size / 8,
+From (From'First)'Address,
to_GL_Enum (Usage));
Errors.log;
end return;
end to_Buffer;
function to_Buffer (From : in Element_Array;
Usage : in Buffer.Usage) return Object
is
use GL.Pointers;
begin
Tasks.check;
return new_Buffer : Object
do
new_Buffer.Usage := Usage;
new_Buffer.Length := From'Length;
new_Buffer.verify_Name;
new_Buffer.enable;
glBufferData (to_GL_Enum (new_Buffer.Kind),
From'Size / 8,
+From (From'First)'Address,
to_GL_Enum (Usage));
end return;
end to_Buffer;
end Forge;
procedure set (Self : in out Object; Position : in Positive := 1;
To : in Element_Array)
is
use GL.Pointers;
new_Vertices : aliased Element_Array := To;
Vertex_Size_in_bits : constant Natural := To (To'First)'Size;
begin
Tasks.check;
if Self.Length = To'Length
then
Self.enable;
glBufferSubData (Target => to_GL_Enum (Self.Kind),
Offset => GLintptr ((Position - 1) * Vertex_Size_in_bits / 8),
Size => new_Vertices'Size / 8,
Data => +new_Vertices (new_Vertices'First)'Address);
else
Self.destroy;
Self.verify_Name;
Self.Length := To'Length;
Self.enable;
glBufferData (to_GL_Enum (Self.Kind),
To'Size / 8,
+To (To'First)'Address,
to_GL_Enum (Self.Usage));
end if;
Errors.log;
end set;
procedure set (Self : in out Object; Position : in Positive := 1;
To : access constant Element_Array)
is
begin
Self.set (Position, To.all);
end set;
end openGL.Buffer.general;
|
-- public domain
with Ada.Calendar;
with Ada.Strings.Maps;
with Interfaces;
package String_Ops is
pragma Elaborate_Body;
type String_Pointer_Type is access String;
-- All the control characters plus space and non-breaking-space.
--
function Is_White_Space
(Char : in Character) return Boolean;
-- The Stuff routines place the source into the target,
-- padding with space or zeros.
--
procedure Stuff
(This : in String;
Into : out String);
procedure Stuff_Right
(This : in String;
Into : out String);
procedure Stuff_Number
(Number : in Integer;
Into : out String);
procedure Stuff_Hex
(Number : in Interfaces.Unsigned_32;
Into : out String);
-- Kills Ada comments from The_String
--
function Drop_Ada_Comments
(The_String : String) return String;
function Drop_Vole_Comments
(The_String : String) return String;
function Up_Case
(The_String : String) return String;
function Down_Case
(The_String : String) return String;
-- Discards blanks from the front and back end
-- of The_String.
--
function Trim_Blanks
(The_String : String) return String;
-- Many times the important string will be enclosed in
-- quotation marks or brackets. This trims one character
-- off of each end.
--
function Trim_One_From_Both_Ends(The_String : String) return String;
-- Discards non-printable characters from
-- The_String.
--
function Filter
(The_String : String) return String;
-- Return the first substring of Str (deliniated by white space).
-- Note: Str is assumed to not start with white space.
--
function First
(Str : in String) return String;
-- Return the second part of Str.
--
function Rest
(Str : in String) return String;
-- Return the second substring of Str (deliniated by white space).
--
function Second
(Str : in String) return String;
-- This returns the Rest of the Rest.
--
function Second_Rest
(Str : in String) return String;
-- Return the third substring of Str (deliniated by white space).
--
function Third
(Str : in String) return String;
-- Return the Nth substring of Str (deliniated by white space).
--
function Nth
(Str : in String;
N : in Positive) return String;
-- Return the Nth substring of Str (deliniated by Set).
--
function Nth
(Str : in String;
N : in Positive;
Set : in Ada.Strings.Maps.Character_Set) return String;
-- This is a caseless compare.
--
function Same(L, R : in String) return Boolean;
-- This is a specialized "=" for strings. For
-- the length of the smaller of Check and Master,
-- both strings must be the same.
--
function Conformance
(Master : in String;
Check : in String) return Boolean;
-- Returns a string in the form "16#0000_0000#"
--
function Integer_To_Hex_String
(Value : in Interfaces.Unsigned_32) return String;
-- These return images without leading blanks.
--
function Str
(Int : Integer) return String;
function Str
(Int : Interfaces.Unsigned_32) return String;
-- This "image" routine will only resort to scientific notation
-- if the number is too large or too small.
--
function Img
(Flt : Float) return String;
-- This will take a number (floating point or integer) from the
-- string and return a Float.
--
function Value
(Str : String) return Float;
function Img
(Int : Integer) return String renames Str;
function Value
(Str : String) return Integer;
function Long_Date
(Date : in Ada.Calendar.Time := Ada.Calendar.Clock) return String;
function Short_Date
(Date : in Ada.Calendar.Time := Ada.Calendar.Clock) return String;
function Date_As_Filename
(Date : in Ada.Calendar.Time := Ada.Calendar.Clock) return String;
function IP_Address
(Addr : Interfaces.Unsigned_32) return String;
-----------------------------------------------------------------------------
generic
type Selection_Type is (<>); -- enumeration
package Selection_Ops is
-- Return true if and only if Str passes "Conformance"
-- to the image of a member of Selection_Type.
-- Str is up cased before conformance checking.
--
function String_Matches
(Str : in String) return Boolean;
-- Return the number of "Conformance" matches.
--
function String_Matches
(Str : in String) return Natural;
-- Returns the first member of Selection_Type to
-- conform to Str, or the first member of
-- Selection_Type.
--
function To_Selection
(Str : in String) return Selection_Type;
end Selection_Ops;
end String_Ops;
|
-- ----------------------------------------------------------------- --
-- AdaSDL --
-- Binding to Simple Direct Media Layer --
-- Copyright (C) 2001 A.M.F.Vargas --
-- Antonio M. F. Vargas --
-- Ponta Delgada - Azores - Portugal --
-- http://www.adapower.net/~avargas --
-- E-mail: avargas@adapower.net --
-- ----------------------------------------------------------------- --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public --
-- License as published by the Free Software Foundation; either --
-- version 2 of the License, or (at your option) any later version. --
-- --
-- This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public --
-- License along with this library; if not, write to the --
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, --
-- Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
-- ----------------------------------------------------------------- --
-- **************************************************************** --
-- This is an Ada binding to SDL ( Simple DirectMedia Layer from --
-- Sam Lantinga - www.libsld.org ) --
-- **************************************************************** --
-- In order to help the Ada programmer, the comments in this file --
-- are, in great extent, a direct copy of the original text in the --
-- SDL header files. --
-- **************************************************************** --
with System;
with Interfaces.C;
with Interfaces.C.Strings;
with Interfaces.C_Streams;
with SDL.Types; use SDL.Types;
-- This is a set of routines from SDL lib that doesn't
-- have a dependency from the SDL Ada package.
package SDL.RWops is
package C renames Interfaces.C;
package C_Streams renames Interfaces.C_Streams;
package CS renames Interfaces.C.Strings;
type void_ptr is new System.Address;
type FILE_ptr is new C_Streams.FILEs;
type RWops;
type RWops_ptr is access all RWops;
-- Seek to 'offset' relative to whence, one of stdio's
-- whence values: SEEK_SET, SEEK_CUR, SEEK_END
-- returns the finnal offset in the data source.
type Seek_Type is access function (
context : RWops_ptr;
offset : C.int;
whence : C.int) return C.int;
pragma Convention (C, Seek_Type);
-- Read up to 'num' objects each of size 'objsize' from
-- the data source to the ares pointed by 'ptr'.
-- Returns number of objects read, or -1 if the read failed.
type Read_Type is access function (
context : RWops_ptr;
ptr : void_ptr;
size : C.int;
maxnum : C.int) return C.int;
pragma Convention (C, Read_Type);
-- Write exactly 'num' objects each of size 'objsize' from
-- the area pointed by 'ptr' to data source.
-- Returns 'num', or -1 if the write failed.
type Write_Type is access function (
context : RWops_ptr;
ptr : void_ptr;
size : C.int;
num : C.int) return C.int;
pragma Convention (C, Write_Type);
-- Close and free an allocated SDL_FSops structure.
type Close_Type is access function (
context : RWops_ptr) return C.int;
pragma Convention (C, Close_Type);
type Stdio_Type is
record
autoclose : C.int;
fp : FILE_ptr;
end record;
pragma Convention (C, Stdio_Type);
type Uint8_ptr is access all Uint8;
type Mem_Type is
record
base,
here,
stop : Uint8_ptr;
end record;
pragma Convention (C, Mem_Type);
type Unknown_Type is
record
data1 : void_ptr;
end record;
pragma Convention (C, Unknown_Type);
type Hidden_Select_Type is (Is_Stdio, Is_Mem, Is_Unknown);
type Hidden_Union_Type (Hidden_Select : Hidden_Select_Type := Is_Stdio) is
record
case Hidden_Select is
when Is_Stdio => stdio : Stdio_Type;
when Is_Mem => mem : Mem_Type;
when Is_Unknown => unknown : Unknown_Type;
end case;
end record;
pragma Convention (C, Hidden_Union_Type);
pragma Unchecked_Union (Hidden_Union_Type);
-- This is the read/write operation structure -- very basic */
type RWops is
record
seek : Seek_Type;
read : Read_Type;
write : Read_Type;
close : Close_Type;
type_union : Uint32;
hidden : Hidden_Union_Type;
end record;
function RWFromFile (
file : CS.chars_ptr;
mode : CS.chars_ptr)
return RWops_ptr;
pragma Import (C, RWFromFile, "SDL_RWFromFile");
function RW_From_File (
file : String;
mode : String)
return RWops_ptr;
pragma Inline (RW_From_File);
function RWFromFP (
file : FILE_ptr;
autoclose : C.int)
return RWops_ptr;
pragma Import (C, RWFromFP, "SDL_RWFromFP");
function RWFromMem (
mem : void_ptr;
size : C.int)
return RWops_ptr;
pragma Import (C, RWFromMem, "SDL_RWFromMem");
function AllocRW return RWops_ptr;
pragma Import (C, AllocRW, "SDL_AllocRW");
procedure FreeRW (
area : RWops_ptr);
pragma Import (C, FreeRW, "SDL_FreeRW");
function RWSeek (
ctx : RWops_ptr;
offset : C.int;
whence : C.int)
return C.int;
pragma Inline (RWSeek);
function RWtell (
ctx : RWops_ptr)
return C.int;
pragma Inline (RWtell);
function RWread (
ctx : RWops_ptr;
ptr : void_ptr;
size : C.int;
n : C.int)
return C.int;
pragma Inline (RWread);
function RWwrite (
ctx : RWops_ptr;
ptr : void_ptr;
size : C.int;
n : C.int)
return C.int;
pragma Inline (RWwrite);
function RWclose (
ctx : RWops_ptr)
return C.int;
pragma Inline (RWclose);
end SDL.RWops;
|
-- SPDX-FileCopyrightText: 2021 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
package body WebIDL.Simple_Factories is
package body Nodes is
type Argument_Vector_C_Access is access constant Argument_Vector;
overriding function Arguments (Self : Constructor)
return not null WebIDL.Arguments.Argument_Iterator_Access
is
X : constant Argument_Vector_C_Access :=
Self.Arguments'Unchecked_Access;
begin
return WebIDL.Arguments.Argument_Iterator_Access (X);
end Arguments;
overriding function First (Self : Member_Vector)
return WebIDL.Interface_Members.Cursor is
begin
if Self.Vector.Is_Empty then
return (1, null);
else
return (1, Self.Vector.First_Element);
end if;
end First;
overriding function First (Self : Argument_Vector)
return WebIDL.Arguments.Cursor is
begin
if Self.Vector.Is_Empty then
return (1, null);
else
return (1, Self.Vector.First_Element);
end if;
end First;
overriding function First (Self : Union_Member_Vector)
return WebIDL.Types.Cursor is
begin
if Self.Vector.Is_Empty then
return (1, null);
else
return (1, Self.Vector.First_Element);
end if;
end First;
overriding function Next
(Self : Member_Vector;
Position : WebIDL.Interface_Members.Cursor)
return WebIDL.Interface_Members.Cursor is
begin
if Position.Index >= Self.Vector.Last_Index then
return (Self.Vector.Last_Index + 1, null);
else
return (Position.Index + 1, Self.Vector (Position.Index + 1));
end if;
end Next;
overriding function Next
(Self : Argument_Vector;
Position : WebIDL.Arguments.Cursor)
return WebIDL.Arguments.Cursor is
begin
if Position.Index >= Self.Vector.Last_Index then
return (Self.Vector.Last_Index + 1, null);
else
return (Position.Index + 1, Self.Vector (Position.Index + 1));
end if;
end Next;
overriding function Next
(Self : Union_Member_Vector;
Position : WebIDL.Types.Cursor)
return WebIDL.Types.Cursor is
begin
if Position.Index >= Self.Vector.Last_Index then
return (Self.Vector.Last_Index + 1, null);
else
return (Position.Index + 1, Self.Vector (Position.Index + 1));
end if;
end Next;
overriding procedure Append
(Self : in out Member_Vector;
Item : not null WebIDL.Interface_Members.Interface_Member_Access) is
begin
Self.Vector.Append (Item);
end Append;
overriding procedure Append
(Self : in out Argument_Vector;
Item : not null WebIDL.Arguments.Argument_Access) is
begin
Self.Vector.Append (Item);
end Append;
overriding procedure Append
(Self : in out Union_Member_Vector;
Item : not null WebIDL.Types.Type_Access) is
begin
Self.Vector.Append (Item);
end Append;
type Member_Vector_C_Access is access constant Member_Vector;
overriding function Members (Self : Interfase)
return WebIDL.Interface_Members.Interface_Member_Iterator_Access
is
X : constant Member_Vector_C_Access := Self.Members'Unchecked_Access;
begin
return WebIDL.Interface_Members.Interface_Member_Iterator_Access (X);
end Members;
end Nodes;
package body Types is
overriding function Name (Self : Union)
return League.Strings.Universal_String
is
Result : League.Strings.Universal_String :=
Self.Member.Vector.First_Element.Name;
begin
for J in 2 .. Self.Member.Vector.Last_Index loop
Result.Append ("Or");
Result.Append (Self.Member.Vector.Element (J).Name);
end loop;
return Result;
end Name;
type Type_Vector_C_Access is access constant Nodes.Union_Member_Vector;
overriding function Members (Self : Union)
return not null WebIDL.Types.Type_Iterator_Access
is
X : constant Type_Vector_C_Access :=
Self.Member'Unchecked_Access;
begin
return WebIDL.Types.Type_Iterator_Access (X);
end Members;
end Types;
---------
-- Any --
---------
overriding function Any (Self : in out Factory)
return not null WebIDL.Types.Type_Access is
begin
return Types.Any'Access;
end Any;
--------------
-- Argument --
--------------
overriding function Argument
(Self : in out Factory;
Type_Def : WebIDL.Types.Type_Access;
Name : League.Strings.Universal_String;
Is_Optional : Boolean;
Has_Ellipsis : Boolean)
return not null WebIDL.Arguments.Argument_Access
is
Result : constant Nodes.Argument_Access := new Nodes.Argument'
(Name, Type_Def, Is_Optional, Has_Ellipsis);
begin
return WebIDL.Arguments.Argument_Access (Result);
end Argument;
---------------
-- Arguments --
---------------
overriding function Arguments (Self : in out Factory)
return not null WebIDL.Factories.Argument_Vector_Access
is
Result : constant Nodes.Argument_Vector_Access :=
new Nodes.Argument_Vector;
begin
return WebIDL.Factories.Argument_Vector_Access (Result);
end Arguments;
------------
-- BigInt --
------------
overriding function BigInt (Self : in out Factory)
return not null WebIDL.Types.Type_Access is
begin
return Types.BigInt'Access;
end BigInt;
----------
-- Bool --
----------
overriding function Bool (Self : in out Factory)
return not null WebIDL.Types.Type_Access is
begin
return Types.Bool'Access;
end Bool;
-------------------------
-- Buffer_Related_Type --
-------------------------
overriding function Buffer_Related_Type
(Self : in out Factory;
Name : League.Strings.Universal_String)
return not null WebIDL.Types.Type_Access
is
Ok : Boolean;
Cursor : Type_Maps.Cursor := Self.Buffers.Find (Name);
Result : Types.Buffer_Type_Access;
begin
if not Type_Maps.Has_Element (Cursor) then
Result := new Types.Buffer_Type'(Name => Name);
Self.Buffers.Insert
(Name,
WebIDL.Types.Type_Access (Result),
Cursor,
Ok);
end if;
return Type_Maps.Element (Cursor);
end Buffer_Related_Type;
----------
-- Byte --
----------
overriding function Byte (Self : in out Factory)
return not null WebIDL.Types.Type_Access is
begin
return Types.Byte'Access;
end Byte;
----------------
-- ByteString --
----------------
overriding function ByteString (Self : in out Factory)
return not null WebIDL.Types.Type_Access is
begin
return Types.ByteString'Access;
end ByteString;
-----------------
-- Constructor --
-----------------
overriding function Constructor
(Self : in out Factory;
Args : not null WebIDL.Factories.Argument_Vector_Access)
return not null WebIDL.Constructors.Constructor_Access
is
Result : constant Nodes.Constructor_Access := new Nodes.Constructor'
(Arguments => <>);
begin
Result.Arguments.Vector := Nodes.Argument_Vector (Args.all).Vector;
return WebIDL.Constructors.Constructor_Access (Result);
end Constructor;
---------------
-- DOMString --
---------------
overriding function DOMString (Self : in out Factory)
return not null WebIDL.Types.Type_Access is
begin
return Types.DOMString'Access;
end DOMString;
-----------------
-- Enumeration --
-----------------
overriding function Enumeration
(Self : in out Factory; Name : League.Strings.Universal_String;
Values : League.String_Vectors.Universal_String_Vector)
return not null WebIDL.Enumerations.Enumeration_Access
is
Result : constant Nodes.Enumeration_Access := new Nodes.Enumeration'
(Name, Values);
begin
return WebIDL.Enumerations.Enumeration_Access (Result);
end Enumeration;
-----------
-- Float --
-----------
overriding function Float
(Self : in out Factory;
Restricted : Boolean;
Double : Boolean)
return not null WebIDL.Types.Type_Access is
begin
if Double then
return Types.Double'Access;
else
return Types.Float'Access;
end if;
end Float;
------------------
-- Frozen_Array --
------------------
overriding function Frozen_Array
(Self : in out Factory;
T : not null WebIDL.Types.Type_Access)
return not null WebIDL.Types.Type_Access
is
Ok : Boolean;
Name : constant League.Strings.Universal_String := T.Name;
Cursor : Type_Maps.Cursor := Self.Arrays.Find (Name);
Result : Types.Frozen_Array_Access;
begin
if not Type_Maps.Has_Element (Cursor) then
Result := new Types.Frozen_Array'(Element => T);
Self.Arrays.Insert
(Name,
WebIDL.Types.Type_Access (Result),
Cursor,
Ok);
end if;
return Type_Maps.Element (Cursor);
end Frozen_Array;
-------------
-- Integer --
-------------
overriding function Integer
(Self : in out Factory;
Is_Unsigned : Boolean;
Long : Natural)
return not null WebIDL.Types.Type_Access is
begin
if Is_Unsigned then
if Long = 0 then
return Types.Unsigned_Short'Access;
elsif Long = 1 then
return Types.Unsigned_Long'Access;
else
return Types.Unsigned_Long_Long'Access;
end if;
elsif Long = 0 then
return Types.Short'Access;
elsif Long = 1 then
return Types.Long'Access;
else
return Types.Long_Long'Access;
end if;
end Integer;
-----------------------
-- Interface_Members --
-----------------------
overriding function Interface_Members (Self : in out Factory)
return not null WebIDL.Factories.Interface_Member_Vector_Access
is
Result : constant Nodes.Member_Vector_Access := new Nodes.Member_Vector;
begin
return WebIDL.Factories.Interface_Member_Vector_Access (Result);
end Interface_Members;
-------------------
-- New_Interface --
-------------------
overriding function New_Interface
(Self : in out Factory;
Name : League.Strings.Universal_String;
Parent : League.Strings.Universal_String;
Members : not null WebIDL.Factories.Interface_Member_Vector_Access)
return not null WebIDL.Interfaces.Interface_Access
is
Result : constant Nodes.Interface_Access := new Nodes.Interfase'
(Name, Parent, Members => <>);
begin
Result.Members.Vector := Nodes.Member_Vector (Members.all).Vector;
return WebIDL.Interfaces.Interface_Access (Result);
end New_Interface;
--------------
-- Nullable --
--------------
overriding function Nullable
(Self : in out Factory;
T : not null WebIDL.Types.Type_Access)
return not null WebIDL.Types.Type_Access
is
Ok : Boolean;
Name : constant League.Strings.Universal_String := T.Name;
Cursor : Type_Maps.Cursor := Self.Nullables.Find (Name);
Result : Types.Nullable_Access;
begin
if not Type_Maps.Has_Element (Cursor) then
Result := new Types.Nullable'(Inner => T);
Self.Nullables.Insert
(Name,
WebIDL.Types.Type_Access (Result),
Cursor,
Ok);
end if;
return Type_Maps.Element (Cursor);
end Nullable;
------------
-- Object --
------------
overriding function Object (Self : in out Factory)
return not null WebIDL.Types.Type_Access is
begin
return Types.Object'Access;
end Object;
----------------------
-- Observable_Array --
----------------------
overriding function Observable_Array
(Self : in out Factory;
T : not null WebIDL.Types.Type_Access)
return not null WebIDL.Types.Type_Access
is
Ok : Boolean;
Name : constant League.Strings.Universal_String := T.Name;
Cursor : Type_Maps.Cursor := Self.Observables.Find (Name);
Result : Types.Observable_Array_Access;
begin
if not Type_Maps.Has_Element (Cursor) then
Result := new Types.Observable_Array'(Element => T);
Self.Observables.Insert
(Name,
WebIDL.Types.Type_Access (Result),
Cursor,
Ok);
end if;
return Type_Maps.Element (Cursor);
end Observable_Array;
-----------
-- Octet --
-----------
overriding function Octet (Self : in out Factory)
return not null WebIDL.Types.Type_Access is
begin
return Types.Octet'Access;
end Octet;
-------------
-- Promise --
-------------
overriding function Promise
(Self : in out Factory;
T : not null WebIDL.Types.Type_Access)
return not null WebIDL.Types.Type_Access
is
Ok : Boolean;
Name : constant League.Strings.Universal_String := T.Name;
Cursor : Type_Maps.Cursor := Self.Promises.Find (Name);
Result : Types.Promise_Access;
begin
if not Type_Maps.Has_Element (Cursor) then
Result := new Types.Promise'(Element => T);
Self.Promises.Insert
(Name,
WebIDL.Types.Type_Access (Result),
Cursor,
Ok);
end if;
return Type_Maps.Element (Cursor);
end Promise;
-----------------
-- Record_Type --
-----------------
overriding function Record_Type
(Self : in out Factory;
Key : not null WebIDL.Types.Type_Access;
Value : not null WebIDL.Types.Type_Access)
return not null WebIDL.Types.Type_Access
is
use type League.Strings.Universal_String;
Ok : Boolean;
Name : constant League.Strings.Universal_String :=
Key.Name & "/" & Value.Name;
Cursor : Type_Maps.Cursor := Self.Records.Find (Name);
Result : Types.Record_Type_Access;
begin
if not Type_Maps.Has_Element (Cursor) then
Result := new Types.Record_Type'(Key, Value);
Self.Records.Insert
(Name,
WebIDL.Types.Type_Access (Result),
Cursor,
Ok);
end if;
return Type_Maps.Element (Cursor);
end Record_Type;
--------------
-- Sequence --
--------------
overriding function Sequence
(Self : in out Factory;
T : not null WebIDL.Types.Type_Access)
return not null WebIDL.Types.Type_Access
is
Ok : Boolean;
Name : constant League.Strings.Universal_String := T.Name;
Cursor : Type_Maps.Cursor := Self.Sequences.Find (Name);
Result : Types.Sequence_Access;
begin
if not Type_Maps.Has_Element (Cursor) then
Result := new Types.Sequence'(Element => T);
Self.Sequences.Insert
(Name,
WebIDL.Types.Type_Access (Result),
Cursor,
Ok);
end if;
return Type_Maps.Element (Cursor);
end Sequence;
------------
-- Symbol --
------------
overriding function Symbol (Self : in out Factory)
return not null WebIDL.Types.Type_Access is
begin
return Types.Symbol'Access;
end Symbol;
---------------
-- Undefined --
---------------
overriding function Undefined (Self : in out Factory)
return not null WebIDL.Types.Type_Access is
begin
return Types.Undefined'Access;
end Undefined;
-----------
-- Union --
-----------
overriding function Union
(Self : in out Factory;
T : not null WebIDL.Factories.Union_Member_Vector_Access)
return not null WebIDL.Types.Type_Access
is
Result : constant Types.Union_Access := new Types.Union'
(Member => <>);
begin
Result.Member.Vector := Nodes.Union_Member_Vector (T.all).Vector;
return WebIDL.Types.Type_Access (Result);
end Union;
-------------------
-- Union_Members --
-------------------
overriding function Union_Members (Self : in out Factory)
return not null WebIDL.Factories.Union_Member_Vector_Access
is
Result : constant Nodes.Union_Member_Vector_Access :=
new Nodes.Union_Member_Vector;
begin
return WebIDL.Factories.Union_Member_Vector_Access (Result);
end Union_Members;
---------------
-- USVString --
---------------
overriding function USVString (Self : in out Factory)
return not null WebIDL.Types.Type_Access is
begin
return Types.USVString'Access;
end USVString;
end WebIDL.Simple_Factories;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- R E P I N F O --
-- --
-- B o d y --
-- --
-- Copyright (C) 1999-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Alloc;
with Atree; use Atree;
with Casing; use Casing;
with Debug; use Debug;
with Einfo; use Einfo;
with Lib; use Lib;
with Namet; use Namet;
with Nlists; use Nlists;
with Opt; use Opt;
with Output; use Output;
with Sem_Aux; use Sem_Aux;
with Sem_Eval; use Sem_Eval;
with Sinfo; use Sinfo;
with Sinput; use Sinput;
with Snames; use Snames;
with Stringt; use Stringt;
with Table;
with Ttypes;
with Uname; use Uname;
with Urealp; use Urealp;
with Ada.Unchecked_Conversion;
with GNAT.HTable;
package body Repinfo is
SSU : Pos renames Ttypes.System_Storage_Unit;
-- Value for Storage_Unit
---------------------------------------
-- Representation of GCC Expressions --
---------------------------------------
-- A table internal to this unit is used to hold the values of back
-- annotated expressions.
-- Node values are stored as Uint values using the negative of the node
-- index in this table. Constants appear as non-negative Uint values.
type Exp_Node is record
Expr : TCode;
Op1 : Node_Ref_Or_Val;
Op2 : Node_Ref_Or_Val;
Op3 : Node_Ref_Or_Val;
end record;
-- The following representation clause ensures that the above record
-- has no holes. We do this so that when instances of this record are
-- written, we do not write uninitialized values to the file.
for Exp_Node use record
Expr at 0 range 0 .. 31;
Op1 at 4 range 0 .. 31;
Op2 at 8 range 0 .. 31;
Op3 at 12 range 0 .. 31;
end record;
for Exp_Node'Size use 16 * 8;
-- This ensures that we did not leave out any fields
package Rep_Table is new Table.Table (
Table_Component_Type => Exp_Node,
Table_Index_Type => Nat,
Table_Low_Bound => 1,
Table_Initial => Alloc.Rep_Table_Initial,
Table_Increment => Alloc.Rep_Table_Increment,
Table_Name => "BE_Rep_Table");
--------------------------------------------------------------
-- Representation of Front-End Dynamic Size/Offset Entities --
--------------------------------------------------------------
package Dynamic_SO_Entity_Table is new Table.Table (
Table_Component_Type => Entity_Id,
Table_Index_Type => Nat,
Table_Low_Bound => 1,
Table_Initial => Alloc.Rep_Table_Initial,
Table_Increment => Alloc.Rep_Table_Increment,
Table_Name => "FE_Rep_Table");
Unit_Casing : Casing_Type;
-- Identifier casing for current unit. This is set by List_Rep_Info for
-- each unit, before calling subprograms which may read it.
Need_Separator : Boolean;
-- Set True if a separator is needed before outputting any information for
-- the current entity.
------------------------------
-- Set of Relevant Entities --
------------------------------
Relevant_Entities_Size : constant := 4093;
-- Number of headers in hash table
subtype Entity_Header_Num is Integer range 0 .. Relevant_Entities_Size - 1;
-- Range of headers in hash table
function Entity_Hash (Id : Entity_Id) return Entity_Header_Num;
-- Simple hash function for Entity_Ids
package Relevant_Entities is new GNAT.Htable.Simple_HTable
(Header_Num => Entity_Header_Num,
Element => Boolean,
No_Element => False,
Key => Entity_Id,
Hash => Entity_Hash,
Equal => "=");
-- Hash table to record which compiler-generated entities are relevant
-----------------------
-- Local Subprograms --
-----------------------
function Back_End_Layout return Boolean;
-- Test for layout mode, True = back end, False = front end. This function
-- is used rather than checking the configuration parameter because we do
-- not want Repinfo to depend on Targparm.
procedure List_Entities
(Ent : Entity_Id;
Bytes_Big_Endian : Boolean;
In_Subprogram : Boolean := False);
-- This procedure lists the entities associated with the entity E, starting
-- with the First_Entity and using the Next_Entity link. If a nested
-- package is found, entities within the package are recursively processed.
-- When recursing within a subprogram body, Is_Subprogram suppresses
-- duplicate information about signature.
procedure List_Name (Ent : Entity_Id);
-- List name of entity Ent in appropriate case. The name is listed with
-- full qualification up to but not including the compilation unit name.
procedure List_Array_Info (Ent : Entity_Id; Bytes_Big_Endian : Boolean);
-- List representation info for array type Ent
procedure List_Common_Type_Info (Ent : Entity_Id);
-- List common type info (name, size, alignment) for type Ent
procedure List_Linker_Section (Ent : Entity_Id);
-- List linker section for Ent (caller has checked that Ent is an entity
-- for which the Linker_Section_Pragma field is defined).
procedure List_Location (Ent : Entity_Id);
-- List location information for Ent
procedure List_Object_Info (Ent : Entity_Id);
-- List representation info for object Ent
procedure List_Record_Info (Ent : Entity_Id; Bytes_Big_Endian : Boolean);
-- List representation info for record type Ent
procedure List_Scalar_Storage_Order
(Ent : Entity_Id;
Bytes_Big_Endian : Boolean);
-- List scalar storage order information for record or array type Ent.
-- Also includes bit order information for record types, if necessary.
procedure List_Subprogram_Info (Ent : Entity_Id);
-- List subprogram info for subprogram Ent
procedure List_Type_Info (Ent : Entity_Id);
-- List type info for type Ent
function Rep_Not_Constant (Val : Node_Ref_Or_Val) return Boolean;
-- Returns True if Val represents a variable value, and False if it
-- represents a value that is fixed at compile time.
procedure Spaces (N : Natural);
-- Output given number of spaces
procedure Write_Info_Line (S : String);
-- Routine to write a line to Repinfo output file. This routine is passed
-- as a special output procedure to Output.Set_Special_Output. Note that
-- Write_Info_Line is called with an EOL character at the end of each line,
-- as per the Output spec, but the internal call to the appropriate routine
-- in Osint requires that the end of line sequence be stripped off.
procedure Write_Mechanism (M : Mechanism_Type);
-- Writes symbolic string for mechanism represented by M
procedure Write_Separator;
-- Called before outputting anything for an entity. Ensures that
-- a separator precedes the output for a particular entity.
procedure Write_Unknown_Val;
-- Writes symbolic string for an unknown or non-representable value
procedure Write_Val (Val : Node_Ref_Or_Val; Paren : Boolean := False);
-- Given a representation value, write it out. No_Uint values or values
-- dependent on discriminants are written as two question marks. If the
-- flag Paren is set, then the output is surrounded in parentheses if it is
-- other than a simple value.
---------------------
-- Back_End_Layout --
---------------------
function Back_End_Layout return Boolean is
begin
-- We have back-end layout if the back end has made any entries in the
-- table of GCC expressions, otherwise we have front-end layout.
return Rep_Table.Last > 0;
end Back_End_Layout;
------------------------
-- Create_Discrim_Ref --
------------------------
function Create_Discrim_Ref (Discr : Entity_Id) return Node_Ref is
begin
return Create_Node
(Expr => Discrim_Val,
Op1 => Discriminant_Number (Discr));
end Create_Discrim_Ref;
---------------------------
-- Create_Dynamic_SO_Ref --
---------------------------
function Create_Dynamic_SO_Ref (E : Entity_Id) return Dynamic_SO_Ref is
begin
Dynamic_SO_Entity_Table.Append (E);
return UI_From_Int (-Dynamic_SO_Entity_Table.Last);
end Create_Dynamic_SO_Ref;
-----------------
-- Create_Node --
-----------------
function Create_Node
(Expr : TCode;
Op1 : Node_Ref_Or_Val;
Op2 : Node_Ref_Or_Val := No_Uint;
Op3 : Node_Ref_Or_Val := No_Uint) return Node_Ref
is
begin
Rep_Table.Append (
(Expr => Expr,
Op1 => Op1,
Op2 => Op2,
Op3 => Op3));
return UI_From_Int (-Rep_Table.Last);
end Create_Node;
-----------------
-- Entity_Hash --
-----------------
function Entity_Hash (Id : Entity_Id) return Entity_Header_Num is
begin
return Entity_Header_Num (Id mod Relevant_Entities_Size);
end Entity_Hash;
---------------------------
-- Get_Dynamic_SO_Entity --
---------------------------
function Get_Dynamic_SO_Entity (U : Dynamic_SO_Ref) return Entity_Id is
begin
return Dynamic_SO_Entity_Table.Table (-UI_To_Int (U));
end Get_Dynamic_SO_Entity;
-----------------------
-- Is_Dynamic_SO_Ref --
-----------------------
function Is_Dynamic_SO_Ref (U : SO_Ref) return Boolean is
begin
return U < Uint_0;
end Is_Dynamic_SO_Ref;
----------------------
-- Is_Static_SO_Ref --
----------------------
function Is_Static_SO_Ref (U : SO_Ref) return Boolean is
begin
return U >= Uint_0;
end Is_Static_SO_Ref;
---------
-- lgx --
---------
procedure lgx (U : Node_Ref_Or_Val) is
begin
List_GCC_Expression (U);
Write_Eol;
end lgx;
----------------------
-- List_Array_Info --
----------------------
procedure List_Array_Info (Ent : Entity_Id; Bytes_Big_Endian : Boolean) is
begin
Write_Separator;
if List_Representation_Info_To_JSON then
Write_Line ("{");
end if;
List_Common_Type_Info (Ent);
if List_Representation_Info_To_JSON then
Write_Line (",");
Write_Str (" ""Component_Size"": ");
Write_Val (Component_Size (Ent));
else
Write_Str ("for ");
List_Name (Ent);
Write_Str ("'Component_Size use ");
Write_Val (Component_Size (Ent));
Write_Line (";");
end if;
List_Scalar_Storage_Order (Ent, Bytes_Big_Endian);
List_Linker_Section (Ent);
if List_Representation_Info_To_JSON then
Write_Eol;
Write_Line ("}");
end if;
-- The component type is relevant for an array
if List_Representation_Info = 4
and then Is_Itype (Component_Type (Base_Type (Ent)))
then
Relevant_Entities.Set (Component_Type (Base_Type (Ent)), True);
end if;
end List_Array_Info;
---------------------------
-- List_Common_Type_Info --
---------------------------
procedure List_Common_Type_Info (Ent : Entity_Id) is
begin
if List_Representation_Info_To_JSON then
Write_Str (" ""name"": """);
List_Name (Ent);
Write_Line (""",");
List_Location (Ent);
end if;
-- Do not list size info for unconstrained arrays, not meaningful
if Is_Array_Type (Ent) and then not Is_Constrained (Ent) then
null;
else
-- If Esize and RM_Size are the same, list as Size. This is a common
-- case, which we may as well list in simple form.
if Esize (Ent) = RM_Size (Ent) then
if List_Representation_Info_To_JSON then
Write_Str (" ""Size"": ");
Write_Val (Esize (Ent));
Write_Line (",");
else
Write_Str ("for ");
List_Name (Ent);
Write_Str ("'Size use ");
Write_Val (Esize (Ent));
Write_Line (";");
end if;
-- Otherwise list size values separately
else
if List_Representation_Info_To_JSON then
Write_Str (" ""Object_Size"": ");
Write_Val (Esize (Ent));
Write_Line (",");
Write_Str (" ""Value_Size"": ");
Write_Val (RM_Size (Ent));
Write_Line (",");
else
Write_Str ("for ");
List_Name (Ent);
Write_Str ("'Object_Size use ");
Write_Val (Esize (Ent));
Write_Line (";");
Write_Str ("for ");
List_Name (Ent);
Write_Str ("'Value_Size use ");
Write_Val (RM_Size (Ent));
Write_Line (";");
end if;
end if;
end if;
if List_Representation_Info_To_JSON then
Write_Str (" ""Alignment"": ");
Write_Val (Alignment (Ent));
else
Write_Str ("for ");
List_Name (Ent);
Write_Str ("'Alignment use ");
Write_Val (Alignment (Ent));
Write_Line (";");
end if;
end List_Common_Type_Info;
-------------------
-- List_Entities --
-------------------
procedure List_Entities
(Ent : Entity_Id;
Bytes_Big_Endian : Boolean;
In_Subprogram : Boolean := False)
is
Body_E : Entity_Id;
E : Entity_Id;
function Find_Declaration (E : Entity_Id) return Node_Id;
-- Utility to retrieve declaration node for entity in the
-- case of package bodies and subprograms.
----------------------
-- Find_Declaration --
----------------------
function Find_Declaration (E : Entity_Id) return Node_Id is
Decl : Node_Id;
begin
Decl := Parent (E);
while Present (Decl)
and then Nkind (Decl) /= N_Package_Body
and then Nkind (Decl) /= N_Subprogram_Declaration
and then Nkind (Decl) /= N_Subprogram_Body
loop
Decl := Parent (Decl);
end loop;
return Decl;
end Find_Declaration;
-- Start of processing for List_Entities
begin
-- List entity if we have one, and it is not a renaming declaration.
-- For renamings, we don't get proper information, and really it makes
-- sense to restrict the output to the renamed entity.
if Present (Ent)
and then Nkind (Declaration_Node (Ent)) not in N_Renaming_Declaration
and then not Is_Ignored_Ghost_Entity (Ent)
then
-- If entity is a subprogram and we are listing mechanisms,
-- then we need to list mechanisms for this entity. We skip this
-- if it is a nested subprogram, as the information has already
-- been produced when listing the enclosing scope.
if List_Representation_Info_Mechanisms
and then (Is_Subprogram (Ent)
or else Ekind (Ent) = E_Entry
or else Ekind (Ent) = E_Entry_Family)
and then not In_Subprogram
then
List_Subprogram_Info (Ent);
end if;
E := First_Entity (Ent);
while Present (E) loop
-- We list entities that come from source (excluding private or
-- incomplete types or deferred constants, for which we will list
-- the information for the full view). If requested, we also list
-- relevant entities that have been generated when processing the
-- original entities coming from source. But if debug flag A is
-- set, then all entities are listed.
if ((Comes_From_Source (E)
or else (Ekind (E) = E_Block
and then
Nkind (Parent (E)) = N_Implicit_Label_Declaration
and then
Comes_From_Source (Label_Construct (Parent (E)))))
and then not Is_Incomplete_Or_Private_Type (E)
and then not (Ekind (E) = E_Constant
and then Present (Full_View (E))))
or else (List_Representation_Info = 4
and then Relevant_Entities.Get (E))
or else Debug_Flag_AA
then
if Is_Subprogram (E) then
if List_Representation_Info_Mechanisms then
List_Subprogram_Info (E);
end if;
-- Recurse into entities local to subprogram
List_Entities (E, Bytes_Big_Endian, True);
elsif Ekind (E) in E_Entry
| E_Entry_Family
| E_Subprogram_Type
then
if List_Representation_Info_Mechanisms then
List_Subprogram_Info (E);
end if;
elsif Is_Record_Type (E) then
if List_Representation_Info >= 1 then
List_Record_Info (E, Bytes_Big_Endian);
end if;
-- Recurse into entities local to a record type
if List_Representation_Info = 4 then
List_Entities (E, Bytes_Big_Endian, False);
end if;
elsif Is_Array_Type (E) then
if List_Representation_Info >= 1 then
List_Array_Info (E, Bytes_Big_Endian);
end if;
elsif Is_Type (E) then
if List_Representation_Info >= 2 then
List_Type_Info (E);
end if;
-- Note that formals are not annotated so we skip them here
elsif Ekind (E) in E_Constant
| E_Loop_Parameter
| E_Variable
then
if List_Representation_Info >= 2 then
List_Object_Info (E);
end if;
end if;
-- Recurse into nested package, but not if they are package
-- renamings (in particular renamings of the enclosing package,
-- as for some Java bindings and for generic instances).
if Ekind (E) = E_Package then
if No (Renamed_Object (E)) then
List_Entities (E, Bytes_Big_Endian);
end if;
-- Recurse into bodies
elsif Ekind (E) in E_Package_Body
| E_Protected_Body
| E_Protected_Type
| E_Subprogram_Body
| E_Task_Body
| E_Task_Type
then
List_Entities (E, Bytes_Big_Endian);
-- Recurse into blocks
elsif Ekind (E) = E_Block then
List_Entities (E, Bytes_Big_Endian);
end if;
end if;
Next_Entity (E);
end loop;
-- For a package body, the entities of the visible subprograms are
-- declared in the corresponding spec. Iterate over its entities in
-- order to handle properly the subprogram bodies. Skip bodies in
-- subunits, which are listed independently.
if Ekind (Ent) = E_Package_Body
and then Present (Corresponding_Spec (Find_Declaration (Ent)))
then
E := First_Entity (Corresponding_Spec (Find_Declaration (Ent)));
while Present (E) loop
if Is_Subprogram (E)
and then
Nkind (Find_Declaration (E)) = N_Subprogram_Declaration
then
Body_E := Corresponding_Body (Find_Declaration (E));
if Present (Body_E)
and then
Nkind (Parent (Find_Declaration (Body_E))) /= N_Subunit
then
List_Entities (Body_E, Bytes_Big_Endian);
end if;
end if;
Next_Entity (E);
end loop;
end if;
end if;
end List_Entities;
-------------------------
-- List_GCC_Expression --
-------------------------
procedure List_GCC_Expression (U : Node_Ref_Or_Val) is
procedure Print_Expr (Val : Node_Ref_Or_Val);
-- Internal recursive procedure to print expression
----------------
-- Print_Expr --
----------------
procedure Print_Expr (Val : Node_Ref_Or_Val) is
begin
if Val >= 0 then
UI_Write (Val, Decimal);
else
declare
Node : Exp_Node renames Rep_Table.Table (-UI_To_Int (Val));
procedure Unop (S : String);
-- Output text for unary operator with S being operator name
procedure Binop (S : String);
-- Output text for binary operator with S being operator name
----------
-- Unop --
----------
procedure Unop (S : String) is
begin
if List_Representation_Info_To_JSON then
Write_Str ("{ ""code"": """);
if S (S'Last) = ' ' then
Write_Str (S (S'First .. S'Last - 1));
else
Write_Str (S);
end if;
Write_Str (""", ""operands"": [ ");
Print_Expr (Node.Op1);
Write_Str (" ] }");
else
Write_Str (S);
Print_Expr (Node.Op1);
end if;
end Unop;
-----------
-- Binop --
-----------
procedure Binop (S : String) is
begin
if List_Representation_Info_To_JSON then
Write_Str ("{ ""code"": """);
Write_Str (S (S'First + 1 .. S'Last - 1));
Write_Str (""", ""operands"": [ ");
Print_Expr (Node.Op1);
Write_Str (", ");
Print_Expr (Node.Op2);
Write_Str (" ] }");
else
Write_Char ('(');
Print_Expr (Node.Op1);
Write_Str (S);
Print_Expr (Node.Op2);
Write_Char (')');
end if;
end Binop;
-- Start of processing for Print_Expr
begin
case Node.Expr is
when Cond_Expr =>
if List_Representation_Info_To_JSON then
Write_Str ("{ ""code"": ""?<>""");
Write_Str (", ""operands"": [ ");
Print_Expr (Node.Op1);
Write_Str (", ");
Print_Expr (Node.Op2);
Write_Str (", ");
Print_Expr (Node.Op3);
Write_Str (" ] }");
else
Write_Str ("(if ");
Print_Expr (Node.Op1);
Write_Str (" then ");
Print_Expr (Node.Op2);
Write_Str (" else ");
Print_Expr (Node.Op3);
Write_Str (" end)");
end if;
when Plus_Expr =>
Binop (" + ");
when Minus_Expr =>
Binop (" - ");
when Mult_Expr =>
Binop (" * ");
when Trunc_Div_Expr =>
Binop (" /t ");
when Ceil_Div_Expr =>
Binop (" /c ");
when Floor_Div_Expr =>
Binop (" /f ");
when Trunc_Mod_Expr =>
Binop (" modt ");
when Ceil_Mod_Expr =>
Binop (" modc ");
when Floor_Mod_Expr =>
Binop (" modf ");
when Exact_Div_Expr =>
Binop (" /e ");
when Negate_Expr =>
Unop ("-");
when Min_Expr =>
Binop (" min ");
when Max_Expr =>
Binop (" max ");
when Abs_Expr =>
Unop ("abs ");
when Truth_And_Expr =>
Binop (" and ");
when Truth_Or_Expr =>
Binop (" or ");
when Truth_Xor_Expr =>
Binop (" xor ");
when Truth_Not_Expr =>
Unop ("not ");
when Lt_Expr =>
Binop (" < ");
when Le_Expr =>
Binop (" <= ");
when Gt_Expr =>
Binop (" > ");
when Ge_Expr =>
Binop (" >= ");
when Eq_Expr =>
Binop (" == ");
when Ne_Expr =>
Binop (" != ");
when Bit_And_Expr =>
Binop (" & ");
when Discrim_Val =>
Unop ("#");
when Dynamic_Val =>
Unop ("var");
end case;
end;
end if;
end Print_Expr;
-- Start of processing for List_GCC_Expression
begin
if U = No_Uint then
Write_Unknown_Val;
else
Print_Expr (U);
end if;
end List_GCC_Expression;
-------------------------
-- List_Linker_Section --
-------------------------
procedure List_Linker_Section (Ent : Entity_Id) is
Args : List_Id;
Sect : Node_Id;
begin
if Present (Linker_Section_Pragma (Ent)) then
Args := Pragma_Argument_Associations (Linker_Section_Pragma (Ent));
Sect := Expr_Value_S (Get_Pragma_Arg (Last (Args)));
if List_Representation_Info_To_JSON then
Write_Line (",");
Write_Str (" ""Linker_Section"": """);
else
Write_Str ("pragma Linker_Section (");
List_Name (Ent);
Write_Str (", """);
end if;
pragma Assert (Nkind (Sect) = N_String_Literal);
String_To_Name_Buffer (Strval (Sect));
Write_Str (Name_Buffer (1 .. Name_Len));
Write_Str ("""");
if not List_Representation_Info_To_JSON then
Write_Line (");");
end if;
end if;
end List_Linker_Section;
-------------------
-- List_Location --
-------------------
procedure List_Location (Ent : Entity_Id) is
begin
pragma Assert (List_Representation_Info_To_JSON);
Write_Str (" ""location"": """);
Write_Location (Sloc (Ent));
Write_Line (""",");
end List_Location;
---------------
-- List_Name --
---------------
procedure List_Name (Ent : Entity_Id) is
C : Character;
begin
-- List the qualified name recursively, except
-- at compilation unit level in default mode.
if Is_Compilation_Unit (Ent) then
null;
elsif not Is_Compilation_Unit (Scope (Ent))
or else List_Representation_Info_To_JSON
then
List_Name (Scope (Ent));
Write_Char ('.');
end if;
Get_Unqualified_Decoded_Name_String (Chars (Ent));
Set_Casing (Unit_Casing);
-- The name of operators needs to be properly escaped for JSON
for J in 1 .. Name_Len loop
C := Name_Buffer (J);
if C = '"' and then List_Representation_Info_To_JSON then
Write_Char ('\');
end if;
Write_Char (C);
end loop;
end List_Name;
---------------------
-- List_Object_Info --
---------------------
procedure List_Object_Info (Ent : Entity_Id) is
begin
Write_Separator;
if List_Representation_Info_To_JSON then
Write_Line ("{");
Write_Str (" ""name"": """);
List_Name (Ent);
Write_Line (""",");
List_Location (Ent);
Write_Str (" ""Size"": ");
Write_Val (Esize (Ent));
Write_Line (",");
Write_Str (" ""Alignment"": ");
Write_Val (Alignment (Ent));
List_Linker_Section (Ent);
Write_Eol;
Write_Line ("}");
else
Write_Str ("for ");
List_Name (Ent);
Write_Str ("'Size use ");
Write_Val (Esize (Ent));
Write_Line (";");
Write_Str ("for ");
List_Name (Ent);
Write_Str ("'Alignment use ");
Write_Val (Alignment (Ent));
Write_Line (";");
List_Linker_Section (Ent);
end if;
-- The type is relevant for an object
if List_Representation_Info = 4 and then Is_Itype (Etype (Ent)) then
Relevant_Entities.Set (Etype (Ent), True);
end if;
end List_Object_Info;
----------------------
-- List_Record_Info --
----------------------
procedure List_Record_Info (Ent : Entity_Id; Bytes_Big_Endian : Boolean) is
procedure Compute_Max_Length
(Ent : Entity_Id;
Starting_Position : Uint := Uint_0;
Starting_First_Bit : Uint := Uint_0;
Prefix_Length : Natural := 0);
-- Internal recursive procedure to compute the max length
procedure List_Component_Layout
(Ent : Entity_Id;
Starting_Position : Uint := Uint_0;
Starting_First_Bit : Uint := Uint_0;
Prefix : String := "";
Indent : Natural := 0);
-- Procedure to display the layout of a single component
procedure List_Record_Layout
(Ent : Entity_Id;
Starting_Position : Uint := Uint_0;
Starting_First_Bit : Uint := Uint_0;
Prefix : String := "");
-- Internal recursive procedure to display the layout
procedure List_Structural_Record_Layout
(Ent : Entity_Id;
Outer_Ent : Entity_Id;
Variant : Node_Id := Empty;
Indent : Natural := 0);
-- Internal recursive procedure to display the structural layout
Incomplete_Layout : exception;
-- Exception raised if the layout is incomplete in -gnatc mode
Not_In_Extended_Main : exception;
-- Exception raised when an ancestor is not declared in the main unit
Max_Name_Length : Natural := 0;
Max_Spos_Length : Natural := 0;
------------------------
-- Compute_Max_Length --
------------------------
procedure Compute_Max_Length
(Ent : Entity_Id;
Starting_Position : Uint := Uint_0;
Starting_First_Bit : Uint := Uint_0;
Prefix_Length : Natural := 0)
is
Comp : Entity_Id;
begin
Comp := First_Component_Or_Discriminant (Ent);
while Present (Comp) loop
-- Skip a completely hidden discriminant or a discriminant in an
-- unchecked union (since it is not there).
if Ekind (Comp) = E_Discriminant
and then (Is_Completely_Hidden (Comp)
or else Is_Unchecked_Union (Ent))
then
goto Continue;
end if;
-- Skip _Parent component in extension (to avoid overlap)
if Chars (Comp) = Name_uParent then
goto Continue;
end if;
-- All other cases
declare
Ctyp : constant Entity_Id := Underlying_Type (Etype (Comp));
Bofs : constant Uint := Component_Bit_Offset (Comp);
Npos : Uint;
Fbit : Uint;
Spos : Uint;
Sbit : Uint;
Name_Length : Natural;
begin
Get_Decoded_Name_String (Chars (Comp));
Name_Length := Prefix_Length + Name_Len;
if Rep_Not_Constant (Bofs) then
-- If the record is not packed, then we know that all fields
-- whose position is not specified have starting normalized
-- bit position of zero.
if Unknown_Normalized_First_Bit (Comp)
and then not Is_Packed (Ent)
then
Set_Normalized_First_Bit (Comp, Uint_0);
end if;
UI_Image_Length := 2; -- For "??" marker
else
Npos := Bofs / SSU;
Fbit := Bofs mod SSU;
-- Complete annotation in case not done
if Unknown_Normalized_First_Bit (Comp) then
Set_Normalized_Position (Comp, Npos);
Set_Normalized_First_Bit (Comp, Fbit);
end if;
Spos := Starting_Position + Npos;
Sbit := Starting_First_Bit + Fbit;
if Sbit >= SSU then
Spos := Spos + 1;
Sbit := Sbit - SSU;
end if;
-- If extended information is requested, recurse fully into
-- record components, i.e. skip the outer level.
if List_Representation_Info_Extended
and then Is_Record_Type (Ctyp)
then
Compute_Max_Length (Ctyp, Spos, Sbit, Name_Length + 1);
goto Continue;
end if;
UI_Image (Spos);
end if;
Max_Name_Length := Natural'Max (Max_Name_Length, Name_Length);
Max_Spos_Length :=
Natural'Max (Max_Spos_Length, UI_Image_Length);
end;
<<Continue>>
Next_Component_Or_Discriminant (Comp);
end loop;
end Compute_Max_Length;
---------------------------
-- List_Component_Layout --
---------------------------
procedure List_Component_Layout
(Ent : Entity_Id;
Starting_Position : Uint := Uint_0;
Starting_First_Bit : Uint := Uint_0;
Prefix : String := "";
Indent : Natural := 0)
is
Esiz : constant Uint := Esize (Ent);
Npos : constant Uint := Normalized_Position (Ent);
Fbit : constant Uint := Normalized_First_Bit (Ent);
Spos : Uint;
Sbit : Uint;
Lbit : Uint;
begin
if List_Representation_Info_To_JSON then
Spaces (Indent);
Write_Line (" {");
Spaces (Indent);
Write_Str (" ""name"": """);
Write_Str (Prefix);
Write_Str (Name_Buffer (1 .. Name_Len));
Write_Line (""",");
if Ekind (Ent) = E_Discriminant then
Spaces (Indent);
Write_Str (" ""discriminant"": ");
UI_Write (Discriminant_Number (Ent), Decimal);
Write_Line (",");
end if;
Spaces (Indent);
Write_Str (" ""Position"": ");
else
Write_Str (" ");
Write_Str (Prefix);
Write_Str (Name_Buffer (1 .. Name_Len));
Spaces (Max_Name_Length - Prefix'Length - Name_Len);
Write_Str (" at ");
end if;
if Known_Static_Normalized_Position (Ent) then
Spos := Starting_Position + Npos;
Sbit := Starting_First_Bit + Fbit;
if Sbit >= SSU then
Spos := Spos + 1;
end if;
UI_Image (Spos);
Spaces (Max_Spos_Length - UI_Image_Length);
Write_Str (UI_Image_Buffer (1 .. UI_Image_Length));
elsif Known_Normalized_Position (Ent)
and then List_Representation_Info >= 3
then
Spaces (Max_Spos_Length - 2);
if Starting_Position /= Uint_0 then
UI_Write (Starting_Position, Decimal);
Write_Str (" + ");
end if;
Write_Val (Npos);
else
Write_Unknown_Val;
end if;
if List_Representation_Info_To_JSON then
Write_Line (",");
Spaces (Indent);
Write_Str (" ""First_Bit"": ");
else
Write_Str (" range ");
end if;
Sbit := Starting_First_Bit + Fbit;
if Sbit >= SSU then
Sbit := Sbit - SSU;
end if;
UI_Write (Sbit, Decimal);
if List_Representation_Info_To_JSON then
Write_Line (", ");
Spaces (Indent);
Write_Str (" ""Size"": ");
else
Write_Str (" .. ");
end if;
-- Allowing Uint_0 here is an annoying special case. Really this
-- should be a fine Esize value but currently it means unknown,
-- except that we know after gigi has back annotated that a size
-- of zero is real, since otherwise gigi back annotates using
-- No_Uint as the value to indicate unknown.
if (Esize (Ent) = Uint_0 or else Known_Static_Esize (Ent))
and then Known_Static_Normalized_First_Bit (Ent)
then
Lbit := Sbit + Esiz - 1;
if List_Representation_Info_To_JSON then
UI_Write (Esiz, Decimal);
else
if Lbit >= 0 and then Lbit < 10 then
Write_Char (' ');
end if;
UI_Write (Lbit, Decimal);
end if;
-- The test for Esize (Ent) not Uint_0 here is an annoying special
-- case. Officially a value of zero for Esize means unknown, but
-- here we use the fact that we know that gigi annotates Esize with
-- No_Uint, not Uint_0. Really everyone should use No_Uint???
elsif List_Representation_Info < 3
or else (Esize (Ent) /= Uint_0 and then Unknown_Esize (Ent))
then
Write_Unknown_Val;
-- List_Representation >= 3 and Known_Esize (Ent)
else
Write_Val (Esiz, Paren => not List_Representation_Info_To_JSON);
-- If in front-end layout mode, then dynamic size is stored in
-- storage units, so renormalize for output.
if not Back_End_Layout then
Write_Str (" * ");
Write_Int (SSU);
end if;
-- Add appropriate first bit offset
if not List_Representation_Info_To_JSON then
if Sbit = 0 then
Write_Str (" - 1");
elsif Sbit = 1 then
null;
else
Write_Str (" + ");
Write_Int (UI_To_Int (Sbit) - 1);
end if;
end if;
end if;
if List_Representation_Info_To_JSON then
Write_Eol;
Spaces (Indent);
Write_Str (" }");
else
Write_Line (";");
end if;
-- The type is relevant for a component
if List_Representation_Info = 4 and then Is_Itype (Etype (Ent)) then
Relevant_Entities.Set (Etype (Ent), True);
end if;
end List_Component_Layout;
------------------------
-- List_Record_Layout --
------------------------
procedure List_Record_Layout
(Ent : Entity_Id;
Starting_Position : Uint := Uint_0;
Starting_First_Bit : Uint := Uint_0;
Prefix : String := "")
is
Comp : Entity_Id;
First : Boolean := True;
begin
Comp := First_Component_Or_Discriminant (Ent);
while Present (Comp) loop
-- Skip a completely hidden discriminant or a discriminant in an
-- unchecked union (since it is not there).
if Ekind (Comp) = E_Discriminant
and then (Is_Completely_Hidden (Comp)
or else Is_Unchecked_Union (Ent))
then
goto Continue;
end if;
-- Skip _Parent component in extension (to avoid overlap)
if Chars (Comp) = Name_uParent then
goto Continue;
end if;
-- All other cases
declare
Ctyp : constant Entity_Id := Underlying_Type (Etype (Comp));
Npos : constant Uint := Normalized_Position (Comp);
Fbit : constant Uint := Normalized_First_Bit (Comp);
Spos : Uint;
Sbit : Uint;
begin
Get_Decoded_Name_String (Chars (Comp));
Set_Casing (Unit_Casing);
-- If extended information is requested, recurse fully into
-- record components, i.e. skip the outer level.
if List_Representation_Info_Extended
and then Is_Record_Type (Ctyp)
and then Known_Static_Normalized_Position (Comp)
and then Known_Static_Normalized_First_Bit (Comp)
then
Spos := Starting_Position + Npos;
Sbit := Starting_First_Bit + Fbit;
if Sbit >= SSU then
Spos := Spos + 1;
Sbit := Sbit - SSU;
end if;
List_Record_Layout (Ctyp,
Spos, Sbit, Prefix & Name_Buffer (1 .. Name_Len) & ".");
goto Continue;
end if;
if List_Representation_Info_To_JSON then
if First then
Write_Eol;
First := False;
else
Write_Line (",");
end if;
end if;
List_Component_Layout (Comp,
Starting_Position, Starting_First_Bit, Prefix);
end;
<<Continue>>
Next_Component_Or_Discriminant (Comp);
end loop;
end List_Record_Layout;
-----------------------------------
-- List_Structural_Record_Layout --
-----------------------------------
procedure List_Structural_Record_Layout
(Ent : Entity_Id;
Outer_Ent : Entity_Id;
Variant : Node_Id := Empty;
Indent : Natural := 0)
is
function Derived_Discriminant (Disc : Entity_Id) return Entity_Id;
-- This function assumes that Outer_Ent is an extension of Ent.
-- Disc is a discriminant of Ent that does not itself constrain a
-- discriminant of the parent type of Ent. Return the discriminant
-- of Outer_Ent that ultimately constrains Disc, if any.
----------------------------
-- Derived_Discriminant --
----------------------------
function Derived_Discriminant (Disc : Entity_Id) return Entity_Id is
Corr_Disc : Entity_Id;
Derived_Disc : Entity_Id;
begin
Derived_Disc := First_Discriminant (Outer_Ent);
-- Loop over the discriminants of the extension
while Present (Derived_Disc) loop
-- Check if this discriminant constrains another discriminant.
-- If so, find the ultimately constrained discriminant and
-- compare with the original components in the base type.
if Present (Corresponding_Discriminant (Derived_Disc)) then
Corr_Disc := Corresponding_Discriminant (Derived_Disc);
while Present (Corresponding_Discriminant (Corr_Disc)) loop
Corr_Disc := Corresponding_Discriminant (Corr_Disc);
end loop;
if Original_Record_Component (Corr_Disc) =
Original_Record_Component (Disc)
then
return Derived_Disc;
end if;
end if;
Next_Discriminant (Derived_Disc);
end loop;
-- Disc is not constrained by a discriminant of Outer_Ent
return Empty;
end Derived_Discriminant;
-- Local declarations
Comp : Node_Id;
Comp_List : Node_Id;
First : Boolean := True;
Var : Node_Id;
-- Start of processing for List_Structural_Record_Layout
begin
-- If we are dealing with a variant, just process the components
if Present (Variant) then
Comp_List := Component_List (Variant);
-- Otherwise, we are dealing with the full record and need to get
-- to its definition in order to retrieve its structural layout.
else
declare
Definition : Node_Id :=
Type_Definition (Declaration_Node (Ent));
Is_Extension : constant Boolean :=
Is_Tagged_Type (Ent)
and then Nkind (Definition) =
N_Derived_Type_Definition;
Disc : Entity_Id;
Listed_Disc : Entity_Id;
Parent_Type : Entity_Id;
begin
-- If this is an extension, first list the layout of the parent
-- and then proceed to the extension part, if any.
if Is_Extension then
Parent_Type := Parent_Subtype (Ent);
if No (Parent_Type) then
raise Incomplete_Layout;
end if;
if Is_Private_Type (Parent_Type) then
Parent_Type := Full_View (Parent_Type);
pragma Assert (Present (Parent_Type));
end if;
Parent_Type := Base_Type (Parent_Type);
if not In_Extended_Main_Source_Unit (Parent_Type) then
raise Not_In_Extended_Main;
end if;
List_Structural_Record_Layout (Parent_Type, Outer_Ent);
First := False;
if Present (Record_Extension_Part (Definition)) then
Definition := Record_Extension_Part (Definition);
end if;
end if;
-- If the record has discriminants and is not an unchecked
-- union, then display them now. Note that, even if this is
-- a structural layout, we list the visible discriminants.
if Has_Discriminants (Ent)
and then not Is_Unchecked_Union (Ent)
then
Disc := First_Discriminant (Ent);
while Present (Disc) loop
-- If this is a record extension and the discriminant is
-- the renaming of another discriminant, skip it.
if Is_Extension
and then Present (Corresponding_Discriminant (Disc))
then
goto Continue_Disc;
end if;
-- If this is the parent type of an extension, retrieve
-- the derived discriminant from the extension, if any.
if Ent /= Outer_Ent then
Listed_Disc := Derived_Discriminant (Disc);
if No (Listed_Disc) then
goto Continue_Disc;
end if;
else
Listed_Disc := Disc;
end if;
Get_Decoded_Name_String (Chars (Listed_Disc));
Set_Casing (Unit_Casing);
if First then
Write_Eol;
First := False;
else
Write_Line (",");
end if;
List_Component_Layout (Listed_Disc, Indent => Indent);
<<Continue_Disc>>
Next_Discriminant (Disc);
end loop;
end if;
Comp_List := Component_List (Definition);
end;
end if;
-- Bail out for the null record
if No (Comp_List) then
return;
end if;
-- Now deal with the regular components, if any
if Present (Component_Items (Comp_List)) then
Comp := First_Non_Pragma (Component_Items (Comp_List));
while Present (Comp) loop
-- Skip _Parent component in extension (to avoid overlap)
if Chars (Defining_Identifier (Comp)) = Name_uParent then
goto Continue_Comp;
end if;
Get_Decoded_Name_String (Chars (Defining_Identifier (Comp)));
Set_Casing (Unit_Casing);
if First then
Write_Eol;
First := False;
else
Write_Line (",");
end if;
List_Component_Layout
(Defining_Identifier (Comp), Indent => Indent);
<<Continue_Comp>>
Next_Non_Pragma (Comp);
end loop;
end if;
-- We are done if there is no variant part
if No (Variant_Part (Comp_List)) then
return;
end if;
Write_Eol;
Spaces (Indent);
Write_Line (" ],");
Spaces (Indent);
Write_Str (" ""variant"" : [");
-- Otherwise we recurse on each variant
Var := First_Non_Pragma (Variants (Variant_Part (Comp_List)));
First := True;
while Present (Var) loop
if First then
Write_Eol;
First := False;
else
Write_Line (",");
end if;
Spaces (Indent);
Write_Line (" {");
Spaces (Indent);
Write_Str (" ""present"": ");
Write_Val (Present_Expr (Var));
Write_Line (",");
Spaces (Indent);
Write_Str (" ""record"": [");
List_Structural_Record_Layout (Ent, Outer_Ent, Var, Indent + 4);
Write_Eol;
Spaces (Indent);
Write_Line (" ]");
Spaces (Indent);
Write_Str (" }");
Next_Non_Pragma (Var);
end loop;
end List_Structural_Record_Layout;
-- Start of processing for List_Record_Info
begin
Write_Separator;
if List_Representation_Info_To_JSON then
Write_Line ("{");
end if;
List_Common_Type_Info (Ent);
-- First find out max line length and max starting position
-- length, for the purpose of lining things up nicely.
Compute_Max_Length (Ent);
-- Then do actual output based on those values
if List_Representation_Info_To_JSON then
Write_Line (",");
Write_Str (" ""record"": [");
-- ??? We can output structural layout only for base types fully
-- declared in the extended main source unit for the time being,
-- because otherwise declarations might not be processed at all.
if Is_Base_Type (Ent) then
begin
List_Structural_Record_Layout (Ent, Ent);
exception
when Incomplete_Layout
| Not_In_Extended_Main
=>
List_Record_Layout (Ent);
when others =>
raise Program_Error;
end;
else
List_Record_Layout (Ent);
end if;
Write_Eol;
Write_Str (" ]");
else
Write_Str ("for ");
List_Name (Ent);
Write_Line (" use record");
List_Record_Layout (Ent);
Write_Line ("end record;");
end if;
List_Scalar_Storage_Order (Ent, Bytes_Big_Endian);
List_Linker_Section (Ent);
if List_Representation_Info_To_JSON then
Write_Eol;
Write_Line ("}");
end if;
-- The type is relevant for a record subtype
if List_Representation_Info = 4
and then not Is_Base_Type (Ent)
and then Is_Itype (Etype (Ent))
then
Relevant_Entities.Set (Etype (Ent), True);
end if;
end List_Record_Info;
-------------------
-- List_Rep_Info --
-------------------
procedure List_Rep_Info (Bytes_Big_Endian : Boolean) is
Col : Nat;
begin
if List_Representation_Info /= 0
or else List_Representation_Info_Mechanisms
then
-- For the normal case, we output a single JSON stream
if not List_Representation_Info_To_File
and then List_Representation_Info_To_JSON
then
Write_Line ("[");
Need_Separator := False;
end if;
for U in Main_Unit .. Last_Unit loop
if In_Extended_Main_Source_Unit (Cunit_Entity (U)) then
Unit_Casing := Identifier_Casing (Source_Index (U));
if List_Representation_Info = 4 then
Relevant_Entities.Reset;
end if;
-- Normal case, list to standard output
if not List_Representation_Info_To_File then
if not List_Representation_Info_To_JSON then
Write_Eol;
Write_Str ("Representation information for unit ");
Write_Unit_Name (Unit_Name (U));
Col := Column;
Write_Eol;
for J in 1 .. Col - 1 loop
Write_Char ('-');
end loop;
Write_Eol;
Need_Separator := True;
end if;
List_Entities (Cunit_Entity (U), Bytes_Big_Endian);
-- List representation information to file
else
Create_Repinfo_File_Access.all
(Get_Name_String (File_Name (Source_Index (U))));
Set_Special_Output (Write_Info_Line'Access);
if List_Representation_Info_To_JSON then
Write_Line ("[");
end if;
Need_Separator := False;
List_Entities (Cunit_Entity (U), Bytes_Big_Endian);
if List_Representation_Info_To_JSON then
Write_Line ("]");
end if;
Cancel_Special_Output;
Close_Repinfo_File_Access.all;
end if;
end if;
end loop;
if not List_Representation_Info_To_File
and then List_Representation_Info_To_JSON
then
Write_Line ("]");
end if;
end if;
end List_Rep_Info;
-------------------------------
-- List_Scalar_Storage_Order --
-------------------------------
procedure List_Scalar_Storage_Order
(Ent : Entity_Id;
Bytes_Big_Endian : Boolean)
is
procedure List_Attr (Attr_Name : String; Is_Reversed : Boolean);
-- Show attribute definition clause for Attr_Name (an endianness
-- attribute), depending on whether or not the endianness is reversed
-- compared to native endianness.
---------------
-- List_Attr --
---------------
procedure List_Attr (Attr_Name : String; Is_Reversed : Boolean) is
begin
if List_Representation_Info_To_JSON then
Write_Line (",");
Write_Str (" """);
Write_Str (Attr_Name);
Write_Str (""": ""System.");
else
Write_Str ("for ");
List_Name (Ent);
Write_Char (''');
Write_Str (Attr_Name);
Write_Str (" use System.");
end if;
if Bytes_Big_Endian xor Is_Reversed then
Write_Str ("High");
else
Write_Str ("Low");
end if;
Write_Str ("_Order_First");
if List_Representation_Info_To_JSON then
Write_Str ("""");
else
Write_Line (";");
end if;
end List_Attr;
List_SSO : constant Boolean :=
Has_Rep_Item (Ent, Name_Scalar_Storage_Order)
or else SSO_Set_Low_By_Default (Ent)
or else SSO_Set_High_By_Default (Ent);
-- Scalar_Storage_Order is displayed if specified explicitly or set by
-- Default_Scalar_Storage_Order.
-- Start of processing for List_Scalar_Storage_Order
begin
-- For record types, list Bit_Order if not default, or if SSO is shown
-- Also, when -gnatR4 is in effect always list bit order and scalar
-- storage order explicitly, so that you don't need to know the native
-- endianness of the target for which the output was produced in order
-- to interpret it.
if Is_Record_Type (Ent)
and then (List_SSO
or else Reverse_Bit_Order (Ent)
or else List_Representation_Info = 4)
then
List_Attr ("Bit_Order", Reverse_Bit_Order (Ent));
end if;
-- List SSO if required. If not, then storage is supposed to be in
-- native order.
if List_SSO or else List_Representation_Info = 4 then
List_Attr ("Scalar_Storage_Order", Reverse_Storage_Order (Ent));
else
pragma Assert (not Reverse_Storage_Order (Ent));
null;
end if;
end List_Scalar_Storage_Order;
--------------------------
-- List_Subprogram_Info --
--------------------------
procedure List_Subprogram_Info (Ent : Entity_Id) is
First : Boolean := True;
Plen : Natural;
Form : Entity_Id;
begin
Write_Separator;
if List_Representation_Info_To_JSON then
Write_Line ("{");
Write_Str (" ""name"": """);
List_Name (Ent);
Write_Line (""",");
List_Location (Ent);
Write_Str (" ""Convention"": """);
else
case Ekind (Ent) is
when E_Function =>
Write_Str ("function ");
when E_Operator =>
Write_Str ("operator ");
when E_Procedure =>
Write_Str ("procedure ");
when E_Subprogram_Type =>
Write_Str ("type ");
when E_Entry
| E_Entry_Family
=>
Write_Str ("entry ");
when others =>
raise Program_Error;
end case;
List_Name (Ent);
Write_Str (" declared at ");
Write_Location (Sloc (Ent));
Write_Eol;
Write_Str ("convention : ");
end if;
case Convention (Ent) is
when Convention_Ada =>
Write_Str ("Ada");
when Convention_Ada_Pass_By_Copy =>
Write_Str ("Ada_Pass_By_Copy");
when Convention_Ada_Pass_By_Reference =>
Write_Str ("Ada_Pass_By_Reference");
when Convention_Intrinsic =>
Write_Str ("Intrinsic");
when Convention_Entry =>
Write_Str ("Entry");
when Convention_Protected =>
Write_Str ("Protected");
when Convention_Assembler =>
Write_Str ("Assembler");
when Convention_C =>
Write_Str ("C");
when Convention_C_Variadic =>
declare
N : Nat :=
Convention_Id'Pos (Convention (Ent)) -
Convention_Id'Pos (Convention_C_Variadic_0);
begin
Write_Str ("C_Variadic_");
if N >= 10 then
Write_Char ('1');
N := N - 10;
end if;
pragma Assert (N < 10);
Write_Char (Character'Val (Character'Pos ('0') + N));
end;
when Convention_COBOL =>
Write_Str ("COBOL");
when Convention_CPP =>
Write_Str ("C++");
when Convention_Fortran =>
Write_Str ("Fortran");
when Convention_Stdcall =>
Write_Str ("Stdcall");
when Convention_Stubbed =>
Write_Str ("Stubbed");
end case;
if List_Representation_Info_To_JSON then
Write_Line (""",");
Write_Str (" ""formal"": [");
else
Write_Eol;
end if;
-- Find max length of formal name
Plen := 0;
Form := First_Formal (Ent);
while Present (Form) loop
Get_Unqualified_Decoded_Name_String (Chars (Form));
if Name_Len > Plen then
Plen := Name_Len;
end if;
Next_Formal (Form);
end loop;
-- Output formals and mechanisms
Form := First_Formal (Ent);
while Present (Form) loop
Get_Unqualified_Decoded_Name_String (Chars (Form));
Set_Casing (Unit_Casing);
if List_Representation_Info_To_JSON then
if First then
Write_Eol;
First := False;
else
Write_Line (",");
end if;
Write_Line (" {");
Write_Str (" ""name"": """);
Write_Str (Name_Buffer (1 .. Name_Len));
Write_Line (""",");
Write_Str (" ""mechanism"": """);
Write_Mechanism (Mechanism (Form));
Write_Line ("""");
Write_Str (" }");
else
while Name_Len <= Plen loop
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := ' ';
end loop;
Write_Str (" ");
Write_Str (Name_Buffer (1 .. Plen + 1));
Write_Str (": passed by ");
Write_Mechanism (Mechanism (Form));
Write_Eol;
end if;
Next_Formal (Form);
end loop;
if List_Representation_Info_To_JSON then
Write_Eol;
Write_Str (" ]");
end if;
if Ekind (Ent) = E_Function then
if List_Representation_Info_To_JSON then
Write_Line (",");
Write_Str (" ""mechanism"": """);
Write_Mechanism (Mechanism (Ent));
Write_Str ("""");
else
Write_Str ("returns by ");
Write_Mechanism (Mechanism (Ent));
Write_Eol;
end if;
end if;
if not Is_Entry (Ent) then
List_Linker_Section (Ent);
end if;
if List_Representation_Info_To_JSON then
Write_Eol;
Write_Line ("}");
end if;
end List_Subprogram_Info;
--------------------
-- List_Type_Info --
--------------------
procedure List_Type_Info (Ent : Entity_Id) is
begin
Write_Separator;
if List_Representation_Info_To_JSON then
Write_Line ("{");
end if;
List_Common_Type_Info (Ent);
-- Special stuff for fixed-point
if Is_Fixed_Point_Type (Ent) then
-- Write small (always a static constant)
if List_Representation_Info_To_JSON then
Write_Line (",");
Write_Str (" ""Small"": ");
UR_Write (Small_Value (Ent));
else
Write_Str ("for ");
List_Name (Ent);
Write_Str ("'Small use ");
UR_Write (Small_Value (Ent));
Write_Line (";");
end if;
-- Write range if static
declare
R : constant Node_Id := Scalar_Range (Ent);
begin
if Nkind (Low_Bound (R)) = N_Real_Literal
and then
Nkind (High_Bound (R)) = N_Real_Literal
then
if List_Representation_Info_To_JSON then
Write_Line (",");
Write_Str (" ""Range"": [ ");
UR_Write (Realval (Low_Bound (R)));
Write_Str (", ");
UR_Write (Realval (High_Bound (R)));
Write_Str (" ]");
else
Write_Str ("for ");
List_Name (Ent);
Write_Str ("'Range use ");
UR_Write (Realval (Low_Bound (R)));
Write_Str (" .. ");
UR_Write (Realval (High_Bound (R)));
Write_Line (";");
end if;
end if;
end;
end if;
List_Linker_Section (Ent);
if List_Representation_Info_To_JSON then
Write_Eol;
Write_Line ("}");
end if;
end List_Type_Info;
----------------------
-- Rep_Not_Constant --
----------------------
function Rep_Not_Constant (Val : Node_Ref_Or_Val) return Boolean is
begin
if Val = No_Uint or else Val < 0 then
return True;
else
return False;
end if;
end Rep_Not_Constant;
---------------
-- Rep_Value --
---------------
function Rep_Value (Val : Node_Ref_Or_Val; D : Discrim_List) return Uint is
function B (Val : Boolean) return Uint;
-- Returns Uint_0 for False, Uint_1 for True
function T (Val : Node_Ref_Or_Val) return Boolean;
-- Returns True for 0, False for any non-zero (i.e. True)
function V (Val : Node_Ref_Or_Val) return Uint;
-- Internal recursive routine to evaluate tree
function W (Val : Uint) return Word;
-- Convert Val to Word, assuming Val is always in the Int range. This
-- is a helper function for the evaluation of bitwise expressions like
-- Bit_And_Expr, for which there is no direct support in uintp. Uint
-- values out of the Int range are expected to be seen in such
-- expressions only with overflowing byte sizes around, introducing
-- inherent unreliabilities in computations anyway.
-------
-- B --
-------
function B (Val : Boolean) return Uint is
begin
if Val then
return Uint_1;
else
return Uint_0;
end if;
end B;
-------
-- T --
-------
function T (Val : Node_Ref_Or_Val) return Boolean is
begin
if V (Val) = 0 then
return False;
else
return True;
end if;
end T;
-------
-- V --
-------
function V (Val : Node_Ref_Or_Val) return Uint is
L, R, Q : Uint;
begin
if Val >= 0 then
return Val;
else
declare
Node : Exp_Node renames Rep_Table.Table (-UI_To_Int (Val));
begin
case Node.Expr is
when Cond_Expr =>
if T (Node.Op1) then
return V (Node.Op2);
else
return V (Node.Op3);
end if;
when Plus_Expr =>
return V (Node.Op1) + V (Node.Op2);
when Minus_Expr =>
return V (Node.Op1) - V (Node.Op2);
when Mult_Expr =>
return V (Node.Op1) * V (Node.Op2);
when Trunc_Div_Expr =>
return V (Node.Op1) / V (Node.Op2);
when Ceil_Div_Expr =>
return
UR_Ceiling
(V (Node.Op1) / UR_From_Uint (V (Node.Op2)));
when Floor_Div_Expr =>
return
UR_Floor
(V (Node.Op1) / UR_From_Uint (V (Node.Op2)));
when Trunc_Mod_Expr =>
return V (Node.Op1) rem V (Node.Op2);
when Floor_Mod_Expr =>
return V (Node.Op1) mod V (Node.Op2);
when Ceil_Mod_Expr =>
L := V (Node.Op1);
R := V (Node.Op2);
Q := UR_Ceiling (L / UR_From_Uint (R));
return L - R * Q;
when Exact_Div_Expr =>
return V (Node.Op1) / V (Node.Op2);
when Negate_Expr =>
return -V (Node.Op1);
when Min_Expr =>
return UI_Min (V (Node.Op1), V (Node.Op2));
when Max_Expr =>
return UI_Max (V (Node.Op1), V (Node.Op2));
when Abs_Expr =>
return UI_Abs (V (Node.Op1));
when Truth_And_Expr =>
return B (T (Node.Op1) and then T (Node.Op2));
when Truth_Or_Expr =>
return B (T (Node.Op1) or else T (Node.Op2));
when Truth_Xor_Expr =>
return B (T (Node.Op1) xor T (Node.Op2));
when Truth_Not_Expr =>
return B (not T (Node.Op1));
when Bit_And_Expr =>
L := V (Node.Op1);
R := V (Node.Op2);
return UI_From_Int (Int (W (L) and W (R)));
when Lt_Expr =>
return B (V (Node.Op1) < V (Node.Op2));
when Le_Expr =>
return B (V (Node.Op1) <= V (Node.Op2));
when Gt_Expr =>
return B (V (Node.Op1) > V (Node.Op2));
when Ge_Expr =>
return B (V (Node.Op1) >= V (Node.Op2));
when Eq_Expr =>
return B (V (Node.Op1) = V (Node.Op2));
when Ne_Expr =>
return B (V (Node.Op1) /= V (Node.Op2));
when Discrim_Val =>
declare
Sub : constant Int := UI_To_Int (Node.Op1);
begin
pragma Assert (Sub in D'Range);
return D (Sub);
end;
when Dynamic_Val =>
return No_Uint;
end case;
end;
end if;
end V;
-------
-- W --
-------
-- We use an unchecked conversion to map Int values to their Word
-- bitwise equivalent, which we could not achieve with a normal type
-- conversion for negative Ints. We want bitwise equivalents because W
-- is used as a helper for bit operators like Bit_And_Expr, and can be
-- called for negative Ints in the context of aligning expressions like
-- X+Align & -Align.
function W (Val : Uint) return Word is
function To_Word is new Ada.Unchecked_Conversion (Int, Word);
begin
return To_Word (UI_To_Int (Val));
end W;
-- Start of processing for Rep_Value
begin
if Val = No_Uint then
return No_Uint;
else
return V (Val);
end if;
end Rep_Value;
------------
-- Spaces --
------------
procedure Spaces (N : Natural) is
begin
for J in 1 .. N loop
Write_Char (' ');
end loop;
end Spaces;
---------------------
-- Write_Info_Line --
---------------------
procedure Write_Info_Line (S : String) is
begin
Write_Repinfo_Line_Access.all (S (S'First .. S'Last - 1));
end Write_Info_Line;
---------------------
-- Write_Mechanism --
---------------------
procedure Write_Mechanism (M : Mechanism_Type) is
begin
case M is
when 0 =>
Write_Str ("default");
when -1 =>
Write_Str ("copy");
when -2 =>
Write_Str ("reference");
when others =>
raise Program_Error;
end case;
end Write_Mechanism;
---------------------
-- Write_Separator --
---------------------
procedure Write_Separator is
begin
if Need_Separator then
if List_Representation_Info_To_JSON then
Write_Line (",");
else
Write_Eol;
end if;
else
Need_Separator := True;
end if;
end Write_Separator;
-----------------------
-- Write_Unknown_Val --
-----------------------
procedure Write_Unknown_Val is
begin
if List_Representation_Info_To_JSON then
Write_Str ("""??""");
else
Write_Str ("??");
end if;
end Write_Unknown_Val;
---------------
-- Write_Val --
---------------
procedure Write_Val (Val : Node_Ref_Or_Val; Paren : Boolean := False) is
begin
if Rep_Not_Constant (Val) then
if List_Representation_Info < 3 or else Val = No_Uint then
Write_Unknown_Val;
else
if Paren then
Write_Char ('(');
end if;
if Back_End_Layout then
List_GCC_Expression (Val);
else
Write_Name_Decoded (Chars (Get_Dynamic_SO_Entity (Val)));
end if;
if Paren then
Write_Char (')');
end if;
end if;
else
UI_Write (Val, Decimal);
end if;
end Write_Val;
end Repinfo;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with System;
package HAL.Filesystem is
pragma Preelaborate;
type Status_Code is
(OK,
Non_Empty_Directory,
Disk_Error, -- A hardware error occurred in the low level disk I/O
Disk_Full,
Internal_Error,
Drive_Not_Ready,
No_Such_File,
No_Such_Path,
Not_Mounted, -- The mount point is invalid
Invalid_Name,
Access_Denied,
Already_Exists,
Invalid_Object_Entry,
Write_Protected,
Invalid_Drive,
No_Filesystem, -- The volume is not a FAT volume
Locked,
Too_Many_Open_Files, -- All available handles are used
Invalid_Parameter,
Input_Output_Error,
No_MBR_Found,
No_Partition_Found,
No_More_Entries,
Read_Only_File_System,
Operation_Not_Permitted);
type File_Mode is (Read_Only, Write_Only, Read_Write);
type Seek_Mode is
(
-- Seek from the beginning of the file, forward
From_Start,
-- Seek from the end of the file, backward
From_End,
-- Seek from the current position, forward
Forward,
-- Seek from the current position, backward
Backward);
type File_Size is new HAL.UInt64;
-- Modern fs all support 64-bit file size. Only old or limited ones support
-- max 32-bit (FAT in particular). So let's see big and not limit ourselves
-- in this API with 32-bit only.
type Filesystem_Driver is limited interface;
type Any_Filesystem_Driver is access all Filesystem_Driver'Class;
type Directory_Handle is limited interface;
type Any_Directory_Handle is access all Directory_Handle'Class;
type File_Handle is limited interface;
type Any_File_Handle is access all File_Handle'Class;
type Node_Handle is interface;
type Any_Node_Handle is access all Node_Handle'Class;
---------------------------
-- Directory operations --
---------------------------
function Open
(This : in out Filesystem_Driver;
Path : String;
Handle : out Any_Directory_Handle)
return Status_Code is abstract;
-- Open a new Directory Handle at the given Filesystem_Driver Path
function Create_File (This : in out Filesystem_Driver;
Path : String)
return Status_Code is abstract;
function Unlink (This : in out Filesystem_Driver;
Path : String)
return Status_Code is abstract;
-- Remove the regular file located at Path in the This filesystem_Driver
function Remove_Directory (This : in out Filesystem_Driver;
Path : String)
return Status_Code is abstract;
-- Remove the directory located at Path in the This filesystem_Driver
function Get_FS
(This : Directory_Handle) return Any_Filesystem_Driver
is abstract;
-- Return the filesystem_Driver the handle belongs to.
function Root_Node
(This : in out Filesystem_Driver;
As : String;
Handle : out Any_Node_Handle)
return Status_Code is abstract;
-- Open a new Directory Handle at the given Filesystem_Driver Path
function Read
(This : in out Directory_Handle;
Handle : out Any_Node_Handle)
return Status_Code is abstract;
-- Reads the next directory entry. If no such entry is there, an error
-- code is returned in Status.
procedure Reset (This : in out Directory_Handle) is abstract;
-- Resets the handle to the first node
procedure Close (This : in out Directory_Handle) is abstract;
-- Closes the handle, and free the associated resources.
---------------------
-- Node operations --
---------------------
function Get_FS (This : Node_Handle) return Any_Filesystem_Driver is abstract;
function Basename (This : Node_Handle) return String is abstract;
function Is_Read_Only (This : Node_Handle) return Boolean is abstract;
function Is_Hidden (This : Node_Handle) return Boolean is abstract;
function Is_Subdirectory (This : Node_Handle) return Boolean is abstract;
function Is_Symlink (This : Node_Handle) return Boolean is abstract;
function Size (This : Node_Handle) return File_Size is abstract;
procedure Close (This : in out Node_Handle) is abstract;
---------------------
-- File operations --
---------------------
function Open
(This : in out Filesystem_Driver;
Path : String;
Mode : File_Mode;
Handle : out Any_File_Handle)
return Status_Code is abstract;
-- Open a new File Handle at the given Filesystem_Driver Path
function Open
(This : Node_Handle;
Name : String;
Mode : File_Mode;
Handle : out Any_File_Handle)
return Status_Code is abstract
with Pre'Class => Is_Subdirectory (This);
function Get_FS
(This : in out File_Handle) return Any_Filesystem_Driver is abstract;
function Size
(This : File_Handle) return File_Size is abstract;
function Mode
(This : File_Handle) return File_Mode is abstract;
function Read
(This : in out File_Handle;
Addr : System.Address;
Length : in out File_Size)
return Status_Code is abstract
with Pre'Class => Mode (This) in Read_Only | Read_Write;
function Write
(This : in out File_Handle;
Addr : System.Address;
Length : File_Size)
return Status_Code is abstract
with
Pre'Class => Mode (This) in Write_Only | Read_Write;
function Offset
(This : File_Handle)
return File_Size is abstract;
function Flush
(This : in out File_Handle)
return Status_Code is abstract;
function Seek
(This : in out File_Handle;
Origin : Seek_Mode;
Amount : in out File_Size)
return Status_Code is abstract;
procedure Close (This : in out File_Handle) is abstract;
-------------------
-- FS operations --
-------------------
procedure Close (This : in out Filesystem_Driver) is abstract;
end HAL.Filesystem;
|
-- Copyright 2017-2021 Bartek thindil Jasicki
--
-- This file is part of Steam Sky.
--
-- Steam Sky 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.
--
-- Steam Sky 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 Steam Sky. If not, see <http://www.gnu.org/licenses/>.
-- ****h* Ships/SMovement
-- FUNCTION
-- Provides code related to ships movement
-- SOURCE
package Ships.Movement is
-- ****
-- ****f* SMovement/SMovement.MoveShip
-- FUNCTION
-- Move player ship
-- PARAMETERS
-- X - Amount of X coordinate fields to move player ship
-- Y - Amount of Y coordinate fields to move player ship
-- Message - If ship cannot be moved, here will be reason of why
-- RESULT
-- State after move (or not, then return 0) player ship and parameter
-- Message
-- SOURCE
function MoveShip
(X, Y: Integer; Message: in out Unbounded_String) return Natural with
Test_Case => (Name => "Test_MoveShip", Mode => Robustness);
-- ****
-- ****f* SMovement/SMovement.DockShip
-- FUNCTION
-- Dock/Undock ship at base
-- PARAMETERS
-- Docking - If true, ship docks to the base, otherwise false
-- Escape - If true, the player is trying to escape from the base
-- without paying. Default value is False
-- RESULT
-- Empty string if operation was succesfull, otherwise message what goes
-- wrong
-- SOURCE
function DockShip
(Docking: Boolean; Escape: Boolean := False) return String with
Test_Case => (Name => "Test_DockShip", Mode => Robustness);
-- ****
-- ****f* SMovement/SMovement.ChangeShipSpeed
-- FUNCTION
-- Change speed of ship
-- PARAMETERS
-- SpeedValue - New speed for the ship
-- RESULT
-- Empty string if speed was changed, otherwise message what goes wrong
-- SOURCE
function ChangeShipSpeed(SpeedValue: Ship_Speed) return String with
Test_Case => (Name => "Test_ChangeShipSpeed", Mode => Robustness);
-- ****
-- ****f* SMovement/SMovement.RealSpeed
-- FUNCTION
-- Count real ship speed in meters per minute
-- PARAMETERS
-- Ship - Ship which real speed will be counted
-- InfoOnly - If true and ship is docked to the base, count max speed
-- of the ship. Default is false
-- RESULT
-- The real speed of the selected ship or 0 if the ship can't move
-- SOURCE
function RealSpeed
(Ship: Ship_Record; InfoOnly: Boolean := False) return Natural with
Test_Case => (Name => "Test_RealSpeed", Mode => Robustness);
-- ****
-- ****f* SMovement/SMovement.CountFuelNeeded
-- FUNCTION
-- Count amount of fuel needed by player ship to travel
-- RESULT
-- Amount of fuel needed by player ship to travel
-- SOURCE
function CountFuelNeeded return Integer with
Test_Case => (Name => "Test_CountFuelNeeded", Mode => Robustness);
-- ****
-- ****f* SMovement/SMovement.WaitInPlace
-- FUNCTION
-- Use fuel when ship wait in place
-- PARAMETERS
-- Minutes - Amount of passed in-game minutes
-- SOURCE
procedure WaitInPlace(Minutes: Positive) with
Test_Case => (Name => "Test_WaitInPlace", Mode => Robustness);
-- ****
end Ships.Movement;
|
------------------------------------------------------------------------------
-- --
-- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . O S _ I N T E R F A C E --
-- --
-- S p e c --
-- --
-- $Revision$
-- --
-- Copyright (C) 1991-2001 Florida State University --
-- --
-- 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 2, 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. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNARL; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. It is --
-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
-- State University (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
-- RT GNU/Linux version.
-- This package encapsulates all direct interfaces to OS services
-- that are needed by children of System.
-- PLEASE DO NOT add any with-clauses to this package
-- or remove the pragma Elaborate_Body.
-- It is designed to be a bottom-level (leaf) package.
with Interfaces.C;
package System.OS_Interface is
pragma Preelaborate;
subtype int is Interfaces.C.int;
subtype unsigned_long is Interfaces.C.unsigned_long;
-- RT GNU/Linux kernel threads should not use the
-- OS signal interfaces.
Max_Interrupt : constant := 2;
type Signal is new int range 0 .. Max_Interrupt;
type sigset_t is new Integer;
----------
-- Time --
----------
RT_TICKS_PER_SEC : constant := 1193180;
-- the amount of time units in one second.
RT_TIME_END : constant := 16#7fffFfffFfffFfff#;
type RTIME is range -2 ** 63 .. 2 ** 63 - 1;
-- the introduction of type RTIME is due to the fact that RT-GNU/Linux
-- uses this type to represent time. In RT-GNU/Linux, it's a long long
-- integer that takes 64 bits for storage
-------------------------
-- Priority Scheduling --
-------------------------
RT_LOWEST_PRIORITY : constant System.Any_Priority :=
System.Any_Priority'First;
-- for the lowest priority task in RT-GNU/Linux. By the design, this
-- task is the regular GNU/Linux kernel.
RT_TASK_MAGIC : constant := 16#754d2774#;
-- a special constant used as a label for a task that has been created
----------------------------
-- RT constants and types --
----------------------------
SFIF : Integer;
pragma Import (C, SFIF, "SFIF");
-- Interrupt emulation flag used by RT-GNU/Linux. If it's 0, the regular
-- GNU/Linux kernel is preempted. Otherwise, the regular Linux kernel is
-- running
GFP_ATOMIC : constant := 16#1#;
GFP_KERNEL : constant := 16#3#;
-- constants to indicate the priority of a call to kmalloc.
-- GFP_KERNEL is used in the current implementation to allocate
-- stack space for a task. Since GFP_ATOMIC has higher priority,
-- if necessary, replace GFP_KERNEL with GFP_ATOMIC
type Rt_Task_States is (RT_TASK_READY, RT_TASK_DELAYED, RT_TASK_DORMANT);
-------------
-- Threads --
-------------
type Thread_Body is access
function (arg : System.Address) return System.Address;
-- ??? need to define a type for references to (IDs of)
-- RT GNU/Linux lock objects, and implement the lock objects.
subtype Thread_Id is System.Address;
-------------------------------
-- Useful imported functions --
-------------------------------
-------------------------------------
-- Functions from GNU/Linux kernel --
-------------------------------------
function Kmalloc (size : Integer; Priority : Integer) return System.Address;
pragma Import (C, Kmalloc, "kmalloc");
procedure Kfree (Ptr : System.Address);
pragma Import (C, Kfree, "kfree");
procedure Printk (Msg : String);
pragma Import (C, Printk, "printk");
---------------------
-- RT time related --
---------------------
function Rt_Get_Time return RTIME;
pragma Import (C, Rt_Get_Time, "rt_get_time");
function Rt_Request_Timer (Fn : System.Address) return Integer;
procedure Rt_Request_Timer (Fn : System.Address);
pragma Import (C, Rt_Request_Timer, "rt_request_timer");
procedure Rt_Free_Timer;
pragma Import (C, Rt_Free_Timer, "rt_free_timer");
procedure Rt_Set_Timer (T : RTIME);
pragma Import (C, Rt_Set_Timer, "rt_set_timer");
procedure Rt_No_Timer;
pragma Import (C, Rt_No_Timer, "rt_no_timer");
---------------------
-- RT FIFO related --
---------------------
function Rtf_Create (Fifo : Integer; Size : Integer) return Integer;
pragma Import (C, Rtf_Create, "rtf_create");
function Rtf_Destroy (Fifo : Integer) return Integer;
pragma Import (C, Rtf_Destroy, "rtf_destroy");
function Rtf_Resize (Minor : Integer; Size : Integer) return Integer;
pragma Import (C, Rtf_Resize, "rtf_resize");
function Rtf_Put
(Fifo : Integer;
Buf : System.Address;
Count : Integer) return Integer;
pragma Import (C, Rtf_Put, "rtf_put");
function Rtf_Get
(Fifo : Integer;
Buf : System.Address;
Count : Integer) return Integer;
pragma Import (C, Rtf_Get, "rtf_get");
function Rtf_Create_Handler
(Fifo : Integer;
Handler : System.Address) return Integer;
pragma Import (C, Rtf_Create_Handler, "rtf_create_handler");
private
type Require_Body;
end System.OS_Interface;
|
package body GA_Sine_Globals is
--------------------
-- Toggle_Options --
--------------------
procedure Toggle_Options (started : Boolean) is
begin
for i in Enum_Options loop
declare
option : Option_Use renames options (i).optionUse;
widget : access Gtk_Widget_Record'Class renames
options (i).optionWidget;
begin
if started and then option = OU_Before then
Set_Sensitive (widget, False);
else
Set_Sensitive (widget, True);
end if;
end;
end loop;
end Toggle_Options;
end GA_Sine_Globals;
|
package body scanner.IO is
use Ada.Wide_Wide_Text_IO;
-- Gets input and stuffs it into 'buf'. number of characters read, or
-- YY_NULL is returned in 'result'.
procedure YY_Input
(Buf : out Unbounded_Character_Array;
Result : out Integer;
Max_Size : integer)
is
C : Wide_Wide_character;
I : Integer := 1;
Loc : Integer := Buf'First;
begin
if Is_Open (User_Input_File) then
while I <= Max_Size loop
if End_Of_Line (User_Input_File) then
-- Ada ate our newline, put it back on the end.
Buf (Loc) := Ada.Characters.Wide_Wide_Latin_1.LF;
Skip_Line (User_Input_File, 1);
else
-- UCI CODES CHANGED:
-- The following codes are modified. Previous codes is commented out.
-- The purpose of doing this is to make it possible to set Temp_Line
-- in Ayacc-extension specific codes. Definitely, we can read the character
-- into the Temp_Line and then set the buf. But Temp_Line will only
-- be used in Ayacc-extension specific codes which makes this approach impossible.
Get (User_Input_File, C);
Buf (Loc) := C;
-- get(user_input_file, buf(loc));
end if;
Loc := Loc + 1;
I := I + 1;
end loop;
else
while I <= Max_Size loop
if end_of_line then
-- Ada ate our newline, put it back on the end.
Buf (Loc) := Ada.Characters.Wide_Wide_Latin_1.LF;
Skip_Line (1);
else
-- The following codes are modified. Previous codes is commented out.
-- The purpose of doing this is to make it possible to set Temp_Line
-- in Ayacc-extension specific codes. Definitely, we can read the character
-- into the Temp_Line and then set the buf. But Temp_Line will only
-- be used in Ayacc-extension specific codes which makes this approach impossible.
get(c);
buf(loc) := c;
-- get(buf(loc));
end if;
loc := loc + 1;
i := i + 1;
end loop;
end if; -- for input file being standard input
result := i - 1;
exception
when END_ERROR => result := i - 1;
-- when we hit EOF we need to set yy_eof_has_been_seen
yy_eof_has_been_seen := true;
end YY_INPUT;
-- yy_get_next_buffer - try to read in new buffer
--
-- returns a code representing an action
-- EOB_ACT_LAST_MATCH -
-- EOB_ACT_RESTART_SCAN - restart the scanner
-- EOB_ACT_END_OF_FILE - end of file
function yy_get_next_buffer return eob_action_type is
dest : integer := 0;
source : integer := yytext_ptr - 1; -- copy prev. char, too
number_to_move : integer;
ret_val : eob_action_type;
num_to_read : integer;
begin
if ( yy_c_buf_p > yy_n_chars + 1 ) then
raise NULL_IN_INPUT;
end if;
-- try to read more data
-- first move last chars to start of buffer
number_to_move := yy_c_buf_p - yytext_ptr;
for i in 0..number_to_move - 1 loop
yy_ch_buf.data (dest) := yy_ch_buf.data (source);
dest := dest + 1;
source := source + 1;
end loop;
if ( yy_eof_has_been_seen ) then
-- don't do the read, it's not guaranteed to return an EOF,
-- just force an EOF
yy_n_chars := 0;
else
num_to_read := YY_BUF_SIZE - number_to_move - 1;
if ( num_to_read > YY_READ_BUF_SIZE ) then
num_to_read := YY_READ_BUF_SIZE;
end if;
-- read in more data
YY_INPUT( yy_ch_buf.data (number_to_move..yy_ch_buf.data'last), yy_n_chars, num_to_read );
end if;
if ( yy_n_chars = 0 ) then
if ( number_to_move = 1 ) then
ret_val := EOB_ACT_END_OF_FILE;
else
ret_val := EOB_ACT_LAST_MATCH;
end if;
yy_eof_has_been_seen := true;
else
ret_val := EOB_ACT_RESTART_SCAN;
end if;
yy_n_chars := yy_n_chars + number_to_move;
yy_ch_buf.data (yy_n_chars) := YY_END_OF_BUFFER_CHAR;
yy_ch_buf.data (yy_n_chars + 1) := YY_END_OF_BUFFER_CHAR;
-- yytext begins at the second character in
-- yy_ch_buf; the first character is the one which
-- preceded it before reading in the latest buffer;
-- it needs to be kept around in case it's a
-- newline, so yy_get_previous_state() will have
-- with '^' rules active
yytext_ptr := 1;
return ret_val;
end yy_get_next_buffer;
procedure YYUnput (C : Wide_Wide_Character; YY_BP: in out Integer) is
number_to_move : Integer;
dest : integer;
source : integer;
tmp_yy_cp : integer;
begin
tmp_yy_cp := yy_c_buf_p;
if ( tmp_yy_cp < 2 ) then
-- need to shift things up to make room
number_to_move := yy_n_chars + 2; -- +2 for EOB chars
dest := YY_BUF_SIZE + 2;
source := number_to_move;
while ( source > 0 ) loop
dest := dest - 1;
source := source - 1;
yy_ch_buf.data (dest) := yy_ch_buf.data (source);
end loop;
tmp_yy_cp := tmp_yy_cp + dest - source;
yy_bp := yy_bp + dest - source;
yy_n_chars := YY_BUF_SIZE;
if ( tmp_yy_cp < 2 ) then
raise PUSHBACK_OVERFLOW;
end if;
end if;
if tmp_yy_cp > yy_bp
and then yy_ch_buf.data (tmp_yy_cp-1) = Ada.Characters.Wide_Wide_Latin_1.LF
then
yy_ch_buf.data (tmp_yy_cp-2) := Ada.Characters.Wide_Wide_Latin_1.LF;
end if;
tmp_yy_cp := tmp_yy_cp - 1;
yy_ch_buf.data (tmp_yy_cp) := c;
-- Note: this code is the text of YY_DO_BEFORE_ACTION, only
-- here we get different yy_cp and yy_bp's
yytext_ptr := yy_bp;
yy_c_buf_p := tmp_yy_cp;
end yyunput;
procedure Unput (C : Wide_Wide_Character) is
begin
YYUnput (C, yy_bp);
end Unput;
function Input return Wide_Wide_Character is
C : Wide_Wide_Character;
YY_CP : Integer := YY_C_Buf_P;
begin
if YY_CH_Buf.Data (YY_C_Buf_P) = YY_END_OF_BUFFER_CHAR then
-- need more input
yytext_ptr := yy_c_buf_p;
yy_c_buf_p := yy_c_buf_p + 1;
case yy_get_next_buffer is
-- this code, unfortunately, is somewhat redundant with
-- that above
when EOB_ACT_END_OF_FILE =>
if yywrap then
yy_c_buf_p := yytext_ptr;
return Ada.Characters.Wide_Wide_Latin_1.NUL;
end if;
yy_ch_buf.data (0) := Ada.Characters.Wide_Wide_Latin_1.LF;
yy_n_chars := 1;
yy_ch_buf.data (yy_n_chars) := YY_END_OF_BUFFER_CHAR;
yy_ch_buf.data (yy_n_chars + 1) := YY_END_OF_BUFFER_CHAR;
yy_eof_has_been_seen := false;
yy_c_buf_p := 1;
yytext_ptr := yy_c_buf_p;
return Input;
when EOB_ACT_RESTART_SCAN =>
yy_c_buf_p := yytext_ptr;
when EOB_ACT_LAST_MATCH =>
raise UNEXPECTED_LAST_MATCH;
when others => null;
end case;
end if;
c := yy_ch_buf.data (yy_c_buf_p);
yy_c_buf_p := yy_c_buf_p + 1;
return C;
end Input;
procedure Output (C : Wide_Wide_Character) is
begin
if Is_Open (User_Output_File) then
Put (User_Output_File, C);
else
Put (C);
end if;
end Output;
-- Default yywrap function - always treat EOF as an EOF
function YYWrap return Boolean is
begin
return True;
end YYWrap;
procedure Open_Input (FName : String) is
begin
YY_Init := True;
Open (User_Input_File, In_File, FName, "wcem=8");
end Open_Input;
procedure Create_Output (FName : String := "") is
begin
if fname /= "" then
Create (User_Output_File, Out_File, FName);
end if;
end Create_Output;
procedure Close_Input is
begin
if Is_Open (User_Input_File) then
Close (User_Input_File);
end if;
end Close_Input;
procedure Close_Output is
begin
if Is_Open (User_Output_File) then
Close (User_Output_File);
end if;
end Close_Output;
end scanner.IO;
|
with STM32.SYSCFG;
with Ada.Real_Time;
package body STM32.COMP is
------------
-- Enable --
------------
procedure Enable (This : in out Comparator) is
use Ada.Real_Time;
begin
-- Enable clock for the SYSCFG_COMP_OPAMP peripheral
STM32.SYSCFG.Enable_SYSCFG_Clock;
This.CSR.EN := True;
-- Delay required to reach propagation delay specification.
delay until Clock + Microseconds (10);
end Enable;
-------------
-- Disable --
-------------
procedure Disable (This : in out Comparator) is
begin
This.CSR.EN := False;
end Disable;
-------------
-- Enabled --
-------------
function Enabled (This : Comparator) return Boolean is
begin
return This.CSR.EN;
end Enabled;
------------------------------
-- Set_Inverting_Input_Port --
------------------------------
procedure Set_Inverting_Input_Port
(This : in out Comparator;
Input : Inverting_Input_Port) is
begin
This.CSR.INMSEL_3 := Input'Enum_Rep > 7;
This.CSR.INMSEL := UInt3 (Input'Enum_Rep);
end Set_Inverting_Input_Port;
------------------------------
-- Get_Inverting_Input_Port --
------------------------------
function Get_Inverting_Input_Port
(This : Comparator) return Inverting_Input_Port
is
Value : UInt4;
begin
if This.CSR.INMSEL_3 then
Value := UInt4 (This.CSR.INMSEL) + 8;
else
Value := UInt4 (This.CSR.INMSEL);
end if;
return Inverting_Input_Port'Val (Value);
end Get_Inverting_Input_Port;
----------------------
-- Set_Output_Timer --
----------------------
procedure Set_Output_Timer (This : in out Comparator;
Output : Output_Selection) is
begin
This.CSR.OUTSEL := Output'Enum_Rep;
end Set_Output_Timer;
----------------------
-- Get_Output_Timer --
----------------------
function Get_Output_Timer (This : Comparator) return Output_Selection is
begin
return Output_Selection'Val (This.CSR.OUTSEL);
end Get_Output_Timer;
-------------------------
-- Set_Output_Polarity --
-------------------------
procedure Set_Output_Polarity (This : in out Comparator;
Output : Output_Polarity) is
begin
This.CSR.POL := Output = Inverted;
end Set_Output_Polarity;
-------------------------
-- Get_Output_Polarity --
-------------------------
function Get_Output_Polarity (This : Comparator) return Output_Polarity is
begin
return Output_Polarity'Val (Boolean'Pos (This.CSR.POL));
end Get_Output_Polarity;
-------------------------
-- Set_Output_Blanking --
-------------------------
procedure Set_Output_Blanking (This : in out Comparator;
Output : Output_Blanking) is
begin
This.CSR.BLANKING := Output'Enum_Rep;
end Set_Output_Blanking;
-------------------------
-- Get_Output_Blanking --
-------------------------
function Get_Output_Blanking (This : Comparator) return Output_Blanking is
begin
return Output_Blanking'Val (This.CSR.BLANKING);
end Get_Output_Blanking;
--------------------------
-- Configure_Comparator --
--------------------------
procedure Configure_Comparator
(This : in out Comparator;
Param : Init_Parameters)
is
begin
This.CSR :=
(INMSEL => Param.Input_Minus'Enum_Rep,
OUTSEL => Param.Output_Timer'Enum_Rep,
POL => Param.Output_Pol = Inverted,
BLANKING => Param.Blanking_Source'Enum_Rep,
others => <>);
end Configure_Comparator;
---------------------------
-- Get_Comparator_Output --
---------------------------
function Get_Comparator_Output
(This : Comparator) return Comparator_Output is
begin
return Comparator_Output'Val (Boolean'Pos (This.CSR.OUT_k));
end Get_Comparator_Output;
-------------------------
-- Set_Lock_Comparator --
-------------------------
procedure Set_Lock_Comparator (This : in out Comparator) is
begin
This.CSR.LOCK := True;
end Set_Lock_Comparator;
-------------------------
-- Get_Lock_Comparator --
-------------------------
function Get_Lock_Comparator (This : Comparator) return Boolean is
begin
return This.CSR.LOCK;
end Get_Lock_Comparator;
end STM32.COMP;
|
-----------------------------------------------------------------------
-- helios-commands-check -- Helios check commands
-- Copyright (C) 2017, 2018, 2019 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Real_Time;
with Ada.Text_IO;
with Util.Events.Timers;
with Helios.Monitor.Agent;
with Helios.Reports.Files;
package body Helios.Commands.Check is
use type Ada.Real_Time.Time_Span;
-- ------------------------------
-- Execute a information command to report information about the agent and monitoring.
-- ------------------------------
overriding
procedure Execute (Command : in out Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is
pragma Unreferenced (Command, Name);
type Info_Report is new Helios.Reports.Files.File_Report_Type with null record;
-- The timer handler executed when the timer deadline has passed.
overriding
procedure Time_Handler (Report : in out Info_Report;
Event : in out Util.Events.Timers.Timer_Ref'Class);
-- ------------------------------
-- The timer handler executed when the timer deadline has passed.
-- ------------------------------
overriding
procedure Time_Handler (Report : in out Info_Report;
Event : in out Util.Events.Timers.Timer_Ref'Class) is
begin
Helios.Reports.Files.File_Report_Type (Report).Time_Handler (Event);
Context.Runtime.Stop := True;
end Time_Handler;
Timer : Util.Events.Timers.Timer_Ref;
Report : aliased Info_Report;
begin
if Args.Get_Count /= 1 then
Helios.Commands.Usage (Args);
else
Report.Path := Ada.Strings.Unbounded.To_Unbounded_String (Args.Get_Argument (1));
Load (Context);
Monitor.Agent.Configure (Context.Runtime, Context.Config);
Context.Runtime.Timers.Set_Timer (Report'Unchecked_Access, Timer,
Context.Runtime.Report_Period
+ Ada.Real_Time.Seconds (1));
Monitor.Agent.Run (Context.Runtime);
end if;
end Execute;
-- ------------------------------
-- Write the help associated with the command.
-- ------------------------------
overriding
procedure Help (Command : in out Command_Type;
Name : in String;
Context : in out Context_Type) is
pragma Unreferenced (Name, Command, Context);
begin
Ada.Text_IO.Put_Line ("check: check the configuration and collect results in a file");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line ("Usage: check {result-file}");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line (" The check command reads the configuration files, ");
Ada.Text_IO.Put_Line (" configures the plugin agents and collects the data to generate");
Ada.Text_IO.Put_Line (" a JSON file that contains the results. The JSON file can be");
Ada.Text_IO.Put_Line (" checked to verify the values that were collected.");
end Help;
end Helios.Commands.Check;
|
pragma SPARK_Mode;
with Interfaces.C; use Interfaces.C;
package Types is
type Byte is mod 2 ** 8
with Size => 8;
subtype Byte_Array_Index_Type is Byte range Byte'First .. Byte'Last - 1;
type Word is mod 65536
with Size => 16;
type Byte_Array is array (Byte_Array_Index_Type range <>) of Byte
with Pack;
-- enum for tracking axises
-- @value X x axis
-- @value Y y axis
-- @value Z z axis
type Axises is (X, Y, Z);
type Axis_Data is array (Axises) of short;
-- Mode for a pin
-- @value INPUT input mode
-- @value OUTPUT output mode
-- @value INPUT_PULLUP input mode with internal pullup
type PinMode is
(INPUT,
OUTPUT,
INPUT_PULLUP);
-- Value for pin
-- @value LOW pin low
-- @value HIGH pin high
type DigPinValue is
(LOW,
HIGH);
-- Pull up state for a pin
-- @value Disabled pullup disabled
-- @value Enabled pullup enabled
type PinPullUpState is
(Disabled,
Enabled);
-- Default state for a pin
-- @value DefaultStateLow set the default value of a pin low
-- @value DefaultStateHigh set the default value of a pin high
type PinDefaultState is
(DefaultStateLow,
DefaultStateHigh);
-- Frequency for the buzzer
type Frequency is new Natural range 40 .. 10_000;
-- Volume for the buzzer
type Volume is new Natural range 0 .. 15
with Size => 8;
-- Duration for a note on the buzzer
type Duration is new Natural;
-- Max value that a sensor will have to decay
Timeout : constant := 1000;
-- Number of sensors in the array
Num_Sensors : constant := 6;
type Sensor_Value is new Natural range 0 .. Timeout;
type Sensor_Array is array (1 .. Num_Sensors) of Sensor_Value;
Robot_Scale : constant := (Num_Sensors - 1) * Timeout / 2;
-- Type used to determine where with the line is ref to the robot
subtype Robot_Position is Integer range (-1) * Robot_Scale .. Robot_Scale;
subtype Sensor_Value_Scaled is Float range 0.0 .. 1.0;
type Sensor_Scaled_Array is array (1 .. 6) of Sensor_Value_Scaled;
-- Mode to read sensors with
-- @value Emitters_Off read sensors with emitters off
-- @value Emitters_On read sensors with the emitters on
-- @value Emitters_On_Off read sensors with emitters on then again with off
type Sensor_Read_Mode is
(Emitters_Off,
Emitters_On,
Emitters_On_Off);
-- Max value for the motor speed
PWM_Max : constant := 400;
subtype Motor_Speed is Integer range (-1) * PWM_Max .. PWM_Max;
subtype Degrees is Float;
type Degree_Axis is array (Axises) of Degrees;
type Boolean_Array is array (Integer range <>) of Boolean;
end Types;
|
-- { dg-do compile }
-- { dg-options "-gnatws" }
with Slice8_Pkg1;
with Slice8_Pkg3;
procedure Slice8 is
package Bp is new Slice8_Pkg3 (Slice8_Pkg1);
begin
null;
end;
|
with Ada.Text_IO;
procedure Hofstadter_Q_Sequence is
type Callback is access procedure(N: Positive);
procedure Q(First, Last: Positive; Q_Proc: Callback) is
-- calls Q_Proc(Q(First)); Q_Proc(Q(First+1)); ... Q_Proc(Q(Last));
-- precondition: Last > 2
Q_Store: array(1 .. Last) of Natural := (1 => 1, 2 => 1, others => 0);
-- "global" array to store the Q(I)
-- if Q_Store(I)=0, we compute Q(I) and update Q_Store(I)
-- else we already know Q(I) = Q_Store(I)
function Q(N: Positive) return Positive is
begin
if Q_Store(N) = 0 then
Q_Store(N) := Q(N - Q(N-1)) + Q(N-Q(N-2));
end if;
return Q_Store(N);
end Q;
begin
for I in First .. Last loop
Q_Proc(Q(I));
end loop;
end Q;
procedure Print(P: Positive) is
begin
Ada.Text_IO.Put(Positive'Image(P));
end Print;
Decrease_Counter: Natural := 0;
Previous_Value: Positive := 1;
procedure Decrease_Count(P: Positive) is
begin
if P < Previous_Value then
Decrease_Counter := Decrease_Counter + 1;
end if;
Previous_Value := P;
end Decrease_Count;
begin
Q(1, 10, Print'Access);
-- the first ten terms of the sequence are: 1, 1, 2, 3, 3, 4, 5, 5, 6, and 6
Ada.Text_IO.New_Line;
Q(1000, 1000, Print'Access);
-- the 1000'th term is: 502
Ada.Text_IO.New_Line;
Q(2, 100_000, Decrease_Count'Access);
Ada.Text_IO.Put_Line(Integer'Image(Decrease_Counter));
-- how many times a member of the sequence is less than its preceding term
-- for terms up to and including the 100,000'th term
end Hofstadter_Q_Sequence;
|
package body Bubble with SPARK_Mode is
procedure Sort (A : in out Arr) is
Tmp : Integer;
begin
Outer: for I in reverse A'First .. A'Last - 1 loop
Inner: for J in A'First .. I loop
if A(J) > A(J + 1) then
Tmp := A(J);
A(J) := A(J + 1);
A(J + 1) := Tmp;
end if;
pragma Loop_Invariant (for all K1 in A'Range => (for some K2 in A'Range => A(K2) = A'Loop_Entry(Inner)(K1)));
end loop Inner;
pragma Loop_Invariant (for all K1 in A'Range => (for some K2 in A'Range => A(K2) = A'Loop_Entry(Outer)(K1)));
end loop Outer;
end Sort;
end Bubble;
|
--PRÁCTICA 4: CÉSAR BORAO MORATINOS (Handlers.adb)
with Ada.Text_IO;
with Chat_Messages;
with Chat_Procedures;
with Ada.Strings.Unbounded;
package body Handlers is
package ATI renames Ada.Text_IO;
package CM renames Chat_Messages;
package CP renames Chat_Procedures;
package ASU renames Ada.Strings.Unbounded;
procedure Client_Handler(From: in LLU.End_Point_Type;
To: in LLU.End_Point_Type;
P_Buffer: access LLU.Buffer_Type) is
Mess: CM.Message_Type;
Nick: ASU.Unbounded_String;
Comment: ASU.Unbounded_String;
begin
Mess := CM.Message_Type'Input(P_Buffer);
Nick := ASU.Unbounded_String'Input(P_Buffer);
Comment := ASU.Unbounded_String'Input(P_Buffer);
ATI.New_Line;
ATI.Put_Line(ASU.To_String(Nick) & ": " & ASU.To_String(Comment));
LLU.Reset(P_Buffer.all);
ATI.Put(">> ");
end Client_Handler;
procedure Server_Handler (From: in LLU.End_Point_Type;
To: in LLU.End_Point_Type;
P_Buffer: access LLU.Buffer_Type) is
Mess: CM.Message_Type;
Buffer_Out: aliased LLU.Buffer_Type(1024);
begin
Mess := CM.Message_Type'Input (P_Buffer);
case Mess is
when CM.Init =>
CP.Case_Init(P_Buffer,Buffer_Out'Access);
when CM.Writer =>
CP.Case_Writer(P_Buffer,Buffer_Out'Access);
when CM.Logout =>
CP.Case_Logout(P_Buffer,Buffer_Out'Access);
when others =>
ATI.Put_Line("Unknown message type");
end case;
LLU.Reset (P_Buffer.all);
end Server_Handler;
end Handlers;
|
with Ada.Unchecked_Conversion;
with C_String;
with Interfaces.C;
with System;
package body Agar.Core.DSO is
package C renames Interfaces.C;
use type C.int;
function Load
(Name : in String;
Path : in String) return DSO_Access_t
is
Ch_Name : aliased C.char_array := C.To_C (Name);
Ch_Path : aliased C.char_array := C.To_C (Path);
begin
return Thin.DSO.Load
(Name => C_String.To_C_String (Ch_Name'Unchecked_Access),
Path => C_String.To_C_String (Ch_Path'Unchecked_Access),
Flags => 0);
end Load;
function Unload (DSO : DSO_Not_Null_Access_t) return Boolean is
begin
return 1 = Thin.DSO.Unload (DSO);
end Unload;
function Lookup (Name : in String) return DSO_Access_t is
Ch_Name : aliased C.char_array := C.To_C (Name);
begin
return Thin.DSO.Lookup (C_String.To_C_String (Ch_Name'Unchecked_Access));
end Lookup;
function Generic_Symbol_Lookup
(DSO : in DSO_Not_Null_Access_t;
Name : in String) return Subprogram_Access_Type
is
Ch_Name : aliased C.char_array := C.To_C (Name);
Result : aliased System.Address;
-- XXX: Risky...
function Convert is new Ada.Unchecked_Conversion
(Source => System.Address,
Target => Subprogram_Access_Type);
begin
if 1 = Thin.DSO.Symbol
(DSO => DSO,
Name => C_String.To_C_String (Ch_Name'Unchecked_Access),
Value => Result'Unchecked_Access) then
return Convert (Result);
else
return Convert (System.Null_Address);
end if;
end Generic_Symbol_Lookup;
end Agar.Core.DSO;
|
pragma License (Unrestricted);
-- implementation unit specialized for Windows
package System.Native_Directories.Temporary is
-- There are subprograms to create temporary file or directory.
pragma Preelaborate;
function Temporary_Directory return String;
procedure Set_Temporary_Directory (Name : String);
function Create_Temporary_File (Directory : String) return String;
function Create_Temporary_Directory (Directory : String) return String;
end System.Native_Directories.Temporary;
|
WITH P_DesHandler;
USE P_DesHandler;
----------
-- Main --
----------
procedure mainSequential is
DesAlg : aliased DesHandler;
begin
DesAlg.Process;
end mainSequential;
|
-- Copyright 2017-2021 Bartek thindil Jasicki
--
-- This file is part of Steam Sky.
--
-- Steam Sky 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.
--
-- Steam Sky 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 Steam Sky. If not, see <http://www.gnu.org/licenses/>.
with Messages; use Messages;
with ShipModules; use ShipModules;
with Ships.Cargo; use Ships.Cargo;
with Ships.Crew; use Ships.Crew;
with Crew.Inventory; use Crew.Inventory;
with Config; use Config;
package body Ships.Upgrade is
procedure StartUpgrading
(ModuleIndex: Modules_Container.Extended_Index; UpgradeType: Positive) is
MaxValue, UpgradeProgress: Natural;
UpgradeAction: Ship_Upgrade;
begin
if Player_Ship.Modules(ModuleIndex).Durability = 0 and
UpgradeType /= 3 then
raise Ship_Upgrade_Error
with "You can't upgrade " &
To_String(Player_Ship.Modules(ModuleIndex).Name) &
" because it's destroyed.";
end if;
case UpgradeType is
when 1 => -- Upgrade durability
MaxValue :=
Natural
(Float
(Modules_List(Player_Ship.Modules(ModuleIndex).Proto_Index)
.Durability) *
1.5);
if Player_Ship.Modules(ModuleIndex).Max_Durability = MaxValue then
raise Ship_Upgrade_Error
with "You can't further improve the durability of " &
To_String(Player_Ship.Modules(ModuleIndex).Name) & ".";
end if;
UpgradeAction := DURABILITY;
UpgradeProgress :=
Modules_List(Player_Ship.Modules(ModuleIndex).Proto_Index)
.Durability;
when 2 => -- Upgrade various max value of selected module
MaxValue :=
Natural
(Float
(Modules_List(Player_Ship.Modules(ModuleIndex).Proto_Index)
.MaxValue) *
1.5);
case Modules_List(Player_Ship.Modules(ModuleIndex).Proto_Index)
.MType is
when ENGINE =>
if Player_Ship.Modules(ModuleIndex).Power = MaxValue then
raise Ship_Upgrade_Error
with "You can't further improve the power of " &
To_String(Player_Ship.Modules(ModuleIndex).Name) & ".";
end if;
UpgradeProgress :=
Integer
(Float
(Modules_List
(Player_Ship.Modules(ModuleIndex).Proto_Index)
.MaxValue /
20) *
Float(New_Game_Settings.Upgrade_Cost_Bonus));
when CABIN =>
if Player_Ship.Modules(ModuleIndex).Quality = MaxValue then
raise Ship_Upgrade_Error
with "You can't further improve the quality of " &
To_String(Player_Ship.Modules(ModuleIndex).Name) & ".";
end if;
UpgradeProgress :=
Integer
(Float
(Modules_List
(Player_Ship.Modules(ModuleIndex).Proto_Index)
.MaxValue) *
Float(New_Game_Settings.Upgrade_Cost_Bonus));
when GUN | BATTERING_RAM =>
declare
Damage: constant Positive :=
(if Player_Ship.Modules(ModuleIndex).M_Type = GUN then
Player_Ship.Modules(ModuleIndex).Damage
else Player_Ship.Modules(ModuleIndex).Damage2);
begin
if Damage = MaxValue then
raise Ship_Upgrade_Error
with "You can't further improve the damage of " &
To_String(Player_Ship.Modules(ModuleIndex).Name) &
".";
end if;
end;
UpgradeProgress :=
Integer
(Float
(Modules_List
(Player_Ship.Modules(ModuleIndex).Proto_Index)
.MaxValue *
2) *
Float(New_Game_Settings.Upgrade_Cost_Bonus));
when HULL =>
if Player_Ship.Modules(ModuleIndex).Max_Modules =
MaxValue then
raise Ship_Upgrade_Error
with "You can't further enlarge the size of" &
To_String(Player_Ship.Modules(ModuleIndex).Name) & ".";
end if;
UpgradeProgress :=
Integer
(Float
(Modules_List
(Player_Ship.Modules(ModuleIndex).Proto_Index)
.MaxValue *
40) *
Float(New_Game_Settings.Upgrade_Cost_Bonus));
when HARPOON_GUN =>
if Player_Ship.Modules(ModuleIndex).Duration = MaxValue then
raise Ship_Upgrade_Error
with "You can't further improve the strength of " &
To_String(Player_Ship.Modules(ModuleIndex).Name) & ".";
end if;
UpgradeProgress :=
Integer
(Float
(Modules_List
(Player_Ship.Modules(ModuleIndex).Proto_Index)
.MaxValue *
10) *
Float(New_Game_Settings.Upgrade_Cost_Bonus));
when others =>
raise Ship_Upgrade_Error
with To_String(Player_Ship.Modules(ModuleIndex).Name) &
" can't be upgraded in that way.";
end case;
UpgradeAction := MAX_VALUE;
when 3 => -- Upgrade various value of selected module
case Modules_List(Player_Ship.Modules(ModuleIndex).Proto_Index)
.MType is
when ENGINE =>
MaxValue :=
Natural
(Float
(Modules_List
(Player_Ship.Modules(ModuleIndex).Proto_Index)
.Value) /
2.0);
if MaxValue < 1 then
MaxValue := 1;
end if;
if Player_Ship.Modules(ModuleIndex).Fuel_Usage =
MaxValue then
raise Ship_Upgrade_Error
with "You can't further reduce the fuel usage of " &
To_String(Player_Ship.Modules(ModuleIndex).Name) & ".";
end if;
UpgradeProgress :=
Integer
(Float
(Modules_List
(Player_Ship.Modules(ModuleIndex).Proto_Index)
.Value *
20) *
Float(New_Game_Settings.Upgrade_Cost_Bonus));
when others =>
raise Ship_Upgrade_Error
with To_String(Player_Ship.Modules(ModuleIndex).Name) &
" can't be upgraded in that way.";
end case;
UpgradeAction := VALUE;
when 4 => -- Continue previous upgrade
if Player_Ship.Modules(ModuleIndex).Upgrade_Action = NONE then
raise Ship_Upgrade_Error
with To_String(Player_Ship.Modules(ModuleIndex).Name) &
" doesn't have any upgrade set yet.";
end if;
UpgradeAction := Player_Ship.Modules(ModuleIndex).Upgrade_Action;
when others =>
return;
end case;
declare
MaterialIndex: constant Inventory_Container.Extended_Index :=
FindItem
(Inventory => Player_Ship.Cargo,
ItemType =>
Modules_List(Player_Ship.Modules(ModuleIndex).Proto_Index)
.RepairMaterial);
begin
if MaterialIndex = 0 then
Materials_Loop :
for Item of Items_List loop
if Item.IType =
Modules_List(Player_Ship.Modules(ModuleIndex).Proto_Index)
.RepairMaterial then
raise Ship_Upgrade_Error
with "You don't have the " & To_String(Item.Name) &
" to upgrade " &
To_String(Player_Ship.Modules(ModuleIndex).Name) & ".";
end if;
end loop Materials_Loop;
end if;
end;
Player_Ship.Upgrade_Module := ModuleIndex;
if Player_Ship.Modules(ModuleIndex).Upgrade_Action /= UpgradeAction then
Player_Ship.Modules(ModuleIndex).Upgrade_Progress :=
Integer
(Float(UpgradeProgress) *
Float(New_Game_Settings.Upgrade_Cost_Bonus));
if Player_Ship.Modules(ModuleIndex).Upgrade_Progress = 0 then
Player_Ship.Modules(ModuleIndex).Upgrade_Progress := 1;
end if;
Player_Ship.Modules(ModuleIndex).Upgrade_Action := UpgradeAction;
end if;
AddMessage
("You set the " & To_String(Player_Ship.Modules(ModuleIndex).Name) &
" to upgrade.",
OrderMessage);
end StartUpgrading;
procedure UpgradeShip(Minutes: Positive) is
ResultAmount, UpgradePoints, UpgradeProgress, MaterialCost,
MaxValue: Natural := 0;
UpgradeValue: Positive;
WeightGain: Natural;
Times: Natural := 0;
OrderTime, CurrentMinutes: Integer;
UpgradedModule: Module_Data;
UpgradeMaterial, UpgradeTools: Inventory_Container.Extended_Index;
WorkerIndex: Crew_Container.Extended_Index;
procedure FindMatsAndTools is
begin
UpgradeTools := FindTools(WorkerIndex, Repair_Tools, Upgrading);
UpgradeMaterial :=
FindItem
(Inventory => Player_Ship.Cargo,
ItemType =>
Modules_List(UpgradedModule.Proto_Index).RepairMaterial);
end FindMatsAndTools;
procedure MaxUpgradeReached(MessageText: String) is
begin
AddMessage
(MessageText & To_String(UpgradedModule.Name) & ".", OrderMessage,
YELLOW);
UpgradedModule.Upgrade_Progress := 0;
UpgradedModule.Upgrade_Action := NONE;
Player_Ship.Modules(Player_Ship.Upgrade_Module) := UpgradedModule;
Player_Ship.Upgrade_Module := 0;
GiveOrders(Player_Ship, WorkerIndex, Rest);
end MaxUpgradeReached;
begin
if Player_Ship.Upgrade_Module = 0 then
return;
end if;
WorkerIndex := FindMember(Upgrading);
if WorkerIndex = 0 then
return;
end if;
UpgradedModule := Player_Ship.Modules(Player_Ship.Upgrade_Module);
CurrentMinutes := Minutes;
OrderTime := Player_Ship.Crew(WorkerIndex).OrderTime;
if UpgradedModule.Durability = 0 then
AddMessage
(To_String(Player_Ship.Crew(WorkerIndex).Name) &
" stops upgrading " & To_String(UpgradedModule.Name) &
" because it's destroyed.",
OrderMessage, RED);
GiveOrders(Player_Ship, WorkerIndex, Rest);
return;
end if;
Count_Time_Loop :
while CurrentMinutes > 0 loop
if CurrentMinutes >= OrderTime then
CurrentMinutes := CurrentMinutes - OrderTime;
Times := Times + 1;
OrderTime := 15;
else
OrderTime := OrderTime - CurrentMinutes;
CurrentMinutes := 0;
end if;
end loop Count_Time_Loop;
Player_Ship.Crew(WorkerIndex).OrderTime := OrderTime;
if Times = 0 then
return;
end if;
UpgradePoints :=
((GetSkillLevel
(Player_Ship.Crew(WorkerIndex),
Modules_List(UpgradedModule.Proto_Index).RepairSkill) /
10) *
Times) +
Times;
Upgrade_Loop :
while UpgradePoints > 0 and UpgradedModule.Upgrade_Progress > 0 loop
ResultAmount := UpgradePoints;
if ResultAmount > UpgradedModule.Upgrade_Progress then
ResultAmount := UpgradedModule.Upgrade_Progress;
end if;
FindMatsAndTools;
if UpgradeMaterial = 0 then
AddMessage
("You don't have enough materials to upgrade " &
To_String(UpgradedModule.Name),
OrderMessage, RED);
GiveOrders(Player_Ship, WorkerIndex, Rest);
exit Upgrade_Loop;
end if;
if UpgradeTools = 0 then
AddMessage
("You don't have the repair tool to upgrade " &
To_String(UpgradedModule.Name),
OrderMessage, RED);
GiveOrders(Player_Ship, WorkerIndex, Rest);
exit Upgrade_Loop;
end if;
if UpgradedModule.Upgrade_Action = MAX_VALUE then
case UpgradedModule.M_Type is
when ENGINE =>
if ResultAmount >
Player_Ship.Cargo(UpgradeMaterial).Amount * 200 then
ResultAmount :=
Player_Ship.Cargo(UpgradeMaterial).Amount * 200;
end if;
MaterialCost := ResultAmount / 200;
when CABIN =>
if ResultAmount >
Player_Ship.Cargo(UpgradeMaterial).Amount * 20 then
ResultAmount :=
Player_Ship.Cargo(UpgradeMaterial).Amount * 20;
end if;
MaterialCost := ResultAmount / 20;
when GUN | BATTERING_RAM | HARPOON_GUN =>
if ResultAmount >
Player_Ship.Cargo(UpgradeMaterial).Amount * 10 then
ResultAmount :=
Player_Ship.Cargo(UpgradeMaterial).Amount * 10;
end if;
MaterialCost := ResultAmount / 10;
when HULL =>
if ResultAmount >
Player_Ship.Cargo(UpgradeMaterial).Amount * 2 then
ResultAmount :=
Player_Ship.Cargo(UpgradeMaterial).Amount * 2;
end if;
MaterialCost := ResultAmount / 2;
when others =>
if ResultAmount >
Player_Ship.Cargo(UpgradeMaterial).Amount then
ResultAmount := Player_Ship.Cargo(UpgradeMaterial).Amount;
end if;
MaterialCost := ResultAmount;
end case;
elsif UpgradedModule.Upgrade_Action = DURABILITY then
if ResultAmount >
Player_Ship.Cargo(UpgradeMaterial).Amount * 10 then
ResultAmount := Player_Ship.Cargo(UpgradeMaterial).Amount * 10;
end if;
MaterialCost := ResultAmount / 10;
else
if ResultAmount > Player_Ship.Cargo(UpgradeMaterial).Amount then
ResultAmount := Player_Ship.Cargo(UpgradeMaterial).Amount;
end if;
MaterialCost := ResultAmount;
end if;
if MaterialCost < Times then
MaterialCost := Times;
end if;
if MaterialCost > Player_Ship.Cargo(UpgradeMaterial).Amount then
MaterialCost := Player_Ship.Cargo(UpgradeMaterial).Amount;
end if;
GainExp
(ResultAmount, Modules_List(UpgradedModule.Proto_Index).RepairSkill,
WorkerIndex);
DamageItem
(Player_Ship.Crew(WorkerIndex).Inventory, UpgradeTools,
GetSkillLevel
(Player_Ship.Crew(WorkerIndex),
Modules_List(UpgradedModule.Proto_Index).RepairSkill),
WorkerIndex);
FindMatsAndTools;
UpgradeProgress := UpgradedModule.Upgrade_Progress - ResultAmount;
UpgradePoints := UpgradePoints - ResultAmount;
UpdateCargo
(Player_Ship, Player_Ship.Cargo.Element(UpgradeMaterial).ProtoIndex,
(0 - MaterialCost));
if UpgradeProgress = 0 then
WeightGain :=
Modules_List(UpgradedModule.Proto_Index).Weight /
Modules_List(UpgradedModule.Proto_Index).Durability;
if WeightGain < 1 then
WeightGain := 1;
end if;
case UpgradedModule.Upgrade_Action is
when DURABILITY =>
if
(Modules_List(UpgradedModule.Proto_Index).Durability /
20) >
0 then
UpgradedModule.Max_Durability :=
UpgradedModule.Max_Durability +
(Modules_List(UpgradedModule.Proto_Index).Durability /
20);
UpgradedModule.Weight :=
UpgradedModule.Weight +
(WeightGain *
(Modules_List(UpgradedModule.Proto_Index).Durability /
20));
else
UpgradedModule.Max_Durability :=
UpgradedModule.Max_Durability + 1;
UpgradedModule.Weight :=
UpgradedModule.Weight + WeightGain;
end if;
AddMessage
(To_String(Player_Ship.Crew(WorkerIndex).Name) &
" has upgraded the durability of " &
To_String(UpgradedModule.Name) & ".",
OrderMessage, GREEN);
MaxValue :=
Positive
(Float
(Modules_List(UpgradedModule.Proto_Index)
.Durability) *
1.5);
if UpgradedModule.Max_Durability = MaxValue then
MaxUpgradeReached
("You've reached the maximum durability for ");
return;
else
UpgradedModule.Upgrade_Progress :=
Modules_List(UpgradedModule.Proto_Index).Durability;
end if;
when MAX_VALUE =>
case UpgradedModule.M_Type is
when HULL =>
WeightGain := WeightGain * 10;
UpgradedModule.Max_Modules :=
UpgradedModule.Max_Modules + 1;
UpgradeValue := UpgradedModule.Max_Modules;
when ENGINE =>
WeightGain :=
(Modules_List(UpgradedModule.Proto_Index).MaxValue /
40);
UpgradedModule.Power :=
UpgradedModule.Power +
(Modules_List(UpgradedModule.Proto_Index).MaxValue /
20);
UpgradeValue := UpgradedModule.Power;
when CABIN =>
UpgradedModule.Quality :=
UpgradedModule.Quality +
(Modules_List(UpgradedModule.Proto_Index).MaxValue /
20);
UpgradeValue := UpgradedModule.Quality;
when GUN =>
if
(Modules_List(UpgradedModule.Proto_Index).MaxValue /
20) >
0 then
UpgradedModule.Damage :=
UpgradedModule.Damage +
(Modules_List(UpgradedModule.Proto_Index)
.MaxValue /
20);
else
UpgradedModule.Damage := UpgradedModule.Damage + 1;
end if;
UpgradeValue := UpgradedModule.Damage;
when BATTERING_RAM =>
if
(Modules_List(UpgradedModule.Proto_Index).MaxValue /
20) >
0 then
UpgradedModule.Damage2 :=
UpgradedModule.Damage2 +
(Modules_List(UpgradedModule.Proto_Index)
.MaxValue /
20);
else
UpgradedModule.Damage2 :=
UpgradedModule.Damage2 + 1;
end if;
UpgradeValue := UpgradedModule.Damage2;
when HARPOON_GUN =>
if
(Modules_List(UpgradedModule.Proto_Index).MaxValue /
20) >
0 then
UpgradedModule.Duration :=
UpgradedModule.Duration +
(Modules_List(UpgradedModule.Proto_Index)
.MaxValue /
20);
else
UpgradedModule.Duration :=
UpgradedModule.Duration + 1;
end if;
UpgradeValue := UpgradedModule.Duration;
when others =>
null;
end case;
UpgradedModule.Weight := UpgradedModule.Weight + WeightGain;
AddMessage
(To_String(Player_Ship.Crew(WorkerIndex).Name) &
" has upgraded " & To_String(UpgradedModule.Name) & ".",
OrderMessage, GREEN);
MaxValue :=
Positive
(Float
(Modules_List(UpgradedModule.Proto_Index).MaxValue) *
1.5);
if UpgradeValue >= MaxValue then
MaxUpgradeReached
("You've reached the maximum upgrade for ");
return;
else
case Modules_List(UpgradedModule.Proto_Index).MType is
when ENGINE =>
UpgradedModule.Upgrade_Progress :=
Integer
(Float
(Modules_List
(Player_Ship.Modules
(Player_Ship.Upgrade_Module)
.Proto_Index)
.MaxValue /
20) *
Float(New_Game_Settings.Upgrade_Cost_Bonus));
when HARPOON_GUN =>
UpgradedModule.Upgrade_Progress :=
Integer
(Float
(Modules_List
(Player_Ship.Modules
(Player_Ship.Upgrade_Module)
.Proto_Index)
.MaxValue *
10) *
Float(New_Game_Settings.Upgrade_Cost_Bonus));
when GUN | BATTERING_RAM =>
UpgradedModule.Upgrade_Progress :=
Integer
(Float
(Modules_List
(Player_Ship.Modules
(Player_Ship.Upgrade_Module)
.Proto_Index)
.MaxValue *
2) *
Float(New_Game_Settings.Upgrade_Cost_Bonus));
when CABIN =>
UpgradedModule.Upgrade_Progress :=
Integer
(Float
(Modules_List
(Player_Ship.Modules
(Player_Ship.Upgrade_Module)
.Proto_Index)
.MaxValue) *
Float(New_Game_Settings.Upgrade_Cost_Bonus));
when HULL =>
UpgradedModule.Upgrade_Progress :=
Integer
(Float
(Modules_List
(Player_Ship.Modules
(Player_Ship.Upgrade_Module)
.Proto_Index)
.MaxValue *
40) *
Float(New_Game_Settings.Upgrade_Cost_Bonus));
when others =>
null;
end case;
if UpgradedModule.Upgrade_Progress = 0 then
UpgradedModule.Upgrade_Progress := 1;
end if;
end if;
when VALUE =>
if UpgradedModule.M_Type = ENGINE then
WeightGain := WeightGain * 10;
UpgradedModule.Fuel_Usage :=
UpgradedModule.Fuel_Usage - 1;
UpgradeValue := UpgradedModule.Fuel_Usage;
end if;
UpgradedModule.Weight := UpgradedModule.Weight + WeightGain;
AddMessage
(To_String(Player_Ship.Crew(WorkerIndex).Name) &
" has upgraded " & To_String(UpgradedModule.Name) & ".",
OrderMessage, GREEN);
MaxValue :=
Natural
(Float(Modules_List(UpgradedModule.Proto_Index).Value) /
2.0);
if MaxValue < 1 then
MaxValue := 1;
end if;
if UpgradeValue = MaxValue then
MaxUpgradeReached
("You've reached the maximum upgrade for ");
return;
else
case Modules_List(UpgradedModule.Proto_Index).MType is
when ENGINE =>
UpgradedModule.Upgrade_Progress :=
Integer
(Float
(Modules_List
(Player_Ship.Modules
(Player_Ship.Upgrade_Module)
.Proto_Index)
.Value *
20) *
Float(New_Game_Settings.Upgrade_Cost_Bonus));
if UpgradedModule.Upgrade_Progress = 0 then
UpgradedModule.Upgrade_Progress := 1;
end if;
when others =>
null;
end case;
end if;
when others =>
null;
end case;
else
UpgradedModule.Upgrade_Progress := UpgradeProgress;
end if;
end loop Upgrade_Loop;
Player_Ship.Modules(Player_Ship.Upgrade_Module) := UpgradedModule;
end UpgradeShip;
end Ships.Upgrade;
|
------------------------------------------------------------------------------
-- Copyright (c) 2015, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- This access log implementation uses a straightforward single-table --
-- SQLite 3 backend. --
------------------------------------------------------------------------------
with Ada.Containers.Doubly_Linked_Lists;
with Ada.Exceptions;
with Ada.Strings.Unbounded;
with Ada.Text_IO;
with AWS.Headers;
with AWS.Messages;
with Interfaces.C;
with Natools.Web;
with SQLite3;
package body Lithium.Access_Log is
subtype String_Holder is Ada.Strings.Unbounded.Unbounded_String;
function Hold (Value : in String) return String_Holder
renames Ada.Strings.Unbounded.To_Unbounded_String;
function To_String (Holder : in String_Holder) return String
renames Ada.Strings.Unbounded.To_String;
function Is_Empty (Holder : in String_Holder) return Boolean
is (Ada.Strings.Unbounded.Length (Holder) = 0);
Empty_Holder : constant String_Holder
:= Ada.Strings.Unbounded.Null_Unbounded_String;
package String_Tables is
type Enum is
(Peer_Name, Method, Path, Http_Version, Referrer,
User_Agent, Cookies, Host, Real_IP, Forwarded_For, Forwarded_Proto);
end String_Tables;
type Holder_Array is array (String_Tables.Enum) of String_Holder;
type Extended_Log_Entry (Is_Empty : Boolean := True) is record
case Is_Empty is
when True => null;
when False =>
Strings : Holder_Array;
Status_Code : Integer;
Bytes : Long_Integer;
Build_Time : Duration;
Export_Time : Duration;
end case;
end record;
subtype Log_Entry is Extended_Log_Entry (Is_Empty => False);
SQLite_Error : exception;
package Log_Queue is new Ada.Containers.Doubly_Linked_Lists (Log_Entry);
Create_SQL : constant String := "CREATE TABLE IF NOT EXISTS access ("
& "time NOT NULL DEFAULT CURRENT_TIMESTAMP, "
& "peer_name INTEGER, "
& "method INTEGER, "
& "path INTEGER, "
& "http_version INTEGER, "
& "status_code INTEGER, "
& "bytes INTEGER, "
& "referrer INTEGER, "
& "user_agent INTEGER, "
& "cookies INTEGER, "
& "build_time REAL, "
& "export_time REAL, "
& "host INTEGER, "
& "real_ip INTEGER, "
& "forwarded_for INTEGER, "
& "forwarded_proto INTEGER, "
& "FOREIGN KEY (peer_name) REFERENCES peer_names(rowid), "
& "FOREIGN KEY (method) REFERENCES methods(rowid), "
& "FOREIGN KEY (path) REFERENCES paths(rowid), "
& "FOREIGN KEY (http_version) REFERENCES http_versions(rowid), "
& "FOREIGN KEY (referrer) REFERENCES referrers(rowid), "
& "FOREIGN KEY (user_agent) REFERENCES user_agents(rowid), "
& "FOREIGN KEY (cookies) REFERENCES cookies(rowid), "
& "FOREIGN KEY (host) REFERENCES hosts(rowid), "
& "FOREIGN KEY (real_ip) REFERENCES real_ips(rowid), "
& "FOREIGN KEY (forwarded_for) REFERENCES forwarded_fors(rowid), "
& "FOREIGN KEY (forwarded_proto) REFERENCES forwarded_fors(rowid));";
Insert_SQL : constant String := "INSERT INTO access "
& "(peer_name, method, path, http_version, status_code, bytes, referrer, "
& "user_agent, cookies, build_time, export_time, "
& "host, real_ip, forwarded_for, forwarded_proto) "
& "VALUES ("
& "(SELECT rowid FROM peer_names WHERE value = ?1),"
& "(SELECT rowid FROM methods WHERE value = ?2),"
& "(SELECT rowid FROM paths WHERE value = ?3),"
& "(SELECT rowid FROM http_versions WHERE value = ?4),"
& "?5, ?6, "
& "(SELECT rowid FROM referrers WHERE value = ?7),"
& "(SELECT rowid FROM user_agents WHERE value = ?8),"
& "(SELECT rowid FROM cookies WHERE value = ?9),"
& "?10, ?11, "
& "(SELECT rowid FROM hosts WHERE value = ?12),"
& "(SELECT rowid FROM real_ips WHERE value = ?13),"
& "(SELECT rowid FROM forwarded_fors WHERE value = ?14),"
& "(SELECT rowid FROM forwarded_protos WHERE value = ?15)"
& ");";
procedure Bind
(Stmt : in out SQLite3.SQLite3_Statement;
Values : in Log_Entry);
-- Bind a log entry to the main insert statement
procedure Bind
(Stmt : in out SQLite3.SQLite3_Statement;
Value : in String);
-- Bind a string value to a table-specific insert statement
procedure Initialize
(Handle : in out SQLite3.SQLite3_DB;
Name : in String);
procedure Run_Simple_SQL
(Handle : in SQLite3.SQLite3_DB;
SQL_String : in String;
Name : in String);
-- Run a simple one-time SQL query, without error handling
-- besides throwing SQLite_Error exceptions.
generic
type Input_Type (<>) is limited private;
with procedure Bind
(Stmt : in out SQLite3.SQLite3_Statement;
Input : in Input_Type) is <>;
procedure Run_SQL
(Handle : in SQLite3.SQLite3_DB;
Stmt : in out SQLite3.SQLite3_Statement;
Stmt_Ready : in out Boolean;
Input : in Input_Type;
SQL_String : in String;
Name : in String);
-- Run one attempt of the given statement and handle errors
function Table_Name (T : in String_Tables.Enum) return String;
-- Return the SQL table name associated with T
protected Queue is
entry Append (Values : in Log_Entry);
procedure Next (Values : out Extended_Log_Entry);
private
Task_Waiting : Boolean := True;
List : Log_Queue.List;
end Queue;
task Worker is
entry Run (Values : in Log_Entry);
end Worker;
------------------------------
-- Local Helper Subprograms --
------------------------------
procedure Bind
(Stmt : in out SQLite3.SQLite3_Statement;
Values : in Log_Entry)
is
use type SQLite3.Error_Code;
generic
type Value_Type (<>) is limited private;
with procedure SQLite3_Bind
(Stmt : in SQLite3.SQLite3_Statement;
Index : in SQLite3.SQL_Parameter_Index;
Value : in Value_Type;
Status : out SQLite3.Error_Code);
procedure Generic_Bind
(Index : in SQLite3.SQL_Parameter_Index;
Value : in Value_Type;
Name : in String);
procedure Bind
(Index : in SQLite3.SQL_Parameter_Index;
Value : in String_Holder;
Name : in String);
Status : SQLite3.Error_Code;
procedure Generic_Bind
(Index : in SQLite3.SQL_Parameter_Index;
Value : in Value_Type;
Name : in String) is
begin
SQLite3_Bind (Stmt, Index, Value, Status);
if Status /= SQLite3.SQLITE_OK then
Natools.Web.Log
(Natools.Web.Severities.Error,
"Unable to bind " & Name & " to statement: "
& SQLite3.Error_Code'Image (Status));
raise SQLite_Error;
end if;
end Generic_Bind;
procedure Bind is new Generic_Bind (String, SQLite3.Bind);
procedure Bind is new Generic_Bind (Long_Integer, SQLite3.Bind);
procedure Bind is new Generic_Bind (Interfaces.C.double, SQLite3.Bind);
procedure Bind
(Index : in SQLite3.SQL_Parameter_Index;
Value : in String_Holder;
Name : in String) is
begin
if not Is_Empty (Value) then
Bind (Index, To_String (Value), Name);
end if;
end Bind;
use String_Tables;
begin
Bind (1, Values.Strings (Peer_Name), "peer name");
Bind (2, Values.Strings (Method), "method");
Bind (3, Values.Strings (Path), "path");
Bind (4, Values.Strings (Http_Version), "HTTP version");
Bind (5, Long_Integer (Values.Status_Code), "status code");
Bind (6, Values.Bytes, "response size");
Bind (7, Values.Strings (Referrer), "response size");
Bind (8, Values.Strings (User_Agent), "response size");
Bind (9, Values.Strings (Cookies), "response size");
Bind (10, Interfaces.C.double (Values.Build_Time), "build time");
Bind (11, Interfaces.C.double (Values.Export_Time), "export time");
Bind (12, Values.Strings (Host), "host");
Bind (13, Values.Strings (Real_IP), "real IP");
Bind (14, Values.Strings (Forwarded_For), "forwarded for");
Bind (15, Values.Strings (Forwarded_Proto), "forwarded proto");
end Bind;
procedure Bind
(Stmt : in out SQLite3.SQLite3_Statement;
Value : in String)
is
use type SQLite3.Error_Code;
Status : SQLite3.Error_Code;
begin
SQLite3.Bind (Stmt, 1, Value, Status);
if Status /= SQLite3.SQLITE_OK then
Natools.Web.Log
(Natools.Web.Severities.Error,
"Unable to bind string value to statement: "
& SQLite3.Error_Code'Image (Status));
raise SQLite_Error;
end if;
end Bind;
procedure Initialize
(Handle : in out SQLite3.SQLite3_DB;
Name : in String)
is
use type SQLite3.Error_Code;
Status : SQLite3.Error_Code;
begin
SQLite3.Open (Name, Handle, Status);
if Status /= SQLite3.SQLITE_OK then
Natools.Web.Log
(Natools.Web.Severities.Critical,
"Unable to open """ & Name & """: "
& SQLite3.Error_Code'Image (Status));
raise SQLite_Error;
end if;
Create_Tables :
begin
Run_Simple_SQL (Handle, Create_SQL, "main create");
for T in String_Tables.Enum loop
Run_Simple_SQL
(Handle,
"CREATE TABLE IF NOT EXISTS " & Table_Name (T)
& " (value TEXT PRIMARY KEY);",
Table_Name (T) & " create");
end loop;
exception
when SQLite_Error =>
SQLite3.Close (Handle, Status);
raise;
end Create_Tables;
end Initialize;
procedure Run_Simple_SQL
(Handle : in SQLite3.SQLite3_DB;
SQL_String : in String;
Name : in String)
is
use type SQLite3.Error_Code;
Status : SQLite3.Error_Code;
Stmt : SQLite3.SQLite3_Statement;
begin
SQLite3.Prepare (Handle, SQL_String, Stmt, Status);
if Status /= SQLite3.SQLITE_OK then
Natools.Web.Log
(Natools.Web.Severities.Error,
"Unable to prepare " & Name & " statement: "
& SQLite3.Error_Code'Image (Status)
& ' ' & SQLite3.Error_Message (Handle));
raise SQLite_Error;
end if;
loop
SQLite3.Step (Stmt, Status);
exit when Status = SQLite3.SQLITE_DONE;
if Status /= SQLite3.SQLITE_ROW then
Natools.Web.Log
(Natools.Web.Severities.Error,
"Unable to run " & Name & ": "
& SQLite3.Error_Code'Image (Status)
& ' ' & SQLite3.Error_Message (Handle));
raise SQLite_Error;
end if;
end loop;
SQLite3.Finish (Stmt, Status);
if Status /= SQLite3.SQLITE_OK then
Natools.Web.Log
(Natools.Web.Severities.Error,
"Unable to finish " & Name & " statement: "
& SQLite3.Error_Code'Image (Status)
& ' ' & SQLite3.Error_Message (Handle));
raise SQLite_Error;
end if;
end Run_Simple_SQL;
procedure Run_SQL
(Handle : in SQLite3.SQLite3_DB;
Stmt : in out SQLite3.SQLite3_Statement;
Stmt_Ready : in out Boolean;
Input : in Input_Type;
SQL_String : in String;
Name : in String)
is
use type SQLite3.Error_Code;
Status : SQLite3.Error_Code;
Retry_Left : Natural := 16;
begin
Retry_Loop :
loop
if not Stmt_Ready then
SQLite3.Prepare (Handle, SQL_String, Stmt, Status);
if Status /= SQLite3.SQLITE_OK then
raise SQLite_Error with
"Unable to prepare " & Name & " statement: "
& SQLite3.Error_Code'Image (Status)
& ' ' & SQLite3.Error_Message (Handle);
end if;
Stmt_Ready := True;
end if;
Run_Statement :
begin
Bind (Stmt, Input);
SQL_Step :
loop
SQLite3.Step (Stmt, Status);
exit SQL_Step when Status = SQLite3.SQLITE_DONE;
if Status /= SQLite3.SQLITE_ROW then
raise SQLite_Error with
"Unable to run " & Name & ": "
& SQLite3.Error_Code'Image (Status)
& ' ' & SQLite3.Error_Message (Handle);
end if;
end loop SQL_Step;
SQLite3.Reset (Stmt, Status);
if Status /= SQLite3.SQLITE_OK then
raise SQLite_Error with
"Unable to reset " & Name & " statement: "
& SQLite3.Error_Code'Image (Status)
& ' ' & SQLite3.Error_Message (Handle);
end if;
SQLite3.Clear_Bindings (Stmt, Status);
if Status /= SQLite3.SQLITE_OK then
raise SQLite_Error with
"Unable to reset " & Name & " statement: "
& SQLite3.Error_Code'Image (Status)
& ' ' & SQLite3.Error_Message (Handle);
end if;
exception
when Ex : SQLite_Error =>
Natools.Web.Log
(Natools.Web.Severities.Error,
Ada.Exceptions.Exception_Information (Ex));
SQLite3.Finish (Stmt, Status);
Stmt_Ready := False;
Retry_Left := Retry_Left - 1;
if Retry_Left > 0 then
delay 1.0;
else
raise;
end if;
end Run_Statement;
exit Retry_Loop when Stmt_Ready;
end loop Retry_Loop;
end Run_SQL;
function Table_Name (T : in String_Tables.Enum) return String is
use String_Tables;
begin
case T is
when Peer_Name => return "peer_names";
when Method => return "methods";
when Path => return "paths";
when Http_Version => return "http_versions";
when Referrer => return "referrers";
when User_Agent => return "user_agents";
when Cookies => return "cookies";
when Host => return "hosts";
when Real_IP => return "real_ips";
when Forwarded_For => return "forwarded_fors";
when Forwarded_Proto => return "forwarded_protos";
end case;
end Table_Name;
----------------------
-- Public Interface --
----------------------
procedure Log
(Request : in AWS.Status.Data;
Response : in AWS.Response.Data;
Build_Time, Export_Time : in Duration)
is
function Hold_Header (Name : in String) return String_Holder;
Headers : constant AWS.Headers.List := AWS.Status.Header (Request);
function Hold_Header (Name : in String) return String_Holder is
begin
if AWS.Headers.Exist (Headers, Name) then
return Hold (AWS.Headers.Get_Values (Headers, Name));
else
return Empty_Holder;
end if;
end Hold_Header;
use String_Tables;
begin
Queue.Append
((Is_Empty => False,
Strings =>
(Peer_Name => Hold (AWS.Status.Peername (Request)),
Method => Hold (AWS.Status.Method (Request)),
Path => Hold (AWS.Status.URI (Request)),
Http_Version => Hold (AWS.Status.HTTP_Version (Request)),
Referrer => Hold_Header ("Referer"),
User_Agent => Hold_Header ("User-Agent"),
Cookies => Hold_Header ("Cookie"),
Host => Hold_Header ("Host"),
Real_IP => Hold_Header ("X-Real-IP"),
Forwarded_For => Hold_Header ("X-Forwarded-For"),
Forwarded_Proto => Hold_Header ("X-Forwarded-Proto")),
Status_Code => Integer'Value (AWS.Messages.Image
(AWS.Response.Status_Code (Response))),
Bytes => Long_Integer (AWS.Response.Content_Length (Response)),
Build_Time => Build_Time,
Export_Time => Export_Time));
end Log;
---------------------
-- Log Entry Queue --
---------------------
protected body Queue is
entry Append (Values : in Log_Entry) when True is
begin
if Task_Waiting then
Task_Waiting := False;
requeue Worker.Run;
else
List.Append (Values);
end if;
end Append;
procedure Next (Values : out Extended_Log_Entry) is
begin
if List.Is_Empty then
Task_Waiting := True;
Values := (Is_Empty => True);
else
pragma Assert (not Task_Waiting);
Values := List.First_Element;
List.Delete_First;
end if;
end Next;
end Queue;
-----------------
-- Worker Task --
-----------------
procedure Run_SQL_Main is new Run_SQL (Log_Entry);
procedure Run_SQL_String is new Run_SQL (String);
task body Worker is
use type SQLite3.Error_Code;
Status : SQLite3.Error_Code;
Current : Extended_Log_Entry;
Handle : SQLite3.SQLite3_DB;
Stmt : SQLite3.SQLite3_Statement;
Stmt_Ready : Boolean := False;
String_Stmt : array (String_Tables.Enum) of SQLite3.SQLite3_Statement;
String_Stmt_Ready : array (String_Tables.Enum) of Boolean
:= (others => False);
begin
select
accept Run (Values : in Log_Entry) do
Current := Values;
end Run;
or
terminate;
end select;
pragma Assert (not Current.Is_Empty);
Initialize (Handle, "access.dat");
SQLite3.Busy_Timeout (Handle, 60_000, Status);
Main_Loop :
loop
Run_String_Inserts :
for T in String_Tables.Enum loop
Run_SQL_String
(Handle,
String_Stmt (T),
String_Stmt_Ready (T),
To_String (Current.Strings (T)),
"INSERT OR IGNORE INTO " & Table_Name (T) & " VALUES (?1);",
Table_Name (T) & " insert");
end loop Run_String_Inserts;
Run_SQL_Main
(Handle, Stmt, Stmt_Ready, Current, Insert_SQL, "main insert");
Queue.Next (Current);
if Current.Is_Empty then
select
accept Run (Values : in Log_Entry) do
Current := Values;
end Run;
or
terminate;
end select;
end if;
end loop Main_Loop;
exception
when Ex : others =>
if not Natools.Web."="
(Natools.Web.Log, Natools.Web.Default_Log'Access)
then
Natools.Web.Log
(Natools.Web.Severities.Critical,
"Exception raised in Lithium.Access_Log.Worker task");
Natools.Web.Log
(Natools.Web.Severities.Critical,
Ada.Exceptions.Exception_Information (Ex));
else
Ada.Text_IO.Put_Line
(Ada.Text_IO.Current_Error,
"Exception raised in Lithium.Access_Log.Worker task");
Ada.Text_IO.Put_Line
(Ada.Text_IO.Current_Error,
Ada.Exceptions.Exception_Information (Ex));
end if;
end Worker;
end Lithium.Access_Log;
|
with Libtcod, Libtcod.Console, Libtcod.Color;
limited with Engines;
private with Ada.Strings.Bounded, Ada.Containers.Vectors;
package GUIs is
use Libtcod;
Panel_Height : constant := 7;
Bar_Width : constant := 30;
subtype RGB_Color is Libtcod.Color.RGB_Color;
type GUI is tagged limited private;
procedure render(self : in out GUI; main_screen : in out Console.Screen;
engine : in out Engines.Engine);
procedure log(self : in out GUI; text : String; color : RGB_Color := Libtcod.Color.light_grey);
function make_GUI(screen_w : Width) return GUI;
private
package Log_Strings is new Ada.Strings.Bounded.Generic_Bounded_Length(Max => 40);
subtype Log_String is Log_Strings.Bounded_String;
type Log_Message is record
text : Log_String;
color : RGB_Color;
end record;
package Log_Message_Vectors is new Ada.Containers.Vectors(Index_Type => Natural,
Element_Type => Log_Message);
use type Ada.Containers.Count_Type;
subtype Log_Message_Vector is Log_Message_Vectors.Vector;
type GUI is tagged limited record
screen : Libtcod.Console.Screen;
log : Log_Message_Vector;
end record;
end GUIs;
|
with Ada.Text_IO; use Ada.Text_IO;
use Ada;
with GNAT.OS_Lib;
package body BMP is
procedure Debug (Line : String);
procedure Print_Palette (File_Out : Ada.Text_IO.File_Type;
Palette_Data : Palette;
Pixel_Size : Integer);
-----------
-- Debug --
-----------
procedure Debug (Line : String) is
begin
if Verbose then
Put_Line (Line);
end if;
end Debug;
procedure Standard
(File_In : Stream_IO.File_Type;
Input : Stream_IO.Stream_Access;
File_Out : Ada.Text_IO.File_Type;
Package_Name : String;
Header : BMP.Header;
Info : BMP.Info;
Row_Size : Integer)
is
procedure Put_Package_Header;
procedure Put_Package_Footer;
------------------------
-- Put_Package_Header --
------------------------
procedure Put_Package_Header is
begin
Put_Line (File_Out, "-- This file was generated by bmp2ada");
New_Line (File_Out);
-- Dependecies
if DMA2D_Format then
Put_Line (File_Out, "with Giza.Image;");
Put_Line (File_Out, "with Giza.Image.DMA2D;");
Put_Line (File_Out, "use Giza.Image.DMA2D;");
else
Put_Line (File_Out, "with Giza.Bitmaps; use Giza.Bitmaps;");
Put_Line (File_Out, "with Giza.Image.Bitmap;");
end if;
New_Line (File_Out);
-- Package name
Put_Line (File_Out, "package " & Package_Name & " is");
-- Disable style checks
Put_Line (File_Out, " pragma Style_Checks (Off);");
New_Line (File_Out);
end Put_Package_Header;
------------------------
-- Put_Package_Footer --
------------------------
procedure Put_Package_Footer is
begin
Put_Line (File_Out, " pragma Style_Checks (On);");
Put_Line (File_Out, "end " & Package_Name & ";");
end Put_Package_Footer;
begin
if Info.Pixel_Size /= 24 then
Put_Line ("Only 24bits/pix supported.");
GNAT.OS_Lib.OS_Exit (-1);
end if;
declare
subtype Row is BMP.Image_RGB24 (1 .. Integer (Info.Width));
I : Row;
Offset : Integer;
Pix_Cnt : Positive := 1;
begin
Put_Package_Header;
if DMA2D_Format then
Put_Line (File_Out,
" Data : aliased constant RGB888_Data_T := (");
else
Put_Line
(File_Out, " Data : aliased constant Bitmap :=");
Put_Line
(File_Out,
" (W =>" & Info.Width'Img &
", H =>" & Info.Height'Img &
", Length =>" & Integer_32'Image (Info.Width * Info.Height) &
", Data => (");
end if;
for Row_Cnt in reverse 0 .. Integer (Info.Height) - 1 loop
Offset := Integer (Header.Offset) + Row_Size * Row_Cnt;
-- Move read pointer to where the row data starts.
Stream_IO.Set_Index (File_In,
Stream_IO.Positive_Count (Offset + 1));
Row'Read (Input, I);
for Index in I'Range loop
Text_IO.Put (File_Out,
" " &
Pix_Cnt'Img & " => (R => " & I (Index).R'Img &
", G =>" & I (Index).G'Img &
", B =>" & I (Index).B'Img & ")");
Pix_Cnt := Pix_Cnt + 1;
if Index /= I'Last or else Row_Cnt /= 0 then
Text_IO.Put_Line (File_Out, ",");
end if;
end loop;
end loop;
if DMA2D_Format then
Text_IO.Put_Line (File_Out, ");");
-- with Linker_Section => "".rodata"";");
Text_IO.New_Line (File_Out);
Put_Line
(File_Out,
" Image : constant Giza.Image.Ref :=" &
" new Giza.Image.DMA2D.Instance'");
Put_Line
(File_Out,
" (Mode => RGB888" &
", W =>" & Info.Width'Img &
", H =>" & Info.Height'Img &
", Length =>" & Integer_32'Image (Info.Width * Info.Height) &
", RGB888_Data => Data'Access);");
else
Text_IO.Put_Line (File_Out, "));");
-- with Linker_Section => "".rodata"";");
Text_IO.New_Line (File_Out);
Text_IO.Put_Line
(File_Out, " Image : " &
"aliased Giza.Image.Bitmap.Instance (Data'Access);");
end if;
Put_Package_Footer;
end;
end Standard;
-------------------
-- Print_Palette --
-------------------
procedure Print_Palette (File_Out : Ada.Text_IO.File_Type;
Palette_Data : Palette;
Pixel_Size : Integer)
is
C : Color_Definition;
Require_Palette_Size : constant Natural :=
(if DMA2D_Format then
-- DMA2D only support 4 and 8 bits palettes, for 1 and 2 bits bmp
-- files we use 4bit format and pad with zeros
(case Pixel_Size is
when 1 | 2 | 4 => 2**4,
when 8 => 2**8,
when others => 0)
else
2**Pixel_Size);
begin
for Index in Palette_Data'Range loop
C := Palette_Data (Index);
Debug ("Index:" & Index'Img & " R:" & C.R'Img & " G:" &
C.G'Img & " B:" & C.B'Img);
Text_IO.Put (File_Out, "(R =>" & C.R'Img &
", G =>" & C.G'Img &
", B =>" & C.B'Img &
")");
if Index = Palette_Data'Last then
if Palette_Data'Length = Require_Palette_Size then
Text_IO.Put (File_Out, ")");
else
Text_IO.Put (File_Out, ", others => (0, 0, 0))");
end if;
else
Text_IO.Put_Line (File_Out, ",");
end if;
end loop;
end Print_Palette;
----------------
-- Palettized --
----------------
procedure Palettized
(File_In : Stream_IO.File_Type;
Input : Stream_IO.Stream_Access;
File_Out : Ada.Text_IO.File_Type;
Package_Name : String;
Header : BMP.Header;
Info : BMP.Info;
Row_Size : Integer)
is
Raw_palette : P8_Array (0 .. Integer (Info.Palette_Size / 2));
type P16_Array is array (Integer range <>) of Unsigned_16;
Raw_palette_16 : P16_Array (0 .. Integer (Info.Palette_Size - 1));
Palette_Data : Palette (0 .. Unsigned_8 (Info.Palette_Size - 1));
Offset : Integer;
Pix_Values : Pix_Index_Array (0 .. Row_Size - 1);
Raw_Bytes : P8_Array (0 .. Row_Size - 1);
Byte_Index, Pix_Index : Integer;
Palette_Index : Unsigned_8;
Size_Str : constant String := (case Info.Pixel_Size is
when 1 => "1bit",
when 2 => "2bits",
when 4 => "4bits",
when 8 => "8bits",
when others => "invalid_pix_size");
procedure Put_Package_Header;
procedure Put_Package_Footer;
procedure Push_Pix_Index (Index : Unsigned_8; Last : Boolean);
function Output_Pix_Size return Natural;
function Length_In_Bytes return Natural;
------------------------
-- Put_Package_Header --
------------------------
procedure Put_Package_Header is
begin
Put_Line (File_Out, "-- This file was generated by bmp2ada");
-- Dependecies
if DMA2D_Format then
Put_Line (File_Out, "with Giza.Image;");
Put_Line (File_Out, "with Giza.Image.DMA2D;");
Put_Line (File_Out, "use Giza.Image.DMA2D;");
else
Put_Line (File_Out, "with Giza.Bitmaps.Indexed_" & Size_Str & ";");
Put_Line (File_Out, "use Giza.Bitmaps.Indexed_" & Size_Str & ";");
Put_Line (File_Out, "with Giza.Image.Bitmap.Indexed_" &
Size_Str & ";");
end if;
New_Line (File_Out);
-- Package name
Put_Line (File_Out, "package " & Package_Name & " is");
-- Disable style checks
Put_Line (File_Out, " pragma Style_Checks (Off);");
New_Line (File_Out);
end Put_Package_Header;
------------------------
-- Put_Package_Footer --
------------------------
procedure Put_Package_Footer is
begin
Put_Line (File_Out, " pragma Style_Checks (On);");
Put_Line (File_Out, "end " & Package_Name & ";");
end Put_Package_Footer;
--------------------
-- Push_Pix_Index --
--------------------
Push_Val : Pix_Index_Rec := (Size => Pix_8, P8 => (others => 0));
Push_Cnt : Natural := 0;
Overall_Cnt : Natural := 0;
procedure Push_Pix_Index (Index : Unsigned_8; Last : Boolean) is
begin
case Output_Pix_Size is
when 1 =>
Push_Val.P1 (Push_Cnt) := Unsigned_1 (Index);
when 2 =>
Push_Val.P2 (Push_Cnt) := Unsigned_2 (Index);
when 4 =>
Push_Val.P4 (Push_Cnt) := Unsigned_4 (Index);
when 8 =>
Push_Val.P8 (Push_Cnt) := Index;
when others =>
raise Program_Error;
end case;
Push_Cnt := Push_Cnt + 1;
Overall_Cnt := Overall_Cnt + 1;
if Push_Cnt = 8 / Output_Pix_Size or else Last then
Text_IO.Put (File_Out, Push_Val.P8 (0)'Img);
Push_Cnt := 0;
if not Last then
Text_IO.Put (File_Out, ",");
end if;
if Overall_Cnt mod 100 = 0 then
Text_IO.New_Line (File_Out);
end if;
end if;
end Push_Pix_Index;
---------------------
-- Output_Pix_Size --
---------------------
function Output_Pix_Size return Natural is
(if DMA2D_Format and then Info.Pixel_Size in 1 .. 4 then
4
else
Natural (Info.Pixel_Size));
---------------------
-- Length_In_Bytes --
---------------------
function Length_In_Bytes return Natural is
Pix_Size : constant Natural := Output_Pix_Size;
Pix_Nbr : constant Natural := Natural (Info.Width * Info.Height);
Full_Data_Size_Bits : constant Natural := Pix_Size * Pix_Nbr;
Bits_Pad : constant Natural :=
(8 - (Full_Data_Size_Bits mod 8)) mod 8;
begin
return (Full_Data_Size_Bits + Bits_Pad) / 8;
end Length_In_Bytes;
Format_Str : constant String :=
(case Info.Pixel_Size is
when 1 | 2 | 4 => "L4",
when 8 => "L8",
when others => "Invalid_DMA2D_Pixel_Size");
begin
if Info.Pixel_Size /= 1
and then Info.Pixel_Size /= 2
and then Info.Pixel_Size /= 4
and then Info.Pixel_Size /= 8
then
Put_Line ("Pix size not supported for palettized BMP.");
GNAT.OS_Lib.OS_Exit (-1);
end if;
Stream_IO.Set_Index (File_In,
Stream_IO.Positive_Count (55));
Palette'Read (Input, Palette_Data);
Put_Line ("Reading palette and converting to 24bits RGB...");
Stream_IO.Set_Index (File_In,
Stream_IO.Positive_Count (55));
P8_Array'Read (Input, Raw_palette);
Stream_IO.Set_Index (File_In,
Stream_IO.Positive_Count (55));
P16_Array'Read (Input, Raw_palette_16);
Put_Package_Header;
if DMA2D_Format then
Put_Line (File_Out, " CLUT : aliased constant " & Format_Str &
"_CLUT_T := (");
Print_Palette (File_Out, Palette_Data, Integer (Info.Pixel_Size));
Put_Line (File_Out, ";");
New_Line (File_Out);
Put_Line (File_Out, " Data : aliased constant " & Format_Str &
"_Data_T := (");
else
Text_IO.Put (File_Out, " Data : aliased constant ");
Text_IO.Put (File_Out, "Bitmap_Indexed");
Text_IO.Put_Line
(File_Out, " := (W =>" &
Info.Width'Img &
", H =>" & Info.Height'Img &
", Length_Byte =>" & Length_In_Bytes'Img & ",");
Text_IO.Put_Line (File_Out, "Palette => (");
Print_Palette (File_Out, Palette_Data, Integer (Info.Pixel_Size));
Text_IO.Put_Line (File_Out, ", Data => (");
end if;
Put_Line ("Reading bitmap data...");
for Row_Cnt in reverse 0 .. Integer (Info.Height) - 1 loop
Offset := Integer (Header.Offset) + Row_Size * Row_Cnt + 1;
Debug ("Read Row at offset:" & Offset'Img);
-- Move read pointer to where the row data starts.
Stream_IO.Set_Index (File_In,
Stream_IO.Positive_Count (Offset));
P8_Array'Read (Input, Raw_Bytes);
for Index in Raw_Bytes'Range loop
Pix_Values (Index).P8 (0) := Raw_Bytes (Index);
end loop;
for Index in 0 .. Integer (Info.Width - 1) loop
Byte_Index := Index / (8 / Integer (Info.Pixel_Size));
Pix_Index := Index mod (8 / Integer (Info.Pixel_Size));
Debug ("Byte_Index:" & Byte_Index'Img);
Debug ("Pix_Index:" & Pix_Index'Img);
case Info.Pixel_Size is
when 1 =>
Palette_Index :=
Unsigned_8 (Pix_Values (Byte_Index).P1 (7 - Pix_Index));
when 2 =>
Palette_Index :=
Unsigned_8 (Pix_Values (Byte_Index).P2 (3 - Pix_Index));
when 4 =>
Palette_Index :=
Unsigned_8 (Pix_Values (Byte_Index).P4 (1 - Pix_Index));
when 8 =>
Palette_Index := Pix_Values (Byte_Index).P8 (Pix_Index);
when others =>
raise Program_Error;
end case;
Debug ("Palette_Index:" & Palette_Index'Img);
Push_Pix_Index
(Palette_Index,
Last => Index = Integer (Info.Width - 1)
and then
Row_Cnt = 0);
end loop;
end loop;
if DMA2D_Format then
Text_IO.Put_Line (File_Out, ");");
Put_Line (File_Out,
" Image : constant Giza.Image.Ref :=" &
" new Giza.Image.DMA2D.Instance'");
Put_Line
(File_Out,
" (Mode => " & Format_Str &
", W =>" & Info.Width'Img &
", H =>" & Info.Height'Img &
", Length =>" & Length_In_Bytes'Img &
", " & Format_Str & "_CLUT => CLUT'Access" &
", " & Format_Str & "_Data => Data'Access);");
else
Text_IO.Put_Line (File_Out, "));");
-- with Linker_Section => "".rodata"";");
Text_IO.New_Line (File_Out);
Text_IO.Put_Line (File_Out, " Image :");
Text_IO.Put_Line (File_Out, " aliased Giza.Image.Bitmap.Indexed_" &
Size_Str & ".Instance");
Text_IO.Put_Line (File_Out, " (Data'Access);");
end if;
Put_Package_Footer;
end Palettized;
end BMP;
|
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.COMP is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Comparator status register
type SR_Register is record
-- Read-only. COMP channel 1 output status bit
C1VAL : Boolean;
-- Read-only. COMP channel 2 output status bit
C2VAL : Boolean;
-- unspecified
Reserved_2_15 : HAL.UInt14;
-- Read-only. COMP channel 1 Interrupt Flag
C1IF : Boolean;
-- Read-only. COMP channel 2 Interrupt Flag
C2IF : Boolean;
-- unspecified
Reserved_18_31 : HAL.UInt14;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register use record
C1VAL at 0 range 0 .. 0;
C2VAL at 0 range 1 .. 1;
Reserved_2_15 at 0 range 2 .. 15;
C1IF at 0 range 16 .. 16;
C2IF at 0 range 17 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
-- Comparator interrupt clear flag register
type ICFR_Register is record
-- unspecified
Reserved_0_15 : HAL.UInt16 := 16#0#;
-- Write-only. Clear COMP channel 1 Interrupt Flag
CC1IF : Boolean := False;
-- Write-only. Clear COMP channel 2 Interrupt Flag
CC2IF : Boolean := False;
-- unspecified
Reserved_18_31 : HAL.UInt14 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ICFR_Register use record
Reserved_0_15 at 0 range 0 .. 15;
CC1IF at 0 range 16 .. 16;
CC2IF at 0 range 17 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
subtype OR_AFOP_Field is HAL.UInt11;
-- Comparator option register
type OR_Register is record
-- Selection of source for alternate function of output ports
AFOP : OR_AFOP_Field := 16#0#;
-- unspecified
Reserved_11_31 : HAL.UInt21 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for OR_Register use record
AFOP at 0 range 0 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
subtype CFGR1_HYST_Field is HAL.UInt2;
subtype CFGR1_PWRMODE_Field is HAL.UInt2;
subtype CFGR1_INMSEL_Field is HAL.UInt3;
subtype CFGR1_BLANKING_Field is HAL.UInt4;
-- Comparator configuration register 1
type CFGR1_Register is record
-- COMP channel 1 enable bit
EN : Boolean := False;
-- Scaler bridge enable
BRGEN : Boolean := False;
-- Voltage scaler enable bit
SCALEN : Boolean := False;
-- COMP channel 1 polarity selection bit
POLARITY : Boolean := False;
-- unspecified
Reserved_4_5 : HAL.UInt2 := 16#0#;
-- COMP channel 1 interrupt enable
ITEN : Boolean := False;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- COMP channel 1 hysteresis selection bits
HYST : CFGR1_HYST_Field := 16#0#;
-- unspecified
Reserved_10_11 : HAL.UInt2 := 16#0#;
-- Power Mode of the COMP channel 1
PWRMODE : CFGR1_PWRMODE_Field := 16#0#;
-- unspecified
Reserved_14_15 : HAL.UInt2 := 16#0#;
-- COMP channel 1 inverting input selection field
INMSEL : CFGR1_INMSEL_Field := 16#0#;
-- unspecified
Reserved_19_19 : HAL.Bit := 16#0#;
-- COMP channel 1 non-inverting input selection bit
INPSEL : Boolean := False;
-- unspecified
Reserved_21_23 : HAL.UInt3 := 16#0#;
-- COMP channel 1 blanking source selection bits
BLANKING : CFGR1_BLANKING_Field := 16#0#;
-- unspecified
Reserved_28_30 : HAL.UInt3 := 16#0#;
-- Lock bit
LOCK : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CFGR1_Register use record
EN at 0 range 0 .. 0;
BRGEN at 0 range 1 .. 1;
SCALEN at 0 range 2 .. 2;
POLARITY at 0 range 3 .. 3;
Reserved_4_5 at 0 range 4 .. 5;
ITEN at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
HYST at 0 range 8 .. 9;
Reserved_10_11 at 0 range 10 .. 11;
PWRMODE at 0 range 12 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
INMSEL at 0 range 16 .. 18;
Reserved_19_19 at 0 range 19 .. 19;
INPSEL at 0 range 20 .. 20;
Reserved_21_23 at 0 range 21 .. 23;
BLANKING at 0 range 24 .. 27;
Reserved_28_30 at 0 range 28 .. 30;
LOCK at 0 range 31 .. 31;
end record;
subtype CFGR2_HYST_Field is HAL.UInt2;
subtype CFGR2_PWRMODE_Field is HAL.UInt2;
subtype CFGR2_INMSEL_Field is HAL.UInt3;
subtype CFGR2_BLANKING_Field is HAL.UInt4;
-- Comparator configuration register 2
type CFGR2_Register is record
-- COMP channel 1 enable bit
EN : Boolean := False;
-- Scaler bridge enable
BRGEN : Boolean := False;
-- Voltage scaler enable bit
SCALEN : Boolean := False;
-- COMP channel 1 polarity selection bit
POLARITY : Boolean := False;
-- Window comparator mode selection bit
WINMODE : Boolean := False;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- COMP channel 1 interrupt enable
ITEN : Boolean := False;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- COMP channel 1 hysteresis selection bits
HYST : CFGR2_HYST_Field := 16#0#;
-- unspecified
Reserved_10_11 : HAL.UInt2 := 16#0#;
-- Power Mode of the COMP channel 1
PWRMODE : CFGR2_PWRMODE_Field := 16#0#;
-- unspecified
Reserved_14_15 : HAL.UInt2 := 16#0#;
-- COMP channel 1 inverting input selection field
INMSEL : CFGR2_INMSEL_Field := 16#0#;
-- unspecified
Reserved_19_19 : HAL.Bit := 16#0#;
-- COMP channel 1 non-inverting input selection bit
INPSEL : Boolean := False;
-- unspecified
Reserved_21_23 : HAL.UInt3 := 16#0#;
-- COMP channel 1 blanking source selection bits
BLANKING : CFGR2_BLANKING_Field := 16#0#;
-- unspecified
Reserved_28_30 : HAL.UInt3 := 16#0#;
-- Lock bit
LOCK : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CFGR2_Register use record
EN at 0 range 0 .. 0;
BRGEN at 0 range 1 .. 1;
SCALEN at 0 range 2 .. 2;
POLARITY at 0 range 3 .. 3;
WINMODE at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
ITEN at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
HYST at 0 range 8 .. 9;
Reserved_10_11 at 0 range 10 .. 11;
PWRMODE at 0 range 12 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
INMSEL at 0 range 16 .. 18;
Reserved_19_19 at 0 range 19 .. 19;
INPSEL at 0 range 20 .. 20;
Reserved_21_23 at 0 range 21 .. 23;
BLANKING at 0 range 24 .. 27;
Reserved_28_30 at 0 range 28 .. 30;
LOCK at 0 range 31 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- COMP
type COMP_Peripheral is record
-- Comparator status register
SR : aliased SR_Register;
-- Comparator interrupt clear flag register
ICFR : aliased ICFR_Register;
-- Comparator option register
OR_k : aliased OR_Register;
-- Comparator configuration register 1
CFGR1 : aliased CFGR1_Register;
-- Comparator configuration register 2
CFGR2 : aliased CFGR2_Register;
end record
with Volatile;
for COMP_Peripheral use record
SR at 16#0# range 0 .. 31;
ICFR at 16#4# range 0 .. 31;
OR_k at 16#8# range 0 .. 31;
CFGR1 at 16#C# range 0 .. 31;
CFGR2 at 16#10# range 0 .. 31;
end record;
-- COMP
COMP_Periph : aliased COMP_Peripheral
with Import, Address => COMP_Base;
end STM32_SVD.COMP;
|
package body Ada.Text_IO.Generic_Unbounded_IO is
procedure Put (
File : File_Type;
Item : Unbounded_Strings.Unbounded_String) is
begin
Put (
File, -- checking the predicate
Unbounded_Strings.Constant_Reference (Item).Element.all);
end Put;
procedure Put (
Item : Unbounded_Strings.Unbounded_String) is
begin
Put (Current_Output.all, Item);
end Put;
procedure Put_Line (
File : File_Type;
Item : Unbounded_Strings.Unbounded_String) is
begin
Put_Line (
File, -- checking the predicate
Unbounded_Strings.Constant_Reference (Item).Element.all);
end Put_Line;
procedure Put_Line (
Item : Unbounded_Strings.Unbounded_String) is
begin
Put_Line (Current_Output.all, Item);
end Put_Line;
function Get_Line (
File : File_Type)
return Unbounded_Strings.Unbounded_String is
begin
return Result : Unbounded_Strings.Unbounded_String do
Get_Line (File, Result); -- checking the predicate
end return;
end Get_Line;
function Get_Line
return Unbounded_Strings.Unbounded_String is
begin
return Get_Line (Current_Input.all);
end Get_Line;
procedure Get_Line (
File : File_Type;
Item : out Unbounded_Strings.Unbounded_String)
is
Last : Natural := 0;
Capacity : Natural := 256;
begin
loop
Unbounded_Strings.Set_Length (Item, Capacity);
Get_Line (
File, -- checking the predicate
Unbounded_Strings.Reference (Item).Element (Last + 1 .. Capacity),
Last);
exit when Last < Capacity;
-- growth
if Unbounded_Strings.String_Type'Component_Size =
String'Component_Size
then
Capacity := String_Grow (Capacity);
elsif Unbounded_Strings.String_Type'Component_Size =
Wide_String'Component_Size
then
Capacity := Wide_String_Grow (Capacity);
elsif Unbounded_Strings.String_Type'Component_Size =
Wide_Wide_String'Component_Size
then
Capacity := Wide_Wide_String_Grow (Capacity);
else
declare
function Grow is
new System.Growth.Good_Grow (
Natural,
Component_Size =>
Unbounded_Strings.String_Type'Component_Size);
begin
Capacity := Grow (Capacity);
end;
end if;
end loop;
Unbounded_Strings.Set_Length (Item, Last);
end Get_Line;
procedure Get_Line (
Item : out Unbounded_Strings.Unbounded_String) is
begin
Get_Line (Current_Input.all, Item);
end Get_Line;
end Ada.Text_IO.Generic_Unbounded_IO;
|
with Ada.Real_Time; use Ada.Real_Time;
with STM_Board; use STM_Board;
with Inverter_ADC; use Inverter_ADC;
with Inverter_PWM; use Inverter_PWM;
with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler);
-- The "last chance handler" is the user-defined routine that is called when
-- an exception is propagated. We need it in the executable, therefore it
-- must be somewhere in the closure of the context clauses.
procedure Demo_Inverter is
-- This demonstration program only initializes the GPIOs and PWM timer and
-- presents on the output of the full-bridge a sinusoidal wave of 60 Hz.
-- There is no initialization for ADC and timer, so there is no analog monitoring.
begin
-- Initialize GPIO ports
Initialize_GPIO;
-- Select gain = 1.0 to see only sine table sinusoid
Sine_Gain := 1.0;
-- Select the AC frequency of the inverter, 25_000 for 50 Hz, 30_000 for 60 Hz.
PWM_Frequency_Hz := 30_000.0;
-- Disable PWM gate drivers because some gate drivers enable with
-- low level.
Set_PWM_Gate_Power (False);
-- Initialize PWM generator
Initialize_PWM (Frequency => PWM_Frequency_Hz,
Deadtime => PWM_Deadtime,
Alignment => Center);
-- Test if all peripherals are correctly initialized
while not (STM_Board.Is_Initialized and Inverter_PWM.Is_Initialized) loop
Set_Toggle (Green_LED);
delay until Clock + Milliseconds (1000); -- arbitrary
end loop;
-- Enable PWM gate drivers
Set_PWM_Gate_Power (True);
-- Start generating the sinusoid
Start_PWM;
-- Enter steady state
loop
Set_Toggle (Green_LED);
delay until Clock + Milliseconds (3000); -- arbitrary
end loop;
end Demo_Inverter;
|
WITH Ada.TeXt_iO;
ProCEDure HElLoworLd iS
beGin
ADA.tEXt_Io.PuT_liNE("Hello, World!");
ENd heLLoWORlD;
|
-- Data Watchpoint and Trace (DWT) Unit
-- Gives access to cycle counter.
pragma Restrictions (No_Elaboration_Code);
with Interfaces; use Interfaces;
with System;
package STM32.DWT is
DWT_Core_Base : constant System.Address :=
System'To_Address (16#E000_1000#);
procedure Enable;
procedure Disable;
-- enable/disable overall DWT functionality
procedure Enable_Cycle_Counter;
procedure Enable_Sleep_Counter;
procedure Disable_Cycle_Counter;
procedure Disable_Sleep_Counter;
function Read_Cycle_Counter return Unsigned_32;
function Read_Sleep_Counter return Unsigned_8;
type DWT_Ctrl_Register is record
NUMCOMP : HAL.Uint4;
Reserved_23_27 : HAL.Uint5;
CYCEVTENA : Boolean;
FOLDEVTENA : Boolean;
LSUEVTENA : Boolean;
SLEEPEVTENA : Boolean;
EXCEVTENA : Boolean;
CPIEVTENA : Boolean;
EXCTRCENA : Boolean;
Reserved_13_15 : HAL.Uint3;
PCSAMPLEENA : Boolean;
SYNCTAP : HAL.UInt2;
CYCTAP : Boolean;
POSTCNT : HAL.Uint4;
POSTPRESET : HAL.Uint4;
CYCCNTENA : Boolean;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DWT_Ctrl_Register use record
NUMCOMP at 0 range 28 .. 31;
Reserved_23_27 at 0 range 23 .. 27;
CYCEVTENA at 0 range 22 .. 22;
FOLDEVTENA at 0 range 21 .. 21;
LSUEVTENA at 0 range 20 .. 20;
SLEEPEVTENA at 0 range 19 .. 19;
EXCEVTENA at 0 range 18 .. 18;
CPIEVTENA at 0 range 17 .. 17;
EXCTRCENA at 0 range 16 .. 16;
Reserved_13_15 at 0 range 13 .. 15;
PCSAMPLEENA at 0 range 12 .. 12;
SYNCTAP at 0 range 10 .. 11;
CYCTAP at 0 range 9 .. 9;
POSTCNT at 0 range 5 .. 8;
POSTPRESET at 0 range 1 .. 4;
CYCCNTENA at 0 range 0 .. 0;
end record;
----------------
-- DWT_Core_T --
----------------
type DWT_Core_T is record
DWT_CTRL : DWT_Ctrl_Register;
-- cycle count
DWT_CYCCNT : Word;
-- additional cycles required to execute multi-cycle
-- instructions and instruction fetch stalls
DWT_CPICNT : Byte; -- 8..31 reserved
-- exception overhead (entry and exit) count
DWT_EXCNT : Byte; -- 8..31 reserved
-- sleep count
DWT_SLEEPCNT : Byte; -- 8..31 reserved
-- cycles waiting for Load/Store to complete
DWT_LSUCNT : Byte; -- 8..31 reserved
-- folded instruction count (saved cycles)
DWT_FOLDCNT : Byte; -- 8..31 reserved
-- program counter sample reg
DWT_PCSR : Word;
-- Comparator and Mask Registers
DWT_COMP0 : Word;
DWT_MASK0 : Word;
DWT_FUNC0 : Word;
DWT_COMP1 : Word;
DWT_MASK1 : Word;
DWT_FUNC1 : Word;
DWT_COMP2 : Word;
DWT_MASK2 : Word;
DWT_FUNC2 : Word;
DWT_COMP3 : Word;
DWT_MASK3 : Word;
DWT_FUNC4 : Word;
end record
with Volatile;
for DWT_Core_T use record
DWT_CTRL at 0 range 0 .. 31;
DWT_CYCCNT at 4 range 0 .. 31;
DWT_CPICNT at 8 range 0 .. 7;
DWT_EXCNT at 12 range 0 .. 7;
DWT_SLEEPCNT at 16 range 0 .. 7;
DWT_LSUCNT at 20 range 0 .. 7;
DWT_FOLDCNT at 24 range 0 .. 7;
DWT_PCSR at 28 range 0 .. 31;
DWT_COMP0 at 32 range 0 .. 31;
DWT_MASK0 at 36 range 0 .. 31;
DWT_FUNC0 at 40 range 0 .. 31;
-- there is an address jump
DWT_COMP1 at 48 range 0 .. 31;
DWT_MASK1 at 52 range 0 .. 31;
DWT_FUNC1 at 56 range 0 .. 31;
-- another address jump
DWT_COMP2 at 64 range 0 .. 31;
DWT_MASK2 at 68 range 0 .. 31;
DWT_FUNC2 at 72 range 0 .. 31;
-- another address jump
DWT_COMP3 at 80 range 0 .. 31;
DWT_MASK3 at 84 range 0 .. 31;
DWT_FUNC4 at 88 range 0 .. 31;
-- TODO: PID4..0
end record;
Core_DWT : aliased DWT_Core_T
with Import, Address => DWT_Core_Base;
-- Linker_Section => ".ccmdata"; -- pointer to CCM
end STM32.DWT;
|
-- Práctica 4: César Borao Moratinos (Hash_Maps_G_Chaining.adb)
with Ada.Text_IO;
with Ada.Strings.Unbounded;
with Ada.Unchecked_Deallocation;
package body Hash_Maps_G is
package ASU renames Ada.Strings.Unbounded;
procedure Put (M: in out Map;
Key: Key_Type;
Value: Value_Type) is
P_Aux: Cell_A;
Success: Boolean;
begin
Success := False;
if M.P_Array = null then
M.P_Array := new Cell_Array;
M.P_Array(Hash(Key)) := new Cell'(Key,Value,null);
M.Length := 1;
M.Counter := 1;
else
if M.P_Array(Hash(Key)) = null then
if M.Length = Max then
raise Full_Map;
end if;
M.P_Array(Hash(Key)) := new Cell'(Key, Value, null);
M.Length := M.Length + 1;
M.Counter := M.Counter + 1;
else
P_Aux := M.P_Array(Hash(Key));
while P_Aux.Next /= null and not Success loop
if P_Aux.Key = Key then
P_Aux.Value := Value;
Success := True;
end if;
P_Aux := P_Aux.Next;
end loop;
if P_Aux.Next = null and not Success then
if P_Aux.Key = Key then
P_Aux.Value := Value;
Success := True;
end if;
end if;
if not Success then
if M.Counter = Max then
raise Full_Map;
end if;
P_Aux.Next := new Cell'(Key,Value,null);
M.Counter := M.Counter + 1;
end if;
end if;
end if;
end Put;
procedure Get (M: Map;Key: in Key_Type;
Value: out Value_Type;
Success: out Boolean) is
P_Aux: Cell_A;
begin
Success := False;
if M.P_Array /= null then
P_Aux := M.P_Array(Hash(Key));
if P_Aux /= null then
while P_Aux.Next /= null and not Success loop
if P_Aux.Key = Key then
Value := P_Aux.Value;
Success := True;
end if;
P_Aux := P_Aux.Next;
end loop;
if P_Aux.Next = null and not Success then
if P_Aux.Key = Key then
Value := P_Aux.Value;
Success := True;
end if;
end if;
end if;
end if;
end Get;
procedure Delete (M: in out Map;
Key: in Key_Type;
Success: out Boolean) is
P_Current: Cell_A := M.P_Array(Hash(Key));
P_Previous: Cell_A := P_Current;
procedure Free is new Ada.Unchecked_Deallocation (Cell, Cell_A);
begin
Success := False;
while P_Current /= null loop
if P_Previous.Key = Key then
Success := True;
M.P_Array(Hash(Key)) := M.P_Array(Hash(Key)).Next;
Free(P_Current);
M.Counter := M.Counter - 1;
if M.P_Array(Hash(Key)) = null then
M.Length := M.Length - 1;
end if;
elsif P_Current.Key = Key then
Success := True;
P_Previous.Next := P_Current.Next;
Free(P_Current);
M.Counter := M.Counter - 1;
else
P_Previous := P_Current;
P_Current := P_Current.Next;
end if;
end loop;
end Delete;
function Map_Length (M : Map) return Natural is
begin
return M.Length;
end Map_Length;
function First (M: Map) return Cursor is
C: Cursor;
begin
C.M := M;
C.Position := 0;
while C.M.P_Array(C.Position) = null and C.Position < Hash_Range'Last loop
C.Position := C.Position + 1;
end loop;
C.Pointer := C.M.P_Array(C.Position);
return C;
end First;
procedure Next (C: in out Cursor) is
begin
if C.Pointer.Next = null then
C.Position := C.Position + 1;
if C.Position = Hash_Range'First then
C.Pointer := null;
else
C.Pointer := C.M.P_Array(C.Position);
while C.Pointer = null and C.Position < Hash_Range'Last loop
C.Position := C.Position + 1;
C.Pointer := C.M.P_Array(C.Position);
end loop;
end if;
else
C.Pointer := C.Pointer.Next;
end if;
end Next;
function Has_Element (C: Cursor) return Boolean is
begin
if C.Pointer /= null then
return True;
else
return False;
end if;
end Has_Element;
function Element (C: Cursor) return Element_Type is
Element: Element_Type;
begin
if Has_Element (C) then
Element.Key := C.Pointer.Key;
Element.Value := C.Pointer.Value;
else
raise No_Element;
end if;
return Element;
end Element;
end Hash_Maps_G;
|
with IntrospectorPackage, VisitablePackage, ObjectPack;
use IntrospectorPackage, VisitablePackage, ObjectPack;
package VisitableIntrospectorPackage is
type VisitableIntrospector is new Introspector and Object with null record;
function setChildren(intro: access VisitableIntrospector; o: ObjectPtr; children: ObjectPtrArrayPtr) return ObjectPtr;
function getChildren(intro: access VisitableIntrospector; o: ObjectPtr) return ObjectPtrArrayPtr;
function setChildAt(intro: access VisitableIntrospector; o: ObjectPtr; i: Integer; child: ObjectPtr) return ObjectPtr;
function getChildAt(intro: access VisitableIntrospector; o: ObjectPtr; i: Integer) return ObjectPtr;
function getChildCount(intro: access VisitableIntrospector; o: ObjectPtr) return Integer;
function getInstance return IntrospectorPtr;
function toString(vi : VisitableIntrospector) return String;
mapping : IntrospectorPtr := new VisitableIntrospector;
end VisitableIntrospectorPackage;
|
with Ada.Unchecked_Deallocation;
package body Generic_Stack is
procedure Free is new Ada.Unchecked_Deallocation( Stack_Node,
Stack_Node_Ptr );
------------------------------------------------------------
procedure Push( Stack: in out T; Element: in Element_Type ) is
New_Node : Stack_Node_Ptr := new Stack_Node'( Data => Element,
Next => Stack.Head );
begin
Stack.Head := New_Node;
end Push;
------------------------------------------------------------
procedure Pop( Stack: in out T; Element: out Element_Type ) is
Old_Head : Stack_Node_Ptr := Stack.Head;
begin
if Stack.Head = null then
raise Underflow;
end if;
Stack.Head := Old_Head.Next;
Element := Old_Head.Data;
Free( Old_Head );
end Pop;
------------------------------------------------------------
procedure Peek( Stack: in out T; Element: out Element_Type ) is
begin
if Stack.Head = null then
raise Underflow;
end if;
Element := Stack.Head.Data;
end Peek;
------------------------------------------------------------
function Empty( Stack: in T ) return Boolean is
begin
return Stack.Head = null;
end Empty;
------------------------------------------------------------
procedure Reset( Stack: in out T ) is
Old_Head : Stack_Node_Ptr := Stack.Head;
begin
while Old_Head /= null loop
Stack.Head := Old_Head.Next;
Free( Old_Head );
Old_Head := Stack.Head;
end loop;
end Reset;
end Generic_Stack;
|
with Ada.Strings;
with GNAT.Sockets; use GNAT.Sockets;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
procedure Client is
Client : Socket_Type;
Address : Sock_Addr_Type;
-- Key : Character;
-- Recieving msg task --
task Rec_Msg is
entry Start (Socket : Socket_Type);
end Rec_Msg;
task body Rec_Msg is
Sock : Socket_Type;
Channel : Stream_Access;
begin
accept Start (Socket : Socket_Type) do
Sock := Socket;
end Start;
Channel := Stream (Sock);
loop
Put_Line (String'Input (Channel));
end loop;
end Rec_Msg;
-- Sending msg task --
task Send_Msg is
entry Start (Socket : Socket_Type);
end Send_Msg;
task body Send_Msg is
Sock : Socket_Type;
Channel : Stream_Access;
begin
accept Start (Socket : Socket_Type) do
Sock := Socket;
end Start;
Channel := Stream (Sock);
loop
declare
User_Input : String := Get_Line;
begin
-- exit when End_Of_File;
String'Output
(Channel,
User_Input); -- Sends message to stream (Modified to display current time)
end;
end loop;
end Send_Msg;
-- -- Detecting if user exited group chat --
-- task Check_End;
-- task body Check_End is
-- begin
-- loop
-- Get_Immediate (Key);
-- if Key = ESC then
-- Put_Line ("Closing Socket...");
-- Close_Socket (Client);
-- Finalize;
-- exit;
-- end if;
-- end loop;
-- end Check_End;
begin
-- Get port from user
if Argument_Count = 0 then
Put_Line (Current_Error, "Error - No port was given.");
Set_Exit_Status (Failure);
elsif Argument_Count > 1 then
Put_Line (Current_Error, "Error - Please only put one argument");
Set_Exit_Status (Failure);
else
Initialize; -- Must be called before socket routine
Address.Addr := Addresses (Get_Host_By_Name (Host_Name), 1);
Address.Port := Port_Type (Integer'Value (Argument (1)));
Create_Socket (Socket => Client);
-- Connect and Autmoatically bind to an address since localhost is the server
Connect_Socket (Client, Address);
Put_Line ("Server connected...");
Put_Line ("Please enter a Username");
declare
Username : String := Get_Line;
begin
-- Send username to server
String'Output (Stream (Client), Username);
end;
Put_Line ("Username sent");
--Start Recieving and sending tasks
Rec_Msg.Start (Client);
Send_Msg.Start (Client);
end if;
end Client;
|
-- MIT License
-- Copyright (c) 2020 Jean-Jacques François Reibel
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
with Ada.Text_IO; use Ada.Text_IO;
procedure Car is
--class
type Car is tagged
record
wheels : Integer;
doors : Integer;
cylinders : Integer;
end record;
-- functions
--prior to Ada 2012, passed arguments could not be written to
--that would defeat the purpose of writing functions for records
procedure addWheels(myCar : in out Car; wheelsIn : Integer)
is
begin
myCar.wheels := myCar.wheels + wheelsIn;
end addWheels;
procedure addDoors(myCar : in out Car; doorsIn : Integer)
is
begin
myCar.doors := myCar.doors + doorsIn;
end addDoors;
procedure addCylinders(myCar : in out Car; cylindersIn : Integer)
is
begin
myCar.cylinders := myCar.cylinders + cylindersIn;
end addCylinders;
procedure deleteWheels(myCar : in out Car; wheelsIn : Integer)
is
begin
myCar.wheels := myCar.wheels - wheelsIn;
end deleteWheels;
procedure deleteDoors(myCar : in out Car; doorsIn : Integer)
is
begin
myCar.doors := myCar.doors - doorsIn;
end deleteDoors;
procedure deleteCylinders(myCar : in out Car; cylindersIn : Integer)
is
begin
myCar.cylinders := myCar.cylinders - cylindersIn;
end deleteCylinders;
--main program block
begin
Put_Line("Creating car.");
declare
subaru : Car;
begin
subaru.wheels := 4;
subaru.doors := 4;
subaru.cylinders := 4;
Put("Wheel check: ");
Put(Integer'Image(subaru.wheels));
New_Line;
Put("Door check: ");
Put(Integer'Image(subaru.doors));
New_Line;
Put("Cylinder check: ");
Put(Integer'Image(subaru.cylinders));
New_Line;
New_Line;
Put_Line("Adding wheel directly to car object.");
subaru.wheels := subaru.wheels + 1;
Put("Wheel check: ");
Put(Integer'Image(subaru.wheels));
New_Line;
Put("Door check: ");
Put(Integer'Image(subaru.doors));
New_Line;
Put("Cylinder check: ");
Put(Integer'Image(subaru.cylinders));
New_Line;
New_Line;
Put_Line("Removing wheel using object method.");
deleteWheels(subaru, 1);
Put("Wheel check: ");
Put(Integer'Image(subaru.wheels));
New_Line;
Put("Door check: ");
Put(Integer'Image(subaru.doors));
New_Line;
Put("Cylinder check: ");
Put(Integer'Image(subaru.cylinders));
New_Line;
end;
end Car;
|
with STM32_SVD; use STM32_SVD;
generic
Pin : in GPIO_Pin;
Port : in out Natural;
Mode : in Pin_IO_Modes := Mode_In;
Pull_Resistor : in Internal_Pin_Resistors := Floating;
Alternate_Function : in GPIO_Alternate_Function := 0;
package STM32GD.GPIO.Pin is
pragma Preelaborate;
procedure Init;
procedure Set_Mode (Mode : Pin_IO_Modes);
procedure Set_Type (Pin_Type : Pin_Output_Types);
function Get_Pull_Resistor return Internal_Pin_Resistors;
procedure Set_Pull_Resistor (Pull : Internal_Pin_Resistors);
procedure Configure_Alternate_Function (AF : GPIO_Alternate_Function);
function Is_Set return Boolean;
procedure Set;
procedure Clear;
procedure Toggle;
end STM32GD.GPIO.Pin;
|
------------------------------------------------------------------------------
-- Copyright (c) 2015, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Ada.Streams.Stream_IO;
with Natools.S_Expressions.Test_Tools;
package body Natools.S_Expressions.Enumeration_IO.Tests is
package Stream_IO renames Ada.Streams.Stream_IO;
package Test_IO is new Typed_IO (Stream_IO.File_Mode);
-------------------------
-- Complete Test Suite --
-------------------------
procedure All_Tests (Report : in out NT.Reporter'Class) is
begin
Basic_Usage (Report);
Invalid_Atom (Report);
end All_Tests;
----------------------
-- Individual Tests --
----------------------
procedure Basic_Usage (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Basic usage with Stream_IO.File_Mode");
use type Stream_IO.File_Mode;
begin
Test_Tools.Test_Atom
(Test,
To_Atom ("append-file"),
Test_IO.Image (Stream_IO.Append_File));
declare
Expected : constant Stream_IO.File_Mode := Stream_IO.Out_File;
Found : constant Stream_IO.File_Mode
:= Test_IO.Value (To_Atom ("out-file"));
begin
if Expected /= Found then
Test.Fail ("Test_IO.Value returned "
& Stream_IO.File_Mode'Image (Found)
& ", expected "
& Stream_IO.File_Mode'Image (Expected));
end if;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Basic_Usage;
procedure Invalid_Atom (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Value on invalid atoms");
use type Stream_IO.File_Mode;
begin
Without_Fallback :
declare
Found : Stream_IO.File_Mode;
begin
Found := Test_IO.Value (To_Atom ("invalid-atom"));
Test.Fail ("Exception expected, but Value returned "
& Stream_IO.File_Mode'Image (Found));
exception
when Constraint_Error => null;
end Without_Fallback;
With_Fallback :
declare
Expected : constant Stream_IO.File_Mode := Stream_IO.Out_File;
Found : constant Stream_IO.File_Mode
:= Test_IO.Value (To_Atom ("invalid-atom"), Expected);
begin
if Expected /= Found then
Test.Fail ("Test_IO.Value returned "
& Stream_IO.File_Mode'Image (Found)
& ", expected "
& Stream_IO.File_Mode'Image (Expected));
end if;
end With_Fallback;
exception
when Error : others => Test.Report_Exception (Error);
end Invalid_Atom;
end Natools.S_Expressions.Enumeration_IO.Tests;
|
with EU_Projects.Times.Time_Expressions;
with EU_Projects.Event_Names;
--
-- A timed node represents something related with an event. It is a
-- basic node with a "expected on" date. Currently used for deliverables
-- and milestones
--
package EU_Projects.Nodes.Timed_Nodes is
type Timed_Node is abstract new Node_Type with private;
type Timed_Node_Access is access all Timed_Node'Class;
-- function Create (Label : Identifiers.Identifier;
-- Name : String;
-- Short_Name : String;
-- Index : Node_Index := No_Index)
-- return Timed_Node'Class;
Node_Event_Name : constant Dotted_Identifier := To_ID ("expected_on");
function Time_Fixed (Item : Timed_Node) return Boolean;
procedure Due_On (Item : in out Timed_Node;
Time : in String);
function Due_On (Item : Timed_Node) return Times.Instant
with Pre => Item.Time_Fixed;
function Due_On (Item : Timed_Node)
return Times.Time_Expressions.Symbolic_Instant;
function Due_Time_Var (Item : Timed_Node) return Dotted_Identifier;
function Dependency_Ready_Var (Item : Timed_Node) return String
is abstract;
overriding function Variables (Item : Timed_Node) return Variable_List
is ((1 => Event_Names.Event_Time_Name));
overriding procedure Parse_Raw_Expressions
(Item : in out Timed_Node;
Vars : Times.Time_Expressions.Parsing.Symbol_Table);
overriding function Is_Variable (Item : Timed_Node;
Var : Simple_Identifier) return Boolean;
overriding function Is_A (Item : Timed_Node;
Var : Simple_Identifier;
Class : Times.Time_Type)
return Boolean;
overriding function Is_Fixed (Item : Timed_Node;
Var : Simple_Identifier)
return Boolean;
overriding procedure Fix_Instant
(Item : in out Timed_Node;
Var : Simple_Identifier;
Value : Times.Instant)
with
Pre => not Item.Time_Fixed,
Post => Item.Time_Fixed;
overriding function Get_Symbolic_Instant
(X : Timed_Node;
Var : Simple_Identifier)
return Times.Time_Expressions.Symbolic_Instant;
overriding function Get_Symbolic_Duration
(X : Timed_Node;
Var : Simple_Identifier)
return Times.Time_Expressions.Symbolic_Duration;
private
use type Times.Time_Type;
type Timed_Node is abstract
new Node_Type
with
record
Expected_Raw : Unbounded_String;
Expected_Symbolic : Times.Time_Expressions.Symbolic_Instant;
Expected_On : Times.Instant;
Fixed : Boolean := False;
end record;
function Time_Fixed (Item : Timed_Node) return Boolean
is (Item.Fixed);
function Due_On (Item : Timed_Node) return Times.Time_Expressions.Symbolic_Instant
is (Item.Expected_Symbolic);
function Due_On (Item : Timed_Node) return Times.Instant
is (Item.Expected_On);
function Due_Time_Var (Item : Timed_Node) return Dotted_Identifier
is (Join (Dotted_Identifier (Item.Label), Node_Event_Name));
function Is_Variable (Item : Timed_Node;
Var : Simple_Identifier) return Boolean
is (Var = Event_Names.Event_Time_Name);
overriding function Is_A (Item : Timed_Node;
Var : Simple_Identifier;
Class : Times.Time_Type)
return Boolean
is (Var = Event_Names.Event_Time_Name and Class = Times.Instant_Value);
function Get_Symbolic_Instant
(X : Timed_Node;
Var : Simple_Identifier)
return Times.Time_Expressions.Symbolic_Instant
is (if Var = Event_Names.Event_Time_Name then
X.Expected_Symbolic
else
raise Unknown_Instant_Var);
function Get_Symbolic_Duration
(X : Timed_Node;
Var : Simple_Identifier)
return Times.Time_Expressions.Symbolic_Duration
is (raise Unknown_Duration_Var);
end EU_Projects.Nodes.Timed_Nodes;
|
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Ada.Characters.Conversions;
with Ada.Characters.Latin_1;
with Interfaces.C_Streams;
package body Program.Directory_Unit_Schemas is
function Find_File
(Self : Directory_Unit_Schema'Class;
Base_Name : Program.Text) return Program.Text;
function Exists (Name : Wide_Wide_String) return Boolean;
-------------------
-- Add_Directory --
-------------------
procedure Add_Directory
(Self : in out Directory_Unit_Schema;
Path : Program.Text)
is
begin
if Ada.Strings.Wide_Wide_Unbounded.Length (Self.Path) = 0 then
Self.Path := Ada.Strings.Wide_Wide_Unbounded.
To_Unbounded_Wide_Wide_String (Path);
elsif Self.Next = null then
Self.Next := new Directory_Unit_Schema'
(Self.Base_Name.all'Unchecked_Access, others => <>);
Self.Next.Add_Directory (Path);
else
Self.Next.Add_Directory (Path);
end if;
end Add_Directory;
--------------------
-- Body_Text_Name --
--------------------
overriding function Body_Text_Name
(Self : Directory_Unit_Schema; Name : Program.Text) return Program.Text
is
Base : constant Program.Text := Self.Base_Name.Body_Text_Name (Name);
begin
return Self.Find_File (Base);
end Body_Text_Name;
---------------------------
-- Declaration_Text_Name --
---------------------------
overriding function Declaration_Text_Name
(Self : Directory_Unit_Schema; Name : Program.Text) return Program.Text
is
Base : constant Program.Text :=
Self.Base_Name.Declaration_Text_Name (Name);
begin
return Self.Find_File (Base);
end Declaration_Text_Name;
------------
-- Exists --
------------
function Exists (Name : Wide_Wide_String) return Boolean is
File : constant String := Ada.Characters.Conversions.To_String (Name) &
Ada.Characters.Latin_1.NUL;
begin
return Interfaces.C_Streams.file_exists (File'Address) /= 0;
end Exists;
---------------
-- Find_File --
---------------
function Find_File
(Self : Directory_Unit_Schema'Class;
Base_Name : Program.Text) return Program.Text
is
Directory : constant Program.Text :=
Ada.Strings.Wide_Wide_Unbounded.To_Wide_Wide_String (Self.Path);
begin
if (Directory'Length = 0 or else
Directory (Directory'Last) in '/' | '\')
and then Exists (Directory & Base_Name)
then
return Directory & Base_Name;
elsif Exists (Directory & '/' & Base_Name) then
return Directory & '/' & Base_Name;
elsif Self.Next = null then
return "";
else
return Self.Next.Find_File (Base_Name);
end if;
end Find_File;
------------------------
-- Standard_Text_Name --
------------------------
overriding function Standard_Text_Name
(Self : Directory_Unit_Schema) return Program.Text
is
Base : constant Program.Text := Self.Base_Name.Standard_Text_Name;
begin
return Self.Find_File (Base);
end Standard_Text_Name;
-----------------------
-- Subunit_Text_Name --
-----------------------
overriding function Subunit_Text_Name
(Self : Directory_Unit_Schema; Name : Program.Text) return Program.Text
is
Base : constant Program.Text := Self.Base_Name.Subunit_Text_Name (Name);
begin
return Self.Find_File (Base);
end Subunit_Text_Name;
end Program.Directory_Unit_Schemas;
|
with Leds; use Leds;
with Ada.Real_Time; use Ada.Real_Time;
package Morse is
procedure Blink_Morse(LED: Led_No; Led_Color : Color; Duration : Time_Span);
procedure Dot;
procedure Dash;
procedure Morse_Display (S : String);
end Morse;
|
with Ada.Unchecked_Conversion;
with System.Address_To_Named_Access_Conversions;
with System.Storage_Elements;
package body Ada.Strings.Generic_Functions is
use type System.Address;
use type System.Storage_Elements.Storage_Offset;
procedure memset (
b : System.Address;
c : Integer;
n : System.Storage_Elements.Storage_Count)
with Import,
Convention => Intrinsic, External_Name => "__builtin_memset";
function memchr (
s : System.Address;
c : Integer;
n : System.Storage_Elements.Storage_Count)
return System.Address
with Import,
Convention => Intrinsic, External_Name => "__builtin_memchr";
procedure Fill (
Target : out String_Type;
Pad : Character_Type := Space);
procedure Fill (
Target : out String_Type;
Pad : Character_Type := Space) is
begin
if Character_Type'Size = Standard'Storage_Unit
and then String_Type'Component_Size = Standard'Storage_Unit
then
memset (Target'Address, Character_Type'Pos (Pad), Target'Length);
else
for I in Target'Range loop
Target (I) := Pad;
end loop;
end if;
end Fill;
-- implementation
procedure Move (
Source : String_Type;
Target : out String_Type;
Drop : Truncation := Error;
Justify : Alignment := Left;
Pad : Character_Type := Space)
is
Target_Offset : constant Integer := Target'Length - 1;
Triming_Limit : Integer;
Source_First : Positive := Source'First;
Source_Last : Natural := Source'Last;
Target_First : Positive;
Target_Last : Natural;
begin
if Justify = Center then
Triming_Limit := -1;
else
Triming_Limit := Target_Offset;
end if;
if Source_Last - Source_First > Triming_Limit then
if Justify /= Right then -- Left or Center
while Source_Last - Source_First > Triming_Limit
and then Source (Source_Last) = Pad
loop
Source_Last := Source_Last - 1;
end loop;
end if;
if Justify /= Left then -- Center or Right
while Source_Last - Source_First > Triming_Limit
and then Source (Source_First) = Pad
loop
Source_First := Source_First + 1;
end loop;
end if;
if Source_Last - Source_First > Target_Offset then
case Drop is
when Left =>
Source_First := Source_Last - Target_Offset;
when Right =>
Source_Last := Source_First + Target_Offset;
when Error =>
raise Length_Error;
end case;
end if;
end if;
case Justify is
when Left =>
Target_First := Target'First;
Target_Last := Target_First + (Source_Last - Source_First);
when Center =>
Target_First :=
(Target'First + Target'Last - (Source_Last - Source_First)) / 2;
Target_Last := Target_First + (Source_Last - Source_First);
when Right =>
Target_Last := Target'Last;
Target_First := Target_Last - (Source_Last - Source_First);
end case;
-- contents
declare
Source_Contents : String_Type
renames Source (Source_First .. Source_Last);
Target_Contents : String_Type
renames Target (Target_First .. Target_Last);
begin
if Source_Contents'Address /= Target_Contents'Address then
Target_Contents := Source_Contents;
end if;
end;
-- left padding
if Target_First /= Target'First then
Fill (Target (Target'First .. Target_First - 1), Pad);
end if;
-- right padding
if Target_Last /= Target'Last then
Fill (Target (Target_Last + 1 .. Target'Last), Pad);
end if;
end Move;
function Index_Element (
Source : String_Type;
Pattern : Character_Type;
From : Positive;
Going : Direction := Forward)
return Natural is
begin
case Going is
when Forward =>
return Index_Element_Forward (
Source (From .. Source'Last),
Pattern);
when Backward =>
return Index_Element_Backward (
Source (Source'First .. From),
Pattern);
end case;
end Index_Element;
function Index_Element (
Source : String_Type;
Pattern : Character_Type;
Going : Direction := Forward)
return Natural is
begin
case Going is
when Forward =>
return Index_Element_Forward (Source, Pattern);
when Backward =>
return Index_Element_Backward (Source, Pattern);
end case;
end Index_Element;
function Index_Element_Forward (
Source : String_Type;
Pattern : Character_Type)
return Natural is
begin
if Character_Type'Size = Standard'Storage_Unit
and then String_Type'Component_Size = Standard'Storage_Unit
then
declare
P : constant System.Address :=
memchr (
Source'Address,
Character_Type'Pos (Pattern),
Source'Length);
begin
if P = System.Null_Address then
return 0;
else
return Source'First + Integer (P - Source'Address);
end if;
end;
else
for I in Source'Range loop
if Source (I) = Pattern then
return I;
end if;
end loop;
return 0;
end if;
end Index_Element_Forward;
function Index_Element_Backward (
Source : String_Type;
Pattern : Character_Type)
return Natural is
begin
-- __builtin_memrchr does not exist...
for I in reverse Source'Range loop
if Source (I) = Pattern then
return I;
end if;
end loop;
return 0;
end Index_Element_Backward;
function Index (
Source : String_Type;
Pattern : String_Type;
From : Positive;
Going : Direction := Forward)
return Natural is
begin
case Going is
when Forward =>
return Index_Forward (Source (From .. Source'Last), Pattern);
when Backward =>
return Index_Backward (
Source (
Source'First ..
Natural'Min (From + (Pattern'Length - 1), Source'Last)),
Pattern);
end case;
end Index;
function Index (
Source : String_Type;
Pattern : String_Type;
Going : Direction := Forward)
return Natural is
begin
case Going is
when Forward =>
return Index_Forward (Source, Pattern);
when Backward =>
return Index_Backward (Source, Pattern);
end case;
end Index;
function Index_Forward (Source : String_Type; Pattern : String_Type)
return Natural is
begin
if Pattern'Length = 0 then
raise Pattern_Error;
else
declare
Pattern_Length : constant Natural := Pattern'Length;
Last : constant Integer := Source'Last - (Pattern_Length - 1);
Searched_Last : Natural := Source'First - 1;
begin
while Searched_Last < Last loop
declare
Position : constant Natural :=
Index_Element_Forward (
Source (Searched_Last + 1 .. Last),
Pattern (Pattern'First));
begin
exit when Position = 0;
if Source (Position .. Position + (Pattern_Length - 1)) =
Pattern
then
return Position;
end if;
Searched_Last := Position;
end;
end loop;
return 0;
end;
end if;
end Index_Forward;
function Index_Backward (Source : String_Type; Pattern : String_Type)
return Natural is
begin
if Pattern'Length = 0 then
raise Pattern_Error;
else
declare
Pattern_Length : constant Natural := Pattern'Length;
Unsearched_Last : Integer := Source'Last - (Pattern_Length - 1);
begin
while Unsearched_Last >= Source'First loop
declare
Position : constant Natural :=
Index_Element_Backward (
Source (Source'First .. Unsearched_Last),
Pattern (Pattern'First));
begin
exit when Position = 0;
if Source (Position .. Position + (Pattern_Length - 1)) =
Pattern
then
return Position;
end if;
Unsearched_Last := Position - 1;
end;
end loop;
return 0;
end;
end if;
end Index_Backward;
function Index_Non_Blank (
Source : String_Type;
From : Positive;
Going : Direction := Forward)
return Natural is
begin
case Going is
when Forward =>
return Index_Non_Blank_Forward (Source (From .. Source'Last));
when Backward =>
return Index_Non_Blank_Backward (Source (Source'First .. From));
end case;
end Index_Non_Blank;
function Index_Non_Blank (
Source : String_Type;
Going : Direction := Forward)
return Natural is
begin
case Going is
when Forward =>
return Index_Non_Blank_Forward (Source);
when Backward =>
return Index_Non_Blank_Backward (Source);
end case;
end Index_Non_Blank;
function Index_Non_Blank_Forward (
Source : String_Type;
Blank : Character_Type := Space)
return Natural is
begin
for I in Source'Range loop
if Source (I) /= Blank then
return I;
end if;
end loop;
return 0;
end Index_Non_Blank_Forward;
function Index_Non_Blank_Backward (
Source : String_Type;
Blank : Character_Type := Space)
return Natural is
begin
for I in reverse Source'Range loop
if Source (I) /= Blank then
return I;
end if;
end loop;
return 0;
end Index_Non_Blank_Backward;
function Count (
Source : String_Type;
Pattern : String_Type)
return Natural
is
Searched_Last : Natural := Source'First - 1;
Result : Natural := 0;
begin
while Searched_Last < Source'Last loop
declare
Position : constant Natural :=
Index_Forward (
Source (Searched_Last + 1 .. Source'Last),
Pattern);
begin
exit when Position = 0;
Searched_Last := Position + (Pattern'Length - 1);
end;
Result := Result + 1;
end loop;
return Result;
end Count;
function Replace_Slice (
Source : String_Type;
Low : Positive;
High : Natural;
By : String_Type)
return String_Type
is
pragma Check (Pre,
Check =>
(Low in
Source'First ..
Integer'Min (Source'Last, Integer'Last - 1) + 1
and then High in Source'First - 1 .. Source'Last)
or else raise Index_Error);
begin
return Result : String_Type (
1 ..
Source'Length + By'Length - Integer'Max (High - Low + 1, 0))
do
declare
Dummy_Last : Natural;
begin
Replace_Slice (Source, Low, High, By, Result, Dummy_Last);
end;
end return;
end Replace_Slice;
procedure Replace_Slice (
Source : in out String_Type;
Low : Positive;
High : Natural;
By : String_Type;
Drop : Truncation := Error;
Justify : Alignment := Left;
Pad : Character_Type := Space)
is
pragma Check (Pre,
Check =>
(Low in
Source'First ..
Integer'Min (Source'Last, Integer'Last - 1) + 1
and then High in Source'First - 1 .. Source'Last)
or else raise Index_Error); -- CXA4005, CXA4016
Offset : constant Integer := By'Length - Integer'Max (High - Low + 1, 0);
begin
if Offset > 0 then -- growing
declare
S : String_Type (1 .. Source'Length + Offset);
S_Last : Natural;
begin
Replace_Slice (Source, Low, High, By, S, S_Last); -- copying
Move (S (1 .. S_Last), Source, Drop, Justify, Pad);
end;
else
declare
Last : Natural := Source'Last;
begin
Replace_Slice (Source, Last, Low, High, By);
Move (Source (Source'First .. Last), Source, Drop, Justify, Pad);
end;
end if;
end Replace_Slice;
procedure Replace_Slice (
Source : String_Type;
Low : Positive;
High : Natural;
By : String_Type;
Target : out String_Type;
Target_Last : out Natural)
is
By_Length : constant Natural := By'Length;
Slice_Last : constant Natural := Integer'Max (High, Low - 1);
Target_Low : constant Positive := Low - Source'First + Target'First;
Target_Slice_Last : constant Natural := Target_Low + (By_Length - 1);
begin
Target_Last :=
Target'First
+ (Source'Length - 1)
- (Slice_Last - Low)
+ (By_Length - 1);
Target (Target'First .. Target_Low - 1) :=
Source (Source'First .. Low - 1);
Target (Target_Low .. Target_Slice_Last) := By;
if Target_Slice_Last < Target_Last then
Target (Target_Slice_Last + 1 .. Target_Last) :=
Source (Slice_Last + 1 .. Source'Last);
end if;
end Replace_Slice;
procedure Replace_Slice (
Source : in out String_Type;
Last : in out Natural;
Low : Positive;
High : Natural;
By : String_Type)
is
Slice_Last : constant Natural := Integer'Max (High, Low - 1);
New_Slice_Last : constant Natural := Low + (By'Length - 1);
New_Last : constant Natural := Last + (New_Slice_Last - Slice_Last);
begin
if New_Slice_Last < New_Last and then New_Slice_Last /= Slice_Last then
Source (New_Slice_Last + 1 .. New_Last) :=
Source (Slice_Last + 1 .. Last);
end if;
Source (Low .. New_Slice_Last) := By;
Last := New_Last;
end Replace_Slice;
function Insert (
Source : String_Type;
Before : Positive;
New_Item : String_Type)
return String_Type
is
pragma Check (Pre,
Check =>
Before in
Source'First ..
Integer'Min (Source'Last, Integer'Last - 1) + 1
or else raise Index_Error); -- CXA4005, CXA4016
begin
return Result : String_Type (1 .. Source'Length + New_Item'Length) do
declare
Dummy_Last : Natural;
begin
Insert (Source, Before, New_Item, Result, Dummy_Last);
end;
end return;
end Insert;
procedure Insert (
Source : in out String_Type;
Before : Positive;
New_Item : String_Type;
Drop : Truncation := Error)
is
pragma Check (Pre,
Check =>
Before in
Source'First ..
Integer'Min (Source'Last, Integer'Last - 1) + 1
or else raise Index_Error);
begin
if New_Item'Length > 0 then -- growing
declare
S : String_Type (1 .. Source'Length + New_Item'Length);
S_Last : Natural;
begin
Insert (Source, Before, New_Item, S, S_Last); -- copying
Move (S (1 .. S_Last), Source, Drop);
end;
end if;
end Insert;
procedure Insert (
Source : String_Type;
Before : Positive;
New_Item : String_Type;
Target : out String_Type;
Target_Last : out Natural)
is
New_Item_Length : constant Natural := New_Item'Length;
Target_Before : constant Positive :=
Before - Source'First + Target'First;
Target_Slice_Last : constant Natural :=
Target_Before + (New_Item_Length - 1);
begin
Target_Last := Target'First + (Source'Length - 1) + New_Item_Length;
Target (Target'First .. Target_Before - 1) :=
Source (Source'First .. Before - 1);
Target (Target_Before .. Target_Slice_Last) := New_Item;
Target (Target_Slice_Last + 1 .. Target_Last) :=
Source (Before .. Source'Last);
end Insert;
procedure Insert (
Source : in out String_Type;
Last : in out Natural;
Before : Positive;
New_Item : String_Type)
is
New_Slice_Last : constant Natural := Before + (New_Item'Length - 1);
New_Last : constant Natural := New_Slice_Last + 1 + Last - Before;
begin
if New_Slice_Last + 1 /= Before then
Source (New_Slice_Last + 1 .. New_Last) := Source (Before .. Last);
end if;
Source (Before .. New_Slice_Last) := New_Item;
Last := New_Last;
end Insert;
function Overwrite (
Source : String_Type;
Position : Positive;
New_Item : String_Type)
return String_Type is
begin
return Replace_Slice (
Source,
Position, -- checking Index_Error
Integer'Min (Position + (New_Item'Length - 1), Source'Last),
New_Item);
end Overwrite;
procedure Overwrite (
Source : in out String_Type;
Position : Positive;
New_Item : String_Type;
Drop : Truncation := Right) is
begin
Replace_Slice (
Source,
Position, -- checking Index_Error
Integer'Min (Position + (New_Item'Length - 1), Source'Last),
New_Item,
Drop);
end Overwrite;
function Delete (
Source : String_Type;
From : Positive;
Through : Natural)
return String_Type
is
pragma Check (Pre,
Check =>
(From <= Integer'Min (Source'Last, Integer'Last - 1) + 1
and then Through <= Source'Last)
or else raise Index_Error);
begin
return Result : String_Type (
1 .. Source'Length - Integer'Max (0, Through - From + 1))
do
declare
Dummy_Last : Natural;
begin
Delete (Source, From, Through, Result, Dummy_Last);
end;
end return;
end Delete;
procedure Delete (
Source : in out String_Type;
From : Positive;
Through : Natural;
Justify : Alignment := Left;
Pad : Character_Type := Space)
is
pragma Check (Pre,
Check =>
(From <= Integer'Min (Source'Last, Integer'Last - 1) + 1
and then Through <= Source'Last)
or else raise Index_Error);
Last : Natural := Source'Last;
begin
Delete (Source, Last, From, Through);
Move (
Source (Source'First .. Last),
Source,
Error, -- no raising because Source'Length be not growing
Justify,
Pad);
end Delete;
procedure Delete (
Source : String_Type;
From : Positive;
Through : Natural;
Target : out String_Type;
Target_Last : out Natural)
is
Source_Slice_Last : Natural;
Target_Slice_Last : Natural;
Following_Length : Natural;
begin
if From <= Through then
Target_Slice_Last := Target'First - 1 + (From - Source'First);
Target (Target'First .. Target_Slice_Last) :=
Source (Source'First .. From - 1);
Source_Slice_Last := Through;
Following_Length := Source'Last - Through;
else
Source_Slice_Last := Source'First - 1;
Target_Slice_Last := Target'First - 1;
Following_Length := Source'Length;
end if;
Target_Last := Target_Slice_Last + Following_Length;
if Target_Slice_Last < Target_Last then
Target (Target_Slice_Last + 1 .. Target_Last) :=
Source (Source_Slice_Last + 1 .. Source'Last);
end if;
end Delete;
procedure Delete (
Source : in out String_Type;
Last : in out Natural;
From : Positive;
Through : Natural) is
begin
if From <= Through then
declare
Old_Last : constant Natural := Last;
begin
Last := Last - (Through - From + 1);
Source (From .. Last) := Source (Through + 1 .. Old_Last);
end;
end if;
end Delete;
function Trim (
Source : String_Type;
Side : Trim_End;
Blank : Character_Type := Space)
return String_Type
is
First : Positive;
Last : Natural;
begin
Trim (Source, Side, Blank, First, Last);
declare
subtype T is String_Type (1 .. Last - First + 1);
begin
return T (Source (First .. Last));
end;
end Trim;
procedure Trim (
Source : in out String_Type;
Side : Trim_End;
Justify : Alignment := Left;
Pad : Character_Type := Space) is
begin
Trim (Source, Side, Space, Justify, Pad);
end Trim;
procedure Trim (
Source : in out String_Type;
Side : Trim_End;
Blank : Character_Type;
Justify : Alignment := Left;
Pad : Character_Type := Space)
is
First : Positive;
Last : Natural;
begin
Trim (Source, Side, Blank, First, Last);
Move (
Source (First .. Last),
Source,
Error, -- no raising because Source'Length be not growing
Justify,
Pad);
end Trim;
procedure Trim (
Source : String_Type;
Side : Trim_End;
Blank : Character_Type := Space;
First : out Positive;
Last : out Natural) is
begin
First := Source'First;
Last := Source'Last;
case Side is
when Left | Both =>
while First < Last and then Source (First) = Blank loop
First := First + 1;
end loop;
when Right =>
null;
end case;
case Side is
when Right | Both =>
while Last > First and then Source (Last) = Blank loop
Last := Last - 1;
end loop;
when Left =>
null;
end case;
if First = Last and then Source (First) = Blank then
First := Source'First;
Last := First - 1;
end if;
end Trim;
function Head (
Source : String_Type;
Count : Natural;
Pad : Character_Type := Space)
return String_Type is
begin
return Result : String_Type (1 .. Count) do
declare
Dummy_Last : Natural;
begin
Head (Source, Count, Pad, Result, Dummy_Last);
end;
end return;
end Head;
procedure Head (
Source : in out String_Type;
Count : Natural;
Justify : Alignment := Left;
Pad : Character_Type := Space) is
begin
if Count > Source'Length then
declare
S : String_Type (1 .. Count);
S_Last : Natural;
begin
Head (Source, Count, Pad, S, S_Last); -- copying
Move (S (1 .. S_Last), Source, Error, Justify, Pad);
end;
else
declare
Last : Natural := Source'Last;
begin
Head (Source, Last, Count, Pad);
Move (Source (Source'First .. Last), Source, Error, Justify, Pad);
end;
end if;
end Head;
procedure Head (
Source : String_Type;
Count : Natural;
Pad : Character_Type := Space;
Target : out String_Type;
Target_Last : out Natural)
is
Taking : constant Natural := Integer'Min (Source'Length, Count);
begin
Target (Target'First .. Target'First - 1 + Taking) :=
Source (Source'First .. Source'First - 1 + Taking);
Target_Last := Target'First - 1 + Count;
Fill (Target (Target'First + Taking .. Target_Last), Pad);
end Head;
procedure Head (
Source : in out String_Type;
Last : in out Natural;
Count : Natural;
Pad : Character_Type := Space)
is
New_Last : constant Natural := Source'First - 1 + Count;
begin
if Last < New_Last then
Fill (Source (Last + 1 .. New_Last), Pad);
end if;
Last := New_Last;
end Head;
function Tail (
Source : String_Type;
Count : Natural;
Pad : Character_Type := Space)
return String_Type is
begin
return Result : String_Type (1 .. Count) do
declare
Dummy_Last : Natural;
begin
Tail (Source, Count, Pad, Result, Dummy_Last);
end;
end return;
end Tail;
procedure Tail (
Source : in out String_Type;
Count : Natural;
Justify : Alignment := Left;
Pad : Character_Type := Space) is
begin
if Count /= Source'Length then
declare
S : String_Type (1 .. Count);
S_Last : Natural;
begin
Tail (Source, Count, Pad, S, S_Last); -- copying
Move (S (1 .. S_Last), Source, Error, Justify, Pad);
end;
end if;
end Tail;
procedure Tail (
Source : String_Type;
Count : Natural;
Pad : Character_Type := Space;
Target : out String_Type;
Target_Last : out Natural)
is
Taking : constant Natural := Natural'Min (Source'Length, Count);
begin
Target_Last := Target'First - 1 + Count;
Target (Target_Last - Taking + 1 .. Target_Last) :=
Source (Source'Last - Taking + 1 .. Source'Last);
Fill (Target (Target'First .. Target_Last - Taking), Pad);
end Tail;
function "*" (Left : Natural; Right : Character_Type)
return String_Type is
begin
return (1 .. Left => Right);
end "*";
function "*" (Left : Natural; Right : String_Type)
return String_Type
is
Right_Length : constant Natural := Right'Length;
begin
return Result : String_Type (1 .. Left * Right_Length) do
declare
Last : Natural := Result'First - 1;
begin
for I in 1 .. Left loop
Result (Last + 1 .. Last + Right_Length) := Right;
Last := Last + Right_Length;
end loop;
end;
end return;
end "*";
package body Generic_Maps is
function Last_Of_Index_Backward (
Source : String_Type;
Pattern : String_Type;
From : Positive)
return Natural;
function Last_Of_Index_Backward (
Source : String_Type;
Pattern : String_Type;
From : Positive)
return Natural
is
Pattern_Count : Natural := 0;
Result : Natural := From - 1;
begin
declare
Pattern_Last : Natural := Pattern'First - 1;
begin
while Pattern_Last < Pattern'Last loop
Pattern_Count := Pattern_Count + 1;
declare
Code : Wide_Wide_Character;
Is_Illegal_Sequence : Boolean; -- ignore
begin
Get (
Pattern (Pattern_Last + 1 .. Pattern'Last),
Pattern_Last,
Code,
Is_Illegal_Sequence => Is_Illegal_Sequence);
end;
end loop;
end;
while Pattern_Count > 0 and then Result < Source'Last loop
declare
Code : Wide_Wide_Character;
Is_Illegal_Sequence : Boolean; -- ignore
begin
Get (Source (Result + 1 .. Source'Last), Result, Code,
Is_Illegal_Sequence => Is_Illegal_Sequence);
end;
Pattern_Count := Pattern_Count - 1;
end loop;
return Result;
end Last_Of_Index_Backward;
type Character_Mapping_Function is access function (
From : Wide_Wide_Character;
Params : System.Address)
return Wide_Wide_Character;
pragma Favor_Top_Level (Character_Mapping_Function);
function Index_Forward (
Source : String_Type;
Pattern : String_Type;
Params : System.Address;
Mapping : not null Character_Mapping_Function)
return Natural;
function Index_Forward (
Source : String_Type;
Pattern : String_Type;
Params : System.Address;
Mapping : not null Character_Mapping_Function)
return Natural is
begin
if Pattern'Length = 0 then
raise Pattern_Error;
else
declare
Searched_Last : Natural := Source'First - 1;
begin
while Searched_Last < Source'Last loop
declare
Source_Index : constant Positive := Searched_Last + 1;
Buffer : String_Type (1 .. Expanding);
J, J_Last, Pattern_Last, Character_Length : Positive;
Code : Wide_Wide_Character;
Is_Illegal_Sequence : Boolean;
begin
Get (
Source (Source_Index .. Source'Last),
Searched_Last,
Code,
Is_Illegal_Sequence => Is_Illegal_Sequence);
if Is_Illegal_Sequence then
Character_Length := Searched_Last - Source_Index + 1;
Buffer (1 .. Character_Length) :=
Source (Source_Index .. Searched_Last);
else
Code := Mapping (Code, Params);
Put (Code, Buffer, Character_Length);
end if;
Pattern_Last := Pattern'First - 1 + Character_Length;
if Buffer (1 .. Character_Length) =
Pattern (Pattern'First .. Pattern_Last)
then
J_Last := Searched_Last;
loop
if Pattern_Last >= Pattern'Last then
return Source_Index;
end if;
J := J_Last + 1;
exit when J > Source'Last;
Get (Source (J .. Source'Last), J_Last, Code,
Is_Illegal_Sequence => Is_Illegal_Sequence);
if Is_Illegal_Sequence then
Character_Length := J_Last - J + 1;
Buffer (1 .. Character_Length) :=
Source (J .. J_Last);
else
Code := Mapping (Code, Params);
Put (Code, Buffer, Character_Length);
end if;
exit when Buffer (1 .. Character_Length) /=
Pattern (
Pattern_Last + 1 ..
Pattern_Last + Character_Length);
Pattern_Last := Pattern_Last + Character_Length;
end loop;
end if;
end;
end loop;
return 0;
end;
end if;
end Index_Forward;
function Index_Backward (
Source : String_Type;
Pattern : String_Type;
Params : System.Address;
Mapping : not null Character_Mapping_Function)
return Natural;
function Index_Backward (
Source : String_Type;
Pattern : String_Type;
Params : System.Address;
Mapping : not null Character_Mapping_Function)
return Natural is
begin
if Pattern'Length = 0 then
raise Pattern_Error;
else
declare
Unsearched_Last : Natural := Source'Last;
begin
while Unsearched_Last >= Source'First loop
declare
Source_Index : constant Positive := Unsearched_Last;
Buffer : String_Type (1 .. Expanding);
J, J_First, Pattern_First, Character_Length : Natural;
Code : Wide_Wide_Character;
Is_Illegal_Sequence : Boolean;
begin
Get_Reverse (
Source (Source'First .. Source_Index),
J_First,
Code,
Is_Illegal_Sequence => Is_Illegal_Sequence);
Unsearched_Last := J_First - 1;
if Is_Illegal_Sequence then
Character_Length := Source_Index - J_First + 1;
Buffer (1 .. Character_Length) :=
Source (J_First .. Source_Index);
else
Code := Mapping (Code, Params);
Put (Code, Buffer, Character_Length);
end if;
Pattern_First := Pattern'Last - Character_Length + 1;
if Buffer (1 .. Character_Length) =
Pattern (Pattern_First .. Pattern'Last)
then
loop
if Pattern_First <= Pattern'First then
return J_First;
end if;
J := J_First - 1;
exit when J < Source'First;
Get_Reverse (
Source (Source'First .. J),
J_First,
Code,
Is_Illegal_Sequence => Is_Illegal_Sequence);
if Is_Illegal_Sequence then
Character_Length := J - J_First + 1;
Buffer (1 .. Character_Length) :=
Source (J_First .. J);
else
Code := Mapping (Code, Params);
Put (Code, Buffer, Character_Length);
end if;
exit when Buffer (1 .. Character_Length) /=
Pattern (
Pattern_First - Character_Length ..
Pattern_First - 1);
Pattern_First := Pattern_First - Character_Length;
end loop;
end if;
end;
end loop;
return 0;
end;
end if;
end Index_Backward;
procedure Translate (
Source : String_Type;
Params : System.Address;
Mapping : not null Character_Mapping_Function;
Target : out String_Type;
Target_Last : out Natural);
procedure Translate (
Source : String_Type;
Params : System.Address;
Mapping : not null Character_Mapping_Function;
Target : out String_Type;
Target_Last : out Natural)
is
Source_Last : Natural := Source'First - 1;
begin
Target_Last := Target'First - 1;
while Source_Last < Source'Last loop
declare
Source_Index : constant Positive := Source_Last + 1;
Target_Index : constant Positive := Target_Last + 1;
Code : Wide_Wide_Character;
Is_Illegal_Sequence : Boolean;
begin
-- get single unicode character
Get (Source (Source_Index .. Source'Last), Source_Last, Code,
Is_Illegal_Sequence => Is_Illegal_Sequence);
if Is_Illegal_Sequence then
-- keep illegal sequence
Target_Last := Target_Index + (Source_Last - Source_Index);
Target (Target_Index .. Target_Last) :=
Source (Source_Index .. Source_Last);
else
-- map it
Code := Mapping (Code, Params);
-- put it
Put (
Code,
Target (Target_Index .. Target'Last),
Target_Last);
end if;
end;
end loop;
end Translate;
function By_Mapping (From : Wide_Wide_Character; Params : System.Address)
return Wide_Wide_Character;
function By_Mapping (From : Wide_Wide_Character; Params : System.Address)
return Wide_Wide_Character
is
type Character_Mapping_Access is access all Character_Mapping;
for Character_Mapping_Access'Storage_Size use 0;
package Conv is
new System.Address_To_Named_Access_Conversions (
Character_Mapping,
Character_Mapping_Access);
begin
return Value (Conv.To_Pointer (Params).all, From);
end By_Mapping;
function By_Func (From : Wide_Wide_Character; Params : System.Address)
return Wide_Wide_Character;
function By_Func (From : Wide_Wide_Character; Params : System.Address)
return Wide_Wide_Character
is
type T is access function (From : Wide_Wide_Character)
return Wide_Wide_Character;
function Cast is new Unchecked_Conversion (System.Address, T);
begin
return Cast (Params) (From);
end By_Func;
function Find_Non_Token_Last (
Source : String_Type;
Set : Character_Set;
Test : Membership)
return Positive;
function Find_Non_Token_Last (
Source : String_Type;
Set : Character_Set;
Test : Membership)
return Positive
is
Unsearched_Last : Natural := Source'Last;
begin
while Unsearched_Last >= Source'First loop
declare
Code_First : Positive;
Code : Wide_Wide_Character;
Is_Illegal_Sequence : Boolean;
begin
Get_Reverse (
Source (Source'First .. Unsearched_Last),
Code_First,
Code,
Is_Illegal_Sequence => Is_Illegal_Sequence);
if Is_Illegal_Sequence then
exit when Test = Inside; -- illegal sequence is outside
else
exit when Is_In (Code, Set) /= (Test = Inside);
end if;
Unsearched_Last := Code_First - 1;
end;
end loop;
return Unsearched_Last;
end Find_Non_Token_Last;
-- implementation
function Index (
Source : String_Type;
Pattern : String_Type;
From : Positive;
Going : Direction := Forward;
Mapping : Character_Mapping)
return Natural is
begin
case Going is
when Forward =>
return Index_Forward (
Source (From .. Source'Last),
Pattern,
Mapping);
when Backward =>
return Index_Backward (
Source (
Source'First ..
Last_Of_Index_Backward (Source, Pattern, From)),
Pattern,
Mapping);
end case;
end Index;
function Index (
Source : String_Type;
Pattern : String_Type;
Going : Direction := Forward;
Mapping : Character_Mapping)
return Natural is
begin
case Going is
when Forward =>
return Index_Forward (Source, Pattern, Mapping);
when Backward =>
return Index_Backward (Source, Pattern, Mapping);
end case;
end Index;
function Index_Forward (
Source : String_Type;
Pattern : String_Type;
Mapping : Character_Mapping)
return Natural is
begin
return Index_Forward (
Source,
Pattern,
Mapping'Address,
By_Mapping'Access);
end Index_Forward;
function Index_Backward (
Source : String_Type;
Pattern : String_Type;
Mapping : Character_Mapping)
return Natural is
begin
return Index_Backward (
Source,
Pattern,
Mapping'Address,
By_Mapping'Access);
end Index_Backward;
function Index (
Source : String_Type;
Pattern : String_Type;
From : Positive;
Going : Direction := Forward;
Mapping : not null access function (From : Wide_Wide_Character)
return Wide_Wide_Character)
return Natural is
begin
case Going is
when Forward =>
return Index_Forward (
Source (From .. Source'Last),
Pattern,
Mapping);
when Backward =>
return Index_Backward (
Source (
Source'First ..
Last_Of_Index_Backward (Source, Pattern, From)),
Pattern,
Mapping);
end case;
end Index;
function Index (
Source : String_Type;
Pattern : String_Type;
Going : Direction := Forward;
Mapping : not null access function (From : Wide_Wide_Character)
return Wide_Wide_Character)
return Natural is
begin
case Going is
when Forward =>
return Index_Forward (Source, Pattern, Mapping);
when Backward =>
return Index_Backward (Source, Pattern, Mapping);
end case;
end Index;
function Index_Forward (
Source : String_Type;
Pattern : String_Type;
Mapping : not null access function (From : Wide_Wide_Character)
return Wide_Wide_Character)
return Natural
is
type T is access function (From : Wide_Wide_Character)
return Wide_Wide_Character;
function Cast is new Unchecked_Conversion (T, System.Address);
begin
return Index_Forward (
Source,
Pattern,
Cast (Mapping),
By_Func'Access);
end Index_Forward;
function Index_Backward (
Source : String_Type;
Pattern : String_Type;
Mapping : not null access function (From : Wide_Wide_Character)
return Wide_Wide_Character)
return Natural
is
type T is access function (From : Wide_Wide_Character)
return Wide_Wide_Character;
function Cast is new Unchecked_Conversion (T, System.Address);
begin
return Index_Backward (
Source,
Pattern,
Cast (Mapping),
By_Func'Access);
end Index_Backward;
function Index_Element (
Source : String_Type;
Pattern : String_Type;
From : Positive;
Going : Direction := Forward;
Mapping : not null access function (From : Character_Type)
return Character_Type)
return Natural is
begin
case Going is
when Forward =>
return Index_Element_Forward (
Source (From .. Source'Last),
Pattern,
Mapping);
when Backward =>
return Index_Element_Backward (
Source (
Source'First ..
Natural'Min (From + (Pattern'Length - 1), Source'Last)),
Pattern,
Mapping);
end case;
end Index_Element;
function Index_Element (
Source : String_Type;
Pattern : String_Type;
Going : Direction := Forward;
Mapping : not null access function (From : Character_Type)
return Character_Type)
return Natural is
begin
case Going is
when Forward =>
return Index_Element_Forward (Source, Pattern, Mapping);
when Backward =>
return Index_Element_Backward (Source, Pattern, Mapping);
end case;
end Index_Element;
function Index_Element_Forward (
Source : String_Type;
Pattern : String_Type;
Mapping : not null access function (From : Character_Type)
return Character_Type)
return Natural is
begin
if Pattern'Length = 0 then
raise Pattern_Error;
else
for I in Source'First .. Source'Last - Pattern'Length + 1 loop
declare
J, P : Positive;
Code : Character_Type;
begin
Code := Mapping (Source (I));
if Code = Pattern (Pattern'First) then
P := Pattern'First;
J := I;
loop
if P >= Pattern'Last then
return I;
end if;
P := P + 1;
J := J + 1;
Code := Mapping (Source (J));
exit when Code /= Pattern (P);
end loop;
end if;
end;
end loop;
return 0;
end if;
end Index_Element_Forward;
function Index_Element_Backward (
Source : String_Type;
Pattern : String_Type;
Mapping : not null access function (From : Character_Type)
return Character_Type)
return Natural is
begin
if Pattern'Length = 0 then
raise Pattern_Error;
else
for I in reverse
Source'First + (Pattern'Length - 1) .. Source'Last
loop
declare
J, P : Natural;
Code : Character_Type;
begin
Code := Mapping (Source (I));
if Code = Pattern (Pattern'Last) then
P := Pattern'Last;
J := I;
loop
if P <= Pattern'First then
return J;
end if;
P := P - 1;
J := J - 1;
Code := Mapping (Source (J));
exit when Code /= Pattern (P);
end loop;
end if;
end;
end loop;
return 0;
end if;
end Index_Element_Backward;
function Index (
Source : String_Type;
Set : Character_Set;
From : Positive;
Test : Membership := Inside;
Going : Direction := Forward)
return Natural is
begin
case Going is
when Forward =>
return Index_Forward (Source (From .. Source'Last), Set, Test);
when Backward =>
return Index_Backward (
Source (Source'First .. From),
Set,
Test);
end case;
end Index;
function Index (
Source : String_Type;
Set : Character_Set;
Test : Membership := Inside;
Going : Direction := Forward)
return Natural is
begin
case Going is
when Forward =>
return Index_Forward (Source, Set, Test);
when Backward =>
return Index_Backward (Source, Set, Test);
end case;
end Index;
function Index_Forward (
Source : String_Type;
Set : Character_Set;
Test : Membership := Inside)
return Natural
is
Searched_Last : Natural := Source'First - 1;
begin
while Searched_Last < Source'Last loop
declare
Source_Index : constant Positive := Searched_Last + 1;
Code : Wide_Wide_Character;
Is_Illegal_Sequence : Boolean;
begin
Get (Source (Source_Index .. Source'Last), Searched_Last, Code,
Is_Illegal_Sequence => Is_Illegal_Sequence);
if Is_Illegal_Sequence then
if Test /= Inside then -- illegal sequence is outside
return Source_Index;
end if;
else
if Is_In (Code, Set) = (Test = Inside) then
return Source_Index;
end if;
end if;
end;
end loop;
return 0;
end Index_Forward;
function Index_Backward (
Source : String_Type;
Set : Character_Set;
Test : Membership := Inside)
return Natural
is
Unsearched_Last : Natural := Source'Last;
begin
while Unsearched_Last >= Source'First loop
declare
Code_First : Positive;
Code : Wide_Wide_Character;
Is_Illegal_Sequence : Boolean;
begin
Get_Reverse (
Source (Source'First .. Unsearched_Last),
Code_First,
Code,
Is_Illegal_Sequence => Is_Illegal_Sequence);
if Is_Illegal_Sequence then
if Test /= Inside then -- illegal sequence is outside
return Code_First;
end if;
else
if Is_In (Code, Set) = (Test = Inside) then
return Code_First;
end if;
end if;
Unsearched_Last := Code_First - 1;
end;
end loop;
return 0;
end Index_Backward;
function Count (
Source : String_Type;
Pattern : String_Type;
Mapping : Character_Mapping)
return Natural is
begin
return Count (Translate (Source, Mapping), Pattern);
end Count;
function Count (
Source : String_Type;
Pattern : String_Type;
Mapping : not null access function (From : Wide_Wide_Character)
return Wide_Wide_Character)
return Natural is
begin
return Count (Translate (Source, Mapping), Pattern);
end Count;
function Count_Element (
Source : String_Type;
Pattern : String_Type;
Mapping : not null access function (From : Character_Type)
return Character_Type)
return Natural
is
Mapped_Source : String_Type (Source'Range);
begin
Translate_Element (Source, Mapping, Mapped_Source);
return Count (Mapped_Source, Pattern);
end Count_Element;
function Count (
Source : String_Type;
Set : Character_Set)
return Natural
is
Last : Natural := Source'First - 1;
Result : Natural := 0;
begin
while Last < Source'Last loop
declare
Code : Wide_Wide_Character;
Is_Illegal_Sequence : Boolean;
begin
Get (Source (Last + 1 .. Source'Last), Last, Code,
Is_Illegal_Sequence => Is_Illegal_Sequence);
if not Is_Illegal_Sequence and then Is_In (Code, Set) then
Result := Result + 1;
end if;
end;
end loop;
return Result;
end Count;
procedure Find_Token (
Source : String_Type;
Set : Character_Set;
From : Positive;
Test : Membership;
First : out Positive;
Last : out Natural) is
begin
Find_Token (Source (From .. Source'Last), Set, Test, First, Last);
end Find_Token;
procedure Find_Token (
Source : String_Type;
Set : Character_Set;
Test : Membership;
First : out Positive;
Last : out Natural)
is
Position : constant Natural := Index_Forward (Source, Set, Test);
begin
if Position >= Source'First then
First := Position;
Last := Find_Token_Last (Source (First .. Source'Last), Set, Test);
else
First := Source'First;
Last := Source'First - 1;
end if;
end Find_Token;
function Find_Token_Last (
Source : String_Type;
Set : Character_Set;
Test : Membership)
return Natural
is
Last : Natural := Source'First - 1;
begin
while Last < Source'Last loop
declare
New_Last : Natural;
Code : Wide_Wide_Character;
Is_Illegal_Sequence : Boolean; -- ignore
begin
Get (Source (Last + 1 .. Source'Last), New_Last, Code,
Is_Illegal_Sequence => Is_Illegal_Sequence);
if Is_Illegal_Sequence then
exit when Test = Inside; -- illegal sequence is outside
else
exit when Is_In (Code, Set) /= (Test = Inside);
end if;
Last := New_Last;
end;
end loop;
return Last;
end Find_Token_Last;
function Find_Token_First (
Source : String_Type;
Set : Character_Set;
Test : Membership)
return Positive
is
Unsearched_Last : constant Natural :=
Find_Non_Token_Last (Source, Set, Test);
begin
if Unsearched_Last = Integer'Last then
raise Constraint_Error;
end if;
return Unsearched_Last + 1;
end Find_Token_First;
function Translate (
Source : String_Type;
Mapping : Character_Mapping)
return String_Type
is
Result : String_Type (1 .. Source'Length * Expanding);
Result_Last : Natural;
begin
Translate (Source, Mapping, Result, Result_Last);
return Result (1 .. Result_Last);
end Translate;
procedure Translate (
Source : in out String_Type;
Mapping : Character_Mapping;
Drop : Truncation := Error;
Justify : Alignment := Left;
Pad : Character_Type := Space)
is
S : String_Type (1 .. Source'Length * Expanding);
S_Last : Natural;
begin
Translate (Source, Mapping, S, S_Last);
Move (S (1 .. S_Last), Source, Drop, Justify, Pad);
end Translate;
procedure Translate (
Source : String_Type;
Mapping : Character_Mapping;
Target : out String_Type;
Target_Last : out Natural) is
begin
Translate (
Source,
Mapping'Address,
By_Mapping'Access,
Target,
Target_Last);
end Translate;
function Translate (
Source : String_Type;
Mapping : not null access function (From : Wide_Wide_Character)
return Wide_Wide_Character)
return String_Type
is
Result : String_Type (1 .. Source'Length * Expanding);
Result_Last : Natural;
begin
Translate (Source, Mapping, Result, Result_Last);
return Result (1 .. Result_Last);
end Translate;
procedure Translate (
Source : in out String_Type;
Mapping : not null access function (From : Wide_Wide_Character)
return Wide_Wide_Character;
Drop : Truncation := Error;
Justify : Alignment := Left;
Pad : Character_Type := Space)
is
S : String_Type (1 .. Source'Length * Expanding);
S_Last : Natural;
begin
Translate (Source, Mapping, S, S_Last);
Move (S (1 .. S_Last), Source, Drop, Justify, Pad);
end Translate;
procedure Translate (
Source : String_Type;
Mapping : not null access function (From : Wide_Wide_Character)
return Wide_Wide_Character;
Target : out String_Type;
Target_Last : out Natural)
is
type T is access function (From : Wide_Wide_Character)
return Wide_Wide_Character;
function Cast is new Unchecked_Conversion (T, System.Address);
begin
Translate (
Source,
Cast (Mapping),
By_Func'Access,
Target,
Target_Last);
end Translate;
function Translate_Element (
Source : String_Type;
Mapping : not null access function (From : Character_Type)
return Character_Type)
return String_Type is
begin
return Result : String_Type (1 .. Source'Length) do
Translate_Element (Source, Mapping, Result);
end return;
end Translate_Element;
procedure Translate_Element (
Source : in out String_Type;
Mapping : not null access function (From : Character_Type)
return Character_Type) is
begin
Translate_Element (Source, Mapping, Source);
end Translate_Element;
procedure Translate_Element (
Source : String_Type;
Mapping : not null access function (From : Character_Type)
return Character_Type;
Target : out String_Type)
is
Length : constant Natural := Source'Length;
begin
for I in 0 .. Length - 1 loop
Target (Target'First + I) := Mapping (Source (Source'First + I));
end loop;
end Translate_Element;
function Trim (
Source : String_Type;
Left : Character_Set;
Right : Character_Set)
return String_Type
is
First : Positive;
Last : Natural;
begin
Trim (Source, Left, Right, First, Last);
declare
subtype T is String_Type (1 .. Last - First + 1);
begin
return T (Source (First .. Last));
end;
end Trim;
procedure Trim (
Source : in out String_Type;
Left : Character_Set;
Right : Character_Set;
Justify : Alignment := Strings.Left;
Pad : Character_Type := Space)
is
First : Positive;
Last : Natural;
begin
Trim (Source, Left, Right, First, Last);
Move (
Source (First .. Last),
Source,
Error, -- no raising because Source'Length be not growing
Justify,
Pad);
end Trim;
procedure Trim (
Source : String_Type;
Left : Character_Set;
Right : Character_Set;
First : out Positive;
Last : out Natural)
is
Left_Last : constant Natural :=
Find_Token_Last (Source, Left, Inside);
begin
if Left_Last = Source'Last then
First := Source'First;
Last := First - 1;
else
First := Left_Last + 1;
Last :=
Find_Non_Token_Last (
Source (First .. Source'Last),
Right,
Inside);
end if;
end Trim;
end Generic_Maps;
end Ada.Strings.Generic_Functions;
|
generic
package any_Math.any_Random
is
function random_Real (Lower : in Real := Real'First;
Upper : in Real := Real'Last) return Real;
function random_Integer (Lower : in Integer := Integer'First;
Upper : in Integer := Integer'Last) return Integer;
function random_Boolean return Boolean;
end any_Math.any_Random;
|
pragma License (Unrestricted);
-- Ada 2012
with Ada.Containers.Synchronized_Queue_Interfaces;
with System;
generic
with package Queue_Interfaces is new Synchronized_Queue_Interfaces (<>);
type Queue_Priority is private;
with function Get_Priority (Element : Queue_Interfaces.Element_Type)
return Queue_Priority is <>;
with function Before (Left, Right : Queue_Priority) return Boolean is <>;
Default_Ceiling : System.Any_Priority := System.Priority'Last;
package Ada.Containers.Unbounded_Priority_Queues is
pragma Preelaborate;
package Implementation is
-- not specified by the language
type Node;
type Node_Access is access Node;
type Node is record
Element : Queue_Interfaces.Element_Type;
Next : Node_Access;
end record;
end Implementation;
protected type Queue (Ceiling : System.Any_Priority := Default_Ceiling)
with Priority => Ceiling is
new Queue_Interfaces.Queue
with
overriding entry Enqueue (New_Item : Queue_Interfaces.Element_Type);
overriding entry Dequeue (Element : out Queue_Interfaces.Element_Type);
procedure Dequeue_Only_High_Priority (
At_Least : Queue_Priority;
Element : in out Queue_Interfaces.Element_Type;
Success : out Boolean);
overriding function Current_Use return Count_Type;
overriding function Peak_Use return Count_Type;
private
First : Implementation.Node_Access := null;
Last : Implementation.Node_Access := null;
Current_Length : Count_Type := 0;
Peak_Length : Count_Type := 0;
end Queue;
private
end Ada.Containers.Unbounded_Priority_Queues;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . A T O M I C _ P R I M I T I V E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2012, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains both atomic primitives defined from gcc built-in
-- functions and operations used by the compiler to generate the lock-free
-- implementation of protected objects.
package System.Atomic_Primitives is
pragma Preelaborate;
type uint is mod 2 ** Long_Integer'Size;
type uint8 is mod 2**8
with Size => 8;
type uint16 is mod 2**16
with Size => 16;
type uint32 is mod 2**32
with Size => 32;
type uint64 is mod 2**64
with Size => 64;
Relaxed : constant := 0;
Consume : constant := 1;
Acquire : constant := 2;
Release : constant := 3;
Acq_Rel : constant := 4;
Seq_Cst : constant := 5;
Last : constant := 6;
subtype Mem_Model is Integer range Relaxed .. Last;
------------------------------------
-- GCC built-in atomic primitives --
------------------------------------
function Atomic_Load_8
(Ptr : Address;
Model : Mem_Model := Seq_Cst) return uint8;
pragma Import (Intrinsic, Atomic_Load_8, "__atomic_load_1");
function Atomic_Load_16
(Ptr : Address;
Model : Mem_Model := Seq_Cst) return uint16;
pragma Import (Intrinsic, Atomic_Load_16, "__atomic_load_2");
function Atomic_Load_32
(Ptr : Address;
Model : Mem_Model := Seq_Cst) return uint32;
pragma Import (Intrinsic, Atomic_Load_32, "__atomic_load_4");
function Atomic_Load_64
(Ptr : Address;
Model : Mem_Model := Seq_Cst) return uint64;
pragma Import (Intrinsic, Atomic_Load_64, "__atomic_load_8");
function Sync_Compare_And_Swap_8
(Ptr : Address;
Expected : uint8;
Desired : uint8) return uint8;
pragma Import (Intrinsic,
Sync_Compare_And_Swap_8,
"__sync_val_compare_and_swap_1");
-- ??? Should use __atomic_compare_exchange_1 (doesn't work yet):
-- function Sync_Compare_And_Swap_8
-- (Ptr : Address;
-- Expected : Address;
-- Desired : uint8;
-- Weak : Boolean := False;
-- Success_Model : Mem_Model := Seq_Cst;
-- Failure_Model : Mem_Model := Seq_Cst) return Boolean;
-- pragma Import (Intrinsic,
-- Sync_Compare_And_Swap_8,
-- "__atomic_compare_exchange_1");
function Sync_Compare_And_Swap_16
(Ptr : Address;
Expected : uint16;
Desired : uint16) return uint16;
pragma Import (Intrinsic,
Sync_Compare_And_Swap_16,
"__sync_val_compare_and_swap_2");
function Sync_Compare_And_Swap_32
(Ptr : Address;
Expected : uint32;
Desired : uint32) return uint32;
pragma Import (Intrinsic,
Sync_Compare_And_Swap_32,
"__sync_val_compare_and_swap_4");
function Sync_Compare_And_Swap_64
(Ptr : Address;
Expected : uint64;
Desired : uint64) return uint64;
pragma Import (Intrinsic,
Sync_Compare_And_Swap_64,
"__sync_val_compare_and_swap_8");
--------------------------
-- Lock-free operations --
--------------------------
-- The lock-free implementation uses two atomic instructions for the
-- expansion of protected operations:
-- * Lock_Free_Read_N atomically loads the value of the protected component
-- accessed by the current protected operation.
-- * Lock_Free_Try_Write_N tries to write the Desired value into Ptr only
-- if Expected and Desired mismatch.
function Lock_Free_Read_8 (Ptr : Address) return uint8;
function Lock_Free_Read_16 (Ptr : Address) return uint16;
function Lock_Free_Read_32 (Ptr : Address) return uint32;
function Lock_Free_Read_64 (Ptr : Address) return uint64;
function Lock_Free_Try_Write_8
(Ptr : Address;
Expected : in out uint8;
Desired : uint8) return Boolean;
function Lock_Free_Try_Write_16
(Ptr : Address;
Expected : in out uint16;
Desired : uint16) return Boolean;
function Lock_Free_Try_Write_32
(Ptr : Address;
Expected : in out uint32;
Desired : uint32) return Boolean;
function Lock_Free_Try_Write_64
(Ptr : Address;
Expected : in out uint64;
Desired : uint64) return Boolean;
pragma Inline (Lock_Free_Read_8);
pragma Inline (Lock_Free_Read_16);
pragma Inline (Lock_Free_Read_32);
pragma Inline (Lock_Free_Read_64);
pragma Inline (Lock_Free_Try_Write_8);
pragma Inline (Lock_Free_Try_Write_16);
pragma Inline (Lock_Free_Try_Write_32);
pragma Inline (Lock_Free_Try_Write_64);
end System.Atomic_Primitives;
|
-- MIT License
-- Copyright (c) 2021 Stephen Merrony
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
with Ada.Text_IO; use Ada.Text_IO;
with Debug_Logs; use Debug_Logs;
with Resolver; use Resolver;
package body Processor.Eclipse_Mem_Ref_P is
procedure Do_Eclipse_Mem_Ref (I : in Decoded_Instr_T; CPU : in out CPU_T) is
Addr : Phys_Addr_T;
Ring : Phys_Addr_T := CPU.PC and 16#7000_0000#;
Bit_Num : Natural;
Word : Word_T;
begin
case I.Instruction is
when I_BLM => -- AC0 - unused, AC1 - no. wds to move, AC2 - src, AC3 - dest
declare
Num_Wds : Word_T := DG_Types.Lower_Word(CPU.AC(1));
Src, Dest : Phys_Addr_T;
begin
if (Num_Wds = 0) or (Num_Wds > 32768) then
Loggers.Debug_Print (Debug_Log, "WARNING: BLM called with AC1 out of bounds, No-Op");
else
Src := Ring or Phys_Addr_T(DG_Types.Lower_Word(CPU.AC(2)));
Dest := Ring or Phys_Addr_T(DG_Types.Lower_Word(CPU.AC(3)));
if CPU.Debug_Logging then
Loggers.Debug_Print (Debug_Log, "BLM moving" & Num_Wds'Image & " words from" &
Src'Image & " to" & Dest'Image);
end if;
while Num_Wds /= 0 loop
RAM.Write_Word (Dest, RAM.Read_Word(Src));
Num_Wds := Num_Wds - 1;
Src := Src + 1;
Dest := Dest + 1;
end loop;
CPU.AC(1) := 0;
CPU.AC(2) := Dword_T(Src); -- TODO verify this
CPU.AC(3) := Dword_T(Dest);
end if;
end;
when I_BTO | I_BTZ =>
Resolve_Eclipse_Bit_Addr (CPU, I.Acd, I.Acs, Addr, Bit_Num);
Addr := Addr or Ring;
Word := RAM.Read_Word (Addr);
if I.Instruction = I_BTO then
Set_W_Bit (Word, Bit_Num);
else
Clear_W_Bit (Word, Bit_Num);
end if;
RAM.Write_Word (Addr, Word);
when I_CMP =>
declare
Byte_1, Byte_2 : Byte_T;
Res : Dword_T := 0;
Str_1_BP, Str_2_BP : Word_T;
Str_1_Len : Integer_16 := Word_To_Integer_16(DG_Types.Lower_Word(CPU.AC(1)));
Str_2_Len : Integer_16 := Word_To_Integer_16(DG_Types.Lower_Word(CPU.AC(0)));
begin
if (Str_1_Len = 0) and (Str_2_Len = 0) then
CPU.AC(1) := 0;
else
Str_1_BP := DG_Types.Lower_Word(CPU.AC(3));
Str_2_BP := DG_Types.Lower_Word(CPU.AC(2));
loop
if Str_1_Len = 0 then
Byte_1 := 32;
else
Byte_1 := RAM.Read_Byte_Eclipse_BA(Ring,Str_1_BP);
end if;
if Str_2_Len = 0 then
Byte_2 := 32;
else
Byte_2 := RAM.Read_Byte_Eclipse_BA(Ring,Str_2_BP);
end if;
if Byte_1 > Byte_2 then
Res := 1;
exit;
end if;
if Byte_1 < Byte_2 then
Res := 16#ffff_ffff#;
exit;
end if;
if Str_1_Len > 0 then
Str_1_BP := Str_1_BP + 1;
Str_1_Len := Str_1_Len - 1;
end if;
if Str_1_Len < 0 then
Str_1_BP := Str_1_BP - 1;
Str_1_Len := Str_1_Len + 1;
end if;
if Str_2_Len > 0 then
Str_2_BP := Str_2_BP + 1;
Str_2_Len := Str_2_Len - 1;
end if;
if Str_2_Len < 0 then
Str_2_BP := Str_2_BP - 1;
Str_2_Len := Str_2_Len + 1;
end if;
exit when (Str_1_Len = 0) and (Str_2_Len = 0);
end loop;
CPU.AC(0) := Dword_T(Str_2_Len);
CPU.AC(1) := Res;
CPU.AC(2) := Dword_T(Str_2_BP);
CPU.AC(3) := Dword_T(Str_1_BP);
end if;
end;
when I_CMV =>
declare
Dest_Ascend, Src_Ascend : Boolean;
Dest_Cnt, Src_Cnt : Integer_16;
begin
Dest_Cnt := Word_To_Integer_16(DG_Types.Lower_Word(CPU.AC(0)));
if Dest_Cnt = 0 then
Loggers.Debug_Print (Debug_Log, "WARNING: CMV called with AC0 = 0, not moving anything");
CPU.Carry := false;
else
Dest_Ascend := Dest_Cnt > 0;
Src_Cnt := Word_To_Integer_16(DG_Types.Lower_Word(CPU.AC(1)));
Src_Ascend := Src_Cnt > 0;
CPU.Carry := (Abs Src_Cnt) > (Abs Dest_Cnt);
-- move Src_Cnt bytes
loop
RAM.Write_Byte_Eclipse_BA(Ring, DG_Types.Lower_Word(CPU.AC(2)),
RAM.Read_Byte_Eclipse_BA(Ring, DG_Types.Lower_Word(CPU.AC(3))));
if Src_Ascend then
CPU.AC(3) := CPU.AC(3) + 1;
Src_Cnt := Src_Cnt - 1;
else
CPU.AC(3) := CPU.AC(3) - 1;
Src_Cnt := Src_Cnt + 1;
end if;
if Dest_Ascend then
CPU.AC(2) := CPU.AC(2) + 1;
Dest_Cnt := Dest_Cnt - 1;
else
CPU.AC(2) := CPU.AC(2) - 1;
Dest_Cnt := Dest_Cnt + 1;
end if;
exit when (Src_Cnt = 0) or (Dest_Cnt = 0);
end loop;
-- now fill any excess bytes with ASCII spaces
while Dest_Cnt /= 0 loop
RAM.Write_Byte_Eclipse_BA(Ring, DG_Types.Lower_Word(CPU.AC(2)), 32);
if Dest_Ascend then
CPU.AC(2) := CPU.AC(2) + 1;
Dest_Cnt := Dest_Cnt - 1;
else
CPU.AC(2) := CPU.AC(2) - 1;
Dest_Cnt := Dest_Cnt + 1;
end if;
end loop;
CPU.AC(0) := 0;
CPU.AC(1) := Dword_T(Src_Cnt);
end if;
end;
when I_ELDA =>
Addr := (Resolve_15bit_Disp (CPU, I.Ind, I.Mode, I.Disp_15, I.Disp_Offset) and 16#7fff#) or Ring;
CPU.AC(I.Ac) := Dword_T(RAM.Read_Word(Addr));
when I_ELEF =>
Addr := (Resolve_15bit_Disp (CPU, I.Ind, I.Mode, I.Disp_15, I.Disp_Offset) and 16#7fff#) or Ring;
CPU.AC(I.Ac) := Dword_T(Addr);
when I_ESTA =>
Addr := (Resolve_15bit_Disp (CPU, I.Ind, I.Mode, I.Disp_15, I.Disp_Offset) and 16#7fff#) or Ring;
RAM.Write_Word (Addr, DG_Types.Lower_Word(CPU.AC(I.Ac)));
when I_LDB =>
CPU.AC(I.Acd) := Dword_T (RAM.Read_Byte_Eclipse_BA (Ring, DG_Types.Lower_Word(CPU.AC(I.Acs))));
when I_LEF =>
Addr := Resolve_8bit_Disp (CPU, I.Ind, I.Mode, I.Disp_15);
Addr := (Addr and 16#0000_7fff#) or Ring;
CPU.AC(I.Ac) := Dword_T(Addr);
when I_STB =>
declare
Low_Byte : Boolean := Test_DW_Bit(CPU.AC(I.Acs), 31);
begin
Addr := Shift_Right (Phys_Addr_T(DG_Types.Lower_Word(CPU.AC(I.Acs))), 1);
Addr := (Addr and 16#7fff#) or Ring;
RAM.Write_Byte(Addr, Low_Byte, Byte_T(CPU.AC(I.Acd)));
end;
when others =>
Put_Line ("ERROR: ECLIPSE_MEMREF instruction " & To_String(I.Mnemonic) &
" not yet implemented");
raise Execution_Failure with "ERROR: ECLIPSE_MEMREF instruction " & To_String(I.Mnemonic) &
" not yet implemented";
end case;
CPU.PC := CPU.PC + Phys_Addr_T(I.Instr_Len);
end Do_Eclipse_Mem_Ref;
end Processor.Eclipse_Mem_Ref_P; |
-----------------------------------------------------------------------
-- atlas-reviews-modules -- Module reviews
-- Copyright (C) 2014 Stephane.Carrez
-- Written by Stephane.Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Calendar;
with AWA.Modules.Beans;
with AWA.Modules.Get;
with Util.Log.Loggers;
with Atlas.Reviews.Beans;
with ADO.Sessions;
with AWA.Services.Contexts;
with AWA.Permissions;
package body Atlas.Reviews.Modules is
package ASC renames AWA.Services.Contexts;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Atlas.Reviews.Module");
package Register is new AWA.Modules.Beans (Module => Review_Module,
Module_Access => Review_Module_Access);
-- ------------------------------
-- Initialize the reviews module.
-- ------------------------------
overriding
procedure Initialize (Plugin : in out Review_Module;
App : in AWA.Modules.Application_Access;
Props : in ASF.Applications.Config) is
begin
Log.Info ("Initializing the reviews module");
-- Register here any bean class, servlet, filter.
Register.Register (Plugin => Plugin,
Name => "Atlas.Reviews.Beans.Reviews_Bean",
Handler => Atlas.Reviews.Beans.Create_Review_Bean'Access);
Register.Register (Plugin => Plugin,
Name => "Atlas.Reviews.Beans.Review_List_Bean",
Handler => Atlas.Reviews.Beans.Create_Review_List_Bean'Access);
AWA.Modules.Module (Plugin).Initialize (App, Props);
-- Add here the creation of manager instances.
end Initialize;
-- ------------------------------
-- Get the reviews module.
-- ------------------------------
function Get_Review_Module return Review_Module_Access is
function Get is new AWA.Modules.Get (Review_Module, Review_Module_Access, NAME);
begin
return Get;
end Get_Review_Module;
-- ------------------------------
-- Save the review.
-- ------------------------------
procedure Save (Model : in Review_Module;
Entity : in out Atlas.Reviews.Models.Review_Ref'Class) is
pragma Unreferenced (Model);
Ctx : constant ASC.Service_Context_Access := ASC.Current;
DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
begin
Ctx.Start;
if not Entity.Is_Inserted then
AWA.Permissions.Check (Permission => ACL_Create_Reviews.Permission);
Entity.Set_Reviewer (Ctx.Get_User);
Entity.Set_Create_Date (Ada.Calendar.Clock);
else
AWA.Permissions.Check (Permission => ACL_Update_Reviews.Permission,
Entity => Entity);
end if;
Entity.Save (DB);
Ctx.Commit;
end Save;
-- ------------------------------
-- Delete the review.
-- ------------------------------
procedure Delete (Model : in Review_Module;
Entity : in out Atlas.Reviews.Models.Review_Ref'Class) is
pragma Unreferenced (Model);
Ctx : constant ASC.Service_Context_Access := ASC.Current;
DB : ADO.Sessions.Master_Session := ASC.Get_Master_Session (Ctx);
begin
AWA.Permissions.Check (Permission => ACL_Delete_Reviews.Permission,
Entity => Entity);
Ctx.Start;
Entity.Delete (DB);
Ctx.Commit;
end Delete;
end Atlas.Reviews.Modules;
|
with
lace.Observer,
lace.Subject,
lace.Response,
lace.event.Logger,
ada.Tags;
package lace.Event.utility
--
-- Provides convenience subprograms for working with events.
--
is
-- Event Kinds
--
function Name_of (Kind : in event.Kind) return String;
function to_Kind (From : in ada.Tags.Tag) return event.Kind;
function "+" (From : in ada.Tags.Tag) return event.Kind
renames to_Kind;
-- Events
--
function Name_of (the_Event : in Event.item'Class) return String;
function Kind_of (the_Event : in Event.item'Class) return Event.Kind;
-- Connections
--
procedure connect (the_Observer : in Observer.view;
to_Subject : in Subject .view;
with_Response : in Response.view;
to_Event_Kind : in event.Kind);
procedure disconnect (the_Observer : in Observer.view;
from_Subject : in Subject .view;
for_Response : in Response.view;
to_Event_Kind : in event.Kind;
subject_Name : in String);
-- Logging
--
procedure use_text_Logger (log_Filename : in String);
--
-- Requests activation of the default text file logger.
function Logger return access lace.event.Logger.item'Class;
--
-- Returns the Logger currently in use.
-- Returns null, if no Logger is in use.
-- Termination
--
procedure close;
--
-- Ensures any registered event logger is destroyed.
end lace.Event.utility;
|
with Ada.Text_IO;
use Ada.Text_IO;
with Maze;
procedure Adamazing is
Size : Integer;
begin
Put_Line("Enter Difficulty (1 to 25), you may have to zoom out.");
-- Making the size an odd number improves impearance.
Size := Integer'Value(Get_Line) * 10 + 1;
Maze (Size);
Put_Line("");
end Adamazing;
|
with PortAudioAda.Thin; use PortAudioAda.Thin;
generic
type Frame;
type User_Data is private;
with function Pre_Processing (frameIn : Frame;
data : User_Data) return Frame;
with function Post_Processing (frameIn : Frame;
data : User_Data) return Frame;
package Generic_Callback is
type Pre_Callback is access function (frameIn : Frame;
data : User_Data) return Frame;
type Post_Callback is access function (frameIn : Frame;
data : User_Data) return Frame;
function PAA_Open_Stream (stream : access PaStream_Ptr;
inputParameters : access PaStreamParameters;
outputParameters : access PaStreamParameters;
sampleRate : Long_Float;
framesPerBuffer : Long_Integer;
streamFlags : PaStreamFlags;
pre : Pre_Callback;
post : Post_Callback;
userData : User_Data)
return PaError;
end Generic_Callback;
|
-- { dg-do compile }
with Discr34_Pkg; use Discr34_Pkg;
procedure Discr34 is
Object : Rec := F;
begin
null;
end;
|
with
AdaM.Factory;
package body AdaM.Parameter
is
-- Storage Pool
--
record_Version : constant := 1;
max_Parameters : constant := 5_000;
package Pool is new AdaM.Factory.Pools (".adam-store",
"parameters",
max_Parameters,
record_Version,
Parameter.item,
Parameter.view);
-- Vector
--
function to_Source (the_Parameters : in Vector) return text_Vectors.Vector
is
use ada.Containers;
the_Source : text_Vectors.Vector;
begin
for i in 1 .. the_Parameters.Length
loop
the_Source.append (the_Parameters.Element (Integer (i)).to_Source);
if i /= the_Parameters.Length
then
the_Source.append (+";");
end if;
end loop;
return the_Source;
end to_Source;
-- Forge
--
procedure define (Self : in out Item; Name : in String)
is
begin
Self.Name := +Name;
end define;
procedure destruct (Self : in out Item)
is
begin
null;
end destruct;
function new_Parameter (Name : in String := "") return View
is
new_View : constant Parameter.view := Pool.new_Item;
begin
define (Parameter.item (new_View.all), Name);
return new_View;
end new_Parameter;
procedure free (Self : in out Parameter.view)
is
begin
destruct (Parameter.item (Self.all));
Pool.free (Self);
end free;
-- Attributes
--
overriding function Id (Self : access Item) return AdaM.Id
is
begin
return Pool.to_Id (Self);
end Id;
function Name (Self : in Item) return String
is
begin
return +Self.Name;
end Name;
procedure Name_is (Self : in out Item; Now : in String)
is
begin
Self.Name := +Now;
end Name_is;
function Mode (Self : in Item) return a_Mode
is
begin
return Self.Mode;
end Mode;
procedure Mode_is (Self : in out Item; Now : in a_Mode)
is
begin
Self.Mode := Now;
end Mode_is;
function my_Type (Self : access Item) return access a_Type.view -- access Text
is
begin
return Self.my_Type'Access;
end my_Type;
function my_Type (Self : in Item) return a_Type.view
is
begin
return Self.my_Type;
end my_Type;
procedure Type_is (Self : in out Item; Now : in a_Type.view)
is
begin
Self.my_Type := Now;
end Type_is;
function Default (Self : in Item) return String
is
begin
return +Self.Default;
end Default;
procedure Default_is (Self : in out Item; Now : in String)
is
begin
Self.Default := +Now;
end Default_is;
function to_Source (Self : in Item) return text_Vectors.Vector
is
the_Source : text_Vectors.Vector;
function mode_Text return String
is
use Parameter;
begin
if Self.Mode = in_Mode then return "in";
elsif Self.Mode = out_Mode then return "out";
elsif Self.Mode = in_out_Mode then return "in out";
elsif Self.Mode = access_Mode then return "access";
end if;
raise Program_Error;
end mode_Text;
begin
the_Source.append ((+Self.Name) & " : " & mode_Text & " " & (+(+Self.my_Type.Name)));
if Self.Default /= ""
then
the_Source.append (+" := " & (+Self.Default));
end if;
return the_Source;
end to_Source;
-- Streams
--
procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : in View)
renames Pool.View_write;
procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : out View)
renames Pool.View_read;
end AdaM.Parameter;
|
-----------------------------------------------------------------------
-- awa-events-dispatchers -- AWA Event Dispatchers
-- Copyright (C) 2012 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Finalization;
with EL.Expressions;
with EL.Beans;
with AWA.Events.Queues;
limited with AWA.Events.Services;
package AWA.Events.Dispatchers is
MAX_DISPATCHER_COUNT : constant Positive := 100;
type Dispatcher is new Ada.Finalization.Limited_Controlled with private;
type Dispatcher_Access is access all Dispatcher'Class;
type Dispatcher_Access_Array is array (1 .. MAX_DISPATCHER_COUNT) of Dispatcher_Access;
-- Start the dispatcher.
procedure Start (Manager : in out Dispatcher) is null;
-- Stop the dispatcher.
procedure Stop (Manager : in out Dispatcher) is null;
-- Add the queue to the dispatcher.
procedure Add_Queue (Manager : in out Dispatcher;
Queue : in AWA.Events.Queues.Queue_Ref;
Added : out Boolean);
-- Dispatch the events from the queue.
-- Increment the <b>Count</b> parameter to indicate the number of events that were dispatched.
procedure Dispatch (Manager : in Dispatcher;
Queue : in AWA.Events.Queues.Queue_Ref;
Count : in out Natural);
-- Dispatch the event identified by <b>Event</b>.
-- The event actions which are associated with the event are executed synchronously.
procedure Dispatch (Manager : in Dispatcher;
Event : in Module_Event'Class);
-- Add an action invoked when an event is dispatched through this dispatcher.
-- When the event queue dispatches the event, the Ada bean identified by the method action
-- represented by <b>Action</b> is created and initialized by evaluating and setting the
-- parameters defined in <b>Params</b>. The action method is then invoked.
procedure Add_Action (Manager : in out Dispatcher;
Action : in EL.Expressions.Method_Expression;
Params : in EL.Beans.Param_Vectors.Vector);
private
type Event_Manager_Access is access all AWA.Events.Services.Event_Manager'Class;
type Dispatcher is new Ada.Finalization.Limited_Controlled with record
Manager : Event_Manager_Access := null;
end record;
end AWA.Events.Dispatchers;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2020 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.Calendar;
with Ada.Characters.Latin_1;
with Ada.Strings.Fixed;
with Ada.Strings.Unbounded;
private with Interfaces.C.Strings;
package WeeChat is
pragma Elaborate_Body;
type Plugin_Ptr is private;
type Plugin_Callback is not null access procedure (Plugin : Plugin_Ptr);
type Callback_Result is (Error, OK, Eat);
function Plugin_Init
(Object : Plugin_Ptr;
On_Initialize : Plugin_Callback) return Callback_Result;
function Plugin_End
(Object : Plugin_Ptr;
On_Finalize : Plugin_Callback) return Callback_Result;
package L1 renames Ada.Characters.Latin_1;
subtype C_String is String
with Dynamic_Predicate => C_String (C_String'Last) = L1.NUL;
Plugin_API_Version : constant String := "20200301-03" & L1.NUL;
-- Generated for version 2.8, the version packaged in Ubuntu 20.04 LTS
-----------------------------------------------------------------------------
package SF renames Ada.Strings.Fixed;
package SU renames Ada.Strings.Unbounded;
function "+" (Value : String) return SU.Unbounded_String renames SU.To_Unbounded_String;
function "+" (Value : SU.Unbounded_String) return String renames SU.To_String;
type String_List is array (Positive range <>) of SU.Unbounded_String;
function Split
(Value : String;
Separator : String := " ";
Maximum : Natural := 0) return String_List;
function Join (List : String_List; Separator : String) return String;
-----------------------------------------------------------------------------
type Void_Ptr is new System.Address;
Null_Void : constant Void_Ptr;
type Data is record
Plugin : Plugin_Ptr;
end record;
type Data_Ptr is access all Data;
type Buffer_Ptr is private;
Any_Buffer : constant Buffer_Ptr;
type Completion_Ptr is private;
type Hashtable_Ptr is private;
type Timer is private;
No_Timer : constant Timer;
-----------------------------------------------------------------------------
type Prefix_Kind is (Error, Network, Action, Join, Quit);
type Data_Kind is (String_Type, Int_Type, Pointer_Type);
type Completion_Position is (Any_Position, Beginning_Of_List, End_Of_List);
type Line_Buffer_Kind is (Formatted, Free);
type Notify_Level is (None, Low, Message, Private_Message, Highlight);
type Line_Data (Kind : Line_Buffer_Kind) is record
Buffer : SU.Unbounded_String;
Name : SU.Unbounded_String;
Message : SU.Unbounded_String;
Displayed : Boolean;
case Kind is
when Formatted =>
Date : Ada.Calendar.Time;
Date_Printed : Ada.Calendar.Time;
Date_Display : SU.Unbounded_String;
Tags : SU.Unbounded_String;
Level : Notify_Level;
Highlight : Boolean;
Prefix : SU.Unbounded_String;
when Free =>
Line_Number : Natural;
end case;
end record;
-----------------------------------------------------------------------------
type On_Modifier_Callback is not null access function
(Plugin : Plugin_Ptr;
Modifier : String;
Modifier_Data : String;
Text : String) return String;
type On_Command_Callback is not null access function
(Plugin : Plugin_Ptr;
Buffer : Buffer_Ptr;
Arguments : String_List) return Callback_Result;
type On_Command_Run_Callback is not null access function
(Plugin : Plugin_Ptr;
Buffer : Buffer_Ptr;
Command : String) return Callback_Result;
type On_Completion_Callback is not null access function
(Plugin : Plugin_Ptr;
Item : String;
Buffer : Buffer_Ptr;
Completion : Completion_Ptr) return Callback_Result;
type On_Line_Callback is not null access procedure
(Plugin : Plugin_Ptr;
Line : in out Line_Data);
type On_Print_Callback is not null access function
(Plugin : Plugin_Ptr;
Buffer : Buffer_Ptr;
Date : Ada.Calendar.Time;
Tags : String_List;
Displayed : Boolean;
Highlight : Boolean;
Prefix : String;
Message : String) return Callback_Result;
type On_Signal_Callback is not null access function
(Plugin : Plugin_Ptr;
Signal : String;
Kind : Data_Kind;
Signal_Data : Void_Ptr) return Callback_Result;
type On_Timer_Callback is not null access function
(Plugin : Plugin_Ptr;
Remaining_Calls : Integer) return Callback_Result;
-----------------------------------------------------------------------------
function Name (Plugin : Plugin_Ptr) return String;
procedure Print (Plugin : Plugin_Ptr; Prefix : Prefix_Kind; Message : String);
-- Print a message with the given prefix to the screen
procedure Print (Plugin : Plugin_Ptr; Prefix : String; Message : String)
with Pre => Prefix'Length > 0;
-- Print a message with an arbitrary prefix to the screen
procedure Print (Plugin : Plugin_Ptr; Message : String);
-- Print a message without a prefix to the screen
procedure Log (Plugin : Plugin_Ptr; Message : String);
-- Log a message to ~/.weechat/weechat.log
-----------------------------------------------------------------------------
procedure Add_Command
(Plugin : Plugin_Ptr;
Command : String;
Description : String;
Arguments : String;
Arguments_Description : String;
Completion : String;
Callback : On_Command_Callback);
-- Add a new command and register a callback called when the command
-- is run
--
-- The callback can be given a priority by prefixing the name
-- with `priority|`.
procedure On_Command_Run
(Plugin : Plugin_Ptr;
Command : String;
Callback : On_Command_Run_Callback);
-- Register a callback called when the given command is run
--
-- Wildcard `*` can be used in the command.
--
-- The callback can be given a priority by prefixing the name
-- with `priority|`.
procedure On_Completion
(Plugin : Plugin_Ptr;
Item : String;
Description : String;
Callback : On_Completion_Callback);
-- Register a callback for a completion
--
-- The item should be added to weechat.completion.default_template,
-- otherwise nothing will happen.
--
-- In the callback, the procedure Add_Completion_Word must be called
-- for each word that must be added to the completion.
--
-- The callback can be given a priority by prefixing the name
-- with `priority|`.
procedure Add_Completion_Word
(Plugin : Plugin_Ptr;
Completion : Completion_Ptr;
Word : String;
Is_Nick : Boolean := False;
Where : Completion_Position := Any_Position);
-- Add a word to a completion
procedure On_Modifier
(Plugin : Plugin_Ptr;
Modifier : String;
Callback : On_Modifier_Callback);
-- Register a callback called to modify certain messages
--
-- The callback can be given a priority by prefixing the name
-- with `priority|`.
procedure On_Line
(Plugin : Plugin_Ptr;
Buffer_Type : Line_Buffer_Kind;
Buffer_Name : String;
Tags : String;
Callback : On_Line_Callback);
-- Register a callback for when a line is to be printed in a buffer
--
-- Buffer_Name is a comma-separated list of masks, or empty , or `*`.
--
-- Wildcard `*` is allowed in tags. Tags must be separated by a
-- a `,` ("or" operation) and can be combined with a `+` ("and"
-- operation).
procedure On_Print
(Plugin : Plugin_Ptr;
Buffer : Buffer_Ptr;
Tags : String;
Message : String;
Strip_Colors : Boolean;
Callback : On_Print_Callback);
-- Register a callback for when message is printed to the screen
--
-- Wildcard `*` is allowed in tags. Tags must be separated by a
-- a `,` ("or" operation) and can be combined with a `+` ("and"
-- operation).
procedure On_Signal
(Plugin : Plugin_Ptr;
Signal : String;
Callback : On_Signal_Callback);
-- Register a callback for when a signal is sent
--
-- Wildcard `*` is allowed in name.
--
-- The callback can be given a priority by prefixing the name
-- with `priority|`.
function Run_Command
(Plugin : Plugin_Ptr;
Buffer : Buffer_Ptr;
Message : String) return Boolean
with Pre => Message'Length > 0;
-- Execute a command and return true if successful, false otherwise
procedure Run_Command
(Plugin : Plugin_Ptr;
Buffer : Buffer_Ptr;
Message : String)
with Pre => Message'Length > 0;
-- Execute a command and raise Program_Error if unsuccessful
procedure Send_Message
(Plugin : Plugin_Ptr;
Server, Recipient, Message : String);
-- Send an IRC message to a user or channel
--
-- For example, to send a message to #ada on freenode:
--
-- Send_Message ("freenode", "#ada", "This message was sent by Ada");
function Get_Nick (Host : String) return String;
procedure Send_Signal
(Plugin : Plugin_Ptr;
Signal : String;
Kind : Data_Kind;
Signal_Data : Void_Ptr);
-- Send a signal
function Set_Timer
(Plugin : Plugin_Ptr;
Interval : Duration;
Align_Second : Natural;
Max_Calls : Natural;
Callback : On_Timer_Callback) return Timer;
procedure Cancel_Timer (Object : Timer)
with Pre => Object /= No_Timer;
procedure Set_Title (Plugin : Plugin_Ptr; Title : String);
function Get_Info (Plugin : Plugin_Ptr; Name, Arguments : String) return String;
function Get_Info (Plugin : Plugin_Ptr; Name : String) return String;
-----------------------------------------------------------------------------
type Option_Set is (Error, Same_Value, Changed);
type Option_Unset is (Error, No_Reset, Reset, Removed);
type Option_Kind is (Boolean_Type, Integer_Type, String_Type, Color_Type);
type Config_Option is private;
function Reset (Object : Config_Option) return Option_Set;
-- Reset the option to its default value
function Unset (Object : Config_Option) return Option_Unset;
-- Unset or reset the option
function Set (Object : Config_Option; Value : String) return Option_Set;
-- Set the option to the given value
function Set_Null (Object : Config_Option) return Option_Set;
-- Set the option to null (undefined)
function Is_Null (Object : Config_Option) return Boolean;
-- Return whether the current value is null
function Is_Default_Null (Object : Config_Option) return Boolean;
-- Return whether the default is null
procedure Rename (Object : Config_Option; Name : String);
-- Rename the option to the given name
function Kind (Object : Config_Option) return Option_Kind;
function Value (Object : Config_Option) return Boolean
with Pre => Kind (Object) = Boolean_Type;
function Value (Object : Config_Option) return Integer
with Pre => Kind (Object) = Integer_Type;
function Value (Object : Config_Option) return String
with Pre => Kind (Object) = String_Type;
function Get_Config_Option (Plugin : Plugin_Ptr; Name : String) return Config_Option;
-- Return the option for the given name
private
use Interfaces.C;
Null_Void : constant Void_Ptr := Void_Ptr (System.Null_Address);
type Pointer is limited null record;
type Hook_Ptr is access all Pointer;
type Buffer_Ptr is access all Pointer;
Any_Buffer : constant Buffer_Ptr := null;
type Completion_Ptr is access all Pointer;
type Hashtable_Ptr is access all Pointer;
type Timer is record
Result : Hook_Ptr;
Plugin : Plugin_Ptr;
end record;
type Config_Option_Ptr is access all Pointer;
type Config_Option is record
Pointer : Config_Option_Ptr;
Plugin : Plugin_Ptr;
end record;
for Callback_Result use
(Error => -1,
OK => 0,
Eat => 1);
for Callback_Result'Size use int'Size;
for Option_Set use
(Error => 0,
Same_Value => 1,
Changed => 2);
for Option_Set'Size use int'Size;
for Option_Unset use
(Error => -1,
No_Reset => 0,
Reset => 1,
Removed => 2);
for Option_Unset'Size use int'Size;
-----------------------------------------------------------------------------
type Long_Long_Int is range -(2**63) .. +(2**63 - 1);
-- Based on C99 long long int
type Unsigned_Long_Long is mod 2**64;
-- Based on C99 unsigned long long int
subtype Time_T is long;
subtype Sa_Data_Array is Interfaces.C.char_array (0 .. 13);
type Sockaddr is record
Sa_Family : aliased unsigned_short;
Sa_Data : aliased Sa_Data_Array;
end record
with Convention => C_Pass_By_Copy;
type Timeval is record
Tv_Sec : aliased long;
Tv_Usec : aliased long;
end record
with Convention => C_Pass_By_Copy;
-----------------------------------------------------------------------------
-- Weechat_Config_Read_Ok : constant := 0;
-- Weechat_Config_Read_Memory_Error : constant := -1;
-- Weechat_Config_Read_File_Not_Found : constant := -2;
-- Weechat_Config_Write_Ok : constant := 0;
-- Weechat_Config_Write_Error : constant := -1;
-- Weechat_Config_Write_Memory_Error : constant := -2;
-- Weechat_Config_Option_Null : aliased constant String := "null" & L1.NUL;
-- Weechat_Config_Option_Set_Option_Not_Found : constant := -1;
-- Weechat_List_Pos_Sort : aliased constant String := "sort" & L1.NUL;
-- Weechat_List_Pos_Beginning : aliased constant String := "beginning" & L1.NUL;
-- Weechat_List_Pos_End : aliased constant String := "end" & L1.NUL;
-- Weechat_Hashtable_Integer : aliased constant String := "integer" & L1.NUL;
Weechat_Hashtable_String : aliased constant String := "string" & L1.NUL;
-- Weechat_Hashtable_Pointer : aliased constant String := "pointer" & L1.NUL;
-- Weechat_Hashtable_Buffer : aliased constant String := "buffer" & L1.NUL;
-- Weechat_Hashtable_Time : aliased constant String := "time" & L1.NUL;
-- Weechat_Hdata_Other : constant := 0;
-- Weechat_Hdata_Char : constant := 1;
-- Weechat_Hdata_Integer : constant := 2;
-- Weechat_Hdata_Long : constant := 3;
-- Weechat_Hdata_String : constant := 4;
-- Weechat_Hdata_Pointer : constant := 5;
-- Weechat_Hdata_Time : constant := 6;
-- Weechat_Hdata_Hashtable : constant := 7;
-- Weechat_Hdata_Shared_String : constant := 8;
-- Weechat_Hdata_List_Check_Pointers : constant := 1;
-- Weechat_Hotlist_Low : aliased constant String := "0" & L1.NUL;
-- Weechat_Hotlist_Message : aliased constant String := "1" & L1.NUL;
-- Weechat_Hotlist_Private : aliased constant String := "2" & L1.NUL;
-- Weechat_Hotlist_Highlight : aliased constant String := "3" & L1.NUL;
-- Weechat_Hook_Process_Running : constant := -1;
-- Weechat_Hook_Process_Error : constant := -2;
-- Weechat_Hook_Process_Child : constant := -3;
-- Weechat_Hook_Connect_Ok : constant := 0;
-- Weechat_Hook_Connect_Address_Not_Found : constant := 1;
-- Weechat_Hook_Connect_Ip_Address_Not_Found : constant := 2;
-- Weechat_Hook_Connect_Connection_Refused : constant := 3;
-- Weechat_Hook_Connect_Proxy_Error : constant := 4;
-- Weechat_Hook_Connect_Local_Hostname_Error : constant := 5;
-- Weechat_Hook_Connect_Gnutls_Init_Error : constant := 6;
-- Weechat_Hook_Connect_Gnutls_Handshake_Error : constant := 7;
-- Weechat_Hook_Connect_Memory_Error : constant := 8;
-- Weechat_Hook_Connect_Timeout : constant := 9;
-- Weechat_Hook_Connect_Socket_Error : constant := 10;
-- Weechat_Hook_Connect_Gnutls_Cb_Verify_Cert : constant := 0;
-- Weechat_Hook_Connect_Gnutls_Cb_Set_Cert : constant := 1;
type T_Weechat_Plugin is record
Filename : Interfaces.C.Strings.chars_ptr;
Handle : System.Address;
Name : Interfaces.C.Strings.chars_ptr;
Description : Interfaces.C.Strings.chars_ptr;
Author : Interfaces.C.Strings.chars_ptr;
Version : Interfaces.C.Strings.chars_ptr;
License : Interfaces.C.Strings.chars_ptr;
Charset : Interfaces.C.Strings.chars_ptr;
Priority : aliased int;
Initialized : aliased int;
Debug : aliased int;
Upgrading : aliased int;
Variables : Hashtable_Ptr;
Prev_Plugin : access T_Weechat_Plugin;
Next_Plugin : access T_Weechat_Plugin;
-- Plugins
Plugin_Get_Name : access function
(Plugin : access T_Weechat_Plugin) return Interfaces.C.Strings.chars_ptr;
-- Strings
Charset_Set : access procedure
(Arg1 : access T_Weechat_Plugin;
Arg2 : Interfaces.C.Strings.chars_ptr);
Iconv_To_Internal : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Iconv_From_Internal : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Gettext : access function
(Arg1 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Ngettext : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : int) return Interfaces.C.Strings.chars_ptr;
Strndup : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : int) return Interfaces.C.Strings.chars_ptr;
String_Tolower : access procedure (Arg1 : Interfaces.C.Strings.chars_ptr);
String_Toupper : access procedure (Arg1 : Interfaces.C.Strings.chars_ptr);
Strcasecmp : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr) return int;
Strcasecmp_Range : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : int) return int;
Strncasecmp : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : int) return int;
Strncasecmp_Range : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : int;
Arg4 : int) return int;
Strcmp_Ignore_Chars : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : Interfaces.C.Strings.chars_ptr;
Arg4 : int) return int;
Strcasestr : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Strlen_Screen : access function (Arg1 : Interfaces.C.Strings.chars_ptr) return int;
String_Match : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : int) return int;
String_Match_List : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : access Interfaces.C.Strings.chars_ptr;
Arg3 : int) return int;
String_Replace : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
String_Expand_Home : access function
(Arg1 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
String_Eval_Path_Home : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : System.Address;
Arg3 : System.Address;
Arg4 : System.Address) return Interfaces.C.Strings.chars_ptr;
String_Remove_Quotes : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
String_Strip : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : int;
Arg3 : int;
Arg4 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
String_Convert_Escaped_Chars : access function
(Arg1 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
String_Mask_To_Regex : access function
(Arg1 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
String_Regex_Flags : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : int;
Arg3 : access int) return Interfaces.C.Strings.chars_ptr;
String_Regcomp : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : int) return int;
String_Has_Highlight : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr) return int;
String_Has_Highlight_Regex : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr) return int;
String_Replace_Regex : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr;
Arg4 : char;
Arg5 : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Arg6 : System.Address) return Interfaces.C.Strings.chars_ptr;
String_Split : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : Interfaces.C.Strings.chars_ptr;
Arg4 : int;
Arg5 : int;
Arg6 : access int) return System.Address;
String_Split_Shell : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : access int) return System.Address;
String_Free_Split : access procedure (Arg1 : System.Address);
String_Build_With_Split_String : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
String_Split_Command : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : char) return System.Address;
String_Free_Split_Command : access procedure (Arg1 : System.Address);
String_Format_Size : access function
(Arg1 : Unsigned_Long_Long) return Interfaces.C.Strings.chars_ptr;
String_Remove_Color : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
String_Base_Encode : access procedure
(Arg1 : int;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : int;
Arg4 : Interfaces.C.Strings.chars_ptr);
String_Base_Decode : access function
(Arg1 : int;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : Interfaces.C.Strings.chars_ptr) return int;
String_Hex_Dump : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : int;
Arg3 : int;
Arg4 : Interfaces.C.Strings.chars_ptr;
Arg5 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
String_Is_Command_Char : access function (Arg1 : Interfaces.C.Strings.chars_ptr) return int;
String_Input_For_Buffer : access function
(Arg1 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
String_Eval_Expression : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : System.Address;
Arg3 : System.Address;
Arg4 : System.Address) return Interfaces.C.Strings.chars_ptr;
String_Dyn_Alloc : access function (Arg1 : int) return System.Address;
String_Dyn_Copy : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return int;
String_Dyn_Concat : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return int;
String_Dyn_Free : access function
(Arg1 : System.Address;
Arg2 : int) return Interfaces.C.Strings.chars_ptr;
-- UTF-8
Utf8_Has_8bits : access function (Arg1 : Interfaces.C.Strings.chars_ptr) return int;
Utf8_Is_Valid : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : int;
Arg3 : System.Address) return int;
Utf8_Normalize : access procedure (Arg1 : Interfaces.C.Strings.chars_ptr; Arg2 : char);
Utf8_Prev_Char : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Utf8_Next_Char : access function
(Arg1 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Utf8_Char_Int : access function (Arg1 : Interfaces.C.Strings.chars_ptr) return int;
Utf8_Char_Size : access function (Arg1 : Interfaces.C.Strings.chars_ptr) return int;
Utf8_Strlen : access function (Arg1 : Interfaces.C.Strings.chars_ptr) return int;
Utf8_Strnlen : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : int) return int;
Utf8_Strlen_Screen : access function (Arg1 : Interfaces.C.Strings.chars_ptr) return int;
Utf8_Charcmp : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr) return int;
Utf8_Charcasecmp : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr) return int;
Utf8_Char_Size_Screen : access function (Arg1 : Interfaces.C.Strings.chars_ptr) return int;
Utf8_Add_Offset : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : int) return Interfaces.C.Strings.chars_ptr;
Utf8_Real_Pos : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : int) return int;
Utf8_Pos : access function (Arg1 : Interfaces.C.Strings.chars_ptr; Arg2 : int) return int;
Utf8_Strndup : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : int) return Interfaces.C.Strings.chars_ptr;
-- Crypto
Crypto_Hash : access function
(Arg1 : System.Address;
Arg2 : int;
Arg3 : Interfaces.C.Strings.chars_ptr;
Arg4 : System.Address;
Arg5 : access int) return int;
Crypto_Hash_Pbkdf2 : access function
(Arg1 : System.Address;
Arg2 : int;
Arg3 : Interfaces.C.Strings.chars_ptr;
Arg4 : System.Address;
Arg5 : int;
Arg6 : int;
Arg7 : System.Address;
Arg8 : access int) return int;
-- Directories
Mkdir_Home : access function (Arg1 : Interfaces.C.Strings.chars_ptr; Arg2 : int) return int;
Mkdir : access function (Arg1 : Interfaces.C.Strings.chars_ptr; Arg2 : int) return int;
Mkdir_Parents : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : int) return int;
Exec_On_Files : access procedure
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : int;
Arg3 : int;
Arg4 : access procedure (Arg1 : System.Address; Arg2 : Interfaces.C.Strings.chars_ptr);
Arg5 : System.Address);
File_Get_Content : access function
(Arg1 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
-- Util
Util_Timeval_Cmp : access function (Arg1 : access Timeval; Arg2 : access Timeval) return int;
Util_Timeval_Diff : access function
(Arg1 : access Timeval;
Arg2 : access Timeval) return Long_Long_Int;
Util_Timeval_Add : access procedure (Arg1 : access Timeval; Arg2 : Long_Long_Int);
Util_Get_Time_String : access function
(Arg1 : access Time_T) return Interfaces.C.Strings.chars_ptr;
Util_Version_Number : access function (Arg1 : Interfaces.C.Strings.chars_ptr) return int;
-- Sorted lists
List_New : access function return System.Address;
List_Add : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : Interfaces.C.Strings.chars_ptr;
Arg4 : System.Address) return System.Address;
List_Search : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return System.Address;
List_Search_Pos : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return int;
List_Casesearch : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return System.Address;
List_Casesearch_Pos : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return int;
List_Get : access function (Arg1 : System.Address; Arg2 : int) return System.Address;
List_Set : access procedure (Arg1 : System.Address; Arg2 : Interfaces.C.Strings.chars_ptr);
List_Next : access function (Arg1 : System.Address) return System.Address;
List_Prev : access function (Arg1 : System.Address) return System.Address;
List_String : access function (Arg1 : System.Address) return Interfaces.C.Strings.chars_ptr;
List_User_Data : access function (Arg1 : System.Address) return System.Address;
List_Size : access function (Arg1 : System.Address) return int;
List_Remove : access procedure (Arg1 : System.Address; Arg2 : System.Address);
List_Remove_All : access procedure (Arg1 : System.Address);
List_Free : access procedure (Arg1 : System.Address);
-- Array lists
Arraylist_New : access function
(Arg1 : int;
Arg2 : int;
Arg3 : int;
Arg4 : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address;
Arg4 : System.Address) return int;
Arg5 : System.Address;
Arg6 : access procedure
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address);
Arg7 : System.Address) return System.Address;
Arraylist_Size : access function (Arg1 : System.Address) return int;
Arraylist_Get : access function (Arg1 : System.Address; Arg2 : int) return System.Address;
Arraylist_Search : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : access int;
Arg4 : access int) return System.Address;
Arraylist_Insert : access function
(Arg1 : System.Address;
Arg2 : int;
Arg3 : System.Address) return int;
Arraylist_Add : access function (Arg1 : System.Address; Arg2 : System.Address) return int;
Arraylist_Remove : access function (Arg1 : System.Address; Arg2 : int) return int;
Arraylist_Clear : access function (Arg1 : System.Address) return int;
Arraylist_Free : access procedure (Arg1 : System.Address);
-- Hashtables
Hashtable_New : access function
(Size : int;
Type_Keys : C_String;
Type_Values : C_String;
Callback_Hash_Key : access function
(Table : Hashtable_Ptr;
Key : System.Address) return Unsigned_Long_Long;
Callback_Key_Compare : access function
(Table : Hashtable_Ptr;
Key_1 : System.Address;
Key_2 : System.Address) return int)
return Hashtable_Ptr;
Hashtable_Set_With_Size : access function
(Table : Hashtable_Ptr;
Key : System.Address;
Key_Size : int;
Value : System.Address;
Value_Size : int) return System.Address;
Hashtable_Set : access function
(Table : Hashtable_Ptr;
Key : C_String;
Value : C_String) return System.Address;
Hashtable_Get : access function
(Table : Hashtable_Ptr;
Key : C_String) return Interfaces.C.Strings.chars_ptr;
Hashtable_Has_Key : access function
(Table : Hashtable_Ptr;
Key : System.Address) return int;
Hashtable_Map : access procedure
(Table : Hashtable_Ptr;
Callback : access procedure
(Data : Data_Ptr;
Table : Hashtable_Ptr;
Key : System.Address;
Value : System.Address);
Callback_Data : Data_Ptr);
Hashtable_Map_String : access procedure
(Table : Hashtable_Ptr;
Callback : access procedure
(Data : Data_Ptr;
Table : Hashtable_Ptr;
Key : Interfaces.C.Strings.chars_ptr;
Value : Interfaces.C.Strings.chars_ptr);
Callback_Data : Data_Ptr);
Hashtable_Dup : access function (Table : Hashtable_Ptr) return Hashtable_Ptr;
Hashtable_Get_Integer : access function
(Table : Hashtable_Ptr;
Property : C_String) return int;
Hashtable_Get_String : access function
(Table : Hashtable_Ptr;
Property : C_String) return Interfaces.C.Strings.chars_ptr;
Hashtable_Set_Pointer : access procedure
(Table : Hashtable_Ptr;
Property : C_String;
Pointer : System.Address);
Hashtable_Add_To_Infolist : access function
(Table : Hashtable_Ptr;
Item : System.Address;
Prefix : C_String) return int;
Hashtable_Add_From_Infolist : access function
(Table : Hashtable_Ptr;
List : System.Address;
Prefix : C_String) return int;
Hashtable_Remove : access procedure (Table : Hashtable_Ptr; Key : System.Address);
Hashtable_Remove_All : access procedure (Table : Hashtable_Ptr);
Hashtable_Free : access procedure (Table : Hashtable_Ptr);
-- Configuration files
Config_New : access function
(Arg1 : access T_Weechat_Plugin;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address) return int;
Arg4 : System.Address;
Arg5 : System.Address) return System.Address;
Config_New_Section : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : int;
Arg4 : int;
Arg5 : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address;
Arg4 : System.Address;
Arg5 : Interfaces.C.Strings.chars_ptr;
Arg6 : Interfaces.C.Strings.chars_ptr) return int;
Arg6 : System.Address;
Arg7 : System.Address;
Arg8 : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address;
Arg4 : Interfaces.C.Strings.chars_ptr) return int;
Arg9 : System.Address;
Arg10 : System.Address;
Arg11 : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address;
Arg4 : Interfaces.C.Strings.chars_ptr) return int;
Arg12 : System.Address;
Arg13 : System.Address;
Arg14 : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address;
Arg4 : System.Address;
Arg5 : Interfaces.C.Strings.chars_ptr;
Arg6 : Interfaces.C.Strings.chars_ptr) return int;
Arg15 : System.Address;
Arg16 : System.Address;
Arg17 : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address;
Arg4 : System.Address;
Arg5 : System.Address) return int;
Arg18 : System.Address;
Arg19 : System.Address) return System.Address;
Config_Search_Section : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return System.Address;
Config_New_Option : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr;
Arg4 : Interfaces.C.Strings.chars_ptr;
Arg5 : Interfaces.C.Strings.chars_ptr;
Arg6 : Interfaces.C.Strings.chars_ptr;
Arg7 : int;
Arg8 : int;
Arg9 : Interfaces.C.Strings.chars_ptr;
Arg10 : Interfaces.C.Strings.chars_ptr;
Arg11 : int;
Arg12 : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address;
Arg4 : Interfaces.C.Strings.chars_ptr) return int;
Arg13 : System.Address;
Arg14 : System.Address;
Arg15 : access procedure
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address);
Arg16 : System.Address;
Arg17 : System.Address;
Arg18 : access procedure
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address);
Arg19 : System.Address;
Arg20 : System.Address) return System.Address;
Config_Search_Option : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return System.Address;
Config_Search_Section_Option : access procedure
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr;
Arg4 : System.Address;
Arg5 : System.Address);
Config_Search_With_String : access procedure
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : System.Address;
Arg3 : System.Address;
Arg4 : System.Address;
Arg5 : System.Address);
Config_String_To_Boolean : access function
(Arg1 : Interfaces.C.Strings.chars_ptr) return int;
Config_Option_Reset : access function
(Option : Config_Option_Ptr;
Run_Callback : int) return Option_Set;
Config_Option_Set : access function
(Option : Config_Option_Ptr;
Value : C_String;
Run_Callback : int) return Option_Set;
Config_Option_Set_Null : access function
(Option : Config_Option_Ptr;
Run_Callback : int) return Option_Set;
Config_Option_Unset : access function
(Option : Config_Option_Ptr) return Option_Unset;
Config_Option_Rename : access procedure
(Option : Config_Option_Ptr;
Name : C_String);
Config_Option_Get_String : access function
(Option : Config_Option_Ptr;
Property : C_String) return Interfaces.C.Strings.chars_ptr;
Config_Option_Get_Pointer : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return System.Address;
Config_Option_Is_Null : access function (Option : Config_Option_Ptr) return int;
Config_Option_Default_Is_Null : access function (Option : Config_Option_Ptr) return int;
Config_Boolean : access function (Option : Config_Option_Ptr) return int;
Config_Boolean_Default : access function (Arg1 : System.Address) return int;
Config_Integer : access function (Option : Config_Option_Ptr) return int;
Config_Integer_Default : access function (Arg1 : System.Address) return int;
Config_String : access function
(Option : Config_Option_Ptr) return Interfaces.C.Strings.chars_ptr;
Config_String_Default : access function
(Arg1 : System.Address) return Interfaces.C.Strings.chars_ptr;
Config_Color : access function (Arg1 : System.Address) return Interfaces.C.Strings.chars_ptr;
Config_Color_Default : access function
(Arg1 : System.Address) return Interfaces.C.Strings.chars_ptr;
Config_Write_Option : access function
(Arg1 : System.Address;
Arg2 : System.Address) return int;
Config_Write_Line : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : Interfaces.C.Strings.chars_ptr -- , ...
) return int;
Config_Write : access function (Arg1 : System.Address) return int;
Config_Read : access function (Arg1 : System.Address) return int;
Config_Reload : access function (Arg1 : System.Address) return int;
Config_Option_Free : access procedure (Arg1 : System.Address);
Config_Section_Free_Options : access procedure (Arg1 : System.Address);
Config_Section_Free : access procedure (Arg1 : System.Address);
Config_Free : access procedure (Arg1 : System.Address);
Config_Get : access function (Option_Name : C_String) return Config_Option_Ptr;
Config_Get_Plugin : access function
(Arg1 : access T_Weechat_Plugin;
Arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Config_Is_Set_Plugin : access function
(Arg1 : access T_Weechat_Plugin;
Arg2 : Interfaces.C.Strings.chars_ptr) return int;
Config_Set_Plugin : access function
(Arg1 : access T_Weechat_Plugin;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : Interfaces.C.Strings.chars_ptr) return int;
Config_Set_Desc_Plugin : access procedure
(Arg1 : access T_Weechat_Plugin;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : Interfaces.C.Strings.chars_ptr);
Config_Unset_Plugin : access function
(Arg1 : access T_Weechat_Plugin;
Arg2 : Interfaces.C.Strings.chars_ptr) return int;
-- Key bindings
Key_Bind : access function
(Context : Interfaces.C.Strings.chars_ptr;
Keys : Hashtable_Ptr) return int;
Key_Unbind : access function
(Context : Interfaces.C.Strings.chars_ptr;
Key : Interfaces.C.Strings.chars_ptr) return int;
-- Display
Prefix : access function
(Prefix : C_String) return Interfaces.C.Strings.chars_ptr;
Color : access function
(Name : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Printf_Date_Tags : access procedure
(Buffer : System.Address;
Date : Time_T;
Tags : Interfaces.C.Strings.chars_ptr;
Message : C_String);
Printf_Y : access procedure
(Buffer : System.Address;
Y : int;
Message : Interfaces.C.Strings.chars_ptr);
Log_Printf : access procedure (Message : C_String);
-- Hooks
Hook_Command : access function
(Plugin : access T_Weechat_Plugin;
Command : C_String;
Description : C_String;
Args : C_String;
Args_Description : C_String;
Completion : C_String;
Callback : access function
(Callback : On_Command_Callback;
Data : Data_Ptr;
Buffer : Buffer_Ptr;
Argc : int;
Argv : access Interfaces.C.Strings.chars_ptr;
Argv_EOL : access Interfaces.C.Strings.chars_ptr) return Callback_Result;
Callback_Pointer : On_Command_Callback;
Callback_Data : Data_Ptr) return Hook_Ptr;
Hook_Command_Run : access function
(Plugin : access T_Weechat_Plugin;
Command : C_String;
Callback : access function
(Callback : On_Command_Run_Callback;
Data : Data_Ptr;
Buffer : Buffer_Ptr;
Command : Interfaces.C.Strings.chars_ptr) return Callback_Result;
Callback_Pointer : On_Command_Run_Callback;
Callback_Data : Data_Ptr) return Hook_Ptr;
Hook_Timer : access function
(Plugin : access T_Weechat_Plugin;
Interval : long;
Align_Second : int;
Max_Calls : int;
Callback : access function
(Callback : On_Timer_Callback;
Data : Data_Ptr;
Remaining_Calls : int) return Callback_Result;
Callback_Pointer : On_Timer_Callback;
Callback_Data : Data_Ptr) return Hook_Ptr;
Hook_FD : access function
(Plugin : access T_Weechat_Plugin;
FD : int;
Flag_Read : int;
Flag_Write : int;
Flag_Exception : int;
Callback : access function
(Pointer : System.Address;
Data : Data_Ptr;
Fd : int) return int;
Callback_Pointer : System.Address;
Callback_Data : Data_Ptr) return Hook_Ptr;
Hook_Process : access function
(Plugin : access T_Weechat_Plugin;
Command : Interfaces.C.Strings.chars_ptr;
Timeout : int;
Callback : access function
(Pointer : System.Address;
Data : Data_Ptr;
Command : Interfaces.C.Strings.chars_ptr;
Return_Code : int;
Standard_Out : Interfaces.C.Strings.chars_ptr;
Standard_Err : Interfaces.C.Strings.chars_ptr) return int;
Callback_Pointer : System.Address;
Callback_Data : Data_Ptr) return Hook_Ptr;
Hook_Process_Hashtable : access function
(Plugin : access T_Weechat_Plugin;
Command : Interfaces.C.Strings.chars_ptr;
Options : Hashtable_Ptr;
Timeout : int;
Callback : access function
(Pointer : System.Address;
Data : Data_Ptr;
Command : Interfaces.C.Strings.chars_ptr;
Return_Code : int;
Standard_Out : Interfaces.C.Strings.chars_ptr;
Standard_Err : Interfaces.C.Strings.chars_ptr) return int;
Callback_Pointer : System.Address;
Callback_Data : Data_Ptr) return Hook_Ptr;
Hook_Connect : access function
(Plugin : access T_Weechat_Plugin;
Proxy : Interfaces.C.Strings.chars_ptr;
Address : Interfaces.C.Strings.chars_ptr;
Port : int;
Ipv6 : int;
Retry : int;
Tls_Session : System.Address;
Tls_Callback : System.Address;
Tls_Dh_Key_Size : int;
Tls_Priorities : Interfaces.C.Strings.chars_ptr;
Local_Hostname : Interfaces.C.Strings.chars_ptr;
Callback : access function
(Pointer : System.Address;
Data : Data_Ptr;
Status : int;
Tls_Rc : int;
Sock : int;
Error : Interfaces.C.Strings.chars_ptr;
Ip_Address : Interfaces.C.Strings.chars_ptr) return int;
Callback_Pointer : System.Address;
Callback_Data : Data_Ptr) return Hook_Ptr;
Hook_Line : access function
(Plugin : access T_Weechat_Plugin;
Buffer_Type : C_String;
Buffer_Name : C_String;
Tags : C_String;
Callback : access function
(Callback : On_Line_Callback;
Data : Data_Ptr;
Line : Hashtable_Ptr) return Hashtable_Ptr;
Callback_Pointer : On_Line_Callback;
Callback_Data : Data_Ptr) return Hook_Ptr;
Hook_Print : access function
(Plugin : access T_Weechat_Plugin;
Buffer : Buffer_Ptr;
Tags : C_String;
Message : C_String;
Strip_Colors : int;
Callback : access function
(Callback : On_Print_Callback;
Data : Data_Ptr;
Buffer : Buffer_Ptr;
Date : Time_T;
Tagc : int;
Tagv : access Interfaces.C.Strings.chars_ptr;
Displayed : int;
Highlight : int;
Prefix : Interfaces.C.Strings.chars_ptr;
Message : Interfaces.C.Strings.chars_ptr) return Callback_Result;
Callback_Pointer : On_Print_Callback;
Callback_Data : Data_Ptr) return Hook_Ptr;
Hook_Signal : access function
(Plugin : access T_Weechat_Plugin;
Signal : C_String;
Callback : access function
(Callback : On_Signal_Callback;
Data : Data_Ptr;
Signal : Interfaces.C.Strings.chars_ptr;
Type_Data : Interfaces.C.Strings.chars_ptr;
Signal_Data : Void_Ptr) return Callback_Result;
Callback_Pointer : On_Signal_Callback;
Callback_Data : Data_Ptr) return Hook_Ptr;
Hook_Signal_Send : access function
(Signal : C_String;
Type_Data : C_String;
Signal_Data : Void_Ptr) return Callback_Result;
Hook_Hsignal : access function
(Plugin : access T_Weechat_Plugin;
Signal : Interfaces.C.Strings.chars_ptr;
Callback : access function
(Pointer : System.Address;
Data : Data_Ptr;
Signal : Interfaces.C.Strings.chars_ptr;
Hashtable : Hashtable_Ptr) return int;
Callback_Pointer : System.Address;
Callback_Data : Data_Ptr) return Hook_Ptr;
Hook_Hsignal_Send : access function
(Signal : Interfaces.C.Strings.chars_ptr;
Hashtable : Hashtable_Ptr) return int;
Hook_Config : access function
(Plugin : access T_Weechat_Plugin;
Option : Interfaces.C.Strings.chars_ptr;
Callback : access function
(Pointer : System.Address;
Data : System.Address;
Option : Interfaces.C.Strings.chars_ptr;
Value : Interfaces.C.Strings.chars_ptr) return int;
Callback_Pointer : System.Address;
Callback_Data : System.Address) return Hook_Ptr;
Hook_Completion : access function
(Plugin : access T_Weechat_Plugin;
Item : C_String;
Description : C_String;
Callback : access function
(Callback : On_Completion_Callback;
Data : Data_Ptr;
Item : Interfaces.C.Strings.chars_ptr;
Buffer : Buffer_Ptr;
Completion : Completion_Ptr) return Callback_Result;
Callback_Pointer : On_Completion_Callback;
Callback_Data : Data_Ptr) return Hook_Ptr;
Hook_Completion_Get_String : access function
(Completion : System.Address;
Property : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Hook_Completion_List_Add : access procedure
(Completion : Completion_Ptr;
Word : C_String;
Nick_Completion : int;
Where : C_String);
Hook_Modifier : access function
(Plugin : access T_Weechat_Plugin;
Modifier : C_String;
Callback : access function
(Callback : On_Modifier_Callback;
Data : Data_Ptr;
Modifier : Interfaces.C.Strings.chars_ptr;
Modifier_Data : Interfaces.C.Strings.chars_ptr;
Text : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Callback_Pointer : On_Modifier_Callback;
Callback_Data : Data_Ptr) return Hook_Ptr;
Hook_Modifier_Exec : access function
(Plugin : access T_Weechat_Plugin;
Modifier : Interfaces.C.Strings.chars_ptr;
Data : Interfaces.C.Strings.chars_ptr;
String : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Hook_Info : access function
(Plugin : access T_Weechat_Plugin;
Name : Interfaces.C.Strings.chars_ptr;
Description : Interfaces.C.Strings.chars_ptr;
Args_Description : Interfaces.C.Strings.chars_ptr;
Callback : access function
(Pointer : System.Address;
Data : System.Address;
Name : Interfaces.C.Strings.chars_ptr;
Arguments : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Callback_Pointer : System.Address;
Callback_Data : System.Address) return Hook_Ptr;
Hook_Info_Hashtable : access function
(Plugin : access T_Weechat_Plugin;
Name : Interfaces.C.Strings.chars_ptr;
Description : Interfaces.C.Strings.chars_ptr;
Args_Description : Interfaces.C.Strings.chars_ptr;
Output_Description : Interfaces.C.Strings.chars_ptr;
Callback : access function
(Pointer : System.Address;
Data : Data_Ptr;
Name : Interfaces.C.Strings.chars_ptr;
Hashtable : System.Address) return Hashtable_Ptr;
Callback_Pointer : System.Address;
Callback_Data : Data_Ptr) return Hook_Ptr;
Hook_Infolist : access function
(Plugin : access T_Weechat_Plugin;
Name : Interfaces.C.Strings.chars_ptr;
Description : Interfaces.C.Strings.chars_ptr;
Pointer_Description : Interfaces.C.Strings.chars_ptr;
Args_Description : Interfaces.C.Strings.chars_ptr;
Callback : access function
(Pointer : System.Address;
Data : System.Address;
Name : Interfaces.C.Strings.chars_ptr;
Object_Pointer : System.Address;
Arguments : Interfaces.C.Strings.chars_ptr) return System.Address;
Callback_Pointer : System.Address;
Callback_Data : System.Address) return Hook_Ptr;
Hook_Hdata : access function
(Plugin : access T_Weechat_Plugin;
Name : Interfaces.C.Strings.chars_ptr;
Description : Interfaces.C.Strings.chars_ptr;
Callback : access function
(Pointer : System.Address;
Data : System.Address;
Name : Interfaces.C.Strings.chars_ptr) return System.Address;
Callback_Pointer : System.Address;
Callback_Data : System.Address) return Hook_Ptr;
Hook_Focus : access function
(Plugin : access T_Weechat_Plugin;
Area : Interfaces.C.Strings.chars_ptr;
Callback : access function
(Pointer : System.Address;
Data : Data_Ptr;
Info : Hashtable_Ptr) return Hashtable_Ptr;
Callback_Pointer : System.Address;
Callback_Data : Data_Ptr) return Hook_Ptr;
Hook_Set : access procedure
(Hook : Hook_Ptr;
Property : Interfaces.C.Strings.chars_ptr;
Value : Interfaces.C.Strings.chars_ptr);
Unhook : access procedure (Hook : Hook_Ptr);
Unhook_All : access procedure
(Plugin : access T_Weechat_Plugin;
Subplugin : Interfaces.C.Strings.chars_ptr);
-- Buffers
Buffer_New : access function
(Arg1 : access T_Weechat_Plugin;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address;
Arg4 : Interfaces.C.Strings.chars_ptr) return int;
Arg4 : System.Address;
Arg5 : System.Address;
Arg6 : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address) return int;
Arg7 : System.Address;
Arg8 : System.Address) return System.Address;
Buffer_Search : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr) return System.Address;
Buffer_Search_Main : access function return System.Address;
Buffer_Clear : access procedure (Arg1 : System.Address);
Buffer_Close : access procedure (Arg1 : System.Address);
Buffer_Merge : access procedure (Arg1 : System.Address; Arg2 : System.Address);
Buffer_Unmerge : access procedure (Arg1 : System.Address; Arg2 : int);
Buffer_Get_Integer : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return int;
Buffer_Get_String : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Buffer_Get_Pointer : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return System.Address;
Buffer_Set : access procedure
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : Interfaces.C.Strings.chars_ptr);
Buffer_Set_Pointer : access procedure
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : System.Address);
Buffer_String_Replace_Local_Var : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Buffer_Match_List : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return int;
-- Windows
Window_Search_With_Buffer : access function (Buffer : System.Address) return System.Address;
Window_Get_Integer : access function
(Window : System.Address;
Property : Interfaces.C.Strings.chars_ptr) return int;
Window_Get_String : access function
(Window : System.Address;
Property : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Window_Get_Pointer : access function
(Window : System.Address;
Property : Interfaces.C.Strings.chars_ptr) return System.Address;
Window_Set_Title : access procedure (Title : C_String);
-- Nicklist
Nicklist_Add_Group : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr;
Arg4 : Interfaces.C.Strings.chars_ptr;
Arg5 : int) return System.Address;
Nicklist_Search_Group : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return System.Address;
Nicklist_Add_Nick : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr;
Arg4 : Interfaces.C.Strings.chars_ptr;
Arg5 : Interfaces.C.Strings.chars_ptr;
Arg6 : Interfaces.C.Strings.chars_ptr;
Arg7 : int) return System.Address;
Nicklist_Search_Nick : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return System.Address;
Nicklist_Remove_Group : access procedure (Arg1 : System.Address; Arg2 : System.Address);
Nicklist_Remove_Nick : access procedure (Arg1 : System.Address; Arg2 : System.Address);
Nicklist_Remove_All : access procedure (Arg1 : System.Address);
Nicklist_Get_Next_Item : access procedure
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address);
Nicklist_Group_Get_Integer : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return int;
Nicklist_Group_Get_String : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Nicklist_Group_Get_Pointer : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return System.Address;
Nicklist_Group_Set : access procedure
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr;
Arg4 : Interfaces.C.Strings.chars_ptr);
Nicklist_Nick_Get_Integer : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return int;
Nicklist_Nick_Get_String : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Nicklist_Nick_Get_Pointer : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return System.Address;
Nicklist_Nick_Set : access procedure
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr;
Arg4 : Interfaces.C.Strings.chars_ptr);
-- Bars
Bar_Item_Search : access function
(Arg1 : Interfaces.C.Strings.chars_ptr) return System.Address;
Bar_Item_New : access function
(Arg1 : access T_Weechat_Plugin;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address;
Arg4 : System.Address;
Arg5 : System.Address;
Arg6 : System.Address) return Interfaces.C.Strings.chars_ptr;
Arg4 : System.Address;
Arg5 : System.Address) return System.Address;
Bar_Item_Update : access procedure (Arg1 : Interfaces.C.Strings.chars_ptr);
Bar_Item_Remove : access procedure (Arg1 : System.Address);
Bar_Search : access function (Arg1 : Interfaces.C.Strings.chars_ptr) return System.Address;
Bar_New : access function
(Arg1 : Interfaces.C.Strings.chars_ptr;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : Interfaces.C.Strings.chars_ptr;
Arg4 : Interfaces.C.Strings.chars_ptr;
Arg5 : Interfaces.C.Strings.chars_ptr;
Arg6 : Interfaces.C.Strings.chars_ptr;
Arg7 : Interfaces.C.Strings.chars_ptr;
Arg8 : Interfaces.C.Strings.chars_ptr;
Arg9 : Interfaces.C.Strings.chars_ptr;
Arg10 : Interfaces.C.Strings.chars_ptr;
Arg11 : Interfaces.C.Strings.chars_ptr;
Arg12 : Interfaces.C.Strings.chars_ptr;
Arg13 : Interfaces.C.Strings.chars_ptr;
Arg14 : Interfaces.C.Strings.chars_ptr;
Arg15 : Interfaces.C.Strings.chars_ptr) return System.Address;
Bar_Set : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : Interfaces.C.Strings.chars_ptr) return int;
Bar_Update : access procedure (Arg1 : Interfaces.C.Strings.chars_ptr);
Bar_Remove : access procedure (Arg1 : System.Address);
-- Commands
Command : access function
(Plugin : access T_Weechat_Plugin;
Buffer : Buffer_Ptr;
Command : C_String) return Callback_Result;
Command_Options : access function
(Plugin : access T_Weechat_Plugin;
Buffer : Buffer_Ptr;
Command : C_String;
Options : Hashtable_Ptr) return Callback_Result;
-- Network
Network_Pass_Proxy : access function
(Proxy : Interfaces.C.Strings.chars_ptr;
Sock : int;
Address : Interfaces.C.Strings.chars_ptr;
Port : int) return int;
Network_Connect_To : access function
(Proxy : Interfaces.C.Strings.chars_ptr;
Address : access Sockaddr;
Length : unsigned) return int;
-- Infos
Info_Get : access function
(Plugin : access T_Weechat_Plugin;
Info_Name : C_String;
Arguments : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Info_Get_Hashtable : access function
(Plugin : access T_Weechat_Plugin;
Info_Name : Interfaces.C.Strings.chars_ptr;
Hashtable : Hashtable_Ptr) return Hashtable_Ptr;
-- Infolists
Infolist_New : access function (Arg1 : access T_Weechat_Plugin) return System.Address;
Infolist_New_Item : access function (Arg1 : System.Address) return System.Address;
Infolist_New_Var_Integer : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : int) return System.Address;
Infolist_New_Var_String : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : Interfaces.C.Strings.chars_ptr) return System.Address;
Infolist_New_Var_Pointer : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : System.Address) return System.Address;
Infolist_New_Var_Buffer : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : System.Address;
Arg4 : int) return System.Address;
Infolist_New_Var_Time : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : Time_T) return System.Address;
Infolist_Search_Var : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return System.Address;
Infolist_Get : access function
(Arg1 : access T_Weechat_Plugin;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : System.Address;
Arg4 : Interfaces.C.Strings.chars_ptr) return System.Address;
Infolist_Next : access function (Arg1 : System.Address) return int;
Infolist_Prev : access function (Arg1 : System.Address) return int;
Infolist_Reset_Item_Cursor : access procedure (Arg1 : System.Address);
Infolist_Fields : access function
(Arg1 : System.Address) return Interfaces.C.Strings.chars_ptr;
Infolist_Integer : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return int;
Infolist_String : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Infolist_Pointer : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return System.Address;
Infolist_Buffer : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : access int) return System.Address;
Infolist_Time : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return Time_T;
Infolist_Free : access procedure (Arg1 : System.Address);
-- Hdata
Hdata_New : access function
(Arg1 : access T_Weechat_Plugin;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : Interfaces.C.Strings.chars_ptr;
Arg4 : Interfaces.C.Strings.chars_ptr;
Arg5 : int;
Arg6 : int;
Arg7 : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address;
Arg4 : System.Address) return int;
Arg8 : System.Address) return System.Address;
Hdata_New_Var : access procedure
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : int;
Arg4 : int;
Arg5 : int;
Arg6 : Interfaces.C.Strings.chars_ptr;
Arg7 : Interfaces.C.Strings.chars_ptr);
Hdata_New_List : access procedure
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr;
Arg3 : System.Address;
Arg4 : int);
Hdata_Get : access function
(Arg1 : access T_Weechat_Plugin;
Arg2 : Interfaces.C.Strings.chars_ptr) return System.Address;
Hdata_Get_Var_Offset : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return int;
Hdata_Get_Var_Type : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return int;
Hdata_Get_Var_Type_String : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Hdata_Get_Var_Array_Size : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return int;
Hdata_Get_Var_Array_Size_String : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Hdata_Get_Var_Hdata : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Hdata_Get_Var : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return System.Address;
Hdata_Get_Var_At_Offset : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : int) return System.Address;
Hdata_Get_List : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return System.Address;
Hdata_Check_Pointer : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address) return int;
Hdata_Move : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : int) return System.Address;
Hdata_Search : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr;
Arg4 : int) return System.Address;
Hdata_Char : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return char;
Hdata_Integer : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return int;
Hdata_Long : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return long;
Hdata_String : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
Hdata_Pointer : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return System.Address;
Hdata_Time : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return Time_T;
Hdata_Hashtable : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr) return System.Address;
Hdata_Compare : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address;
Arg4 : Interfaces.C.Strings.chars_ptr;
Arg5 : int) return int;
Hdata_Set : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : Interfaces.C.Strings.chars_ptr;
Arg4 : Interfaces.C.Strings.chars_ptr) return int;
Hdata_Update : access function
(Arg1 : System.Address;
Arg2 : System.Address;
Arg3 : System.Address) return int;
Hdata_Get_String : access function
(Arg1 : System.Address;
Arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr;
-- Upgrade
Upgrade_New : access function
(File_Name : Interfaces.C.Strings.chars_ptr;
Callback : access function
(Pointer : System.Address;
Data : System.Address;
File : System.Address;
Object_Id : int;
Infolist : System.Address) return int;
Callback_Pointer : System.Address;
Callback_Data : System.Address) return System.Address;
Upgrade_Write_Object : access function
(File : System.Address;
Object_Id : int;
Infolist : System.Address) return int;
Upgrade_Read : access function (File : System.Address) return int;
Upgrade_Close : access procedure (File : System.Address);
end record
with Convention => C_Pass_By_Copy;
type Plugin_Ptr is access all T_Weechat_Plugin;
No_Timer : constant Timer := (Result => null, Plugin => null);
end WeeChat;
|
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
generic
type Object is limited private;
type Object_Access is access all Object;
package Program.Relative_Access_Types is
type Relative_Access is limited private;
function "+" (Value : Object_Access) return Relative_Access with Inline;
function "-" (Value : Relative_Access) return Object_Access with Inline;
private
type Relative_Access is range -2 ** 31 .. 2 ** 31 - 1;
end Program.Relative_Access_Types;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line;
with Ada.Exceptions;
with SPDX;
procedure Main is
Fail_Cnt : Natural := 0;
Pass_Cnt : Natural := 0;
procedure Test (Str : String;
Expected_Error : String := "";
Allow_Custom : Boolean := False);
procedure Test (Str : String;
Expected_Error : String := "";
Allow_Custom : Boolean := False)
is
begin
declare
Exp : constant SPDX.Expression := SPDX.Parse (Str, Allow_Custom);
Error : constant String :=
(if SPDX.Valid (Exp) then "" else SPDX.Error (Exp));
begin
if Error /= Expected_Error then
Put_Line ("FAIL: '" & Str & "'");
if Expected_Error /= "" then
Put_Line (" Expected error: '" & Expected_Error & "'");
Put_Line (" but got : '" & Error & "'");
else
Put_Line (" Unexpected error: '" & Error & "'");
end if;
Fail_Cnt := Fail_Cnt + 1;
elsif Expected_Error = ""
and then
Allow_Custom
and then
not SPDX.Has_Custom (Exp)
then
Put_Line ("FAIL: '" & Str & "'");
Put_Line (" Has_Custom returned False");
Fail_Cnt := Fail_Cnt + 1;
else
Put_Line ("PASS: '" & Str & "'");
Pass_Cnt := Pass_Cnt + 1;
end if;
end;
exception
when E : others =>
Put_Line ("FAIL: '" & Str & "'");
Put_Line (" With exception: '" &
Ada.Exceptions.Exception_Information (E) & "'");
Fail_Cnt := Fail_Cnt + 1;
end Test;
begin
-- Test all invalid chars
for C in Character loop
if C not in 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' |
'-' | '.' | '(' | ')' | '+' | ' ' | ASCII.HT
then
Test ("test" & C, "Invalid character at 5");
end if;
end loop;
Test ("", "Empty license expression at (0:0)");
Test ("test-3", "Invalid license ID: 'test-3' (1:6)");
Test ("test-3.0", "Invalid license ID: 'test-3.0' (1:8)");
Test ("MIT");
Test ("MIT+");
Test ("MIT OR MIT");
Test ("MIT AND MIT");
Test ("MIT Or MIT", "Operator must be uppercase at (5:6)");
Test ("MIT anD MIT", "Operator must be uppercase at (5:7)");
Test ("MIT WITH AND", "License exception id expected at (10:12)");
Test ("MIT WITH", "License exception id expected at (8:8)");
Test ("MIT WITH plop", "Invalid license exception ID: 'plop' (10:13)");
Test ("MIT WITH GPL-3.0-linking-exception");
Test ("(MIT)");
Test ("(MIT) AND MIT");
Test ("(MIT+) AND (MIT)");
Test ("((MIT) AND (MIT+))");
Test ("((MIT) AND (MIT+ OR MIT AND MIT AND (MIT WITH GPL-3.0-linking-exception AND MIT)))");
Test ("MIT +", "+ operator must follow and indentifier without whitespace (5:5)");
Test ("MIT AND +", "+ operator must follow and indentifier without whitespace (9:9)");
Test ("MIT+AND", "Invalid license ID: 'MIT+AND' (1:7)");
Test ("MIT AND", "Empty license expression at (7:7)");
Test ("MIT OR", "Empty license expression at (6:6)");
Test ("MIT MIT", "Unexpected token at (5:7)");
Test ("(MIT", "Missing closing parentheses ')' at (4:4)");
Test ("MIT)", "Unexpected token at (4:4)");
Test ("(MIT AND (MIT OR MIT)", "Missing closing parentheses ')' at (21:21)");
Test ("MIT AND (MIT OR MIT))", "Unexpected token at (21:21)");
Test ("custom-plop", "Invalid license ID: 'custom-plop' (1:11)", Allow_Custom => False);
Test ("custom", "Invalid license ID: 'custom' (1:6)", Allow_Custom => True);
Test ("custom-", "Invalid license ID: 'custom-' (1:7)", Allow_Custom => True);
Test ("custom-plop", Allow_Custom => True);
Test ("custom-plop+", Allow_Custom => True);
Test ("custom-test:test", "Invalid character at 12", Allow_Custom => True);
Test ("CuStoM-test-1.0.3", Allow_Custom => True);
Test ("custom-test AND custom-plop", Allow_Custom => True);
Put_Line ("PASS:" & Pass_Cnt'Img);
Put_Line ("FAIL:" & Fail_Cnt'Img);
if Fail_Cnt /= 0 then
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
end if;
end Main;
|
with Ada.Text_IO, Population_Count; use Population_Count;
procedure Pernicious is
Prime: array(0 .. 64) of Boolean;
-- we are using 64-bit numbers, so the population count is between 0 and 64
X: Num; use type Num;
Cnt: Positive;
begin
-- initialize array Prime; Prime(I) must be true if and only if I is a prime
Prime := (0 => False, 1 => False, others => True);
for I in 2 .. 8 loop
if Prime(I) then
Cnt := I + I;
while Cnt <= 64 loop
Prime(Cnt) := False;
Cnt := Cnt + I;
end loop;
end if;
end loop;
-- print first 25 pernicious numbers
X := 1;
for I in 1 .. 25 loop
while not Prime(Pop_Count(X)) loop
X := X + 1;
end loop;
Ada.Text_IO.Put(Num'Image(X));
X := X + 1;
end loop;
Ada.Text_IO.New_Line;
-- print pernicious numbers between 888_888_877 and 888_888_888 (inclusive)
for Y in Num(888_888_877) .. 888_888_888 loop
if Prime(Pop_Count(Y)) then
Ada.Text_IO.Put(Num'Image(Y));
end if;
end loop;
Ada.Text_IO.New_Line;
end;
|
FROM cardano-container-mainnet-explorer:latest
# for syncing blockchain
RUN mkdir wallet
# expose cardano node ports
EXPOSE 8100 8090 8000
ARG COMMIT
ENV COMMIT ${COMMIT:-undefined}
CMD ["/bin/cardano-start"] |
with Ada.Containers.Vectors;
with Ada.Numerics.Real_Arrays; use Ada.Numerics.Real_Arrays;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO; use Ada.Text_IO;
procedure Solution is
package Line_Vectors is new Ada.Containers.Vectors (Natural, Unbounded_String);
use Line_Vectors;
type Ship is tagged
record
X : Real_Vector := (0.0, 0.0);
end record;
function Read_Instructions(Filename : String) return Vector is
File : File_Type;
Lines : Vector;
begin
Open (File => File,
Mode => In_File,
Name => Filename);
while not End_Of_File (File) loop
Append (Lines, To_Unbounded_String (Get_Line (File)));
end loop;
Close(File);
return Lines;
end Read_Instructions;
Instructions : Vector;
begin
Instructions := Read_Instructions ("input.txt");
for Instruction of Instructions loop
Put_Line (Character'Image (Element (Instruction, 1)));
end loop;
end;
|
--------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2013-2020, Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
-- SDL.TTFs
--
-- Root package implementing the binding to SDL2_ttf.
--------------------------------------------------------------------------------------------------------------------
with Ada.Finalization;
with Ada.Strings.UTF_Encoding;
with Interfaces.C;
with SDL.Video.Palettes;
with SDL.Video.Surfaces;
package SDL.TTFs is
package UTF_Strings renames Ada.Strings.UTF_Encoding;
package C renames Interfaces.C;
TTF_Error : exception;
function Initialise return Boolean with
Inline_Always => True;
procedure Finalise with
Import => True,
Convention => C,
External_Name => "TTF_Quit";
-- Fonts.
type Point_Sizes is new C.int;
type Font_Faces is range 0 .. C.long'Last with
Size => C.long'Size,
Convention => C;
type Font_Styles is mod 2 ** 32 with
Convention => C;
Style_Normal : constant Font_Styles := 16#0000_0000#;
Style_Bold : constant Font_Styles := 16#0000_0001#;
Style_Italic : constant Font_Styles := 16#0000_0002#;
Style_Underline : constant Font_Styles := 16#0000_0004#;
Style_Strike_Through : constant Font_Styles := 16#0000_0008#;
type Font_Outlines is range 0 .. C.int'Last with
Size => C.int'Size,
Convention => C;
Outlines_Off : constant Font_Outlines := Font_Outlines'First;
type Font_Hints is (Normal, Light, Mono, None) with
Convention => C;
type Font_Measurements is range 0 .. C.int'Last with
Size => C.int'Size,
Convention => C;
type Fonts is new Ada.Finalization.Controlled with private;
Null_Font : constant Fonts;
overriding
procedure Finalize (Self : in out Fonts);
function Style (Self : in Fonts) return Font_Styles with
Inline => True;
procedure Set_Style (Self : in out Fonts; Now : in Font_Styles) with
Inline => True;
function Outline (Self : in Fonts) return Font_Outlines with
Inline => True;
procedure Set_Outline (Self : in out Fonts; Now : in Font_Outlines := Outlines_Off) with
Inline => True;
function Hinting (Self : in Fonts) return Font_Hints with
Inline => True;
procedure Set_Hinting (Self : in out Fonts; Now : in Font_Hints := Normal) with
Inline => True;
function Kerning (Self : in Fonts) return Boolean with
Inline => True;
procedure Set_Kerning (Self : in out Fonts; Now : in Boolean) with
Inline => True;
function Height (Self : in Fonts) return Font_Measurements with
Inline => True;
function Ascent (Self : in Fonts) return Font_Measurements with
Inline => True;
function Descent (Self : in Fonts) return Font_Measurements with
Inline => True;
function Line_Skip (Self : in Fonts) return Font_Measurements with
Inline => True;
function Faces (Self : in Fonts) return Font_Faces with
Inline => True;
function Is_Face_Fixed_Width (Self : in Fonts) return Boolean with
Inline => True;
function Face_Family_Name (Self : in Fonts) return String with
Inline => True;
function Face_Style_Name (Self : in Fonts) return String with
Inline => True;
function Size_Latin_1 (Self : in Fonts; Text : in String) return SDL.Sizes with
Inline => True;
function Size_UTF_8 (Self : in Fonts; Text : in UTF_Strings.UTF_8_String) return SDL.Sizes with
Inline => True;
function Render_Solid (Self : in Fonts;
Text : in String;
Colour : in SDL.Video.Palettes.Colour) return SDL.Video.Surfaces.Surface;
function Render_Shaded (Self : in Fonts;
Text : in String;
Colour : in SDL.Video.Palettes.Colour;
Background_Colour : in SDL.Video.Palettes.Colour) return SDL.Video.Surfaces.Surface;
function Render_Blended (Self : in Fonts;
Text : in String;
Colour : in SDL.Video.Palettes.Colour) return SDL.Video.Surfaces.Surface;
private
type Internal_Fonts is null record;
type Fonts_Pointer is access all Internal_Fonts with
Convention => C;
subtype Fonts_Ref is not null Fonts_Pointer;
type Fonts is new Ada.Finalization.Controlled with
record
Internal : Fonts_Pointer := null;
Source_Freed : Boolean := False; -- Whether the Makers.* subprogram has already closed the font.
end record;
Null_Font : constant Fonts := (Ada.Finalization.Controlled with others => <>);
end SDL.TTFs;
|
with Spherical_Harmonics;
with gauss_quadrature_61;
with Text_IO; use Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
procedure Spherical_Harm_Tst_1 is
type Real is digits 15;
package Math is new Ada.Numerics.Generic_Elementary_Functions (Real);
use Math;
type Base_Poly_Index is new Integer;
subtype Poly_Index is Base_Poly_Index range 0..1000;
package Sph is new Spherical_Harmonics
(Real, Sqrt, Exp, Log, Base_Poly_Index, Poly_Index'Last);
use Sph;
package rio is new Float_IO(Real);
use rio;
package Quad is new Gauss_Quadrature_61 (Real, Sqrt);
use Quad;
subtype Gauss_Index is Quad.Gauss_Index_61;
Num_Points : constant := 32 * 16;
-- need 32 * 256 to do l=3000 (m=small)
-- need 32 * 8 to do l=700 (m=small)
type X_axis is range 1 .. Num_Points;
DeltaX : constant Real := (X_Upper_Bound - X_Lower_Bound) / Real (Num_Points);
Area, Max, Diff, Y, W, Y1, Y2 : Real;
X_Start, X_Final : Real;
Error, d_Area : Real;
F_val : Function_Values;
X_g : Gauss_Values;
l_max, m : Real := 1.0;
L, L1, L2, Int_L_Max : Poly_Index;
Int_m : Poly_Index;
k_max : Poly_Index;
procedure Pause (s1,s2,s3,s4,s5,s6,s7,s8 : string := "") is
Continue : Character := ' ';
begin
new_line;
if S1 /= "" then put_line (S1); end if;
if S2 /= "" then put_line (S2); end if;
if S3 /= "" then put_line (S3); end if;
if S4 /= "" then put_line (S4); end if;
if S5 /= "" then put_line (S5); end if;
if S6 /= "" then put_line (S6); end if;
if S7 /= "" then put_line (S7); end if;
if S8 /= "" then put_line (S8); end if;
dialog: loop
begin
New_Line;
Put ("Type a character to continue: ");
Get_Immediate (Continue);
exit dialog;
exception
when others => null;
end;
end loop dialog;
new_line;
end pause;
begin
--
-- Test 1. Compare the two calculations of Polys
--
New_Line;
Pause
("Test 1: Compare two independent calculations of Spherical Harmonics.",
"The difference between Spherical_Harm_2 and Spherical_Harm is printed.",
"Spherical_Harm_2 is used only for testing, and can fail if m>144, so",
"test values of m should be limited to less than 144.");
new_line;
put_line ("Enter the value of the magnetic quantum number m (0, 1, ..), e.g. 40: ");
get (m);
new_line;
put ("Enter the max value of the azimuthal quantum number l (m, m+1, ..), e.g. 60: ");
get (l_max);
Int_l_max := Poly_Index (l_max);
Int_m := Poly_Index (m);
k_max := Int_l_max - Int_m;
for k in Poly_Index range 0 .. k_max loop
L := k + Int_m;
Max := 0.0;
for I in X_Axis loop
X_start := X_Lower_Bound + DeltaX * (Real (I) - Real (X_Axis'First));
X_Final := X_Start + DeltaX;
-- Interval of Gaussian quadrature.
Find_Gauss_Nodes (X_Start, X_Final, X_g);
for N in Gauss_Index loop
Y1 := Spherical_Harm_2 (L, m, X_g(N)); -- use for testing, m>144 fails.
Y2 := Spherical_Harm (L, m, X_g(N)); -- works ok for high L, m
Diff := Abs (Y1 - Y2) / (Abs(Y1) + Abs (Y2) + 1.0e-16);
if (Diff > Max) then
Max := Diff;
end if;
end loop;
end loop;
new_line;
put ("L = "); put (Poly_Index'Image(L));
put(" Max difference between the two = "); put (Max);
end loop;
--
-- Test 2. Create polynomials, check Norm
-- k goes from 0...k_max, and l automatically goes from m, m+1...m+k...
--
New_Line;
Pause
("Test 2: test normalization of the polynomials.",
"The polynomials will be squared and integrated on (-1,1),",
"and the result, will be printed in column 2 below.");
new_line;
put_line ("Enter the value of the magnetic quantum number m (0, 1, ..): ");
get (m);
new_line;
put ("Enter the max value of the azimuthal quantum number l (m, m+1, ..): ");
get (l_max);
Int_l_max := Poly_Index (l_max);
Int_m := Poly_Index (m);
k_max := Int_l_max - Int_m;
for k in Poly_Index range 0 .. k_max loop
L := k + Int_m;
Area := 0.0;
for I in X_Axis loop
X_start := X_Lower_Bound + DeltaX * (Real (I) - Real (X_Axis'First));
X_Final := X_Start + DeltaX;
-- Interval of Gaussian quadrature.
Find_Gauss_Nodes (X_Start, X_Final, X_g);
for N in Gauss_Index loop
W := Poly_Weight (X_g(N));
Y := Spherical_Harm (L, m, X_g(N));
F_val (N) := W*Y*Y;
end loop;
Get_Integral (F_val, X_Start, X_Final, d_Area, Error);
Area := Area + d_Area;
end loop;
new_line; put ("L = "); put (Poly_Index'Image(L));
put(" Norm = "); put (Area);
end loop;
New_Line;
Pause
("Test 3: test orthogonality of the Spherical Harmonics.",
"Two polynomials will be multiplied and integrated on (-1,1)",
"and the result, will be printed in column 2.",
"One of the Polynomials will be fixed at l = m.",
"The other polynomials will be in the range l = m..l_max.");
new_line;
put_line ("Enter the value of the magnetic quantum number m (0, 1, ..): ");
get (m);
new_line;
put ("Enter l_max (m, m+1, ..): ");
get (l_max);
new_line;
Int_l_max := Poly_Index (l_max);
Int_m := Poly_Index (m);
k_max := Int_l_max - Int_m;
for k in Poly_Index range 0 .. k_max loop
L1 := Int_m;
L2 := k + Int_m;
Area := 0.0;
for I in X_Axis loop
X_start := X_Lower_Bound + DeltaX * (Real (I) - Real (X_Axis'First));
X_Final := X_Start + DeltaX;
-- Interval of Gaussian quadrature.
Find_Gauss_Nodes (X_Start, X_Final, X_g);
for N in Gauss_Index loop
W := Poly_Weight (X_g(N)); -- Check this
Y1 := Spherical_Harm (L1, m, X_g(N));
Y2 := Spherical_Harm (L2, m, X_g(N));
F_val (N) := W*Y1*Y2;
end loop;
Get_Integral (F_val, X_Start, X_Final, d_Area, Error);
Area := Area + d_Area;
end loop;
new_line;
put ("L2 = "); put (Poly_Index'Image(L2));
put(" Inner product of the 2 polys = "); put (Area);
end loop;
end Spherical_Harm_Tst_1;
|
with Ada.Text_IO;
with PrimeUtilities;
package body Problem_72 is
package IO renames Ada.Text_IO;
subtype One_Million is Long_Integer range 1 .. 1_000_000;
package Million_Primes is new PrimeUtilities(One_Million);
-- From Farey Sequence Wikipedia Page:
-- Using the fact that |F1| = 2, we can derive an expression for the length of F_n:
-- | F_n | = 1 + ∑(m = 1, n) φ(m).
procedure Solve is
count : Long_Integer := 0;
sieve : constant Million_Primes.Sieve := Million_Primes.Generate_Sieve(One_Million'Last);
procedure Solve_Recursive(min_index : Positive; start_euler, so_far : One_Million) is
prime : One_Million;
total : One_Million;
euler : One_Million;
begin
for prime_index in min_index .. sieve'Last loop
prime := sieve(prime_index);
exit when One_Million'Last / prime < so_far;
total := so_far * prime;
euler := start_euler * (prime - 1);
count := count + euler;
loop
Solve_Recursive(prime_index + 1, euler, total);
exit when One_Million'Last / prime < total;
total := total * prime;
euler := euler * prime;
count := count + euler;
end loop;
end loop;
end Solve_Recursive;
begin
Solve_Recursive(sieve'First, 1, 1);
IO.Put_Line(Long_Integer'Image(count));
end Solve;
end Problem_72;
|
-- Copyright (c) 2021 Devin Hill
-- zlib License -- see LICENSE for details.
with Interfaces;
use Interfaces;
package GBA.Display.Windows is
subtype Toggleable_Window_Element is
Toggleable_Display_Element range Background_0 .. Object_Sprites;
type Window_Horizontal_Dimensions is
record
Left_Bound, Right_Bound : Unsigned_8 range 0 .. 240;
end record
with Size => 16;
for Window_Horizontal_Dimensions use
record
Right_Bound at 0 range 0 .. 7;
Left_Bound at 1 range 0 .. 7;
end record;
type Window_Vertical_Dimensions is
record
Upper_Bound, Lower_Bound : Unsigned_8 range 0 .. 160;
end record
with Size => 16;
for Window_Vertical_Dimensions use
record
Lower_Bound at 0 range 0 .. 7;
Upper_Bound at 1 range 0 .. 7;
end record;
type Window_Display_Control_Info is
record
Displayed_Elements : Displayed_Element_Flags (Toggleable_Window_Element);
Enable_Color_Effect : Boolean;
end record
with Size => 8;
for Window_Display_Control_Info use
record
Displayed_Elements at 0 range 0 .. 4;
Enable_Color_Effect at 0 range 5 .. 5;
end record;
type Window_Region is
( Window_0
, Window_1
, Outside_Windows
, Object_Window
);
subtype Rectangular_Window_Region is
Window_Region range Window_0 .. Window_1;
subtype Irregular_Window_Region is
Window_Region range Outside_Windows .. Object_Window;
Horizontal_Dimensions : array (Rectangular_Window_Region) of Window_Horizontal_Dimensions
with Import, Volatile_Components, Address => WIN0H;
Vertical_Dimensions : array (Rectangular_Window_Region) of Window_Vertical_Dimensions
with Import, Volatile_Components, Address => WIN0V;
Window_Control : array (Window_Region) of Window_Display_Control_Info
with Import, Volatile, Address => WININ;
end GBA.Display.Windows; |
with Ada.Text_IO; use Ada.Text_IO;
with Input17; use Input17;
procedure Day17 is
Grid : array
(Natural range 0 .. 2000, Natural range 0 .. 2000) of Character :=
(others => (others => '.'));
Min_X, Min_Y : Natural := Natural'Last;
Max_X, Max_Y : Natural := Natural'First;
function Can_Spread (X, Y : Natural) return Boolean is
(Grid (X, Y) = '.' or Grid (X, Y) = '|');
procedure Spread_Water (X, Y : Natural) is
begin
if Y > Max_Y then
return;
end if;
if not Can_Spread (X, Y) then
return;
end if;
if not Can_Spread (X, Y + 1) then
declare
Left_X : Natural := X;
Right_X : Natural := X + 1;
begin
while Can_Spread (Left_X, Y) and not Can_Spread (Left_X, Y + 1)
loop
Grid (Left_X, Y) := '|';
Left_X := Left_X - 1;
end loop;
while Can_Spread (Right_X, Y) and not Can_Spread (Right_X, Y + 1)
loop
Grid (Right_X, Y) := '|';
Right_X := Right_X + 1;
end loop;
if Can_Spread (Left_X, Y + 1) or Can_Spread (Right_X, Y + 1) then
Spread_Water (Left_X, Y);
Spread_Water (Right_X, Y);
elsif Grid (Left_X, Y) = '#' and Grid (Right_X, Y) = '#' then
for X2 in Left_X + 1 .. Right_X - 1 loop
Grid (X2, Y) := '~';
end loop;
end if;
end;
elsif Grid (X, Y) = '.' then
Grid (X, Y) := '|';
Spread_Water (X, Y + 1);
if Grid (X, Y + 1) = '~' then
Spread_Water (X, Y);
end if;
end if;
end Spread_Water;
begin
for I in X_Inputs'Range loop
Min_X := Natural'Min (Min_X, X_Inputs (I).Fixed);
Max_X := Natural'Max (Max_X, X_Inputs (I).Fixed);
Min_Y := Natural'Min (Min_Y, X_Inputs (I).First);
Max_Y := Natural'Max (Max_Y, X_Inputs (I).Last);
end loop;
for I in Y_Inputs'Range loop
Min_Y := Natural'Min (Min_Y, Y_Inputs (I).Fixed);
Max_Y := Natural'Max (Max_Y, Y_Inputs (I).Fixed);
Min_X := Natural'Min (Min_X, Y_Inputs (I).First);
Max_X := Natural'Max (Max_X, Y_Inputs (I).Last);
end loop;
for I in X_Inputs'Range loop
declare
X : constant Natural := X_Inputs (I).Fixed;
begin
for Y in X_Inputs (I).First .. X_Inputs (I).Last loop
Grid (X, Y) := '#';
end loop;
end;
end loop;
for I in Y_Inputs'Range loop
declare
Y : constant Natural := Y_Inputs (I).Fixed;
begin
for X in Y_Inputs (I).First .. Y_Inputs (I).Last loop
Grid (X, Y) := '#';
end loop;
end;
end loop;
Spread_Water (500, Min_Y);
declare
Water_Tiles : Natural := 0;
Perma_Water : Natural := 0;
begin
for Y in Min_Y .. Max_Y loop
for X in 0 .. 2000 loop
if Grid (X, Y) = '~' then
Perma_Water := Perma_Water + 1;
Water_Tiles := Water_Tiles + 1;
elsif Grid (X, Y) = '|' then
Water_Tiles := Water_Tiles + 1;
end if;
end loop;
end loop;
Put_Line ("Part 1 =" & Natural'Image (Water_Tiles));
Put_Line ("Part 2 =" & Natural'Image (Perma_Water));
end;
-- Write the whole grid to a file (just for fun).
declare
File : File_Type;
begin
Create (File, Out_File, "grid.out");
for Y in Min_Y .. Max_Y loop
for X in Min_X .. Max_X loop
Put (File, Grid (X, Y));
end loop;
Put_Line (File, "");
end loop;
Close (File);
end;
end Day17;
|
with Ada.Containers.Functional_Maps;
with Ada.Containers.Functional_Vectors;
with Common; use Common;
with Ada.Containers; use Ada.Containers;
generic
type Element_Type is private;
package Bounded_Stack with SPARK_Mode is
Capacity : constant Integer := 200;
Empty : constant Integer := 0;
subtype Extent is Integer range Empty .. Capacity;
subtype Index is Extent range 1 .. Capacity;
type Stack is private;
function Size (S : Stack) return Extent;
function Element (S : Stack; I : Index) return Element_Type
with Ghost, Pre => I <= Size (S);
procedure Push (S : in out Stack; E : Element_Type) with
Pre => Size (S) < Capacity,
Post =>
Size (S) = Size (S'Old) + 1
and then
(for all I in 1 .. Size (S'Old) => Element (S, I) = Element (S'Old, I))
and then
Element (S, Size (S)) = E;
procedure Pop (S : in out Stack; E : out Element_Type) with
Pre => Size (S) > Empty,
Post =>
Size (S) = Size (S'Old) - 1
and then
(for all I in 1 .. Size (S) => Element (S, I) = Element (S'Old, I))
and then
E = Element (S'Old, Size (S'Old));
private
type Content_Array is array (Index) of Element_Type with Relaxed_Initialization;
type Stack is record
Top : Extent := 0;
Content : Content_Array;
end record
with Predicate => (for all I in 1 .. Top => Content (I)'Initialized);
function Size (S : Stack) return Extent is (S.Top);
function Element (S : Stack; I : Index) return Element_Type is (S.Content (I));
end Bounded_Stack;
|
------------------------------------------------------------------------------
-- EMAIL: <darkestkhan@gmail.com> --
-- License: ISC --
-- --
-- Copyright © 2015 - 2016 darkestkhan --
------------------------------------------------------------------------------
-- Permission to use, copy, modify, and/or distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- The software is provided "as is" and the author disclaims all warranties --
-- with regard to this software including all implied warranties of --
-- merchantability and fitness. In no event shall the author be liable for --
-- any special, direct, indirect, or consequential damages or any damages --
-- whatsoever resulting from loss of use, data or profits, whether in an --
-- action of contract, negligence or other tortious action, arising out of --
-- or in connection with the use or performance of this software. --
------------------------------------------------------------------------------
with System;
with Imago.Binary;
use Imago;
package Imago.IL is
--------------------------------------------------------------------------
---------------
-- T Y P E S --
---------------
--------------------------------------------------------------------------
-- New names for old types.
subtype Bitfield is Binary.Word;
subtype Bool is Binary.Byte;
subtype Byte is Binary.S_Byte;
subtype ClampD is Long_Float range 0.0 .. 1.0;
subtype ClampF is Float range 0.0 .. 1.0;
subtype ClampH is Short_Float range 0.0 .. 1.0;
subtype Double is Long_Float;
subtype Int is Integer;
subtype Short is Short_Integer;
subtype SizeI is Integer;
subtype UByte is Binary.Byte;
subtype UShort is Binary.Short;
subtype UInt is Binary.Word;
subtype Pointer is System.Address;
--------------------------------------------------------------------------
-- Try to bring some touch of order to the ILenum mess.
subtype Enum is Binary.Word;
--------------------------------------------------------------------------
-----------------------
-- C O N S T A N T S --
-----------------------
--------------------------------------------------------------------------
-- Useful values.
Null_Pointer: constant Pointer := System.Null_Address;
--------------------------------------------------------------------------
-- "Enumeration" constants.
IL_FALSE : constant Bool := 16#0#;
IL_TRUE : constant Bool := 16#1#;
-- Data formats.
IL_COLOUR_INDEX : constant Enum := 16#1900#;
IL_COLOR_INDEX : constant Enum := 16#1900#;
IL_ALPHA : constant Enum := 16#1906#;
IL_RGB : constant Enum := 16#1907#;
IL_RGBA : constant Enum := 16#1908#;
IL_BGR : constant Enum := 16#80E0#;
IL_BGRA : constant Enum := 16#80E1#;
IL_LUMINANCE : constant Enum := 16#1909#;
IL_LUMINANCE_ALPHA : constant Enum := 16#190A#;
-- Types of data.
IL_BYTE : constant Enum := 16#1400#;
IL_UNSIGNED_BYTE : constant Enum := 16#1401#;
IL_SHORT : constant Enum := 16#1402#;
IL_UNSIGNED_SHORT : constant Enum := 16#1403#;
IL_INT : constant Enum := 16#1404#;
IL_UNSIGNED_INT : constant Enum := 16#1405#;
IL_FLOAT : constant Enum := 16#1406#;
IL_DOUBLE : constant Enum := 16#140A#;
IL_HALF : constant Enum := 16#140B#;
-- IL specific defines.
IL_VENDOR : constant Enum := 16#1F00#;
IL_LOAD_EXT : constant Enum := 16#1F01#;
IL_SAVE_EXT : constant Enum := 16#1F02#;
IL_VERSION_1_7_8 : constant Enum := 16#1#;
IL_VERSION : constant Enum := 178;
-- Attribute bits.
IL_ORIGIN_BIT : constant Bitfield := 16#0000_0001#;
IL_FILE_BIT : constant Bitfield := 16#0000_0002#;
IL_PAL_BIT : constant Bitfield := 16#0000_0004#;
IL_FORMAT_BIT : constant Bitfield := 16#0000_0008#;
IL_TYPE_BIT : constant Bitfield := 16#0000_0010#;
IL_COMPRESS_BIT : constant Bitfield := 16#0000_0020#;
IL_LOADFAIL_BIT : constant Bitfield := 16#0000_0040#;
IL_FORMAT_SPECIFIC_BIT : constant Bitfield := 16#0000_0080#;
IL_ALL_ATTRIB_BITS : constant Bitfield := 16#000F_FFFF#;
-- Types of palettes.
IL_PAL_NONE : constant Enum := 16#0400#;
IL_PAL_RGB24 : constant Enum := 16#0401#;
IL_PAL_RGB32 : constant Enum := 16#0402#;
IL_PAL_RGBA32 : constant Enum := 16#0403#;
IL_PAL_BGR24 : constant Enum := 16#0404#;
IL_PAL_BGR32 : constant Enum := 16#0405#;
IL_PAL_BGRA32 : constant Enum := 16#0406#;
-- Types of images.
IL_TYPE_UNKNOWN : constant Enum := 16#0000#;
IL_BMP : constant Enum := 16#0420#;
IL_CUT : constant Enum := 16#0421#;
IL_DOOM : constant Enum := 16#0422#;
IL_DOOM_FLAT : constant Enum := 16#0423#;
IL_ICO : constant Enum := 16#0424#;
IL_JPG : constant Enum := 16#0425#;
IL_JFIF : constant Enum := 16#0425#;
IL_ILBM : constant Enum := 16#0426#;
IL_PCD : constant Enum := 16#0427#;
IL_PCX : constant Enum := 16#0428#;
IL_PIC : constant Enum := 16#0429#;
IL_PNG : constant Enum := 16#042A#;
IL_PNM : constant Enum := 16#042B#;
IL_SGI : constant Enum := 16#042C#;
IL_TGA : constant Enum := 16#042D#;
IL_TIF : constant Enum := 16#042E#;
IL_CHEAD : constant Enum := 16#042F#;
IL_RAW : constant Enum := 16#0430#;
IL_MDL : constant Enum := 16#0431#;
IL_WAL : constant Enum := 16#0432#;
IL_LIF : constant Enum := 16#0434#;
IL_MNG : constant Enum := 16#0435#;
IL_JNG : constant Enum := 16#0435#;
IL_GIF : constant Enum := 16#0436#;
IL_DDS : constant Enum := 16#0437#;
IL_DCX : constant Enum := 16#0438#;
IL_PSD : constant Enum := 16#0439#;
IL_EXIF : constant Enum := 16#043A#;
IL_PSP : constant Enum := 16#043B#;
IL_PIX : constant Enum := 16#043C#;
IL_PXR : constant Enum := 16#043D#;
IL_XPM : constant Enum := 16#043E#;
IL_HDR : constant Enum := 16#043F#;
IL_ICNS : constant Enum := 16#0440#;
IL_JP2 : constant Enum := 16#0441#;
IL_EXR : constant Enum := 16#0442#;
IL_WDP : constant Enum := 16#0443#;
IL_VTF : constant Enum := 16#0444#;
IL_WBMP : constant Enum := 16#0445#;
IL_SUN : constant Enum := 16#0446#;
IL_IFF : constant Enum := 16#0447#;
IL_TPL : constant Enum := 16#0448#;
IL_FITS : constant Enum := 16#0449#;
IL_DICOM : constant Enum := 16#044A#;
IL_IWI : constant Enum := 16#044B#;
IL_BLP : constant Enum := 16#044C#;
IL_FTX : constant Enum := 16#044D#;
IL_ROT : constant Enum := 16#044E#;
IL_TEXTURE : constant Enum := 16#044F#;
IL_DPX : constant Enum := 16#0450#;
IL_UTX : constant Enum := 16#0451#;
IL_MP3 : constant Enum := 16#0452#;
IL_JASC_PAL : constant Enum := 16#0475#;
-- Types of errors.
IL_NO_ERROR : constant Enum := 16#0000#;
IL_INVALID_ENUM : constant Enum := 16#0501#;
IL_OUT_OF_MEMORY : constant Enum := 16#0502#;
IL_FORMAT_NOT_SUPPORTED : constant Enum := 16#0503#;
IL_INTERNAL_ERROR : constant Enum := 16#0504#;
IL_INVALID_VALUE : constant Enum := 16#0505#;
IL_ILLEGAL_OPERATION : constant Enum := 16#0506#;
IL_ILLEGAL_FILE_VALUE : constant Enum := 16#0507#;
IL_INVALID_FILE_HEADER : constant Enum := 16#0508#;
IL_INVALID_PARAM : constant Enum := 16#0509#;
IL_COULD_NOT_OPEN_FILE : constant Enum := 16#050A#;
IL_INVALID_EXTENSION : constant Enum := 16#050B#;
IL_FILE_ALREADY_EXISTS : constant Enum := 16#050C#;
IL_OUT_FORMAT_SAME : constant Enum := 16#050D#;
IL_STACK_OVERFLOW : constant Enum := 16#050E#;
IL_STACK_UNDERFLOW : constant Enum := 16#050F#;
IL_INVALID_CONVERSION : constant Enum := 16#0510#;
IL_BAD_DIMENSIONS : constant Enum := 16#0511#;
IL_FILE_READ_ERROR : constant Enum := 16#0512#;
IL_FILE_WRITE_ERROR : constant Enum := 16#0513#;
IL_LIB_GIF_ERROR : constant Enum := 16#05E1#;
IL_LIB_JPEG_ERROR : constant Enum := 16#05E2#;
IL_LIB_PNG_ERROR : constant Enum := 16#05E3#;
IL_LIB_TIFF_ERROR : constant Enum := 16#05E4#;
IL_LIB_MNG_ERROR : constant Enum := 16#05E5#;
IL_LIB_JP2_ERROR : constant Enum := 16#05E6#;
IL_LIB_EXR_ERROR : constant Enum := 16#05E7#;
IL_UNKNOWN_ERROR : constant Enum := 16#05FF#;
-- Origin definitions.
IL_ORIGIN_SET : constant Enum := 16#0600#;
IL_ORIGIN_LOWER_LEFT : constant Enum := 16#0601#;
IL_ORIGIN_UPPER_LEFT : constant Enum := 16#0602#;
IL_ORIGIN_MODE : constant Enum := 16#0603#;
-- Format and type mode definitions.
IL_FORMAT_SET : constant Enum := 16#0610#;
IL_FORMAT_MODE : constant Enum := 16#0611#;
IL_TYPE_SET : constant Enum := 16#0612#;
IL_TYPE_MODE : constant Enum := 16#0613#;
-- File definitions.
IL_FILE_OVERWRITE : constant Enum := 16#0620#;
IL_FILE_MODE : constant Enum := 16#0621#;
-- Palette difinitions.
IL_CONV_PAL : constant Enum := 16#0630#;
-- Load fail definitions.
IL_DEFAULT_ON_FAIL : constant Enum := 16#0632#;
-- Key colour and alpha definitions.
IL_USE_KEY_COLOUR : constant Enum := 16#0635#;
IL_USE_KEY_COLOR : constant Enum := 16#0635#;
IL_BLIT_BLEND : constant Enum := 16#0636#;
-- Interlace definitions.
IL_SAVE_INTERLACED : constant Enum := 16#0639#;
IL_INTERLACE_MODE : constant Enum := 16#063A#;
-- Quantization definitions.
IL_QUANTIZATION_MODE : constant Enum := 16#0640#;
IL_WU_QUANT : constant Enum := 16#0641#;
IL_NEU_QUANT : constant Enum := 16#0642#;
IL_NEU_QUANT_SAMPLE : constant Enum := 16#0643#;
IL_MAX_QUANT_INDEXS : constant Enum := 16#0644#;
IL_MAX_QUANT_INDICES : constant Enum := 16#0644#;
-- Hints.
IL_FASTEST : constant Enum := 16#0660#;
IL_LESS_MEM : constant Enum := 16#0661#;
IL_DONT_CARE : constant Enum := 16#0662#;
IL_MEM_SPEED_HINT : constant Enum := 16#0665#;
IL_USE_COMPRESSION : constant Enum := 16#0666#;
IL_NO_COMPRESSION : constant Enum := 16#0667#;
IL_COMPRESSION_HINT : constant Enum := 16#0668#;
-- Compression.
IL_NVIDIA_COMPRESS : constant Enum := 16#0670#;
IL_SQUISH_COMPRESS : constant Enum := 16#0671#;
-- Subimage types.
IL_SUB_NEXT : constant Enum := 16#0680#;
IL_SUB_MIPMAP : constant Enum := 16#0681#;
IL_SUB_LAYER : constant Enum := 16#0682#;
-- Compression definitions.
IL_COMPRESS_MODE : constant Enum := 16#0700#;
IL_COMPRESS_NONE : constant Enum := 16#0701#;
IL_COMPRESS_RLE : constant Enum := 16#0702#;
IL_COMPRESS_LZO : constant Enum := 16#0703#;
IL_COMPRESS_ZLIB : constant Enum := 16#0704#;
-- File format specific values.
IL_TGA_CREATE_STAMP : constant Enum := 16#0710#;
IL_JPG_QUALITY : constant Enum := 16#0711#;
IL_PNG_INTERLACE : constant Enum := 16#0712#;
IL_TGA_RLE : constant Enum := 16#0713#;
IL_BMP_RLE : constant Enum := 16#0714#;
IL_SGI_RLE : constant Enum := 16#0715#;
IL_TGA_ID_STRING : constant Enum := 16#0717#;
IL_TGA_AUTHNAME_STRING : constant Enum := 16#0718#;
IL_TGA_AUTHCOMMENT_STRING : constant Enum := 16#0719#;
IL_PNG_AUTHNAME_STRING : constant Enum := 16#071A#;
IL_PNG_TITLE_STRING : constant Enum := 16#071B#;
IL_PNG_DESCRIPTION_STRING : constant Enum := 16#071C#;
IL_TIF_DESCRIPTION_STRING : constant Enum := 16#071D#;
IL_TIF_HOSTCOMPUTER_STRING : constant Enum := 16#071E#;
IL_TIF_DOCUMENTNAME_STRING : constant Enum := 16#071F#;
IL_TIF_AUTHNAME_STRING : constant Enum := 16#0720#;
IL_JPG_SAVE_FORMAT : constant Enum := 16#0721#;
IL_CHEAD_HEADER_STRING : constant Enum := 16#0722#;
IL_PCD_PICNUM : constant Enum := 16#0723#;
IL_PNG_ALPHA_INDEX : constant Enum := 16#0724#;
IL_JPG_PROGRESSIVE : constant Enum := 16#0725#;
IL_VTF_COMP : constant Enum := 16#0726#;
-- DXTC definitions.
IL_DXTC_FORMAT : constant Enum := 16#0705#;
IL_DXT1 : constant Enum := 16#0706#;
IL_DXT2 : constant Enum := 16#0707#;
IL_DXT3 : constant Enum := 16#0708#;
IL_DXT4 : constant Enum := 16#0709#;
IL_DXT5 : constant Enum := 16#070A#;
IL_DXT_NO_COMP : constant Enum := 16#070B#;
IL_KEEP_DXTC_DATA : constant Enum := 16#070C#;
IL_DXTC_DATA_FORMAT : constant Enum := 16#070D#;
IL_3DC : constant Enum := 16#070E#;
IL_RXGB : constant Enum := 16#070F#;
IL_ATI1N : constant Enum := 16#0710#;
IL_DXT1A : constant Enum := 16#0711#;
-- Environment map definitions.
IL_CUBEMAP_POSITIVEX : constant Bitfield := 16#00000400#;
IL_CUBEMAP_NEGATIVEX : constant Bitfield := 16#00000800#;
IL_CUBEMAP_POSITIVEY : constant Bitfield := 16#00001000#;
IL_CUBEMAP_NEGATIVEY : constant Bitfield := 16#00002000#;
IL_CUBEMAP_POSITIVEZ : constant Bitfield := 16#00004000#;
IL_CUBEMAP_NEGATIVEZ : constant Bitfield := 16#00008000#;
IL_SPHEREMAP : constant Bitfield := 16#00010000#;
-- Values.
IL_VERSION_NUM : constant Enum := 16#0DE2#;
IL_IMAGE_WIDTH : constant Enum := 16#0DE4#;
IL_IMAGE_HEIGHT : constant Enum := 16#0DE5#;
IL_IMAGE_DEPTH : constant Enum := 16#0DE6#;
IL_IMAGE_SIZE_OF_DATA : constant Enum := 16#0DE7#;
IL_IMAGE_BPP : constant Enum := 16#0DE8#;
IL_IMAGE_BYTES_PER_PIXEL : constant Enum := 16#0DE8#;
IL_IMAGE_BITS_PER_PIXEL : constant Enum := 16#0DE9#;
IL_IMAGE_FORMAT : constant Enum := 16#0DEA#;
IL_IMAGE_TYPE : constant Enum := 16#0DEB#;
IL_PALETTE_TYPE : constant Enum := 16#0DEC#;
IL_PALETTE_SIZE : constant Enum := 16#0DED#;
IL_PALETTE_BPP : constant Enum := 16#0DEE#;
IL_PALETTE_NUM_COLS : constant Enum := 16#0DEF#;
IL_PALETTE_BASE_TYPE : constant Enum := 16#0DF0#;
IL_NUM_FACES : constant Enum := 16#0DE1#;
IL_NUM_IMAGES : constant Enum := 16#0DF1#;
IL_NUM_MIPMAPS : constant Enum := 16#0DF2#;
IL_NUM_LAYERS : constant Enum := 16#0DF3#;
IL_ACTIVE_IMAGE : constant Enum := 16#0DF4#;
IL_ACTIVE_MIPMAP : constant Enum := 16#0DF5#;
IL_ACTIVE_LAYER : constant Enum := 16#0DF6#;
IL_ACTIVE_FACE : constant Enum := 16#0E00#;
IL_CUR_IMAGE : constant Enum := 16#0DF7#;
IL_IMAGE_DURATION : constant Enum := 16#0DF8#;
IL_IMAGE_PLANESIZE : constant Enum := 16#0DF9#;
IL_IMAGE_BPC : constant Enum := 16#0DFA#;
IL_IMAGE_OFFX : constant Enum := 16#0DFB#;
IL_IMAGE_OFFY : constant Enum := 16#0DFC#;
IL_IMAGE_CUBEFLAGS : constant Enum := 16#0DFD#;
IL_IMAGE_ORIGIN : constant Enum := 16#0DFE#;
IL_IMAGE_CHANNELS : constant Enum := 16#0DFF#;
IL_SEEK_SET : constant Int := 0;
IL_SEEK_CUR : constant Int := 1;
IL_SEEK_END : constant Int := 2;
IL_EOF : constant Int := -1;
--------------------------------------------------------------------------
---------------------------
-- S U B P R O G R A M S --
---------------------------
--------------------------------------------------------------------------
function Active_Face (Number: in UInt) return Bool
with Import => True, Convention => StdCall, External_Name => "ilActiveFace";
function Active_Image (Number: in UInt) return Bool
with Import => True, Convention => StdCall,
External_Name => "ilActiveImage";
function Active_Layer (Number: in UInt) return Bool
with Import => True, Convention => StdCall,
External_Name => "ilActiveLayer";
function Active_Mipmap (Number: in UInt) return Bool
with Import => True, Convention => StdCall,
External_Name => "ilActiveMipmap";
function Apply_Pal (File_Name: in String) return Bool
with Inline => True;
-- NOTE: Is this correct way to bind to this function?
-- Probably not, but will try fixing it once something breaks over this.
function Apply_Profile
( In_Profile: in String; Out_Profile: in String
) return Bool
with Inline => True;
procedure Bind_Image (Image: in UInt)
with Import => True, Convention => StdCall, External_Name => "ilBindImage";
function Blit
( Source: in UInt; DestX: in Int; DestY: in Int; DestZ: in Int;
SrcX: in UInt; SrcY: in UInt; SrcZ: in UInt;
Width: in UInt; Height: in UInt; Depth: in UInt
) return Bool
with Import => True, Convention => StdCall, External_Name => "ilBlit";
function Clamp_NTSC return Bool
with Import => True, Convention => StdCall, External_Name => "ilClampNTSC";
procedure Clear_Color
( Red: in ClampF; Green: in ClampF; Blue: in ClampF; Alpha: in ClampF )
with Import => True, Convention => StdCall,
External_Name => "ilClearColour";
procedure Clear_Colour
( Red: in ClampF; Green: in ClampF; Blue: in ClampF; Alpha: in ClampF )
with Import => True, Convention => StdCall,
External_Name => "ilClearColour";
function Clear_Image return Bool
with Import => True, Convention => StdCall, External_Name => "ilClearImage";
function Clone_Cur_Image return UInt
with Import => True, Convention => StdCall,
External_Name => "ilCloneCurImage";
function Compress_DXT
( Data: in Pointer; Width: in UInt; Height: in UInt;
Depth: in UInt; DXTC_Format: in Enum; DXTC_Size: in Pointer
) return Pointer
with Import => True, Convention => StdCall,
External_Name => "ilCompressDXT";
function Compress_Func (Mode: in Enum) return Bool
with Import => True, Convention => StdCall,
External_Name => "ilCompressFunc";
function Convert_Image (Dest_Format: in Enum; Dest_Type: in Enum) return Bool
with Import => True, Convention => StdCall,
External_Name => "ilConvertImage";
function Convert_Pal (Dest_Format: in Enum) return Bool
with Import => True, Convention => StdCall,
External_Name => "ilConvertPal";
function Copy_Image (Src: in UInt) return Bool
with Import => True, Convention => StdCall,
External_Name => "ilCopyImage";
function Copy_Pixels
( XOff: in UInt; YOff: in UInt; ZOff: in UInt;
Width: in UInt; Height: in UInt; Depth: in UInt;
Format: in Enum; Type_Of: in Enum; Data: in Pointer
) return UInt
with Import => True, Convention => StdCall,
External_Name => "ilCopyPixels";
function Create_Sub_Image (Type_Of: in Enum; Num: in UInt) return UInt
with Import => True, Convention => StdCall,
External_Name => "ilCreateSubImage";
function Default_Image return Bool
with Import => True, Convention => StdCall,
External_Name => "ilDefaultImage";
procedure Delete_Image (Num: in UInt)
with Import => True, Convention => StdCall,
External_Name => "ilDeleteImage";
procedure Delete_Images (Num: in SizeI; Images: in Pointer)
with Import => True, Convention => StdCall,
External_Name => "ilDeleteImages";
function Determine_Type (File_Name: in String) return Enum
with Inline => True;
function Determine_Type (Lump: in Pointer; Size: in UInt) return Enum
with Import => True, Convention => StdCall,
External_Name => "ilDetermineTypeL";
function Disable (Mode: in Enum) return Bool
with Import => True, Convention => StdCall, External_Name => "ilDisable";
function DXTC_Data_To_Image return Bool
with Import => True, Convention => StdCall,
External_Name => "ilDxtcDataToImage";
function DXTC_Data_To_Surface return Bool
with Import => True, Convention => StdCall,
External_Name => "ilDxtcDataToSurface";
function Enable (Mode: in Enum) return Bool
with Import => True, Convention => StdCall, External_Name => "ilEnable";
procedure Flip_Surface_DXTC_Data
with Import => True, Convention => StdCall,
External_Name => "ilFlipSurfaceDxtcData";
function Format_Func (Mode: in Enum) return Bool
with Import => True, Convention => StdCall,
External_Name => "ilFormatFunc";
function Get_Alpha (Type_Of: in Enum) return Pointer
with Import => True, Convention => StdCall, External_Name => "ilGetAlpha";
function Gen_Image return UInt
with Import => True, Convention => StdCall, External_Name => "ilGenImage";
procedure Gen_Images (Num: in SizeI; Images: in Pointer)
with Import => True, Convention => StdCall, External_Name => "ilGenImages";
function Get_Boolean (Mode: in Enum) return Bool
with Import => True, Convention => StdCall, External_Name => "ilGetBoolean";
procedure Get_Boolean (Mode: in Enum; Param: in Pointer)
with Import => True, Convention => StdCall,
External_Name => "ilGetBooleanv";
function Get_Data return Pointer
with Import => True, Convention => StdCall, External_Name => "ilGetData";
function Get_DXTC_Data
( Buffer: in Pointer; Buffer_Size: in UInt; DXTC_Format: in Enum
) return UInt
with Import => True, Convention => StdCall,
External_Name => "ilGetDXTCData";
function Get_Error return Enum
with Import => True, Convention => StdCall, External_Name => "ilGetError";
function Get_Integer (Mode: in Enum) return Int
with Import => True, Convention => StdCall, External_Name => "ilGetInteger";
procedure Get_Integer (Mode: in Enum; Param: in Pointer)
with Import => True, Convention => StdCall,
External_Name => "ilGetIntegerv";
function Get_Lump_Pos return UInt
with Import => True, Convention => StdCall, External_Name => "ilGetLumpPos";
function Get_Palette return Pointer
with Import => True, Convention => StdCall, External_Name => "ilGetPalette";
function Get_String (String_Name: in Enum) return String
with Inline => True;
procedure Hint (Target: in Enum; Mode: in Enum)
with Import => True, Convention => StdCall, External_Name => "ilHint";
function Invert_Surface_DXTC_Data_Alpha return Bool
with Import => True, Convention => StdCall,
External_Name => "ilInvertSurfaceDxtcDataAlpha";
procedure Init
with Import => True, Convention => StdCall, External_Name => "ilInit";
function Image_To_DXTC_Data (Format: in Enum) return Bool
with Import => True, Convention => StdCall,
External_Name => "ilImageToDxtcData";
function Is_Disabled (Mode: in Enum) return Bool
with Import => True, Convention => StdCall, External_Name => "ilIsDisabled";
function Is_Enabled (Mode: in Enum) return Bool
with Import => True, Convention => StdCall, External_Name => "ilIsEnabled";
function Is_Image (Image: in UInt) return Bool
with Import => True, Convention => StdCall, External_Name => "ilIsImage";
function Is_Valid (Type_Of: in Enum; File_Name: in String) return Bool
with Inline => True;
function Is_Valid
( Type_Of: in Enum; Lump: in Pointer; Size: in UInt
) return Bool
with Import => True, Convention => StdCall, External_Name => "ilIsValidL";
procedure Key_Color
( Red: in ClampF; Green: in ClampF; Blue: in ClampF; Alpha: in ClampF )
with Import => True, Convention => StdCall, External_Name => "ilKeyColour";
procedure Key_Colour
( Red: in ClampF; Green: in ClampF; Blue: in ClampF; Alpha: in ClampF )
with Import => True, Convention => StdCall, External_Name => "ilKeyColour";
function Load (Type_Of: in Enum; File_Name: in String) return Bool
with Inline => True;
function Load
( Type_Of: in Enum; Lump: in Pointer; Size: in UInt
) return Bool
with Import => True, Convention => StdCall, External_Name => "ilLoadL";
function Load_Data
( File_Name: in String;
Width: in UInt; Height: in UInt;
Depth: in UInt; BPP: in UByte
) return Bool
with Inline => True;
function Load_Data
( Lump: in Pointer; Size: in UInt;
Width: in UInt; Height: in UInt;
Depth: in UInt; BPP: in UByte
) return Bool
with Import => True, Convention => StdCall, External_Name => "ilLoadDataL";
function Load_Image (File_Name: in String) return Bool
with Inline => True;
function Load_Pal (File_Name: in String) return Bool
with Inline => True;
procedure Mod_Alpha (Alpha_Value: in Double)
with Import => True, Convention => StdCall, External_Name => "ilModAlpha";
function Original_Func (Mode: in Enum) return Bool
with Import => True, Convention => StdCall, External_Name => "ilOriginFunc";
function Overlay_Image
( Source: in UInt; XCoord: in Int;
YCoord: in Int; ZCoord: in Int
) return Bool
with Import => True, Convention => StdCall,
External_Name => "ilOverlayImage";
procedure Pop_Attrib
with Import => True, Convention => StdCall, External_Name => "ilPopAttrib";
-- NOTE: Type of Bits may need to be changed from UInt to Bitfield
procedure Push_Attrib (Bits: in UInt)
with Import => True, Convention => StdCall, External_Name => "ilPushAttrib";
procedure Register_Format (Format: in Enum)
with Import => True, Convention => StdCall,
External_Name => "ilRegisterFormat";
function Register_Mip_Num (Num: in UInt) return Bool
with Import => True, Convention => StdCall,
External_Name => "ilRegisterMipNum";
function Register_Num_Faces (Num: in UInt) return Bool
with Import => True, Convention => StdCall,
External_Name => "ilRegisterNumFaces";
function Register_Num_Images (Num: in UInt) return Bool
with Import => True, Convention => StdCall,
External_Name => "ilRegisterNumImages";
procedure Register_Origin (Origin: in Enum)
with Import => True, Convention => StdCall,
External_Name => "ilRegisterOrigin";
procedure Register_Pal (Pal: in Pointer; Size: in UInt; Type_Of: in Enum)
with Import => True, Convention => StdCall,
External_Name => "ilRegisterPal";
procedure Register_Type (Type_Of: in Enum)
with Import => True, Convention => StdCall,
External_Name => "ilRegisterType";
function Remove_Load (Ext: in String) return Bool
with Inline => True;
function Remove_Save (Ext: in String) return Bool
with Inline => True;
procedure Reset_Memory
with Import => True, Convention => StdCall,
External_Name => "ilResetMemory";
procedure Reset_Read
with Import => True, Convention => StdCall, External_Name => "ilResetRead";
procedure Reset_Write
with Import => True, Convention => StdCall,
External_Name => "ilResetMemory";
function Save (Type_Of: in Enum; File_Name: in String) return Bool
with Inline => True;
function Save
( Type_Of: in Enum; Lump: in Pointer; Size: in UInt
) return UInt
with Import => True, Convention => StdCall, External_Name => "ilSaveL";
function Save_Data (File_Name: in String) return Bool
with Inline => True;
function Save_Image (File_Name: in String) return Bool
with Inline => True;
function Save_Pal (File_Name: in String) return Bool
with Inline => True;
function Set_Alpha (Alpha_Value: in Double) return Bool
with Import => True, Convention => StdCall, External_Name => "ilSetAlpha";
function Set_Data (Data: in Pointer) return Bool
with Import => True, Convention => StdCall, External_Name => "ilSetData";
function Set_Duration (Duration: in UInt) return Bool
with Import => True, Convention => StdCall,
External_Name => "ilSetDuration";
procedure Set_Integer (Mode: in Enum; Param: in Int)
with Import => True, Convention => StdCall, External_Name => "ilSetInteger";
procedure Set_Pixels
( XOff: in Int; YOff: in Int; ZOff: in Int;
Width: in UInt; Height: in UInt; Depth: in UInt;
Format: in Enum; Type_Of: in Enum; Data: in Pointer
)
with Import => True, Convention => StdCall, External_Name => "ilSetPixels";
procedure Set_String (Mode: in Enum; Value: in String)
with Inline => True;
procedure Shut_Down
with Import => True, Convention => StdCall, External_Name => "ilShutDown";
function Surface_To_DXTC_Data (Format: in Enum) return Bool
with Import => True, Convention => StdCall,
External_Name => "ilSurfaceToDxtcData";
function Tex_Image
( Width: in UInt; Height: in UInt; Depth: in UInt;
Num_Channels: in UByte; Format: in Enum; Type_Of: in Enum;
Data: in Pointer
) return Bool
with Import => True, Convention => StdCall, External_Name => "ilTexImage";
function Tex_Image_DXTC
( W: in Int; H: in Int; D: in Int; DXT_Format: in Enum; Data: in Pointer
) return Bool
with Import => True, Convention => StdCall,
External_Name => "ilTexImageDxtc";
function Type_From_Ext (File_Name: in String) return Enum
with Inline => True;
function Type_Func (Mode: in Enum) return Bool
with Import => True, Convention => StdCall, External_Name => "ilTypeFunc";
--------------------------------------------------------------------------
end Imago.IL;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . B B . B O A R D _ P A R A M E T E R S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2016-2017, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
-- The port of GNARL to bare board targets was initially developed by the --
-- Real-Time Systems Group at the Technical University of Madrid. --
-- --
------------------------------------------------------------------------------
-- This package defines board parameters for the leon3 boards
package System.BB.Board_Parameters is
pragma No_Elaboration_Code_All;
pragma Pure;
--------------------
-- Hardware clock --
--------------------
Clock_Frequency : constant Positive := 40_000_000;
-- Frequency of the system clock
Prescaler_Min : constant := 4;
-- In order to obtain the highest granularity of the clock we set the
-- minimum allowed prescaler division factor, which is 5, corresponding
-- to a prescaler reload register value of 4. According to GRLIB manual,
-- the minimum allowed prescalar division fact is the number of
-- implemented timers (usually 4) + 1.
----------------
-- Interrupts --
----------------
-- Support of extended interrupts. Must be 0 if extended interrupts are not
-- available. Otherwise, extended interrupts are supported (so there are 31
-- interrupts) using this priority level. The priority level must be equal
-- to the EIRQ value of the Leon Interrupt controller.
Extended_Interrupts_Level : constant := 0;
---------------------------
-- Peripheral addressess --
---------------------------
APB_Base : constant := 16#8000_0000#;
Irqmp_Base : constant := APB_Base + 16#200#;
-- Address of the interrupt controler
Timer_Base : constant := APB_Base + 16#300#;
-- Address of the general purpose timer unit
UART_Base : constant := APB_Base + 16#100#;
-- Address of the UART for the console
Timer_1_Interrupt : constant := 6;
-- IRQ line of the timer
----------
-- CPUS --
----------
Max_Number_Of_CPUs : constant := 2;
-- Maximum number of CPUs
end System.BB.Board_Parameters;
|
----------------------------------------------------------------------------
-- Symbolic Expressions (symexpr)
--
-- Copyright (C) 2012, Riccardo Bernardini
--
-- This file is part of symexpr.
--
-- symexpr is free software: you can redistribute it and/or modify
-- it under the terms of the Lesser GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- symexpr 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 Lesser GNU General Public License
-- along with gclp. If not, see <http://www.gnu.org/licenses/>.
----------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Ada.Strings.Fixed;
with Ada.Strings.Unbounded;
package body Symbolic_Expressions is
-- Set to True to enable few debug prints
Verbose : constant Boolean := False;
pragma Unreferenced (Verbose);
---------
-- "+" --
---------
function "+" (L : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Unary_Plus,
Term => Duplicate (L.Expr)));
end "+";
---------
-- "-" --
---------
function "-" (L : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Unary_Minus,
Term => Duplicate (L.Expr)));
end "-";
---------
-- "+" --
---------
function "+" (L, R : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Sum,
Left => Duplicate (L.Expr),
Right => Duplicate (R.Expr)));
end "+";
---------
-- "-" --
---------
function "-" (L, R : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Sub,
Left => Duplicate (L.Expr),
Right => Duplicate (R.Expr)));
end "-";
---------
-- "*" --
---------
function "*" (L, R : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Mult,
Left => Duplicate (L.Expr),
Right => Duplicate (R.Expr)));
end "*";
---------
-- "/" --
---------
function "/" (L, R : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Div,
Left => Duplicate (L.Expr),
Right => Duplicate (R.Expr)));
end "/";
---------
-- "+" --
---------
function "+" (L : Symbolic_Expression; R : Scalar_Type)
return Symbolic_Expression
is
begin
return L + To_Expr (R);
end "+";
---------
-- "-" --
---------
function "-" (L : Symbolic_Expression; R : Scalar_Type)
return Symbolic_Expression
is
begin
return L - To_Expr (R);
end "-";
---------
-- "*" --
---------
function "*" (L : Symbolic_Expression; R : Scalar_Type)
return Symbolic_Expression
is
begin
return L * To_Expr (R);
end "*";
---------
-- "/" --
---------
function "/" (L : Symbolic_Expression; R : Scalar_Type)
return Symbolic_Expression
is
begin
return L / To_Expr (R);
end "/";
---------
-- "+" --
---------
function "+" (L : Scalar_Type; R : Symbolic_Expression)
return Symbolic_Expression
is
begin
return To_Expr (L) + R;
end "+";
---------
-- "-" --
---------
function "-" (L : Scalar_Type; R : Symbolic_Expression)
return Symbolic_Expression
is
begin
return To_Expr (L) - R;
end "-";
---------
-- "*" --
---------
function "*" (L : Scalar_Type; R : Symbolic_Expression)
return Symbolic_Expression
is
begin
return To_Expr (L) * R;
end "*";
---------
-- "/" --
---------
function "/" (L : Scalar_Type; R : Symbolic_Expression)
return Symbolic_Expression
is
begin
return To_Expr (L) / R;
end "/";
-----------------
-- Is_Constant --
-----------------
function Is_Constant (X : Node_Access) return Boolean is
begin
case X.Class is
when Unary_Plus | Unary_Minus =>
return Is_Constant (X.Term);
when Sum | Sub | Mult | Div =>
return Is_Constant (X.Left) and Is_Constant (X.Right);
when Fun_Call =>
for I in 1 .. X.N_Params loop
if not Is_Constant (X.Parameters (I)) then
return False;
end if;
end loop;
return True;
when Var =>
return False;
when Const =>
return True;
end case;
end Is_Constant;
function Is_Constant (X : Symbolic_Expression) return Boolean is
begin
return Is_Constant (X.Expr);
end Is_Constant;
-------------------
-- Constant_Expr --
-------------------
function To_Expr (X : Scalar_Type) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Const,
Value => X));
end To_Expr;
---------------
-- To_Scalar --
---------------
function To_Scalar (X : Node_Access) return Scalar_Type is
begin
case X.Class is
when Unary_Plus =>
return + To_Scalar (X.Term);
when Unary_Minus =>
return - To_Scalar (X.Term);
when Sum =>
return To_Scalar (X.Left) + To_Scalar (X.Right);
when Sub =>
return To_Scalar (X.Left) - To_Scalar (X.Right);
when Mult =>
return To_Scalar (X.Left) * To_Scalar (X.Right);
when Div =>
return To_Scalar (X.Left) / To_Scalar (X.Right);
when Fun_Call =>
declare
Param : Scalar_Array (1 .. X.N_Params);
begin
for I in Param'Range loop
Param (I) := To_Scalar (X.Parameters (I));
end loop;
return Call (Identifier(X.Fun_Name), Param);
end;
when Var =>
raise Not_A_Scalar;
when Const =>
return X.Value;
end case;
end To_Scalar;
function Eval (X : Symbolic_Expression) return Scalar_Type is
begin
return To_Scalar (X.Expr);
end Eval;
-------------------
-- Function_Call --
-------------------
function Function_Call
(Name : Function_Name;
Parameters : Expression_Array)
return Symbolic_Expression
is
Node : constant Node_Access :=
new Node_Type'(Class => Fun_Call,
Fun_Name => Name,
N_Params => Parameters'Length,
Parameters => <>);
begin
for I in Parameters'Range loop
Node.Parameters (I) := Duplicate (Parameters (I).Expr);
end loop;
return Symbolic_Expression'(Controlled with Expr => Node);
end Function_Call;
--------------
-- Variable --
--------------
function Variable
(Name : Variable_Name) return Symbolic_Expression
is
begin
return Symbolic_Expression'(Controlled with Expr =>
new Node_Type'(Class => Var,
Var_Name => Name));
end Variable;
function Replace
(Item : Node_Access;
Var_Name : Variable_Name;
Value : Node_Access)
return Node_Access
is
function Result_Class (Item : Node_Access;
Var_Name : Variable_Name) return Node_Class is
begin
if Item.Class = Var and then Item.Var_Name = Var_Name then
return Const;
else
return Item.Class;
end if;
end Result_Class;
pragma Unreferenced (Result_Class);
Result : Node_Access;
begin
-- Ada.Text_IO.Put_Line ("Bibi" & Item.Class'img);
case Item.Class is
when Unary_Plus | Unary_Minus =>
Result := new Node_Type (Item.Class);
Result.Term := Replace (Item.Term, Var_Name, Value);
pragma Assert (Result.Class = Item.Class);
when Sum | Sub | Mult | Div =>
Result := new Node_Type (Item.Class);
Result.Left := Replace (Item.Left, Var_Name, Value);
Result.Right := Replace (Item.Right, Var_Name, Value);
pragma Assert (Result.Class = Item.Class);
when Fun_Call =>
Result := new Node_Type (Item.Class);
Result.Fun_Name := Item.Fun_Name;
Result.N_Params := Item.N_Params;
for I in 1 .. Result.N_Params loop
Result.Parameters (I) := Replace (Item.Parameters (I), Var_Name, Value);
end loop;
pragma Assert (Result.Class = Fun_Call);
when Var =>
-- Ada.Text_Io.Put_Line ("'" & To_String (Var_Name) & "' '"
-- & To_String (Item.Var_Name) & "'");
if Item.Var_Name = Var_Name then
Result := Duplicate (Value);
else
Result := Duplicate (Item);
end if;
when Const =>
Result := Duplicate (Item);
end case;
-- Ada.Text_IO.Put_Line ("Bobo" & Item.Class'img);
return Result;
end Replace;
-------------
-- Replace --
-------------
function Replace
(Item : Symbolic_Expression;
Var_Name : Variable_Name;
Value : Symbolic_Expression)
return Symbolic_Expression
is
begin
return Symbolic_Expression'
(Controlled with
Expr => Replace (Item => Item.Expr,
Var_Name => Var_Name,
Value => Value.Expr));
end Replace;
function Replace (Item : Symbolic_Expression;
Table : Variable_Tables.Map)
return Symbolic_Expression
is
Result : Symbolic_Expression := Item;
procedure Process (Name : Variable_Name) is
use Variable_Tables;
Pos : constant Cursor := Table.Find (Name);
begin
if Pos = No_Element then
return;
else
Result := Replace (Item => Result,
Var_Name => Name,
Value => Element (Pos));
end if;
end Process;
begin
Iterate_On_Vars (Item, Process'Access);
return Result;
end Replace;
function Replace (Item : Symbolic_Expression;
Var_Name : Variable_Name;
Value : Scalar_Type)
return Symbolic_Expression
is
begin
return Symbolic_Expression'
(Controlled with
Expr => Replace (Item.Expr, Var_Name, To_Expr(Value).Expr));
end Replace;
function Free_Variables (Item : Symbolic_Expression)
return Variable_Sets.Set
is
procedure Fill_List (Item : Node_Access;
Names : in out Variable_Sets.Set)
is
begin
case Item.Class is
when Unary_Plus | Unary_Minus =>
Fill_List (Item.Term, Names);
when Sum | Sub | Mult | Div =>
Fill_List (Item.Left, Names);
Fill_List (Item.Right, Names);
when Fun_Call =>
for I in 1 .. Item.N_Params loop
Fill_List (Item.Parameters (I), Names);
end loop;
when Var =>
Names.Include (Item.Var_Name);
when Const =>
null;
end case;
end Fill_List;
Result : Variable_Sets.Set;
begin
Fill_List (Item.Expr, Result);
return Result;
end Free_Variables;
---------------------
-- Iterate_On_Vars --
---------------------
procedure Iterate_On_Vars
(Item : Symbolic_Expression;
Process : access procedure (Var_Name : Variable_Name))
is
use Variable_Sets;
-- Variables : Var_Lists.Set :=
procedure Call (Pos : Cursor) is
begin
Process (Element (Pos));
end Call;
begin
Free_Variables (Item).Iterate (Call'Access);
end Iterate_On_Vars;
---------------
-- Normalize --
---------------
-- procedure Normalize (Item : in out Symbolic_Expression) is
-- pragma Unreferenced (Item);
-- begin
-- -- Generated stub: replace with real body!
-- pragma Compile_Time_Warning (Standard.False, "Normalize unimplemented");
-- raise Program_Error with "Unimplemented procedure Normalize";
-- end Normalize;
function Duplicate (Item : Node_Access) return Node_Access
is
Result : constant Node_Access := new Node_Type (Item.Class);
begin
if Item = null then
return null;
end if;
case Item.Class is
when Unary_Plus | Unary_Minus =>
Result.Term := Duplicate (Item.Term);
when Sum | Sub | Mult | Div =>
Result.Left := Duplicate (Item.Left);
Result.Right := Duplicate (Item.Right);
when Fun_Call =>
Result.Fun_Name := Item.Fun_Name;
Result.N_Params := Item.N_Params;
for I in 1 .. Result.N_Params loop
Result.Parameters (I) := Duplicate (Item.Parameters (I));
end loop;
when Var =>
Result.Var_Name := Item.Var_Name;
when Const =>
Result.Value := Item.Value;
end case;
return Result;
end Duplicate;
procedure Free (Item : in out Node_Access)
is
procedure Dealloc is
new Ada.Unchecked_Deallocation (Object => Node_Type,
Name => Node_Access);
begin
if Item = null then
return;
end if;
pragma Assert (Item /= null);
case Item.Class is
when Unary_Plus | Unary_Minus =>
Free (Item.Term);
when Sum | Sub | Mult | Div =>
Free (Item.Left);
Free (Item.Right);
when Fun_Call =>
for I in 1 .. Item.N_Params loop
Free (Item.Parameters (I));
end loop;
when Var =>
null;
when Const =>
null;
end case;
Dealloc (Item);
end Free;
function Dump (Item : Node_Access;
Level : Natural)
return String
is
use Ada.Strings.Fixed;
use Ada.Strings.Unbounded;
function Head (X : String) return Unbounded_String is
begin
return To_Unbounded_String (((Level * 3) * " ") & X);
end Head;
CRLF : constant String := Character'Val (13) & Character'Val (10);
Result : Unbounded_String;
begin
case Item.Class is
when Unary_Plus =>
Result := Head ("@+") & CRLF & Dump (Item.Term, Level + 1);
when Unary_Minus =>
Result := Head ("@-") & CRLF & Dump (Item.Term, Level + 1);
when Sum =>
Result := Head ("+")
& CRLF & Dump (Item.Left, Level + 1)
& CRLF & Dump (Item.Right, Level + 1);
when Sub =>
Result := Head ("-")
& CRLF & Dump (Item.Left, Level + 1)
& CRLF & Dump (Item.Right, Level + 1);
when Mult =>
Result := Head ("*")
& CRLF & Dump (Item.Left, Level + 1)
& CRLF & Dump (Item.Right, Level + 1);
when Div =>
Result := Head ("/")
& CRLF & Dump (Item.Left, Level + 1)
& CRLF & Dump (Item.Right, Level + 1);
when Fun_Call =>
Result := Head ("Call " & ID_Image (Item.Fun_Name));
for I in 1 .. Item.N_Params loop
Result := Result & CRLF & Dump (Item.Parameters (I), Level + 1);
end loop;
when Var =>
Result := Head ("Var ") & "(" & ID_Image (Item.Var_Name) & ")";
when Const =>
Result := Head ("Const ") & Image (Item.Value);
end case;
return To_String (Result);
end Dump;
function Dump (Item : Symbolic_Expression) return String
is
begin
return Dump (Item.Expr, 0);
end Dump;
overriding procedure Initialize (Item : in out Symbolic_Expression)
is
begin
Item.Expr := null;
end Initialize;
overriding procedure Finalize (Item : in out Symbolic_Expression)
is
begin
if Item.Expr /= null then
Free (Item.Expr);
end if;
end Finalize;
overriding procedure Adjust (Item : in out Symbolic_Expression)
is
begin
if Item.Expr /= null then
Item.Expr := Duplicate (Item.Expr);
end if;
end Adjust;
end Symbolic_Expressions;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E X P _ C H 3 --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Expand routines for chapter 3 constructs
with Types; use Types;
with Elists; use Elists;
with Uintp; use Uintp;
package Exp_Ch3 is
procedure Expand_N_Object_Declaration (N : Node_Id);
procedure Expand_N_Subtype_Indication (N : Node_Id);
procedure Expand_N_Variant_Part (N : Node_Id);
procedure Expand_N_Full_Type_Declaration (N : Node_Id);
procedure Expand_Previous_Access_Type (Def_Id : Entity_Id);
-- For a full type declaration that contains tasks, or that is a task,
-- check whether there exists an access type whose designated type is an
-- incomplete declarations for the current composite type. If so, build the
-- master for that access type, now that it is known to denote an object
-- with tasks.
procedure Expand_Record_Extension (T : Entity_Id; Def : Node_Id);
-- Add a field _parent in the extension part of the record
procedure Build_Access_Subprogram_Wrapper_Body
(Decl : Node_Id;
New_Decl : Node_Id);
-- Build the wrapper body, which holds the indirect call through an access-
-- to-subprogram, and whose expansion incorporates the contracts of the
-- access type declaration. Called from Build_Access_Subprogram_Wrapper.
-- Building the wrapper is done during analysis to perform proper semantic
-- checks on the relevant aspects. The wrapper body could be simplified to
-- a null body when expansion is disabled ???
procedure Build_Discr_Checking_Funcs (N : Node_Id);
-- Builds function which checks whether the component name is consistent
-- with the current discriminants. N is the full type declaration node,
-- and the discriminant checking functions are inserted after this node.
function Build_Initialization_Call
(Loc : Source_Ptr;
Id_Ref : Node_Id;
Typ : Entity_Id;
In_Init_Proc : Boolean := False;
Enclos_Type : Entity_Id := Empty;
Discr_Map : Elist_Id := New_Elmt_List;
With_Default_Init : Boolean := False;
Constructor_Ref : Node_Id := Empty) return List_Id;
-- Builds a call to the initialization procedure for the base type of Typ,
-- passing it the object denoted by Id_Ref, plus additional parameters as
-- appropriate for the type (the _Master, for task types, for example).
-- Loc is the source location for the constructed tree. In_Init_Proc has
-- to be set to True when the call is itself in an init proc in order to
-- enable the use of discriminals. Enclos_Type is the enclosing type when
-- initializing a component in an outer init proc, and it is used for
-- various expansion cases including the case where Typ is a task type
-- which is an array component, the indexes of the enclosing type are
-- used to build the string that identifies each task at runtime.
--
-- Discr_Map is used to replace discriminants by their discriminals in
-- expressions used to constrain record components. In the presence of
-- entry families bounded by discriminants, protected type discriminants
-- can appear within expressions in array bounds (not as stand-alone
-- identifiers) and a general replacement is necessary.
--
-- Ada 2005 (AI-287): With_Default_Init is used to indicate that the
-- initialization call corresponds to a default initialized component
-- of an aggregate.
--
-- Constructor_Ref is a call to a constructor subprogram. It is currently
-- used only to support C++ constructors.
function Build_Variant_Record_Equality
(Typ : Entity_Id;
Body_Id : Entity_Id;
Param_Specs : List_Id) return Node_Id;
-- Build the body of the equality function Body_Id for the untagged variant
-- record Typ with the given parameters specification list.
procedure Ensure_Activation_Chain_And_Master (Obj_Decl : Node_Id);
-- If tasks are being declared (or might be declared) by the given object
-- declaration then ensure to have an activation chain defined for the
-- tasks (has no effect if we already have one), and also that a Master
-- variable is established (and that the appropriate enclosing construct
-- is established as a task master).
function Freeze_Type (N : Node_Id) return Boolean;
-- This function executes the freezing actions associated with the given
-- freeze type node N and returns True if the node is to be deleted. We
-- delete the node if it is present just for front end purpose and we don't
-- want Gigi to see the node. This function can't delete the node itself
-- since it would confuse any remaining processing of the freeze node.
function Get_Simple_Init_Val
(Typ : Entity_Id;
N : Node_Id;
Size : Uint := No_Uint) return Node_Id;
-- Build an expression that represents the required initial value of type
-- Typ for which predicate Needs_Simple_Initialization is True. N is a node
-- whose source location is used in the construction of the expression.
-- Size is used as follows:
--
-- * If the size of the object to be initialized it is known, it should
-- be passed to the routine.
--
-- * If the size is unknown or is zero, then the Esize of Typ is used as
-- an estimate of the size.
--
-- The object size is needed to prepare a known invalid value for use by
-- Normalize_Scalars. A call to this routine where Typ denotes a scalar
-- type is valid only when Normalize_Scalars or Initialize_Scalars is
-- active, or if N is the node for a 'Invalid_Value attribute node.
procedure Init_Secondary_Tags
(Typ : Entity_Id;
Target : Node_Id;
Init_Tags_List : List_Id;
Stmts_List : List_Id;
Fixed_Comps : Boolean := True;
Variable_Comps : Boolean := True);
-- Ada 2005 (AI-251): Initialize the tags of the secondary dispatch tables
-- of Typ. The generated code referencing tag fields of Target is appended
-- to Init_Tags_List and the code required to complete the elaboration of
-- the dispatch tables of Typ is appended to Stmts_List. If Fixed_Comps is
-- True then the tag components located at fixed positions of Target are
-- initialized; if Variable_Comps is True then tags components located at
-- variable positions of Target are initialized.
function Make_Tag_Assignment (N : Node_Id) return Node_Id;
-- An object declaration that has an initialization for a tagged object
-- requires a separate reassignment of the tag of the given type, because
-- the expression may include an unchecked conversion. This tag assignment
-- is inserted after the declaration, but if the object has an address
-- clause the assignment is handled as part of the freezing of the object,
-- see Check_Address_Clause.
end Exp_Ch3;
|
--
-- This library is free software; you can redistribute it and/or modify
-- it under the terms of the GNU Library General Public License as
-- published by the Free Software Foundation; either version 3 of the
-- License; or (at your option) any later version.
-- This package provides stack abstractions that have a capacity limited only
-- by available memory. These stacks are not thread-safe.
generic
type Element is private;
package Unbounded_Sequential_Stacks is
type Stack is tagged limited private;
procedure Push (Onto : in out Stack; Item : in Element);
procedure Pop (From : in out Stack; Item : out Element);
procedure Pop (This : in out Stack);
-- Removes from This stack the last element added
procedure Clear (This : in out Stack);
-- Removes from This stack the all elements
Underflow : exception;
function Depth (This : Stack) return Natural;
function Empty (This : Stack) return Boolean;
type Reference is access all Element;
function Top (This : Stack) return Reference;
-- Provides access to the top element in the stack (the last element pushed)
-- without requiring that element to be first removed from the stack
private
type Node;
type List is access Node;
type Node is
record
Value : aliased Element;
Next : List;
end record;
type Stack is tagged limited
record
Head : List;
Count : Natural := 0;
end record;
end Unbounded_Sequential_Stacks;
|
pragma License (Unrestricted);
with Ada.Numerics.Long_Complex_Types;
with Ada.Text_IO.Complex_IO;
package Ada.Long_Complex_Text_IO is
new Text_IO.Complex_IO (Numerics.Long_Complex_Types);
|
with Ada.Exceptions,
Ada.Integer_Text_IO,
Ada.Text_IO;
with Utils;
procedure Main is
use Ada.Text_IO;
use Utils;
File : File_Type;
Result : Natural := Natural'First;
begin
Get_File (File);
if End_Of_File (File) then
raise Program_Error with "Empty file";
end if;
-- Resolve puzzle while exploring file
while not End_Of_File (File) loop
declare
use Ada.Integer_Text_IO;
Line : constant String := Get_Line (File);
First : Positive := Line'First;
Last : Positive := Line'First;
Last_Index : Positive := Line'First;
After_Pipe : Boolean := False;
Current_Size : Natural := Natural'First;
begin
while Last <= Line'Last loop
if After_Pipe then
-- Process data
if Line (Last) = ' ' then
Current_Size := Last - First;
First := Last + 1;
if Current_Size in 2 .. 4 or Current_Size = 7 then
Result := Result + 1;
end if;
elsif Last = Line'Last then
Current_Size := Last - First + 1;
First := Last + 1;
if Current_Size in 2 .. 4 or Current_Size = 7 then
Result := Result + 1;
end if;
end if;
Last := Last + 1;
elsif Line (Last) = '|' then
After_Pipe := True;
Last := Last + 2;
First := Last;
else
Last := Last + 1;
end if;
end loop;
end;
end loop;
Put ("Result: ");
Ada.Integer_Text_IO.Put (Result, Width => 0);
New_Line;
Close_If_Open (File);
exception
when Occur : others =>
Close_If_Open (File);
raise;
end Main;
|
-- Copyright (c) 2021 Bartek thindil Jasicki <thindil@laeran.pl>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Tcl.Lists; use Tcl.Lists;
with Tcl.Strings; use Tcl.Strings;
with Tk.TopLevel; use Tk.TopLevel;
with Tk.Widget; use Tk.Widget;
-- ****h* Tk/Wm
-- FUNCTION
-- Provide bindings for Tk command wm (communication with the window manager)
-- SOURCE
package Tk.Wm is
-- ****
--## rule off REDUCEABLE_SCOPE
-- ****t* Wm/Wm.Window_Manager_Types
-- FUNCTION
-- Type of current window manager
-- OPTIONS
-- X_11 - Used on the most Unix systems like Linux, BSD, etc
-- WINDOWS - Microsoft Windows
-- MACOSX - Apple Mac OS X
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Window_Manager_Types is (X_11, WINDOWS, MACOSX) with
Default_Value => X_11;
-- ****
-- ****d* Wm/Wm.Default_Window_Manager
-- FUNCTION
-- Default window manager
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Default_Window_Manager: constant Window_Manager_Types := X_11;
-- ****
-- ****t* Wm/Wm.Alpha_Type
-- FUNCTION
-- Type used to set alpha value for the selected Tk widget. Values below
-- 0.0 are interpreted as empty value. 0.0 means full transparency.
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Alpha_Type is digits 2 range -1.0 .. 1.0 with
Default_Value => 1.0;
-- ****
-- ****d* Wm/Wm.Default_Alpha
-- FUNCTION
-- Default alpha value for Tk widget (not transparent)
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Default_Alpha: constant Alpha_Type := 1.0;
-- ****
-- ****t* Wm/Wm.Window_Types
-- FUNCTION
-- Available types of widget. Used only on X11 and may be not supported by
-- all windows managers there
-- OPTIONS
-- DESKTOP - Desktop window
-- DOCK - Dock/panel window
-- TOOLBAR - Toolbar window that should acting on behalf of another
-- window (transient to it)
-- MENU - Torn-off menu that should acting on behalf of another
-- window (transient to it)
-- UTILITY - Utility window (example: palette, toolbox) that should
-- acting on behalf of another window (transient to it)
-- SPLASH - Splash screen, displayed during application start up
-- DIALOG - Dialog window that should acting on behalf of another
-- window (transient to it)
-- DROPDOWN_MENU - Menu summoned from a menu bar, which should be also
-- override-redirected
-- POPUP_MENU - Popup menu, which should be also override-redirected
-- TOOLTIP - Tooltip window, which should be also override-redirected
-- NOTIFICATION - Notification window, provides information about some
-- events, which should be also override-redirected
-- COMBO - Drop-down list of a combobox widget which should be also
-- override-redirected
-- DND - Widget represents something being dragged, which should
-- be also override-redirected
-- NORMAL - Widget without special intepretation
-- NONE - Used mostly to reset the current type of the widget
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Window_Types is
(DESKTOP, DOCK, TOOLBAR, MENU, UTILITY, SPLASH, DIALOG, DROPDOWN_MENU,
POPUP_MENU, TOOLTIP, NOTIFICATION, COMBO, DND, NORMAL, NONE) with
Default_Value => NONE;
-- ****
-- ****d* Wm/Wm.Default_Window_Type
-- FUNCTION
-- Default type of Tk widget (no type)
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Default_Window_Type: constant Window_Types := NONE;
-- ****
-- ****s* Wm/Wm.Window_Attributes_Data
-- FUNCTION
-- Data structure used to set or get Tk widget attributes. Depends on
-- currently used window manager.
-- PARAMETERS
-- Alpha - Alpha transparency value for the selected Tk widget
-- from 0.0 (full transparent) to 1.0 (opaque). Any
-- value below 0.0 will be ignored
-- Full_Screen - The widget takes the whole screen
-- Topmost - The widget is displayed above all other windows
-- Window_Type - The type of widget (X11 only)
-- Zoomed - The widget is maximized (X11 only)
-- Disabled - The widget is in the disabled state (Windows only)
-- Tool_Window - The widget is tool window (Windows only)
-- Transparent_Color - The color used for the widget transparency (Windows
-- only)
-- Modified - The widget is in the modified state (Mac OS X only)
-- Notify - The widget notification state (Mac OS X only)
-- Title_Path - The path to the widget proxy icon (Mac OS X only)
-- Transparent - Makes the widget content are transparent (Mac OS X
-- only)
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Window_Attributes_Data
(Wm_Type: Window_Manager_Types := Default_Window_Manager) is record
Alpha: Alpha_Type;
Full_Screen: Extended_Boolean;
Topmost: Extended_Boolean;
case Wm_Type is
when X_11 =>
Window_Type: Window_Types;
Zoomed: Extended_Boolean;
when WINDOWS =>
Disabled: Extended_Boolean;
Tool_Window: Extended_Boolean;
Transparent_Color: Tcl_String;
when MACOSX =>
Modified: Extended_Boolean;
Notify: Extended_Boolean;
Title_Path: Tcl_String;
Transparent: Extended_Boolean;
end case;
end record;
-- ****
-- ****d* Wm/Wm.Empty_Window_Attributes
-- FUNCTION
-- Empty attributes for Tk widget
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Empty_Window_Attributes: constant Window_Attributes_Data := (others => <>);
-- ****
-- ****t* Wm/Wm.Window_Atrributes_Type
-- FUNCTION
-- All available types of window's attributes. Used mostly to set them
-- OPTIONS
-- FULLSCREEN - The widget takes the whole screen
-- TOPMOST - The widget is displayed above all other windows
-- ZOOMED - The widget is maximized (X11 only)
-- DISABLED - The widget is in the disabled state (Windows only)
-- TOOLWINDOW - The widget is tool window (Windows only)
-- TRANSPARENTCOLOR - The color used for the widget transparency (Windows
-- only)
-- MODIFIED - The widget is in the modified state (Mac OS X only)
-- NOTIFY - The widget notification state (Mac OS X only)
-- TITLEPATH - The path to the widget proxy icon (Mac OS X only)
-- TRANSPARENT - Makes the widget content are transparent (Mac OS X
-- only)
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Window_Atrributes_Type is
(FULLSCREEN, TOPMOST, ZOOMED, DISABLED, TOOLWINDOW, TRANSPARENTCOLOR,
MODIFIED, NOTIFY, TITLEPATH, TRANSPARENT) with
Default_Value => FULLSCREEN;
-- ****
-- ****d* Tk.Wm/Default_Window_Attribute
-- FUNCTION
-- Default window attribute to set
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Default_Window_Attribute: constant Window_Atrributes_Type := FULLSCREEN;
-- ****
-- ****t* Wm/Wm.Focus_Model_Types
-- FUNCTION
-- Types of Tk widget focus models. Active means that widget will take
-- focus even from the other applications.
-- OPTIONS
-- ACTIVE - The widget will claim the input focus for self and its
-- descendants even if other applications have it.
-- PASSIVE - The widget will not claim the input focus from other
-- applications.
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Focus_Model_Types is (ACTIVE, PASSIVE) with
Default_Value => PASSIVE;
-- ****
-- ****d* Wm/Wm.Default_Focus_Model
-- FUNCTION
-- Default focus model for Tk widget
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Default_Focus_Model: constant Focus_Model_Types := PASSIVE;
-- ****
-- ****s* Wm/Wm.Window_Grid_Geometry
-- FUNCTION
-- Data structure used in setting the Tk widget grid geometry
-- PARAMETERS
-- Base_Width - Number of grid units corresponding to the Tk widget
-- width in pixels
-- Base_Height - Number of grid units corresponding to the Tk widget
-- height in pixels
-- Width_Inc - Number of pixels in one width grid unit
-- Height_Inc - Number of pixels in one height grid unit
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Window_Grid_Geometry is record
Base_Width: Natural := 0;
Base_Height: Natural := 0;
Width_Inc: Natural := 0;
Height_Inc: Natural := 0;
end record;
-- ****
-- ****d* Wm/Wm.Empty_Window_Grid_Geometry
-- FUNCTION
-- Empty values for Tk widget grid geometry
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Empty_Window_Grid_Geometry: constant Window_Grid_Geometry :=
Window_Grid_Geometry'(others => 0);
-- ****
-- ****s* Wm/Wm.Aspect_Data
-- FUNCTION
-- Data structure used to set the Tk widget aspects ratios
-- PARAMETERS
-- Min_Numer - The minimum number for width/height for couting aspect
-- ratios of Tk widget
-- Min_Denom - The minumum denom for width/height for couting aspect
-- ratios of Tk widget
-- Max_Numer - The maximum number for width/height for couting aspect
-- ratios of Tk widget
-- Max_Denom - The maximum denom for width/height for couting aspect
-- ratios of Tk widget
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Aspect_Data is record
Min_Numer: Natural := 0;
Min_Denom: Natural := 0;
Max_Numer: Natural := 0;
Max_Denom: Natural := 0;
end record;
-- ****
-- ****d* Wm/Wm.Empty_Aspect_Data
-- FUNCTION
-- Empty values for aspect ratios of Tk widget
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Empty_Aspect_Data: constant Aspect_Data := (others => 0);
-- ****
-- ****s* Wm/Wm.Window_Size
-- FUNCTION
-- Data structure used to manipulate maximum and minimum size of the Tk
-- widget
-- PARAMETERS
-- Width - For gridded windows, width size in grid units for the selected
-- Tk widget. Otherwise, size in pixels.
-- Height - For gridded windows, height size in grid units for the selected
-- Tk widget. Otherwise, size in pixels.
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Window_Size is record
Width: Natural := 0;
Height: Natural := 0;
end record;
-- ****
-- ****d* Wm/Wm.Empty_Window_Size
-- FUNCTION
-- Empty values for the Tk widget size
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Empty_Window_Size: constant Window_Size := (others => 0);
-- ****
-- ****t* Wm/Wm.Position_From_Value
-- FUNCTION
-- Type used to set source of position and size.
-- OPTIONS
-- USER - Position or size was requested by the user
-- PROGRAM - Position or size was requested by the program
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Position_From_Value is (USER, PROGRAM) with
Default_Value => PROGRAM;
-- ****
-- ****d* Wm/Wm.Default_Position_From
-- FUNCTION
-- Default value for Position_From type
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Default_Position_From: constant Position_From_Value := PROGRAM;
-- ****
-- ****s* Wm/Wm.Resizable_Data
-- FUNCTION
-- Data structure used to manipulate the Tk widget resizability by the user
-- PARAMETERS
-- Width - The Tk widget is resizable horizontaly
-- Height - The Tk widget is resizable vertically
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Resizable_Data is record
Width: Boolean := True;
Height: Boolean := True;
end record;
-- ****
-- ****d* Wm/Wm.Default_Resizable_Data
-- FUNCTION
-- Default value for Tk widget resizability
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Default_Resizable_Data: constant Resizable_Data := (others => True);
-- ****
-- ****t* Wm/Wm.Window_States
-- FUNCTION
-- Types of the Tk widget states. ZOOMED is avaliable only on Window and
-- Mac OS X
-- OPTIONS
-- NORMAL - Standard state of the widget
-- ICONIC - The widget was iconified
-- WITHDRAWN - The widget was withdrawed
-- ICON - The widget is used as icon for another widget. Cannot be set
-- ZOOMED - Availble only on Windows and Mac OS X. The widget was
-- maximized
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Window_States is (NORMAL, ICONIC, WITHDRAWN, ICON, ZOOMED) with
Default_Value => NORMAL;
-- ****
-- ****d* Wm/Wm.Default_Window_State
-- FUNCTION
-- The default state for the Tk widget
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Default_Window_State: constant Window_States := NORMAL;
-- ****
-- ****f* Wm/Wm.Set_Aspect
-- FUNCTION
-- Set the aspect ratio for the selected Tk_Toplevel widget
-- PARAMETERS
-- Window - Tk_Toplevel which aspect ratio will be set
-- Min_Numer - The minimum number for width/height for couting aspect
-- ratios of Tk_Toplevel
-- Min_Denom - The minumum denom for width/height for couting aspect
-- ratios of Tk_Toplevel
-- Max_Numer - The maximum number for width/height for couting aspect
-- ratios of Tk_Toplevel
-- Max_Denom - The maximum denom for width/height for couting aspect
-- ratios of Tk_Toplevel
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the aspect ratio for the main Tk window to 10 10 20 20
-- Set_Aspect(Get_Main_Window, 10, 10, 20, 20);
-- SEE ALSO
-- Wm.Get_Aspect
-- COMMANDS
-- wm aspect Window Min_Numer Min_Denom Max_Numer Max_Denom
-- SOURCE
procedure Set_Aspect
(Window: Tk_Toplevel;
Min_Numer, Min_Denom, Max_Numer, Max_Denom: Natural) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Aspect", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Aspect
-- FUNCTION
-- Get the aspect ratio for the selected Tk_Toplevel widget
-- PARAMETERS
-- Window - Tk_Toplevel which aspect ratio will be get
-- RESULT
-- Aspect_Data record with current aspect ratio for the selected
-- Tk_Toplevel
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the aspect ratio for the main Tk window
-- Aspect_Ratio: constant Aspect_Data := Get_Aspect(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Aspect
-- COMMANDS
-- wm aspect Window
-- SOURCE
function Get_Aspect(Window: Tk_Toplevel) return Aspect_Data with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Aspect2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Attributes
-- FUNCTION
-- Get the platform dependent attributes for the selected Tk widget
-- PARAMETERS
-- Window - Tk_Widget which parameters will be get
-- RESULT
-- Window_Attributes_Data record with platform dependent attributes of
-- the selected Tk_Widget
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the attributes of main Tk window on Linux
-- Window_Attributes: constant Window_Attributes_Data(X_11) := Get_Attributes(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Attributes
-- COMMANDS
-- wm attributes Window
-- SOURCE
function Get_Attributes
(Window: Tk_Widget) return Window_Attributes_Data with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Get_Attributes", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Attributes
-- FUNCTION
-- Set the platform dependent attributes for the selected Tk widget
-- PARAMETERS
-- Window - Tk_Widget which parameters will be set
-- Attributes_Data - The parameters to set
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the Tk main window on Linux as full screen window
-- Set_Attributes(Get_Main_Window, (Full_Screen => True, others => <>));
-- SEE ALSO
-- Wm.Get_Attributes
-- COMMANDS
-- wm attributes Window Atributes_Data
-- SOURCE
procedure Set_Attributes
(Window: Tk_Widget; Attributes_Data: Window_Attributes_Data) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Set_Attributes", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Attribute
-- FUNCTION
-- Get the selected attribute as a selected type of the selected Tk_Widget.
-- It is mostly used in Wm.Get_Attributes and Wm.Set_Attributes
-- subprograms, which generally should be prefered to manipulate widgets
-- attributes.
-- Window - The Tk_Widget which attribute will be get
-- Name - The name of the attribute to get
-- RESULT
-- The value of the selected attribute of the selected Tk_Widget
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the transparent color on Windows for the main Tk window
-- Transparent_Color: constant Tcl_String := Get_Attribute(Get_Main_Window, "transparentcolor");
-- COMMANDS
-- wm attributes Window Name
-- SOURCE
function Get_Attribute
(Window: Tk_Widget; Name: Window_Atrributes_Type) return Tcl_String is
(To_Tcl_String
(Source =>
Tcl_Eval
(Tcl_Script =>
"wm attributes " & Tk_Path_Name(Widgt => Window) & " -" &
To_Lower(Item => Window_Atrributes_Type'Image(Name)),
Interpreter => Tk_Interp(Widgt => Window))
.Result)) with
Pre => (Window /= Null_Widget and Name in TRANSPARENTCOLOR | TITLEPATH)
and then Window_Atrributes_Type'Image(Name)'Length <= 16
and then
Tk_Path_Name(Widgt => Window)'Length +
Window_Atrributes_Type'Image(Name)'Length <
Long_Long_Integer(Integer'Last - 32),
Test_Case => (Name => "Test_Wm_Get_Attribute", Mode => Nominal);
function Get_Attribute
(Window: Tk_Widget; Name: Window_Atrributes_Type)
return Extended_Boolean with
Pre => Window /= Null_Widget and
Name in FULLSCREEN | ZOOMED | DISABLED | TOOLWINDOW | MODIFIED | NOTIFY |
TRANSPARENT,
Test_Case => (Name => "Test_Wm_Get_Attribute2", Mode => Nominal);
function Get_Attribute(Window: Tk_Widget) return Alpha_Type with
Pre => (Window /= Null_Widget and Get_Interpreter /= Null_Interpreter)
and then Tk_Path_Name(Widgt => Window)'Length < Integer'Last - 21,
Test_Case => (Name => "Test_Wm_Get_Attribute3", Mode => Nominal);
function Get_Attribute(Window: Tk_Widget) return Window_Types with
Pre => (Window /= Null_Widget and Get_Interpreter /= Null_Interpreter)
and then Tk_Path_Name(Widgt => Window)'Length < Integer'Last - 20,
Test_Case => (Name => "Test_Wm_Get_Attribute4", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Client
-- FUNCTION
-- Get the value of Window property WM_CLIENT_MACHINE
-- PARAMETERS
-- Window - Tk_Widget which the property will be get
-- RESULT
-- String with value of the property
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the property for the Tk main window
-- Client_Machine: constant String := Get_Client(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Client
-- COMMANDS
-- wm client Window
-- SOURCE
function Get_Client(Window: Tk_Widget) return String is
(Tcl_Eval
(Tcl_Script => "wm client " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window))
.Result) with
Pre => Window /= Null_Widget
and then Tk_Path_Name(Widgt => Window)'Length < Integer'Last - 10,
Test_Case => (Name => "Test_Wm_Client", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Client
-- FUNCTION
-- Set the value of Window property WM_CLIENT_MACHINE
-- PARAMETERS
-- Window - Tk_Widget which the property will be set
-- Name - The host on which the application is executing
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the property for the Tk main window to Localhost
-- Set_Client(Get_Main_Window, To_Tcl_String("Localhost"));
-- SEE ALSO
-- Wm.Get_Client
-- COMMANDS
-- wm client Window Name
-- SOURCE
procedure Set_Client(Window: Tk_Widget; Name: Tcl_String) with
Pre => Window /= Null_Widget and Length(Source => Name) > 0,
Test_Case => (Name => "Test_Wm_Client2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Color_Map_Windows
-- FUNCTION
-- Get the list of Tk widgets which have different color maps than their
-- parents (property WM_COLORMAP_WINDOWS)
-- PARAMETERS
-- Window - Tk_Widget which the list of the Tk widgets will be get
-- RESULT
-- Array_List with the names of Tk widgets which have different color
-- maps than their parents
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the list of widgets for the Tk main window
-- Different_Colors: constant Array_List := Get_Color_Map_Windows(Get_Main_Window);
-- SEE ALSO
-- Set_Color_Map_Windows
-- COMMANDS
-- wm colormapwindows Window
-- SOURCE
function Get_Color_Map_Windows(Window: Tk_Widget) return Array_List with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Color_Map_Windows", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Color_Map_Windows
-- FUNCTION
-- Set the list of Tk widgets which have different color maps than their
-- parents (property WM_COLORMAP_WINDOWS)
-- PARAMETERS
-- Window - Tk_Widget which the list of the Tk widgets will be set
-- Widgets - The list of Tk widgets to set
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the list of widgets to My_Label and My_Button for the Tk main window
-- Set_Color_Map_Windows(Get_Main_Window, (MyLabel, My_Button));
-- SEE ALSO
-- Get_Color_Map_Windows
-- COMMANDS
-- wm colormapwindows Window Widgets
-- SOURCE
procedure Set_Color_Map_Windows
(Window: Tk_Widget; Widgets: Widgets_Array) with
Pre => Window /= Null_Widget and Widgets /= Empty_Widgets_Array,
Test_Case => (Name => "Test_Wm_Color_Map_Windows2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Command
-- FUNCTION
-- Get the value of the Tk_Widget property WM_COMMAND
-- PARAMETERS
-- Window - Tk_Widget which the property will be get
-- RESULT
-- Tcl_String with the value of the property for the selected Tk_Widget
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the property for the Tk main window
-- Wm_Command: constant Tcl_String := Get_Command(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Command
-- COMMANDS
-- wm command Window
-- SOURCE
function Get_Command(Window: Tk_Widget) return Tcl_String is
(To_Tcl_String
(Source =>
Tcl_Eval
(Tcl_Script => "wm command " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window))
.Result)) with
Pre => Window /= Null_Widget
and then Tk_Path_Name(Widgt => Window)'Length < Integer'Last - 11,
Test_Case => (Name => "Test_Wm_Command", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Command
-- FUNCTION
-- Set the value of the Tk_Widget property WM_COMMAND
-- PARAMETERS
-- Window - Tk_Widget which the property will be set
-- Wm_Command - The command which will be set
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the property for the Tk main window
-- Set_Command(Get_Main_Window, To_Tcl_String("puts hello"));
-- SEE ALSO
-- Wm.Set_Command
-- COMMANDS
-- wm command Window Wm_Command
-- SOURCE
procedure Set_Command(Window: Tk_Widget; Wm_Command: Tcl_String) with
Pre => Window /= Null_Widget and Length(Source => Wm_Command) > 0,
Test_Case => (Name => "Test_Wm_Command2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Deiconify
-- FUNCTION
-- Arrange the selected Tk_Widget to be displayed in normal
-- (non-iconified) form.
-- PARAMETERS
-- Window - Tk_Widget to deiconify
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Deicoinify the main Tk window
-- Deiconify(Get_Main_Window);
-- SEE ALSO
-- Wm.Iconify
-- COMMANDS
-- wm deiconify Window
-- SOURCE
procedure Deiconify(Window: Tk_Widget) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Deiconify", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Focus_Model
-- FUNCTION
-- Get the focus model for the selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which focus model will be get
-- RESULT
-- The current focus model of the selected Tk_Widget.
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the focus model for the Tk main window
-- Focus: constant Focus_Model_Types := Get_Focus_Model(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Focus_Model
-- COMMANDS
-- wm focusmodel Window
-- SOURCE
function Get_Focus_Model(Window: Tk_Widget) return Focus_Model_Types with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Focus_Model", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Focus_Model
-- FUNCTION
-- Set the focus model for the selected Tk_Widget
-- PARAMETERS
-- Window - The Tk_Widget which the focus model will be set
-- Model - The new value for the focus model
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the focus model of the Tk main window to ACTIVE
-- Set_Focus_Model(Get_Main_Window, ACTIVE);
-- SEE ALSO
-- Wm.Get_Focus_Model
-- COMMANDS
-- wm focusmodel Window Model
-- SOURCE
procedure Set_Focus_Model(Window: Tk_Widget; Model: Focus_Model_Types) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Focus_Model2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Forget
-- FUNCTION
-- Unmap the selected Tk_Widget from the screen. It will be no longer
-- managed by the windows manager
-- PARAMETERS
-- Window - Tk_Widget to forget
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Unmap the main Tk window
-- Forget(Get_Main_Window);
-- COMMANDS
-- wm forget Window
-- SOURCE
procedure Forget(Window: Tk_Widget) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Forget", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Frame
-- FUNCTION
-- Get the parent frame for the selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which parent frame will be get
-- RESULT
-- If Window was reparented to the other frame by windows manager,
-- returns that frame Tk_Window identifier. Otherwise return the
-- Window Tk_Window identifier
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the parent frame for Tk main window
-- Parent_Frame: constant Tk_Window := Get_Frame(Get_Main_Window);
-- COMMANDS
-- wm frame Window
-- SOURCE
function Get_Frame(Window: Tk_Widget) return Tk_Window with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Frame", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Geometry
-- FUNCTION
-- Get the current geometry of the selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which geometry will be get
-- RESULT
-- Window_Geometry record with the current geometry of the Window
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the geometry of the Tk main window
-- Widget_Geometry: constant Window_Geometry := Geometry(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Geometry_(all_values), Wm.Set_Geometry_(width_height),
-- Wm.Set_Geometry_(x_y)
-- COMMANDS
-- wm geometry Window
-- SOURCE
function Get_Geometry(Window: Tk_Widget) return Window_Geometry with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Geometry", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Geometry_(all_values)
-- FUNCTION
-- Set the new geometry for the selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which geometry will be set
-- Width - The new width for the Window
-- Height - The new height for the Window
-- X - The new X coordinate for top left corner of the Window
-- Y - The new X coordinate for top left corner of the Window
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the main Tk window geometry to 800x600 and at top left corner of the screen
-- Geometry(Get_Main_Window, 800, 600, 0, 0);
-- SEE ALSO
-- Wm.Get_Geometry, Wm.Set_Geometry_(width_height),
-- Wm.Set_Geometry_Position
-- COMMANDS
-- wm geometry Window =WidthxHeight+X+Y
-- SOURCE
procedure Set_Geometry
(Window: Tk_Widget; Width, Height: Positive; X, Y: Natural) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Set_Geometry", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Geometry_(width_height)
-- FUNCTION
-- Set the new geometry for the selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which geometry will be set
-- Width - The new width for the Window
-- Height - The new height for the Window
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the main Tk window geometry to 800x600
-- Geometry(Get_Main_Window, 800, 600);
-- SEE ALSO
-- Wm.Get_Geometry, Wm.Set_Geometry_(all_values),
-- Wm.Set_Geometry_Position
-- COMMANDS
-- wm geometry Window =WidthxHeight
-- SOURCE
procedure Set_Geometry(Window: Tk_Widget; Width, Height: Positive) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Set_Geometry2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Geometry_Position
-- FUNCTION
-- Set the new position for the selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which geometry will be set
-- X - The new X coordinate for top left corner of the Window
-- Y - The new X coordinate for top left corner of the Window
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the main Tk window at top left corner of the screen
-- Geometry(Get_Main_Window, 0, 0);
-- SEE ALSO
-- Wm.Get_Geometry, Wm.Set_Geometry_(width_height),
-- Wm.Set_Geometry_(all_values)
-- COMMANDS
-- wm geometry Window +X+Y
-- SOURCE
procedure Set_Geometry_Position(Window: Tk_Widget; X, Y: Natural) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Set_Geometry_Position", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Grid
-- FUNCTION
-- Get the current setting of the selected Tk_Widget as gridded window
-- PARAMTERS
-- Window - Tk_Widget which grid setting will be get
-- RESULT
-- Window_Grid_Geometry record with current setting of Window
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the setting for the Tk main window
-- Grid_Setting: constant Window_Grid_Geometry := Get_Grid(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Grid
-- COMMANDS
-- wm grid Window
-- SOURCE
function Get_Grid(Window: Tk_Widget) return Window_Grid_Geometry with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Grid", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Grid
-- FUNCTION
-- Set the selected Tk_Widget as a gridded window or change it gridded
-- setting
-- PARAMETERS
-- Window - Tk_Widget which will be set as gridded window
-- Base_Width - The amount of grid units corresponding to the pixels
-- width dimension
-- Base_Height - The amount of grid units corresponding to the pixels
-- height dimension
-- Width_Inc - The amount of pixels in horizontal grid unit
-- Height_Inc - The amount of pixels in vertical grid unit
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the Tk main window as gridded window with base values 10, 10 and amount of pixels to 5, 5
-- Set_Grid(Get_Main_Window, 10, 10, 5, 5);
-- SEE ALSO
-- Wm.Set_Grid
-- COMMANDS
-- wm grid Window Base_Width Base_Height Width_Inc Height_Inc
-- SOURCE
procedure Set_Grid
(Window: Tk_Widget;
Base_Width, Base_Height, Width_Inc, Height_Inc: Positive) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Grid2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Group
-- FUNCTION
-- Get the path name of the leader window in the group of windows to
-- which the selected Tk_Widget belongs
-- PARAMETERS
-- Window - Tk_Widget which leader's group windows name will be get
-- RESULT
-- The Tk path name of the leader window of the group windows to
-- which the Window belongs or empty string if Window isn't in a group
-- of windows.
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the name of the leader window for Tk main window
-- Leader_Path: constant String := Get_Group(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Group
-- COMMANDS
-- wm group Window
-- SOURCE
function Get_Group(Window: Tk_Widget) return String is
(Tcl_Eval
(Tcl_Script => "wm group " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window))
.Result) with
Pre => Window /= Null_Widget
and then Tk_Path_Name(Widgt => Window)'Length < Integer'Last - 9,
Test_Case => (Name => "Test_Wm_Group", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Group
-- FUNCTION
-- Set the path name of the leader window in the group of windows to
-- which the selected Tk_Widget belongs
-- PARAMETERS
-- Window - Tk_Widget which leader's group windows name will be set
-- Path_Name - The name of the leader's window to set
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the name of the leader window for Tk main window to ".mydialog"
-- Set_Group(Get_Main_Window, To_Tcl_String(".mydialog"));
-- SEE ALSO
-- Wm.Get_Group
-- COMMANDS
-- wm group Window Path_Name
-- SOURCE
procedure Set_Group(Window: Tk_Widget; Path_Name: Tcl_String) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Group2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Icon_Bitmap
-- FUNCTION
-- Get the name of the bitmap which is used as an icon for the selected
-- Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which bitmap icon will be get
-- RESULT
-- The String with name of the bitmap which is set as an icon for Window
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the name of a bitmap which is set as the icon for Tk main window
-- Bitmap_Name: constant String := Get_Icon_Bitmap(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Icon_Bitmap
-- COMMANDS
-- wm iconbitmap Window
-- SOURCE
function Get_Icon_Bitmap(Window: Tk_Widget) return String is
(Tcl_Eval
(Tcl_Script => "wm iconbitmap " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window))
.Result) with
Pre => Window /= Null_Widget
and then Tk_Path_Name(Widgt => Window)'Length < Integer'Last - 14,
Test_Case => (Name => "Test_Wm_Icon_Bitmap", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Icon_Bitmap
-- FUNCTION
-- Set the name of the bitmap which is used as an icon for the selected
-- Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which bitmap icon will be set
-- Bitmap - The name of Tk bitmap which will be set as the icon
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the icon for Tk main window from Tk bitmap warning
-- Icon_Bitmap(Get_Main_Window, To_Tcl_String("warning"));
-- SEE ALSO
-- Wm.Get_Icon_Bitmap
-- COMMANDS
-- wm iconbitmap Window Bitmap
-- SOURCE
procedure Set_Icon_Bitmap(Window: Tk_Widget; Bitmap: Tcl_String) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Icon_Bitmap2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Iconify
-- FUNCTION
-- Iconify the selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which will be iconified
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Iconify Tk main window
-- Iconify(Get_Main_Window);
-- SEE ALSO
-- Wm.Deiconify
-- COMMANDS
-- wm iconify Window
-- SOURCE
procedure Iconify(Window: Tk_Widget) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Iconify", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Icon_Mask
-- FUNCTION
-- Get the name of bitmap used as mask for the selected Tk_Widget icon
-- PARAMETERS
-- Window - Tk_Widget which bitmap mask will be taken
-- RESULT
-- String with name of the current bitmap used a mask for the Window
-- icon
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the mask for the Tk main window
-- Mask_Name: constant String := Get_Icon_Mask(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Icon_Mask
-- COMMANDS
-- wm iconmask Window
-- SOURCE
function Get_Icon_Mask(Window: Tk_Widget) return String is
(Tcl_Eval
(Tcl_Script => "wm iconmask " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window))
.Result) with
Pre => Window /= Null_Widget
and then Tk_Path_Name(Widgt => Window)'Length < Integer'Last - 12,
Test_Case => (Name => "Test_Wm_Icon_Mask", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Icon_Mask
-- FUNCTION
-- Set the selected bitmap as a mask for the selected Tk_Widget icon
-- PARAMETERS
-- Window - Tk_Widget which bitmap mask will be set
-- Bitmap - The name of bitmap to set as the mask
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the warning bitmap as mask for the Tk main window
-- Set_Icon_Mask(Get_Main_Window, To_Tcl_String("warning"));
-- SEE ALSO
-- Wm.Get_Icon_Mask
-- COMMANDS
-- wm iconmask Window Bitmap
-- SOURCE
procedure Set_Icon_Mask(Window: Tk_Widget; Bitmap: Tcl_String) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Icon_Mask2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Icon_Name
-- FUNCTION
-- Get the name of the icon of the selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which icon's name will be get
-- RESULT
-- String with the name of the icon of the Window or empty String if
-- the Window doesn't have set any icon.
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the name of icon for the Tk main window
-- Name_Of_Icon: constant String := Get_Icon_Name(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Icon_Name
-- COMMANDS
-- wm iconname Window
-- SOURCE
function Get_Icon_Name(Window: Tk_Widget) return String is
(Tcl_Eval
(Tcl_Script => "wm iconname " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window))
.Result) with
Pre => Window /= Null_Widget
and then Tk_Path_Name(Widgt => Window)'Length < Integer'Last - 12,
Test_Case => (Name => "Test_Wm_Icon_Name", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Icon_Name
-- FUNCTION
-- Get the name of the icon of the selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which icon's name will be set
-- New_Name - The name of the icon which will be set
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the name of icon for the Tk main window to myicon
-- Set_Icon_Name(Get_Main_Window, To_Tcl_String("myicon"));
-- SEE ALSO
-- Wm.Get_Icon_Name
-- COMMANDS
-- wm iconname Window New_Name
-- SOURCE
procedure Set_Icon_Name(Window: Tk_Widget; New_Name: Tcl_String) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Icon_Name2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Icon_Photo
-- FUNCTION
-- Set the titlebar icons for the selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which titlebar icons will be set
-- Images - The array of the Tk icons which will be set
-- Default - If True, use the selected Images as icons also for future
-- toplevel widgets. Can be empty. Default value is False.
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set titlebar icons for the Tk main window to myicon and mybigicon
-- Set_Icon_Photo(Get_Main_Window, (To_Tcl_String("myicon"), To_Tcl_String("mybigicon")));
-- COMMANDS
-- wm iconphoto Window ?-default? Images
-- SOURCE
procedure Set_Icon_Photo
(Window: Tk_Widget; Images: Array_List; Default: Boolean := False) with
Pre => Window /= Null_Widget and Images'Length > 0,
Test_Case => (Name => "Test_Wm_Icon_Photo", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Icon_Position
-- FUNCTION
-- Get the position of the icon for the selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which icon's position will be get
-- RESULT
-- Point_Position record with the current position of the Window's icon
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the position of the Tk main window icon
-- Position: constant Point_Position := Get_Icon_Position(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Icon_Position, Wm.Reset_Icon_Position
-- COMMANDS
-- wm iconposition Window
-- SOURCE
function Get_Icon_Position(Window: Tk_Widget) return Point_Position with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Icon_Position", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Icon_Position
-- FUNCTION
-- Set the position of the icon for the selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which icon's position will be set
-- X - New X coordinate of the Window icon
-- Y - New Y coordinate of the Window icon
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the position of the Tk main window icon to pixel coordinates 20, 20
-- Icon_Position(Get_Main_Window, 20, 20);
-- SEE ALSO
-- Wm.Get_Icon_Position, Wm.Reset_Icon_Position
-- COMMANDS
-- wm iconposition Window X Y
-- SOURCE
procedure Set_Icon_Position(Window: Tk_Widget; X, Y: Natural) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Icon_Set_Position", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Reset_Icon_Position
-- FUNCTION
-- Reset the hint for position of the icon for the selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which icon's position will be set
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Reset the hint for position of the Tk main window icon
-- Icon_Position(Get_Main_Window);
-- SEE ALSO
-- Wm.Get_Icon_Position, Wm.Set_Icon_Position
-- COMMANDS
-- wm iconposition Window {} {}
-- SOURCE
procedure Reset_Icon_Position(Window: Tk_Widget) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Icon_Reset_Position", Mode => Nominal);
-- ****f* Wm/Wm.Get_Icon_Window
-- FUNCTION
-- Get the Tk_Toplevel which is set as the current icon window for the
-- selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which icon window will be get
-- RESULT
-- Tk_Toplevel widget which is icon window of Window or Null_Widget if
-- is not set
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the icon window for the Tk main window
-- Icon: constant Tk_Toplevel := Get_Icon_Window(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Icon_Window
-- COMMANDS
-- wm iconwindow Window
-- SOURCE
function Get_Icon_Window(Window: Tk_Widget) return Tk_Toplevel with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Icon_Window", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Icon_Window
-- FUNCTION
-- Set the Tk_Toplevel as the current icon window for the selected
-- Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which icon window will be set
-- New_Icon_Window - Tk_Toplevel which will be set as new icon window
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set My_Icon_Window as the icon window for the Tk main window
-- Set_Icon_Window(Get_Main_Window, My_Icon_Window);
-- SEE ALSO
-- Wm.Get_Icon_Window
-- COMMANDS
-- wm iconwindow Window New_Icon_Window
-- SOURCE
procedure Set_Icon_Window(Window, New_Icon_Window: Tk_Toplevel) with
Pre => Window /= Null_Widget and New_Icon_Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Icon_Window2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Manage
-- FUNCTION
-- Made the selected Tk_Widget as stand alone toplevel window
-- PARAMETERS
-- Window - Tk_Widget which will become a stand alone toplevel window
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set My_Dialog Tk_Frame as stand alone window
-- Manage(My_Dialog);
-- COMMANDS
-- wm manage Window
-- SOURCE
procedure Manage(Window: Tk_Widget) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Manage", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Max_Size
-- FUNCTION
-- Get the maximum allowed size for the selected Tk_Widget. For gridded
-- windows it will be in grid unit, for others in pixels
-- PARAMETERS
-- Window - Tk_Widget which maximum allowed size will be get
-- RESULT
-- Window_Size record with information about maximum allowed size for
-- the Window
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the maximum allowed size of Tk main window
-- Allowed_Size: constant Window_Size := Get_Max_Size(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Max_Size
-- COMMANDS
-- wm maxsize Window
-- SOURCE
function Get_Max_Size(Window: Tk_Widget) return Window_Size with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Max_Size", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Max_Size
-- FUNCTION
-- Set the maximum allowed size for the selected Tk_Widget. For gridded
-- windows it will be in grid unit, for others in pixels
-- PARAMETERS
-- Window - Tk_Widget which maximum allowed size will be set
-- Width - The new maximum width for the selected Tk_Widget
-- Height - The new maximum height for the selected Tk_Widget
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the maximum allowed size of Tk main window to 100, 120
-- Set_Max_Size(Get_Main_Window, 100, 120);
-- SEE ALSO
-- Wm.Get_Max_Size
-- COMMANDS
-- wm maxsize Window Width Height
-- SOURCE
procedure Set_Max_Size(Window: Tk_Widget; Width, Height: Positive) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Max_Size2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Min_Size
-- FUNCTION
-- Get the minumum allowed size for the selected Tk_Widget. For gridded
-- windows it will be in grid unit, for others in pixels
-- PARAMETERS
-- Window - Tk_Widget which minimum allowed size will be get
-- RESULT
-- Window_Size record with information about minimum allowed size for
-- the Window
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the minimum allowed size of Tk main window
-- Minimum_Size: constant Window_Size := Get_Min_Size(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Min_Size
-- COMMANDS
-- wm minsize Window
-- SOURCE
function Get_Min_Size(Window: Tk_Widget) return Window_Size with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Min_Size", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Min_Size
-- FUNCTION
-- Set the minimum allowed size for the selected Tk_Widget. For gridded
-- windows it will be in grid unit, for others in pixels
-- PARAMETERS
-- Window - Tk_Widget which minimum allowed size will be set
-- Width - The new minimum width for the selected Tk_Widget
-- Height - The new minimum height for the selected Tk_Widget
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the minimum allowed size of Tk main window to 200, 240
-- Set_Min_Size(Get_Main_Window, 200, 240);
-- SEE ALSO
-- Wm.Get_Min_Size
-- COMMANDS
-- wm minsize Window Width Height
-- SOURCE
procedure Set_Min_Size(Window: Tk_Widget; Width, Height: Positive) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Min_Size2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Override_Redirect
-- FUNCTION
-- Get the value of flag overrideredirect for the selected Tk_Widget.
-- PARAMETERS
-- Window - Tk_Widget which value of flag will be taken
-- RESULT
-- True if the Window is ignored by the window manager, otherwise False.
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the flag value for the Tk main window
-- Is_Ignored: constant Tcl_Boolean_Result := Get_Override_Redirect(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Override_Redirect
-- COMMANDS
-- wm overrideredirect Window
-- SOURCE
function Get_Override_Redirect
(Window: Tk_Widget) return Tcl_Boolean_Result is
(Tcl_Eval
(Tcl_Script => "wm overrideredirect " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window))) with
Pre => Window /= Null_Widget
and then Tk_Path_Name(Widgt => Window)'Length < Integer'Last - 20,
Test_Case => (Name => "Test_Wm_Override_Redirect", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Override_Redirect
-- FUNCTION
-- Set the value of flag overrideredirect for the selected Tk_Widget.
-- PARAMETERS
-- Window - Tk_Widget which value of flag will be set
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the flag value for the Tk main window to be ignored
-- Set_Override_Redirect(Get_Main_Window, True);
-- SEE ALSO
-- Wm.Get_Override_Redirect
-- COMMANDS
-- wm overrideredirect Window Override
-- SOURCE
procedure Set_Override_Redirect(Window: Tk_Widget; Override: Boolean) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Override_Redirect", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Position_From
-- FUNCTION
-- Get the information who requested the current position for the
-- selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which position requester will be get
-- RESULT
-- If PROGRAM, then the current position of Window was requested by the
-- program, if USER then user requested the position.
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the requester for the position of Tk main window
-- Requester: constant Position_From_Value := Get_Position_From(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Position_From
-- COMMANDS
-- wm positionfrom Window
-- SOURCE
function Get_Position_From
(Window: Tk_Widget) return Position_From_Value with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Position_From", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Position_From
-- FUNCTION
-- Get the information who requested the current position for the
-- selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which position requester will be set
-- Who - The new requester for the current Window's position. Can be
-- PROGRAM or USER
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the requester for the position of Tk main window to requested by the user
-- Set_Position_From(Get_Main_Window, USER);
-- SEE ALSO
-- Wm.Get_Position_From
-- COMMANDS
-- wm positionfrom Window Who
-- SOURCE
procedure Set_Position_From
(Window: Tk_Widget;
Who: Position_From_Value := Default_Position_From) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Position_From2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Protocols
-- FUNCTION
-- Get the list of all specified window manager protocols for the
-- selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which specified window manager protocols will
-- be get
-- RESULT
-- Array_List with all specified window manager protocols. If nothing
-- was specified, return empty list.
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the protocols for the Tk main window
-- Protocols: constant Array_List := Get_Protocols(Get_Main_Window);
-- SEE ALSO
-- Wm.Get_Protocol, Wm.Set_Protocol
-- COMMANDS
-- wm protocol Window
-- SOURCE
function Get_Protocols(Window: Tk_Widget) return Array_List with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Protocol", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Protocol
-- FUNCTION
-- Get the value of the specified window manager protocol for the
-- selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which specified window manager protocol will
-- be get
-- Name - The name of the window manager protocol value to get
-- RESULT
-- String with the value of specified window manager protocol. If it
-- wasn't specified, return empty string.
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the value of WM_DELETE_WINDOW for the Tk main window
-- Value: constant String := Get_Protocol(Get_Main_Window, "WM_DELETE_WINDOW");
-- SEE ALSO
-- Wm.Get_Protocols, Wm.Set_Protocol
-- COMMANDS
-- wm protocol Window Name
-- SOURCE
function Get_Protocol(Window: Tk_Widget; Name: String) return String is
(Tcl_Eval
(Tcl_Script =>
"wm protocol " & Tk_Path_Name(Widgt => Window) & " " & Name,
Interpreter => Tk_Interp(Widgt => Window))
.Result) with
Pre => (Window /= Null_Widget and Name'Length > 0)
and then Tk_Path_Name(Widgt => Window)'Length + Name'Length <
Long_Long_Integer(Integer'Last - 12),
Test_Case => (Name => "Test_Wm_Protocol2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Protocol
-- FUNCTION
-- Set the value of the specified window manager protocol for the
-- selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which specified window manager protocol will
-- be set
-- Name - The name of the window manager protocol value to set
-- New_Command - The new Tcl command which will be associated with the
-- selected window manager protocol
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the value of WM_DELETE_WINDOW to Tcl command exit for the Tk main window
-- Set_Protocol(Get_Main_Window, "WM_DELETE_WINDOW", To_Tcl_String("exit"));
-- SEE ALSO
-- Wm.Get_Protocols, Wm.Get_Protocol
-- COMMANDS
-- wm protocol Window Name New_Command
-- SOURCE
procedure Set_Protocol
(Window: Tk_Widget; Name: String; New_Command: Tcl_String) with
Pre => Window /= Null_Widget and Name'Length > 0 and
Length(Source => New_Command) > 0,
Test_Case => (Name => "Test_Wm_Protocol3", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Resizable
-- FUNCTION
-- Get the information if the selected Tk_Widget can be resized by the
-- user
-- PARAMETERS
-- Window - Tk_Widget which resizable ability will be get
-- RESULT
-- Resizable_Data record with information about resizable ability by
-- the user. If Height is True, the user can resize Window vertically,
-- if Width is True, the user can resize Window horizontally
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the resizable ability for the Tk main window
-- Is_Resizable: constant Resizable_Data := Get_Resizable(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Resizable
-- COMMANDS
-- wm resizable Window
-- SOURCE
function Get_Resizable(Window: Tk_Widget) return Resizable_Data with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Resizable", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Resizable
-- FUNCTION
-- Set the information if the selected Tk_Widget can be resized by the
-- user
-- PARAMETERS
-- Window - Tk_Widget which resizable ability will be set
-- Width - If True, the user can resize Window horizontally
-- Height - If True, the user can resize Window vertically
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Block the resizable ability for the Tk main window
-- Set_Resizable(Get_Main_Window, False, False);
-- SEE ALSO
-- Wm.Get_Resizable
-- COMMANDS
-- wm resizable Window Width Height
-- SOURCE
procedure Set_Resizable(Window: Tk_Widget; Width, Height: Boolean) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Resizable2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Size_From
-- FUNCTION
-- Get the information who requested the current size for the selected
-- Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which size requester will be get
-- RESULT
-- If PROGRAM, then the current size of Window was requested by the
-- program, if USER then user requested the size.
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the requester for the size of Tk main window
-- Requester: constant Position_From_Value := Get_Size_From(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Size_From
-- COMMANDS
-- wm sizefrom Window
-- SOURCE
function Get_Size_From(Window: Tk_Widget) return Position_From_Value with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Size_From", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Size_From
-- FUNCTION
-- Get the information who requested the current size for the selected
-- Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which size requester will be set
-- Who - The new requester for the current Window's size. Can be
-- PROGRAM or USER
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the requester for the size of Tk main window to requested by the user
-- Size_From(Get_Main_Window, USER);
-- SEE ALSO
-- Wm.Get_Size_From
-- COMMANDS
-- wm sizefrom Window Who
-- SOURCE
procedure Set_Size_From
(Window: Tk_Widget;
Who: Position_From_Value := Default_Position_From) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Size_From2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Stack_Order
-- FUNCTION
-- Get the stacking order from the lowest to highest of children of the
-- selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which stacking order will be get
-- RESULT
-- Widgets_Array with children widgets (including Window as the first)
-- in stacking order
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the stacking order of Tk main window
-- Stacking_Order: constant Widgets_Array := Get_Stack_Order(Get_Main_Window);
-- SEE ALSO
-- Wm.Get_Stack_Order_Above
-- COMMANDS
-- wm stackorder Window
-- SOURCE
function Get_Stack_Order(Window: Tk_Widget) return Widgets_Array with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Stack_Order", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Stack_Order_Above
-- FUNCTION
-- Check if the selected Tk_Widget is above or below the other Tk_Widget
-- in stacking order
-- PARAMETERS
-- Window - Tk_Widget which position in stacking order will be
-- check
-- Second_Window - Tk_Widget which will be reference to check for
-- stacking order
-- Above - If true, check if Window is above Second_Window.
-- Otherwise check if Window is below. Default value is
-- True.
-- RESULT
-- True if Window is above (or below if Above was False) the Second_Window
-- otherwise False
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Check if Tk main window is above My_Dialog in stacking order
-- Is_Above: constant Tcl_Boolean_Result := Get_Stack_Order_Above(Get_Main_Window, My_Dialog);
-- SEE ALSO
-- Wm.Get_Stack_Order
-- COMMANDS
-- wm stackorder Window isabove Second_Window (when Above is True)
-- wm stackorder Window isbelow Second_Window (when Above is False)
-- SOURCE
function Get_Stack_Order_Above
(Window, Second_Window: Tk_Widget; Above: Boolean := True)
return Tcl_Boolean_Result is
(Tcl_Eval
(Tcl_Script =>
"wm stackorder " & Tk_Path_Name(Widgt => Window) & " " &
(if Above then "isabove" else "isbelow") & " " &
Tk_Path_Name(Widgt => Second_Window),
Interpreter => Tk_Interp(Widgt => Window))) with
Pre => (Window /= Null_Widget and Second_Window /= Null_Widget)
and then
Tk_Path_Name(Widgt => Window)'Length +
Tk_Path_Name(Widgt => Second_Window)'Length <
Long_Long_Integer(Integer'Last - 22),
Test_Case => (Name => "Test_Wm_Stack_Order2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_State
-- FUNCTION
-- Get the current state of the selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which state will be get
-- RESULT
-- Window_States with current state of the Window
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the current state of Tk main window
-- Current_State: constant Window_States := Get_State(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_State
-- COMMANDS
-- wm state Window
-- SOURCE
function Get_State(Window: Tk_Widget) return Window_States with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_State", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_State
-- FUNCTION
-- Set the current state of the selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which state will be set
-- New_State - The new state for the Window. Can be empty. Default value
-- is Default_Window_State
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the current state of Tk main window to withdrawn state
-- Set_State(Get_Main_Window, WITHDRAWN);
-- SEE ALSO
-- Wm.Get_State
-- COMMANDS
-- wm state Window New_State
-- SOURCE
procedure Set_State
(Window: Tk_Widget; New_State: Window_States := Default_Window_State) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_State2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Title
-- FUNCTION
-- Get the current title of the selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which the title will be get
-- RESULT
-- Tcl_String with the current title of the Window
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the current title of Tk main window
-- Window_Title: constant Tcl_String := Get_Title(Get_Main_Window);
-- SEE ALSO
-- Wm.Set_Title
-- COMMANDS
-- wm title Window
-- SOURCE
function Get_Title(Window: Tk_Widget) return Tcl_String is
(To_Tcl_String
(Source =>
Tcl_Eval
(Tcl_Script => "wm title " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window))
.Result)) with
Pre => Window /= Null_Widget
and then Tk_Path_Name(Widgt => Window)'Length < Integer'Last - 9,
Test_Case => (Name => "Test_Wm_Title", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Title
-- FUNCTION
-- Set the current title of the selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which the title will be set
-- New_Title - The new title for the Window
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the current title of Tk main window to "My window"
-- Set_Title(Get_Main_Window, To_Tcl_String("My window"));
-- SEE ALSO
-- Wm.Get_Title
-- COMMANDS
-- wm title Window New_Title
-- SOURCE
procedure Set_Title(Window: Tk_Widget; New_Title: Tcl_String) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Title2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Get_Transient
-- FUNCTION
-- Get the Tk_Widget for which the selected Tk_Widget is transient
-- PARAMETERS
-- Window - Tk_Widget which transient value will be get
-- RESULT
-- Tk_Widget which is the master for the Window or Null_Widget if
-- Window don't have any
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the transient window for the My_Menu Tk_Menu
-- Master: constant Tk_Widget := Get_Transient(My_Menu);
-- SEE ALSO
-- Wm.Set_Transient
-- COMMANDS
-- wm transient Window
-- SOURCE
function Get_Transient(Window: Tk_Widget) return Tk_Widget with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Transient", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Set_Transient
-- FUNCTION
-- Set the Tk_Widget for which the selected Tk_Widget as transient
-- PARAMETERS
-- Window - Tk_Widget which transient value will be set
-- Master - Tk_Widget which will be used as master for the Window
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the Tk main window as transient window for the My_Menu Tk_Menu
-- Set_Transient(My_Menu, Get_Main_Window);
-- SEE ALSO
-- Wm.Get_Transient
-- COMMANDS
-- wm transient Window Master
-- SOURCE
procedure Set_Transient(Window, Master: Tk_Widget) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Transient2", Mode => Nominal);
-- ****
-- ****f* Wm/Wm.Withdraw
-- FUNCTION
-- Withdraw from the screen and unmap the selected Tk_Widget
-- PARAMETERS
-- Window - Tk_Widget which will be withdrawn
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Withdraw the Tk main window
-- Withdraw(Get_Main_Window);
-- COMMANDS
-- wm withdraw Window
-- SOURCE
procedure Withdraw(Window: Tk_Widget) with
Pre => Window /= Null_Widget,
Test_Case => (Name => "Test_Wm_Withdraw", Mode => Nominal);
-- ****
--## rule on REDUCEABLE_SCOPE
end Tk.Wm;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ E L A B --
-- --
-- B o d y --
-- --
-- Copyright (C) 1997-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Atree; use Atree;
with Checks; use Checks;
with Debug; use Debug;
with Einfo; use Einfo;
with Elists; use Elists;
with Errout; use Errout;
with Exp_Tss; use Exp_Tss;
with Exp_Util; use Exp_Util;
with Expander; use Expander;
with Fname; use Fname;
with Lib; use Lib;
with Lib.Load; use Lib.Load;
with Namet; use Namet;
with Nlists; use Nlists;
with Nmake; use Nmake;
with Opt; use Opt;
with Output; use Output;
with Restrict; use Restrict;
with Rident; use Rident;
with Sem; use Sem;
with Sem_Aux; use Sem_Aux;
with Sem_Cat; use Sem_Cat;
with Sem_Ch7; use Sem_Ch7;
with Sem_Ch8; use Sem_Ch8;
with Sem_Util; use Sem_Util;
with Sinfo; use Sinfo;
with Sinput; use Sinput;
with Snames; use Snames;
with Stand; use Stand;
with Table;
with Tbuild; use Tbuild;
with Uintp; use Uintp;
with Uname; use Uname;
package body Sem_Elab is
-- The following table records the recursive call chain for output in the
-- Output routine. Each entry records the call node and the entity of the
-- called routine. The number of entries in the table (i.e. the value of
-- Elab_Call.Last) indicates the current depth of recursion and is used to
-- identify the outer level.
type Elab_Call_Entry is record
Cloc : Source_Ptr;
Ent : Entity_Id;
end record;
package Elab_Call is new Table.Table (
Table_Component_Type => Elab_Call_Entry,
Table_Index_Type => Int,
Table_Low_Bound => 1,
Table_Initial => 50,
Table_Increment => 100,
Table_Name => "Elab_Call");
-- This table is initialized at the start of each outer level call. It
-- holds the entities for all subprograms that have been examined for this
-- particular outer level call, and is used to prevent both infinite
-- recursion, and useless reanalysis of bodies already seen
package Elab_Visited is new Table.Table (
Table_Component_Type => Entity_Id,
Table_Index_Type => Int,
Table_Low_Bound => 1,
Table_Initial => 200,
Table_Increment => 100,
Table_Name => "Elab_Visited");
-- This table stores calls to Check_Internal_Call that are delayed until
-- all generics are instantiated and in particular until after all generic
-- bodies have been inserted. We need to delay, because we need to be able
-- to look through the inserted bodies.
type Delay_Element is record
N : Node_Id;
-- The parameter N from the call to Check_Internal_Call. Note that this
-- node may get rewritten over the delay period by expansion in the call
-- case (but not in the instantiation case).
E : Entity_Id;
-- The parameter E from the call to Check_Internal_Call
Orig_Ent : Entity_Id;
-- The parameter Orig_Ent from the call to Check_Internal_Call
Curscop : Entity_Id;
-- The current scope of the call. This is restored when we complete the
-- delayed call, so that we do this in the right scope.
From_SPARK_Code : Boolean;
-- Save indication of whether this call is under SPARK_Mode => On
From_Elab_Code : Boolean;
-- Save indication of whether this call is from elaboration code
Outer_Scope : Entity_Id;
-- Save scope of outer level call
end record;
package Delay_Check is new Table.Table (
Table_Component_Type => Delay_Element,
Table_Index_Type => Int,
Table_Low_Bound => 1,
Table_Initial => 1000,
Table_Increment => 100,
Table_Name => "Delay_Check");
C_Scope : Entity_Id;
-- Top-level scope of current scope. Compute this only once at the outer
-- level, i.e. for a call to Check_Elab_Call from outside this unit.
Outer_Level_Sloc : Source_Ptr;
-- Save Sloc value for outer level call node for comparisons of source
-- locations. A body is too late if it appears after the *outer* level
-- call, not the particular call that is being analyzed.
From_Elab_Code : Boolean;
-- This flag shows whether the outer level call currently being examined
-- is or is not in elaboration code. We are only interested in calls to
-- routines in other units if this flag is True.
In_Task_Activation : Boolean := False;
-- This flag indicates whether we are performing elaboration checks on
-- task procedures, at the point of activation. If true, we do not trace
-- internal calls in these procedures, because all local bodies are known
-- to be elaborated.
Delaying_Elab_Checks : Boolean := True;
-- This is set True till the compilation is complete, including the
-- insertion of all instance bodies. Then when Check_Elab_Calls is called,
-- the delay table is used to make the delayed calls and this flag is reset
-- to False, so that the calls are processed.
-----------------------
-- Local Subprograms --
-----------------------
-- Note: Outer_Scope in all following specs represents the scope of
-- interest of the outer level call. If it is set to Standard_Standard,
-- then it means the outer level call was at elaboration level, and that
-- thus all calls are of interest. If it was set to some other scope,
-- then the original call was an inner call, and we are not interested
-- in calls that go outside this scope.
procedure Activate_Elaborate_All_Desirable (N : Node_Id; U : Entity_Id);
-- Analysis of construct N shows that we should set Elaborate_All_Desirable
-- for the WITH clause for unit U (which will always be present). A special
-- case is when N is a function or procedure instantiation, in which case
-- it is sufficient to set Elaborate_Desirable, since in this case there is
-- no possibility of transitive elaboration issues.
procedure Check_A_Call
(N : Node_Id;
E : Entity_Id;
Outer_Scope : Entity_Id;
Inter_Unit_Only : Boolean;
Generate_Warnings : Boolean := True;
In_Init_Proc : Boolean := False);
-- This is the internal recursive routine that is called to check for
-- possible elaboration error. The argument N is a subprogram call or
-- generic instantiation, or 'Access attribute reference to be checked, and
-- E is the entity of the called subprogram, or instantiated generic unit,
-- or subprogram referenced by 'Access.
--
-- In SPARK mode, N can also be a variable reference, since in SPARK this
-- also triggers a requirement for Elaborate_All, and in this case E is the
-- entity being referenced.
--
-- Outer_Scope is the outer level scope for the original reference.
-- Inter_Unit_Only is set if the call is only to be checked in the
-- case where it is to another unit (and skipped if within a unit).
-- Generate_Warnings is set to False to suppress warning messages about
-- missing pragma Elaborate_All's. These messages are not wanted for
-- inner calls in the dynamic model. Note that an instance of the Access
-- attribute applied to a subprogram also generates a call to this
-- procedure (since the referenced subprogram may be called later
-- indirectly). Flag In_Init_Proc should be set whenever the current
-- context is a type init proc.
--
-- Note: this might better be called Check_A_Reference to recognize the
-- variable case for SPARK, but we prefer to retain the historical name
-- since in practice this is mostly about checking calls for the possible
-- occurrence of an access-before-elaboration exception.
procedure Check_Bad_Instantiation (N : Node_Id);
-- N is a node for an instantiation (if called with any other node kind,
-- Check_Bad_Instantiation ignores the call). This subprogram checks for
-- the special case of a generic instantiation of a generic spec in the
-- same declarative part as the instantiation where a body is present and
-- has not yet been seen. This is an obvious error, but needs to be checked
-- specially at the time of the instantiation, since it is a case where we
-- cannot insert the body anywhere. If this case is detected, warnings are
-- generated, and a raise of Program_Error is inserted. In addition any
-- subprograms in the generic spec are stubbed, and the Bad_Instantiation
-- flag is set on the instantiation node. The caller in Sem_Ch12 uses this
-- flag as an indication that no attempt should be made to insert an
-- instance body.
procedure Check_Internal_Call
(N : Node_Id;
E : Entity_Id;
Outer_Scope : Entity_Id;
Orig_Ent : Entity_Id);
-- N is a function call or procedure statement call node and E is the
-- entity of the called function, which is within the current compilation
-- unit (where subunits count as part of the parent). This call checks if
-- this call, or any call within any accessed body could cause an ABE, and
-- if so, outputs a warning. Orig_Ent differs from E only in the case of
-- renamings, and points to the original name of the entity. This is used
-- for error messages. Outer_Scope is the outer level scope for the
-- original call.
procedure Check_Internal_Call_Continue
(N : Node_Id;
E : Entity_Id;
Outer_Scope : Entity_Id;
Orig_Ent : Entity_Id);
-- The processing for Check_Internal_Call is divided up into two phases,
-- and this represents the second phase. The second phase is delayed if
-- Delaying_Elab_Calls is set to True. In this delayed case, the first
-- phase makes an entry in the Delay_Check table, which is processed when
-- Check_Elab_Calls is called. N, E and Orig_Ent are as for the call to
-- Check_Internal_Call. Outer_Scope is the outer level scope for the
-- original call.
function Has_Generic_Body (N : Node_Id) return Boolean;
-- N is a generic package instantiation node, and this routine determines
-- if this package spec does in fact have a generic body. If so, then
-- True is returned, otherwise False. Note that this is not at all the
-- same as checking if the unit requires a body, since it deals with
-- the case of optional bodies accurately (i.e. if a body is optional,
-- then it looks to see if a body is actually present). Note: this
-- function can only do a fully correct job if in generating code mode
-- where all bodies have to be present. If we are operating in semantics
-- check only mode, then in some cases of optional bodies, a result of
-- False may incorrectly be given. In practice this simply means that
-- some cases of warnings for incorrect order of elaboration will only
-- be given when generating code, which is not a big problem (and is
-- inevitable, given the optional body semantics of Ada).
procedure Insert_Elab_Check (N : Node_Id; C : Node_Id := Empty);
-- Given code for an elaboration check (or unconditional raise if the check
-- is not needed), inserts the code in the appropriate place. N is the call
-- or instantiation node for which the check code is required. C is the
-- test whose failure triggers the raise.
function Is_Call_Of_Generic_Formal (N : Node_Id) return Boolean;
-- Returns True if node N is a call to a generic formal subprogram
function Is_Finalization_Procedure (Id : Entity_Id) return Boolean;
-- Determine whether entity Id denotes a [Deep_]Finalize procedure
procedure Output_Calls
(N : Node_Id;
Check_Elab_Flag : Boolean);
-- Outputs chain of calls stored in the Elab_Call table. The caller has
-- already generated the main warning message, so the warnings generated
-- are all continuation messages. The argument is the call node at which
-- the messages are to be placed. When Check_Elab_Flag is set, calls are
-- enumerated only when flag Elab_Warning is set for the dynamic case or
-- when flag Elab_Info_Messages is set for the static case.
function Same_Elaboration_Scope (Scop1, Scop2 : Entity_Id) return Boolean;
-- Given two scopes, determine whether they are the same scope from an
-- elaboration point of view, i.e. packages and blocks are ignored.
procedure Set_C_Scope;
-- On entry C_Scope is set to some scope. On return, C_Scope is reset
-- to be the enclosing compilation unit of this scope.
function Get_Referenced_Ent (N : Node_Id) return Entity_Id;
-- N is either a function or procedure call or an access attribute that
-- references a subprogram. This call retrieves the relevant entity. If
-- this is a call to a protected subprogram, the entity is a selected
-- component. The callable entity may be absent, in which case Empty is
-- returned. This happens with non-analyzed calls in nested generics.
--
-- If SPARK_Mode is On, then N can also be a reference to an E_Variable
-- entity, in which case, the value returned is simply this entity.
procedure Set_Elaboration_Constraint
(Call : Node_Id;
Subp : Entity_Id;
Scop : Entity_Id);
-- The current unit U may depend semantically on some unit P that is not
-- in the current context. If there is an elaboration call that reaches P,
-- we need to indicate that P requires an Elaborate_All, but this is not
-- effective in U's ali file, if there is no with_clause for P. In this
-- case we add the Elaborate_All on the unit Q that directly or indirectly
-- makes P available. This can happen in two cases:
--
-- a) Q declares a subtype of a type declared in P, and the call is an
-- initialization call for an object of that subtype.
--
-- b) Q declares an object of some tagged type whose root type is
-- declared in P, and the initialization call uses object notation on
-- that object to reach a primitive operation or a classwide operation
-- declared in P.
--
-- If P appears in the context of U, the current processing is correct.
-- Otherwise we must identify these two cases to retrieve Q and place the
-- Elaborate_All_Desirable on it.
function Spec_Entity (E : Entity_Id) return Entity_Id;
-- Given a compilation unit entity, if it is a spec entity, it is returned
-- unchanged. If it is a body entity, then the spec for the corresponding
-- spec is returned
procedure Supply_Bodies (N : Node_Id);
-- Given a node, N, that is either a subprogram declaration or a package
-- declaration, this procedure supplies dummy bodies for the subprogram
-- or for all subprograms in the package. If the given node is not one of
-- these two possibilities, then Supply_Bodies does nothing. The dummy body
-- contains a single Raise statement.
procedure Supply_Bodies (L : List_Id);
-- Calls Supply_Bodies for all elements of the given list L
function Within (E1, E2 : Entity_Id) return Boolean;
-- Given two scopes E1 and E2, returns True if E1 is equal to E2, or is one
-- of its contained scopes, False otherwise.
function Within_Elaborate_All
(Unit : Unit_Number_Type;
E : Entity_Id) return Boolean;
-- Return True if we are within the scope of an Elaborate_All for E, or if
-- we are within the scope of an Elaborate_All for some other unit U, and U
-- with's E. This prevents spurious warnings when the called entity is
-- renamed within U, or in case of generic instances.
--------------------------------------
-- Activate_Elaborate_All_Desirable --
--------------------------------------
procedure Activate_Elaborate_All_Desirable (N : Node_Id; U : Entity_Id) is
UN : constant Unit_Number_Type := Get_Code_Unit (N);
CU : constant Node_Id := Cunit (UN);
UE : constant Entity_Id := Cunit_Entity (UN);
Unm : constant Unit_Name_Type := Unit_Name (UN);
CI : constant List_Id := Context_Items (CU);
Itm : Node_Id;
Ent : Entity_Id;
procedure Add_To_Context_And_Mark (Itm : Node_Id);
-- This procedure is called when the elaborate indication must be
-- applied to a unit not in the context of the referencing unit. The
-- unit gets added to the context as an implicit with.
function In_Withs_Of (UEs : Entity_Id) return Boolean;
-- UEs is the spec entity of a unit. If the unit to be marked is
-- in the context item list of this unit spec, then the call returns
-- True and Itm is left set to point to the relevant N_With_Clause node.
procedure Set_Elab_Flag (Itm : Node_Id);
-- Sets Elaborate_[All_]Desirable as appropriate on Itm
-----------------------------
-- Add_To_Context_And_Mark --
-----------------------------
procedure Add_To_Context_And_Mark (Itm : Node_Id) is
CW : constant Node_Id :=
Make_With_Clause (Sloc (Itm),
Name => Name (Itm));
begin
Set_Library_Unit (CW, Library_Unit (Itm));
Set_Implicit_With (CW, True);
-- Set elaborate all desirable on copy and then append the copy to
-- the list of body with's and we are done.
Set_Elab_Flag (CW);
Append_To (CI, CW);
end Add_To_Context_And_Mark;
-----------------
-- In_Withs_Of --
-----------------
function In_Withs_Of (UEs : Entity_Id) return Boolean is
UNs : constant Unit_Number_Type := Get_Source_Unit (UEs);
CUs : constant Node_Id := Cunit (UNs);
CIs : constant List_Id := Context_Items (CUs);
begin
Itm := First (CIs);
while Present (Itm) loop
if Nkind (Itm) = N_With_Clause then
Ent :=
Cunit_Entity (Get_Cunit_Unit_Number (Library_Unit (Itm)));
if U = Ent then
return True;
end if;
end if;
Next (Itm);
end loop;
return False;
end In_Withs_Of;
-------------------
-- Set_Elab_Flag --
-------------------
procedure Set_Elab_Flag (Itm : Node_Id) is
begin
if Nkind (N) in N_Subprogram_Instantiation then
Set_Elaborate_Desirable (Itm);
else
Set_Elaborate_All_Desirable (Itm);
end if;
end Set_Elab_Flag;
-- Start of processing for Activate_Elaborate_All_Desirable
begin
-- Do not set binder indication if expansion is disabled, as when
-- compiling a generic unit.
if not Expander_Active then
return;
end if;
-- If an instance of a generic package contains a controlled object (so
-- we're calling Initialize at elaboration time), and the instance is in
-- a package body P that says "with P;", then we need to return without
-- adding "pragma Elaborate_All (P);" to P.
if U = Main_Unit_Entity then
return;
end if;
Itm := First (CI);
while Present (Itm) loop
if Nkind (Itm) = N_With_Clause then
Ent := Cunit_Entity (Get_Cunit_Unit_Number (Library_Unit (Itm)));
-- If we find it, then mark elaborate all desirable and return
if U = Ent then
Set_Elab_Flag (Itm);
return;
end if;
end if;
Next (Itm);
end loop;
-- If we fall through then the with clause is not present in the
-- current unit. One legitimate possibility is that the with clause
-- is present in the spec when we are a body.
if Is_Body_Name (Unm)
and then In_Withs_Of (Spec_Entity (UE))
then
Add_To_Context_And_Mark (Itm);
return;
end if;
-- Similarly, we may be in the spec or body of a child unit, where
-- the unit in question is with'ed by some ancestor of the child unit.
if Is_Child_Name (Unm) then
declare
Pkg : Entity_Id;
begin
Pkg := UE;
loop
Pkg := Scope (Pkg);
exit when Pkg = Standard_Standard;
if In_Withs_Of (Pkg) then
Add_To_Context_And_Mark (Itm);
return;
end if;
end loop;
end;
end if;
-- Here if we do not find with clause on spec or body. We just ignore
-- this case; it means that the elaboration involves some other unit
-- than the unit being compiled, and will be caught elsewhere.
end Activate_Elaborate_All_Desirable;
------------------
-- Check_A_Call --
------------------
procedure Check_A_Call
(N : Node_Id;
E : Entity_Id;
Outer_Scope : Entity_Id;
Inter_Unit_Only : Boolean;
Generate_Warnings : Boolean := True;
In_Init_Proc : Boolean := False)
is
Access_Case : constant Boolean := Nkind (N) = N_Attribute_Reference;
-- Indicates if we have Access attribute case
function Call_To_Instance_From_Outside (Id : Entity_Id) return Boolean;
-- True if we're calling an instance of a generic subprogram, or a
-- subprogram in an instance of a generic package, and the call is
-- outside that instance.
procedure Elab_Warning
(Msg_D : String;
Msg_S : String;
Ent : Node_Or_Entity_Id);
-- Generate a call to Error_Msg_NE with parameters Msg_D or Msg_S (for
-- dynamic or static elaboration model), N and Ent. Msg_D is a real
-- warning (output if Msg_D is non-null and Elab_Warnings is set),
-- Msg_S is an info message (output if Elab_Info_Messages is set).
function Find_W_Scope return Entity_Id;
-- Find top-level scope for called entity (not following renamings
-- or derivations). This is where the Elaborate_All will go if it is
-- needed. We start with the called entity, except in the case of an
-- initialization procedure outside the current package, where the init
-- proc is in the root package, and we start from the entity of the name
-- in the call.
-----------------------------------
-- Call_To_Instance_From_Outside --
-----------------------------------
function Call_To_Instance_From_Outside (Id : Entity_Id) return Boolean is
Scop : Entity_Id := Id;
begin
loop
if Scop = Standard_Standard then
return False;
end if;
if Is_Generic_Instance (Scop) then
return not In_Open_Scopes (Scop);
end if;
Scop := Scope (Scop);
end loop;
end Call_To_Instance_From_Outside;
------------------
-- Elab_Warning --
------------------
procedure Elab_Warning
(Msg_D : String;
Msg_S : String;
Ent : Node_Or_Entity_Id)
is
begin
-- Dynamic elaboration checks, real warning
if Dynamic_Elaboration_Checks then
if not Access_Case then
if Msg_D /= "" and then Elab_Warnings then
Error_Msg_NE (Msg_D, N, Ent);
end if;
-- In the access case emit first warning message as well,
-- otherwise list of calls will appear as errors.
elsif Elab_Warnings then
Error_Msg_NE (Msg_S, N, Ent);
end if;
-- Static elaboration checks, info message
else
if Elab_Info_Messages then
Error_Msg_NE (Msg_S, N, Ent);
end if;
end if;
end Elab_Warning;
------------------
-- Find_W_Scope --
------------------
function Find_W_Scope return Entity_Id is
Refed_Ent : constant Entity_Id := Get_Referenced_Ent (N);
W_Scope : Entity_Id;
begin
if Is_Init_Proc (Refed_Ent)
and then not In_Same_Extended_Unit (N, Refed_Ent)
then
W_Scope := Scope (Refed_Ent);
else
W_Scope := E;
end if;
-- Now loop through scopes to get to the enclosing compilation unit
while not Is_Compilation_Unit (W_Scope) loop
W_Scope := Scope (W_Scope);
end loop;
return W_Scope;
end Find_W_Scope;
-- Locals
Variable_Case : constant Boolean :=
Nkind (N) in N_Has_Entity
and then Present (Entity (N))
and then Ekind (Entity (N)) = E_Variable;
-- Indicates if we have variable reference case
Loc : constant Source_Ptr := Sloc (N);
Inst_Case : constant Boolean := Nkind (N) in N_Generic_Instantiation;
-- Indicates if we have instantiation case
Ent : Entity_Id;
Callee_Unit_Internal : Boolean;
Caller_Unit_Internal : Boolean;
Decl : Node_Id;
Inst_Callee : Source_Ptr;
Inst_Caller : Source_Ptr;
Unit_Callee : Unit_Number_Type;
Unit_Caller : Unit_Number_Type;
Body_Acts_As_Spec : Boolean;
-- Set to true if call is to body acting as spec (no separate spec)
Cunit_SC : Boolean := False;
-- Set to suppress dynamic elaboration checks where one of the
-- enclosing scopes has Elaboration_Checks_Suppressed set, or else
-- if a pragma Elaborate[_All] applies to that scope, in which case
-- warnings on the scope are also suppressed. For the internal case,
-- we ignore this flag.
E_Scope : Entity_Id;
-- Top-level scope of entity for called subprogram. This value includes
-- following renamings and derivations, so this scope can be in a
-- non-visible unit. This is the scope that is to be investigated to
-- see whether an elaboration check is required.
Is_DIC_Proc : Boolean := False;
-- Flag set when the call denotes the Default_Initial_Condition
-- procedure of a private type that wraps a nontrivial assertion
-- expression.
Issue_In_SPARK : Boolean;
-- Flag set when a source entity is called during elaboration in SPARK
W_Scope : constant Entity_Id := Find_W_Scope;
-- Top-level scope of directly called entity for subprogram. This
-- differs from E_Scope in the case where renamings or derivations
-- are involved, since it does not follow these links. W_Scope is
-- generally in a visible unit, and it is this scope that may require
-- an Elaborate_All. However, there are some cases (initialization
-- calls and calls involving object notation) where W_Scope might not
-- be in the context of the current unit, and there is an intermediate
-- package that is, in which case the Elaborate_All has to be placed
-- on this intermediate package. These special cases are handled in
-- Set_Elaboration_Constraint.
-- Start of processing for Check_A_Call
begin
-- If the call is known to be within a local Suppress Elaboration
-- pragma, nothing to check. This can happen in task bodies. But
-- we ignore this for a call to a generic formal.
if Nkind (N) in N_Subprogram_Call
and then No_Elaboration_Check (N)
and then not Is_Call_Of_Generic_Formal (N)
then
return;
end if;
-- If this is a rewrite of a Valid_Scalars attribute, then nothing to
-- check, we don't mind in this case if the call occurs before the body
-- since this is all generated code.
if Nkind (Original_Node (N)) = N_Attribute_Reference
and then Attribute_Name (Original_Node (N)) = Name_Valid_Scalars
then
return;
end if;
-- Intrinsics such as instances of Unchecked_Deallocation do not have
-- any body, so elaboration checking is not needed, and would be wrong.
if Is_Intrinsic_Subprogram (E) then
return;
end if;
-- Proceed with check
Ent := E;
-- For a variable reference, just set Body_Acts_As_Spec to False
if Variable_Case then
Body_Acts_As_Spec := False;
-- Additional checks for all other cases
else
-- Go to parent for derived subprogram, or to original subprogram in
-- the case of a renaming (Alias covers both these cases).
loop
if (Suppress_Elaboration_Warnings (Ent)
or else Elaboration_Checks_Suppressed (Ent))
and then (Inst_Case or else No (Alias (Ent)))
then
return;
end if;
-- Nothing to do for imported entities
if Is_Imported (Ent) then
return;
end if;
exit when Inst_Case or else No (Alias (Ent));
Ent := Alias (Ent);
end loop;
Decl := Unit_Declaration_Node (Ent);
if Nkind (Decl) = N_Subprogram_Body then
Body_Acts_As_Spec := True;
elsif Nkind_In (Decl, N_Subprogram_Declaration,
N_Subprogram_Body_Stub)
or else Inst_Case
then
Body_Acts_As_Spec := False;
-- If we have none of an instantiation, subprogram body or subprogram
-- declaration, or in the SPARK case, a variable reference, then
-- it is not a case that we want to check. (One case is a call to a
-- generic formal subprogram, where we do not want the check in the
-- template).
else
return;
end if;
end if;
E_Scope := Ent;
loop
if Elaboration_Checks_Suppressed (E_Scope)
or else Suppress_Elaboration_Warnings (E_Scope)
then
Cunit_SC := True;
end if;
-- Exit when we get to compilation unit, not counting subunits
exit when Is_Compilation_Unit (E_Scope)
and then (Is_Child_Unit (E_Scope)
or else Scope (E_Scope) = Standard_Standard);
pragma Assert (E_Scope /= Standard_Standard);
-- Move up a scope looking for compilation unit
E_Scope := Scope (E_Scope);
end loop;
-- No checks needed for pure or preelaborated compilation units
if Is_Pure (E_Scope) or else Is_Preelaborated (E_Scope) then
return;
end if;
-- If the generic entity is within a deeper instance than we are, then
-- either the instantiation to which we refer itself caused an ABE, in
-- which case that will be handled separately, or else we know that the
-- body we need appears as needed at the point of the instantiation.
-- However, this assumption is only valid if we are in static mode.
if not Dynamic_Elaboration_Checks
and then
Instantiation_Depth (Sloc (Ent)) > Instantiation_Depth (Sloc (N))
then
return;
end if;
-- Do not give a warning for a package with no body
if Ekind (Ent) = E_Generic_Package and then not Has_Generic_Body (N) then
return;
end if;
-- Case of entity is in same unit as call or instantiation. In the
-- instantiation case, W_Scope may be different from E_Scope; we want
-- the unit in which the instantiation occurs, since we're analyzing
-- based on the expansion.
if W_Scope = C_Scope then
if not Inter_Unit_Only then
Check_Internal_Call (N, Ent, Outer_Scope, E);
end if;
return;
end if;
-- Case of entity is not in current unit (i.e. with'ed unit case)
-- We are only interested in such calls if the outer call was from
-- elaboration code, or if we are in Dynamic_Elaboration_Checks mode.
if not From_Elab_Code and then not Dynamic_Elaboration_Checks then
return;
end if;
-- Nothing to do if some scope said that no checks were required
if Cunit_SC then
return;
end if;
-- Nothing to do for a generic instance, because a call to an instance
-- cannot fail the elaboration check, because the body of the instance
-- is always elaborated immediately after the spec.
if Call_To_Instance_From_Outside (Ent) then
return;
end if;
-- Nothing to do if subprogram with no separate spec. However, a call
-- to Deep_Initialize may result in a call to a user-defined Initialize
-- procedure, which imposes a body dependency. This happens only if the
-- type is controlled and the Initialize procedure is not inherited.
if Body_Acts_As_Spec then
if Is_TSS (Ent, TSS_Deep_Initialize) then
declare
Typ : constant Entity_Id := Etype (First_Formal (Ent));
Init : Entity_Id;
begin
if not Is_Controlled (Typ) then
return;
else
Init := Find_Prim_Op (Typ, Name_Initialize);
if Comes_From_Source (Init) then
Ent := Init;
else
return;
end if;
end if;
end;
else
return;
end if;
end if;
-- Check cases of internal units
Callee_Unit_Internal :=
Is_Internal_File_Name (Unit_File_Name (Get_Source_Unit (E_Scope)));
-- Do not give a warning if the with'ed unit is internal and this is
-- the generic instantiation case (this saves a lot of hassle dealing
-- with the Text_IO special child units)
if Callee_Unit_Internal and Inst_Case then
return;
end if;
if C_Scope = Standard_Standard then
Caller_Unit_Internal := False;
else
Caller_Unit_Internal :=
Is_Internal_File_Name (Unit_File_Name (Get_Source_Unit (C_Scope)));
end if;
-- Do not give a warning if the with'ed unit is internal and the
-- caller is not internal (since the binder always elaborates
-- internal units first).
if Callee_Unit_Internal and (not Caller_Unit_Internal) then
return;
end if;
-- For now, if debug flag -gnatdE is not set, do no checking for
-- one internal unit withing another. This fixes the problem with
-- the sgi build and storage errors. To be resolved later ???
if (Callee_Unit_Internal and Caller_Unit_Internal)
and not Debug_Flag_EE
then
return;
end if;
if Is_TSS (E, TSS_Deep_Initialize) then
Ent := E;
end if;
-- If the call is in an instance, and the called entity is not
-- defined in the same instance, then the elaboration issue focuses
-- around the unit containing the template, it is this unit that
-- requires an Elaborate_All.
-- However, if we are doing dynamic elaboration, we need to chase the
-- call in the usual manner.
-- We also need to chase the call in the usual manner if it is a call
-- to a generic formal parameter, since that case was not handled as
-- part of the processing of the template.
Inst_Caller := Instantiation (Get_Source_File_Index (Sloc (N)));
Inst_Callee := Instantiation (Get_Source_File_Index (Sloc (Ent)));
if Inst_Caller = No_Location then
Unit_Caller := No_Unit;
else
Unit_Caller := Get_Source_Unit (N);
end if;
if Inst_Callee = No_Location then
Unit_Callee := No_Unit;
else
Unit_Callee := Get_Source_Unit (Ent);
end if;
if Unit_Caller /= No_Unit
and then Unit_Callee /= Unit_Caller
and then not Dynamic_Elaboration_Checks
and then not Is_Call_Of_Generic_Formal (N)
then
E_Scope := Spec_Entity (Cunit_Entity (Unit_Caller));
-- If we don't get a spec entity, just ignore call. Not quite
-- clear why this check is necessary. ???
if No (E_Scope) then
return;
end if;
-- Otherwise step to enclosing compilation unit
while not Is_Compilation_Unit (E_Scope) loop
E_Scope := Scope (E_Scope);
end loop;
-- For the case where N is not an instance, and is not a call within
-- instance to other than a generic formal, we recompute E_Scope
-- for the error message, since we do NOT want to go to the unit
-- that has the ultimate declaration in the case of renaming and
-- derivation and we also want to go to the generic unit in the
-- case of an instance, and no further.
else
-- Loop to carefully follow renamings and derivations one step
-- outside the current unit, but not further.
if not (Inst_Case or Variable_Case)
and then Present (Alias (Ent))
then
E_Scope := Alias (Ent);
else
E_Scope := Ent;
end if;
loop
while not Is_Compilation_Unit (E_Scope) loop
E_Scope := Scope (E_Scope);
end loop;
-- If E_Scope is the same as C_Scope, it means that there
-- definitely was a local renaming or derivation, and we
-- are not yet out of the current unit.
exit when E_Scope /= C_Scope;
Ent := Alias (Ent);
E_Scope := Ent;
-- If no alias, there could be a previous error, but not if we've
-- already reached the outermost level (Standard).
if No (Ent) then
return;
end if;
end loop;
end if;
if Within_Elaborate_All (Current_Sem_Unit, E_Scope) then
return;
end if;
Is_DIC_Proc := Is_Nontrivial_DIC_Procedure (Ent);
-- Elaboration issues in SPARK are reported only for source constructs
-- and for nontrivial Default_Initial_Condition procedures. The latter
-- must be checked because the default initialization of an object of a
-- private type triggers the evaluation of the Default_Initial_Condition
-- expression, which in turn may have side effects.
Issue_In_SPARK :=
SPARK_Mode = On
and then Dynamic_Elaboration_Checks
and then (Comes_From_Source (Ent) or Is_DIC_Proc);
-- Now check if an Elaborate_All (or dynamic check) is needed
if not Suppress_Elaboration_Warnings (Ent)
and then not Elaboration_Checks_Suppressed (Ent)
and then not Suppress_Elaboration_Warnings (E_Scope)
and then not Elaboration_Checks_Suppressed (E_Scope)
and then ((Elab_Warnings or Elab_Info_Messages)
or else SPARK_Mode = On)
and then Generate_Warnings
then
-- Instantiation case
if Inst_Case then
if Issue_In_SPARK then
Error_Msg_NE
("instantiation of & during elaboration in SPARK", N, Ent);
else
Elab_Warning
("instantiation of & may raise Program_Error?l?",
"info: instantiation of & during elaboration?$?", Ent);
end if;
-- Indirect call case, info message only in static elaboration
-- case, because the attribute reference itself cannot raise an
-- exception. Note that SPARK does not permit indirect calls.
elsif Access_Case then
Elab_Warning ("", "info: access to & during elaboration?$?", Ent);
-- Variable reference in SPARK mode
elsif Variable_Case and Issue_In_SPARK then
Error_Msg_NE
("reference to & during elaboration in SPARK", N, Ent);
-- Subprogram call case
else
if Nkind (Name (N)) in N_Has_Entity
and then Is_Init_Proc (Entity (Name (N)))
and then Comes_From_Source (Ent)
then
Elab_Warning
("implicit call to & may raise Program_Error?l?",
"info: implicit call to & during elaboration?$?",
Ent);
elsif Issue_In_SPARK then
-- Emit a specialized error message when the elaboration of an
-- object of a private type evaluates the expression of pragma
-- Default_Initial_Condition. This prevents the internal name
-- of the procedure from appearing in the error message.
if Is_DIC_Proc then
Error_Msg_N
("call to Default_Initial_Condition during elaboration in "
& "SPARK", N);
else
Error_Msg_NE
("call to & during elaboration in SPARK", N, Ent);
end if;
else
Elab_Warning
("call to & may raise Program_Error?l?",
"info: call to & during elaboration?$?",
Ent);
end if;
end if;
Error_Msg_Qual_Level := Nat'Last;
-- Case of Elaborate_All not present and required, for SPARK this
-- is an error, so give an error message.
if Issue_In_SPARK then
Error_Msg_NE -- CODEFIX
("\Elaborate_All pragma required for&", N, W_Scope);
-- Otherwise we generate an implicit pragma. For a subprogram
-- instantiation, Elaborate is good enough, since no transitive
-- call is possible at elaboration time in this case.
elsif Nkind (N) in N_Subprogram_Instantiation then
Elab_Warning
("\missing pragma Elaborate for&?l?",
"\implicit pragma Elaborate for& generated?$?",
W_Scope);
-- For all other cases, we need an implicit Elaborate_All
else
Elab_Warning
("\missing pragma Elaborate_All for&?l?",
"\implicit pragma Elaborate_All for & generated?$?",
W_Scope);
end if;
Error_Msg_Qual_Level := 0;
-- Take into account the flags related to elaboration warning
-- messages when enumerating the various calls involved. This
-- ensures the proper pairing of the main warning and the
-- clarification messages generated by Output_Calls.
Output_Calls (N, Check_Elab_Flag => True);
-- Set flag to prevent further warnings for same unit unless in
-- All_Errors_Mode.
if not All_Errors_Mode and not Dynamic_Elaboration_Checks then
Set_Suppress_Elaboration_Warnings (W_Scope, True);
end if;
end if;
-- Check for runtime elaboration check required
if Dynamic_Elaboration_Checks then
if not Elaboration_Checks_Suppressed (Ent)
and then not Elaboration_Checks_Suppressed (W_Scope)
and then not Elaboration_Checks_Suppressed (E_Scope)
and then not Cunit_SC
then
-- Runtime elaboration check required. Generate check of the
-- elaboration Boolean for the unit containing the entity.
-- Note that for this case, we do check the real unit (the one
-- from following renamings, since that is the issue).
-- Could this possibly miss a useless but required PE???
Insert_Elab_Check (N,
Make_Attribute_Reference (Loc,
Attribute_Name => Name_Elaborated,
Prefix =>
New_Occurrence_Of (Spec_Entity (E_Scope), Loc)));
-- Prevent duplicate elaboration checks on the same call,
-- which can happen if the body enclosing the call appears
-- itself in a call whose elaboration check is delayed.
if Nkind (N) in N_Subprogram_Call then
Set_No_Elaboration_Check (N);
end if;
end if;
-- Case of static elaboration model
else
-- Do not do anything if elaboration checks suppressed. Note that
-- we check Ent here, not E, since we want the real entity for the
-- body to see if checks are suppressed for it, not the dummy
-- entry for renamings or derivations.
if Elaboration_Checks_Suppressed (Ent)
or else Elaboration_Checks_Suppressed (E_Scope)
or else Elaboration_Checks_Suppressed (W_Scope)
then
null;
-- Do not generate an Elaborate_All for finalization routines
-- that perform partial clean up as part of initialization.
elsif In_Init_Proc and then Is_Finalization_Procedure (Ent) then
null;
-- Here we need to generate an implicit elaborate all
else
-- Generate Elaborate_All warning unless suppressed
if (Elab_Info_Messages and Generate_Warnings and not Inst_Case)
and then not Suppress_Elaboration_Warnings (Ent)
and then not Suppress_Elaboration_Warnings (E_Scope)
and then not Suppress_Elaboration_Warnings (W_Scope)
then
Error_Msg_Node_2 := W_Scope;
Error_Msg_NE
("info: call to& in elaboration code " &
"requires pragma Elaborate_All on&?$?", N, E);
end if;
-- Set indication for binder to generate Elaborate_All
Set_Elaboration_Constraint (N, E, W_Scope);
end if;
end if;
end Check_A_Call;
-----------------------------
-- Check_Bad_Instantiation --
-----------------------------
procedure Check_Bad_Instantiation (N : Node_Id) is
Ent : Entity_Id;
begin
-- Nothing to do if we do not have an instantiation (happens in some
-- error cases, and also in the formal package declaration case)
if Nkind (N) not in N_Generic_Instantiation then
return;
-- Nothing to do if serious errors detected (avoid cascaded errors)
elsif Serious_Errors_Detected /= 0 then
return;
-- Nothing to do if not in full analysis mode
elsif not Full_Analysis then
return;
-- Nothing to do if inside a generic template
elsif Inside_A_Generic then
return;
-- Nothing to do if a library level instantiation
elsif Nkind (Parent (N)) = N_Compilation_Unit then
return;
-- Nothing to do if we are compiling a proper body for semantic
-- purposes only. The generic body may be in another proper body.
elsif
Nkind (Parent (Unit_Declaration_Node (Main_Unit_Entity))) = N_Subunit
then
return;
end if;
Ent := Get_Generic_Entity (N);
-- The case we are interested in is when the generic spec is in the
-- current declarative part
if not Same_Elaboration_Scope (Current_Scope, Scope (Ent))
or else not In_Same_Extended_Unit (N, Ent)
then
return;
end if;
-- If the generic entity is within a deeper instance than we are, then
-- either the instantiation to which we refer itself caused an ABE, in
-- which case that will be handled separately. Otherwise, we know that
-- the body we need appears as needed at the point of the instantiation.
-- If they are both at the same level but not within the same instance
-- then the body of the generic will be in the earlier instance.
declare
D1 : constant Nat := Instantiation_Depth (Sloc (Ent));
D2 : constant Nat := Instantiation_Depth (Sloc (N));
begin
if D1 > D2 then
return;
elsif D1 = D2
and then Is_Generic_Instance (Scope (Ent))
and then not In_Open_Scopes (Scope (Ent))
then
return;
end if;
end;
-- Now we can proceed, if the entity being called has a completion,
-- then we are definitely OK, since we have already seen the body.
if Has_Completion (Ent) then
return;
end if;
-- If there is no body, then nothing to do
if not Has_Generic_Body (N) then
return;
end if;
-- Here we definitely have a bad instantiation
Error_Msg_Warn := SPARK_Mode /= On;
Error_Msg_NE ("cannot instantiate& before body seen<<", N, Ent);
if Present (Instance_Spec (N)) then
Supply_Bodies (Instance_Spec (N));
end if;
Error_Msg_N ("\Program_Error [<<", N);
Insert_Elab_Check (N);
Set_ABE_Is_Certain (N);
end Check_Bad_Instantiation;
---------------------
-- Check_Elab_Call --
---------------------
procedure Check_Elab_Call
(N : Node_Id;
Outer_Scope : Entity_Id := Empty;
In_Init_Proc : Boolean := False)
is
Ent : Entity_Id;
P : Node_Id;
begin
-- If the reference is not in the main unit, there is nothing to check.
-- Elaboration call from units in the context of the main unit will lead
-- to semantic dependencies when those units are compiled.
if not In_Extended_Main_Code_Unit (N) then
return;
end if;
-- For an entry call, check relevant restriction
if Nkind (N) = N_Entry_Call_Statement
and then not In_Subprogram_Or_Concurrent_Unit
then
Check_Restriction (No_Entry_Calls_In_Elaboration_Code, N);
-- Nothing to do if this is not an expected type of reference (happens
-- in some error conditions, and in some cases where rewriting occurs).
elsif Nkind (N) not in N_Subprogram_Call
and then Nkind (N) /= N_Attribute_Reference
and then (SPARK_Mode /= On
or else Nkind (N) not in N_Has_Entity
or else No (Entity (N))
or else Ekind (Entity (N)) /= E_Variable)
then
return;
-- Nothing to do if this is a call already rewritten for elab checking.
-- Such calls appear as the targets of If_Expressions.
-- This check MUST be wrong, it catches far too much
elsif Nkind (Parent (N)) = N_If_Expression then
return;
-- Nothing to do if inside a generic template
elsif Inside_A_Generic
and then No (Enclosing_Generic_Body (N))
then
return;
-- Nothing to do if call is being pre-analyzed, as when within a
-- pre/postcondition, a predicate, or an invariant.
elsif In_Spec_Expression then
return;
end if;
-- Nothing to do if this is a call to a postcondition, which is always
-- within a subprogram body, even though the current scope may be the
-- enclosing scope of the subprogram.
if Nkind (N) = N_Procedure_Call_Statement
and then Is_Entity_Name (Name (N))
and then Chars (Entity (Name (N))) = Name_uPostconditions
then
return;
end if;
-- Here we have a reference at elaboration time that must be checked
if Debug_Flag_LL then
Write_Str (" Check_Elab_Ref: ");
if Nkind (N) = N_Attribute_Reference then
if not Is_Entity_Name (Prefix (N)) then
Write_Str ("<<not entity name>>");
else
Write_Name (Chars (Entity (Prefix (N))));
end if;
Write_Str ("'Access");
elsif No (Name (N)) or else not Is_Entity_Name (Name (N)) then
Write_Str ("<<not entity name>> ");
else
Write_Name (Chars (Entity (Name (N))));
end if;
Write_Str (" reference at ");
Write_Location (Sloc (N));
Write_Eol;
end if;
-- Climb up the tree to make sure we are not inside default expression
-- of a parameter specification or a record component, since in both
-- these cases, we will be doing the actual reference later, not now,
-- and it is at the time of the actual reference (statically speaking)
-- that we must do our static check, not at the time of its initial
-- analysis).
-- However, we have to check references within component definitions
-- (e.g. a function call that determines an array component bound),
-- so we terminate the loop in that case.
P := Parent (N);
while Present (P) loop
if Nkind_In (P, N_Parameter_Specification,
N_Component_Declaration)
then
return;
-- The reference occurs within the constraint of a component,
-- so it must be checked.
elsif Nkind (P) = N_Component_Definition then
exit;
else
P := Parent (P);
end if;
end loop;
-- Stuff that happens only at the outer level
if No (Outer_Scope) then
Elab_Visited.Set_Last (0);
-- Nothing to do if current scope is Standard (this is a bit odd, but
-- it happens in the case of generic instantiations).
C_Scope := Current_Scope;
if C_Scope = Standard_Standard then
return;
end if;
-- First case, we are in elaboration code
From_Elab_Code := not In_Subprogram_Or_Concurrent_Unit;
if From_Elab_Code then
-- Complain if ref that comes from source in preelaborated unit
-- and we are not inside a subprogram (i.e. we are in elab code).
if Comes_From_Source (N)
and then In_Preelaborated_Unit
and then not In_Inlined_Body
and then Nkind (N) /= N_Attribute_Reference
then
-- This is a warning in GNAT mode allowing such calls to be
-- used in the predefined library with appropriate care.
Error_Msg_Warn := GNAT_Mode;
Error_Msg_N
("<<non-static call not allowed in preelaborated unit", N);
return;
end if;
-- Second case, we are inside a subprogram or concurrent unit, which
-- means we are not in elaboration code.
else
-- In this case, the issue is whether we are inside the
-- declarative part of the unit in which we live, or inside its
-- statements. In the latter case, there is no issue of ABE calls
-- at this level (a call from outside to the unit in which we live
-- might cause an ABE, but that will be detected when we analyze
-- that outer level call, as it recurses into the called unit).
-- Climb up the tree, doing this test, and also testing for being
-- inside a default expression, which, as discussed above, is not
-- checked at this stage.
declare
P : Node_Id;
L : List_Id;
begin
P := N;
loop
-- If we find a parentless subtree, it seems safe to assume
-- that we are not in a declarative part and that no
-- checking is required.
if No (P) then
return;
end if;
if Is_List_Member (P) then
L := List_Containing (P);
P := Parent (L);
else
L := No_List;
P := Parent (P);
end if;
exit when Nkind (P) = N_Subunit;
-- Filter out case of default expressions, where we do not
-- do the check at this stage.
if Nkind_In (P, N_Parameter_Specification,
N_Component_Declaration)
then
return;
end if;
-- A protected body has no elaboration code and contains
-- only other bodies.
if Nkind (P) = N_Protected_Body then
return;
elsif Nkind_In (P, N_Subprogram_Body,
N_Task_Body,
N_Block_Statement,
N_Entry_Body)
then
if L = Declarations (P) then
exit;
-- We are not in elaboration code, but we are doing
-- dynamic elaboration checks, in this case, we still
-- need to do the reference, since the subprogram we are
-- in could be called from another unit, also in dynamic
-- elaboration check mode, at elaboration time.
elsif Dynamic_Elaboration_Checks then
-- We provide a debug flag to disable this check. That
-- way we have an easy work around for regressions
-- that are caused by this new check. This debug flag
-- can be removed later.
if Debug_Flag_DD then
return;
end if;
-- Do the check in this case
exit;
elsif Nkind (P) = N_Task_Body then
-- The check is deferred until Check_Task_Activation
-- but we need to capture local suppress pragmas
-- that may inhibit checks on this call.
Ent := Get_Referenced_Ent (N);
if No (Ent) then
return;
elsif Elaboration_Checks_Suppressed (Current_Scope)
or else Elaboration_Checks_Suppressed (Ent)
or else Elaboration_Checks_Suppressed (Scope (Ent))
then
if Nkind (N) in N_Subprogram_Call then
Set_No_Elaboration_Check (N);
end if;
end if;
return;
-- Static model, call is not in elaboration code, we
-- never need to worry, because in the static model the
-- top-level caller always takes care of things.
else
return;
end if;
end if;
end loop;
end;
end if;
end if;
Ent := Get_Referenced_Ent (N);
if No (Ent) then
return;
end if;
-- Nothing to do if this is a recursive call (i.e. a call to
-- an entity that is already in the Elab_Call stack)
for J in 1 .. Elab_Visited.Last loop
if Ent = Elab_Visited.Table (J) then
return;
end if;
end loop;
-- See if we need to analyze this reference. We analyze it if either of
-- the following conditions is met:
-- It is an inner level call (since in this case it was triggered
-- by an outer level call from elaboration code), but only if the
-- call is within the scope of the original outer level call.
-- It is an outer level reference from elaboration code, or a call to
-- an entity is in the same elaboration scope.
-- And in these cases, we will check both inter-unit calls and
-- intra-unit (within a single unit) calls.
C_Scope := Current_Scope;
-- If not outer level reference, then we follow it if it is within the
-- original scope of the outer reference.
if Present (Outer_Scope)
and then Within (Scope (Ent), Outer_Scope)
then
Set_C_Scope;
Check_A_Call
(N => N,
E => Ent,
Outer_Scope => Outer_Scope,
Inter_Unit_Only => False,
In_Init_Proc => In_Init_Proc);
-- Nothing to do if elaboration checks suppressed for this scope.
-- However, an interesting exception, the fact that elaboration checks
-- are suppressed within an instance (because we can trace the body when
-- we process the template) does not extend to calls to generic formal
-- subprograms.
elsif Elaboration_Checks_Suppressed (Current_Scope)
and then not Is_Call_Of_Generic_Formal (N)
then
null;
elsif From_Elab_Code then
Set_C_Scope;
Check_A_Call (N, Ent, Standard_Standard, Inter_Unit_Only => False);
elsif Same_Elaboration_Scope (C_Scope, Scope (Ent)) then
Set_C_Scope;
Check_A_Call (N, Ent, Scope (Ent), Inter_Unit_Only => False);
-- If none of those cases holds, but Dynamic_Elaboration_Checks mode
-- is set, then we will do the check, but only in the inter-unit case
-- (this is to accommodate unguarded elaboration calls from other units
-- in which this same mode is set). We don't want warnings in this case,
-- it would generate warnings having nothing to do with elaboration.
elsif Dynamic_Elaboration_Checks then
Set_C_Scope;
Check_A_Call
(N,
Ent,
Standard_Standard,
Inter_Unit_Only => True,
Generate_Warnings => False);
-- Otherwise nothing to do
else
return;
end if;
-- A call to an Init_Proc in elaboration code may bring additional
-- dependencies, if some of the record components thereof have
-- initializations that are function calls that come from source. We
-- treat the current node as a call to each of these functions, to check
-- their elaboration impact.
if Is_Init_Proc (Ent) and then From_Elab_Code then
Process_Init_Proc : declare
Unit_Decl : constant Node_Id := Unit_Declaration_Node (Ent);
function Check_Init_Call (Nod : Node_Id) return Traverse_Result;
-- Find subprogram calls within body of Init_Proc for Traverse
-- instantiation below.
procedure Traverse_Body is new Traverse_Proc (Check_Init_Call);
-- Traversal procedure to find all calls with body of Init_Proc
---------------------
-- Check_Init_Call --
---------------------
function Check_Init_Call (Nod : Node_Id) return Traverse_Result is
Func : Entity_Id;
begin
if Nkind (Nod) in N_Subprogram_Call
and then Is_Entity_Name (Name (Nod))
then
Func := Entity (Name (Nod));
if Comes_From_Source (Func) then
Check_A_Call
(N, Func, Standard_Standard, Inter_Unit_Only => True);
end if;
return OK;
else
return OK;
end if;
end Check_Init_Call;
-- Start of processing for Process_Init_Proc
begin
if Nkind (Unit_Decl) = N_Subprogram_Body then
Traverse_Body (Handled_Statement_Sequence (Unit_Decl));
end if;
end Process_Init_Proc;
end if;
end Check_Elab_Call;
-----------------------
-- Check_Elab_Assign --
-----------------------
procedure Check_Elab_Assign (N : Node_Id) is
Ent : Entity_Id;
Scop : Entity_Id;
Pkg_Spec : Entity_Id;
Pkg_Body : Entity_Id;
begin
-- For record or array component, check prefix. If it is an access type,
-- then there is nothing to do (we do not know what is being assigned),
-- but otherwise this is an assignment to the prefix.
if Nkind_In (N, N_Indexed_Component,
N_Selected_Component,
N_Slice)
then
if not Is_Access_Type (Etype (Prefix (N))) then
Check_Elab_Assign (Prefix (N));
end if;
return;
end if;
-- For type conversion, check expression
if Nkind (N) = N_Type_Conversion then
Check_Elab_Assign (Expression (N));
return;
end if;
-- Nothing to do if this is not an entity reference otherwise get entity
if Is_Entity_Name (N) then
Ent := Entity (N);
else
return;
end if;
-- What we are looking for is a reference in the body of a package that
-- modifies a variable declared in the visible part of the package spec.
if Present (Ent)
and then Comes_From_Source (N)
and then not Suppress_Elaboration_Warnings (Ent)
and then Ekind (Ent) = E_Variable
and then not In_Private_Part (Ent)
and then Is_Library_Level_Entity (Ent)
then
Scop := Current_Scope;
loop
if No (Scop) or else Scop = Standard_Standard then
return;
elsif Ekind (Scop) = E_Package
and then Is_Compilation_Unit (Scop)
then
exit;
else
Scop := Scope (Scop);
end if;
end loop;
-- Here Scop points to the containing library package
Pkg_Spec := Scop;
Pkg_Body := Body_Entity (Pkg_Spec);
-- All OK if the package has an Elaborate_Body pragma
if Has_Pragma_Elaborate_Body (Scop) then
return;
end if;
-- OK if entity being modified is not in containing package spec
if not In_Same_Source_Unit (Scop, Ent) then
return;
end if;
-- All OK if entity appears in generic package or generic instance.
-- We just get too messed up trying to give proper warnings in the
-- presence of generics. Better no message than a junk one.
Scop := Scope (Ent);
while Present (Scop) and then Scop /= Pkg_Spec loop
if Ekind (Scop) = E_Generic_Package then
return;
elsif Ekind (Scop) = E_Package
and then Is_Generic_Instance (Scop)
then
return;
end if;
Scop := Scope (Scop);
end loop;
-- All OK if in task, don't issue warnings there
if In_Task_Activation then
return;
end if;
-- OK if no package body
if No (Pkg_Body) then
return;
end if;
-- OK if reference is not in package body
if not In_Same_Source_Unit (Pkg_Body, N) then
return;
end if;
-- OK if package body has no handled statement sequence
declare
HSS : constant Node_Id :=
Handled_Statement_Sequence (Declaration_Node (Pkg_Body));
begin
if No (HSS) or else not Comes_From_Source (HSS) then
return;
end if;
end;
-- We definitely have a case of a modification of an entity in
-- the package spec from the elaboration code of the package body.
-- We may not give the warning (because there are some additional
-- checks to avoid too many false positives), but it would be a good
-- idea for the binder to try to keep the body elaboration close to
-- the spec elaboration.
Set_Elaborate_Body_Desirable (Pkg_Spec);
-- All OK in gnat mode (we know what we are doing)
if GNAT_Mode then
return;
end if;
-- All OK if all warnings suppressed
if Warning_Mode = Suppress then
return;
end if;
-- All OK if elaboration checks suppressed for entity
if Checks_May_Be_Suppressed (Ent)
and then Is_Check_Suppressed (Ent, Elaboration_Check)
then
return;
end if;
-- OK if the entity is initialized. Note that the No_Initialization
-- flag usually means that the initialization has been rewritten into
-- assignments, but that still counts for us.
declare
Decl : constant Node_Id := Declaration_Node (Ent);
begin
if Nkind (Decl) = N_Object_Declaration
and then (Present (Expression (Decl))
or else No_Initialization (Decl))
then
return;
end if;
end;
-- Here is where we give the warning
-- All OK if warnings suppressed on the entity
if not Has_Warnings_Off (Ent) then
Error_Msg_Sloc := Sloc (Ent);
Error_Msg_NE
("??& can be accessed by clients before this initialization",
N, Ent);
Error_Msg_NE
("\??add Elaborate_Body to spec to ensure & is initialized",
N, Ent);
end if;
if not All_Errors_Mode then
Set_Suppress_Elaboration_Warnings (Ent);
end if;
end if;
end Check_Elab_Assign;
----------------------
-- Check_Elab_Calls --
----------------------
procedure Check_Elab_Calls is
Save_SPARK_Mode : SPARK_Mode_Type;
begin
-- If expansion is disabled, do not generate any checks, unless we
-- are in GNATprove mode, so that errors are issued in GNATprove for
-- violations of static elaboration rules in SPARK code. Also skip
-- checks if any subunits are missing because in either case we lack the
-- full information that we need, and no object file will be created in
-- any case.
if (not Expander_Active and not GNATprove_Mode)
or else Is_Generic_Unit (Cunit_Entity (Main_Unit))
or else Subunits_Missing
then
return;
end if;
-- Skip delayed calls if we had any errors
if Serious_Errors_Detected = 0 then
Delaying_Elab_Checks := False;
Expander_Mode_Save_And_Set (True);
for J in Delay_Check.First .. Delay_Check.Last loop
Push_Scope (Delay_Check.Table (J).Curscop);
From_Elab_Code := Delay_Check.Table (J).From_Elab_Code;
-- Set appropriate value of SPARK_Mode
Save_SPARK_Mode := SPARK_Mode;
if Delay_Check.Table (J).From_SPARK_Code then
SPARK_Mode := On;
end if;
Check_Internal_Call_Continue (
N => Delay_Check.Table (J).N,
E => Delay_Check.Table (J).E,
Outer_Scope => Delay_Check.Table (J).Outer_Scope,
Orig_Ent => Delay_Check.Table (J).Orig_Ent);
SPARK_Mode := Save_SPARK_Mode;
Pop_Scope;
end loop;
-- Set Delaying_Elab_Checks back on for next main compilation
Expander_Mode_Restore;
Delaying_Elab_Checks := True;
end if;
end Check_Elab_Calls;
------------------------------
-- Check_Elab_Instantiation --
------------------------------
procedure Check_Elab_Instantiation
(N : Node_Id;
Outer_Scope : Entity_Id := Empty)
is
Ent : Entity_Id;
begin
-- Check for and deal with bad instantiation case. There is some
-- duplicated code here, but we will worry about this later ???
Check_Bad_Instantiation (N);
if ABE_Is_Certain (N) then
return;
end if;
-- Nothing to do if we do not have an instantiation (happens in some
-- error cases, and also in the formal package declaration case)
if Nkind (N) not in N_Generic_Instantiation then
return;
end if;
-- Nothing to do if inside a generic template
if Inside_A_Generic then
return;
end if;
-- Nothing to do if the instantiation is not in the main unit
if not In_Extended_Main_Code_Unit (N) then
return;
end if;
Ent := Get_Generic_Entity (N);
From_Elab_Code := not In_Subprogram_Or_Concurrent_Unit;
-- See if we need to analyze this instantiation. We analyze it if
-- either of the following conditions is met:
-- It is an inner level instantiation (since in this case it was
-- triggered by an outer level call from elaboration code), but
-- only if the instantiation is within the scope of the original
-- outer level call.
-- It is an outer level instantiation from elaboration code, or the
-- instantiated entity is in the same elaboration scope.
-- And in these cases, we will check both the inter-unit case and
-- the intra-unit (within a single unit) case.
C_Scope := Current_Scope;
if Present (Outer_Scope) and then Within (Scope (Ent), Outer_Scope) then
Set_C_Scope;
Check_A_Call (N, Ent, Outer_Scope, Inter_Unit_Only => False);
elsif From_Elab_Code then
Set_C_Scope;
Check_A_Call (N, Ent, Standard_Standard, Inter_Unit_Only => False);
elsif Same_Elaboration_Scope (C_Scope, Scope (Ent)) then
Set_C_Scope;
Check_A_Call (N, Ent, Scope (Ent), Inter_Unit_Only => False);
-- If none of those cases holds, but Dynamic_Elaboration_Checks mode is
-- set, then we will do the check, but only in the inter-unit case (this
-- is to accommodate unguarded elaboration calls from other units in
-- which this same mode is set). We inhibit warnings in this case, since
-- this instantiation is not occurring in elaboration code.
elsif Dynamic_Elaboration_Checks then
Set_C_Scope;
Check_A_Call
(N,
Ent,
Standard_Standard,
Inter_Unit_Only => True,
Generate_Warnings => False);
else
return;
end if;
end Check_Elab_Instantiation;
-------------------------
-- Check_Internal_Call --
-------------------------
procedure Check_Internal_Call
(N : Node_Id;
E : Entity_Id;
Outer_Scope : Entity_Id;
Orig_Ent : Entity_Id)
is
function Within_Initial_Condition (Call : Node_Id) return Boolean;
-- Determine whether call Call occurs within pragma Initial_Condition or
-- pragma Check with check_kind set to Initial_Condition.
------------------------------
-- Within_Initial_Condition --
------------------------------
function Within_Initial_Condition (Call : Node_Id) return Boolean is
Args : List_Id;
Nam : Name_Id;
Par : Node_Id;
begin
-- Traverse the parent chain looking for an enclosing pragma
Par := Call;
while Present (Par) loop
if Nkind (Par) = N_Pragma then
Nam := Pragma_Name (Par);
-- Pragma Initial_Condition appears in its alternative from as
-- Check (Initial_Condition, ...).
if Nam = Name_Check then
Args := Pragma_Argument_Associations (Par);
-- Pragma Check should have at least two arguments
pragma Assert (Present (Args));
return
Chars (Expression (First (Args))) = Name_Initial_Condition;
-- Direct match
elsif Nam = Name_Initial_Condition then
return True;
-- Since pragmas are never nested within other pragmas, stop
-- the traversal.
else
return False;
end if;
-- Prevent the search from going too far
elsif Is_Body_Or_Package_Declaration (Par) then
exit;
end if;
Par := Parent (Par);
-- If assertions are not enabled, the check pragma is rewritten
-- as an if_statement in sem_prag, to generate various warnings
-- on boolean expressions. Retrieve the original pragma.
if Nkind (Original_Node (Par)) = N_Pragma then
Par := Original_Node (Par);
end if;
end loop;
return False;
end Within_Initial_Condition;
-- Local variables
Inst_Case : constant Boolean := Nkind (N) in N_Generic_Instantiation;
-- Start of processing for Check_Internal_Call
begin
-- For P'Access, we want to warn if the -gnatw.f switch is set, and the
-- node comes from source.
if Nkind (N) = N_Attribute_Reference
and then ((not Warn_On_Elab_Access and then not Debug_Flag_Dot_O)
or else not Comes_From_Source (N))
then
return;
-- If not function or procedure call, instantiation, or 'Access, then
-- ignore call (this happens in some error cases and rewriting cases).
elsif not Nkind_In (N, N_Attribute_Reference,
N_Function_Call,
N_Procedure_Call_Statement)
and then not Inst_Case
then
return;
-- Nothing to do if this is a call or instantiation that has already
-- been found to be a sure ABE.
elsif Nkind (N) /= N_Attribute_Reference and then ABE_Is_Certain (N) then
return;
-- Nothing to do if errors already detected (avoid cascaded errors)
elsif Serious_Errors_Detected /= 0 then
return;
-- Nothing to do if not in full analysis mode
elsif not Full_Analysis then
return;
-- Nothing to do if analyzing in special spec-expression mode, since the
-- call is not actually being made at this time.
elsif In_Spec_Expression then
return;
-- Nothing to do for call to intrinsic subprogram
elsif Is_Intrinsic_Subprogram (E) then
return;
-- No need to trace local calls if checking task activation, because
-- other local bodies are elaborated already.
elsif In_Task_Activation then
return;
-- Nothing to do if call is within a generic unit
elsif Inside_A_Generic then
return;
-- Nothing to do when the call appears within pragma Initial_Condition.
-- The pragma is part of the elaboration statements of a package body
-- and may only call external subprograms or subprograms whose body is
-- already available.
elsif Within_Initial_Condition (N) then
return;
end if;
-- Delay this call if we are still delaying calls
if Delaying_Elab_Checks then
Delay_Check.Append (
(N => N,
E => E,
Orig_Ent => Orig_Ent,
Curscop => Current_Scope,
Outer_Scope => Outer_Scope,
From_Elab_Code => From_Elab_Code,
From_SPARK_Code => SPARK_Mode = On));
return;
-- Otherwise, call phase 2 continuation right now
else
Check_Internal_Call_Continue (N, E, Outer_Scope, Orig_Ent);
end if;
end Check_Internal_Call;
----------------------------------
-- Check_Internal_Call_Continue --
----------------------------------
procedure Check_Internal_Call_Continue
(N : Node_Id;
E : Entity_Id;
Outer_Scope : Entity_Id;
Orig_Ent : Entity_Id)
is
function Find_Elab_Reference (N : Node_Id) return Traverse_Result;
-- Function applied to each node as we traverse the body. Checks for
-- call or entity reference that needs checking, and if so checks it.
-- Always returns OK, so entire tree is traversed, except that as
-- described below subprogram bodies are skipped for now.
procedure Traverse is new Atree.Traverse_Proc (Find_Elab_Reference);
-- Traverse procedure using above Find_Elab_Reference function
-------------------------
-- Find_Elab_Reference --
-------------------------
function Find_Elab_Reference (N : Node_Id) return Traverse_Result is
Actual : Node_Id;
begin
-- If user has specified that there are no entry calls in elaboration
-- code, do not trace past an accept statement, because the rendez-
-- vous will happen after elaboration.
if Nkind_In (Original_Node (N), N_Accept_Statement,
N_Selective_Accept)
and then Restriction_Active (No_Entry_Calls_In_Elaboration_Code)
then
return Abandon;
-- If we have a function call, check it
elsif Nkind (N) = N_Function_Call then
Check_Elab_Call (N, Outer_Scope);
return OK;
-- If we have a procedure call, check the call, and also check
-- arguments that are assignments (OUT or IN OUT mode formals).
elsif Nkind (N) = N_Procedure_Call_Statement then
Check_Elab_Call (N, Outer_Scope, In_Init_Proc => Is_Init_Proc (E));
Actual := First_Actual (N);
while Present (Actual) loop
if Known_To_Be_Assigned (Actual) then
Check_Elab_Assign (Actual);
end if;
Next_Actual (Actual);
end loop;
return OK;
-- If we have an access attribute for a subprogram, check it.
-- Suppress this behavior under debug flag.
elsif not Debug_Flag_Dot_UU
and then Nkind (N) = N_Attribute_Reference
and then Nam_In (Attribute_Name (N), Name_Access,
Name_Unrestricted_Access)
and then Is_Entity_Name (Prefix (N))
and then Is_Subprogram (Entity (Prefix (N)))
then
Check_Elab_Call (N, Outer_Scope);
return OK;
-- In SPARK mode, if we have an entity reference to a variable, then
-- check it. For now we consider any reference.
elsif SPARK_Mode = On
and then Nkind (N) in N_Has_Entity
and then Present (Entity (N))
and then Ekind (Entity (N)) = E_Variable
then
Check_Elab_Call (N, Outer_Scope);
return OK;
-- If we have a generic instantiation, check it
elsif Nkind (N) in N_Generic_Instantiation then
Check_Elab_Instantiation (N, Outer_Scope);
return OK;
-- Skip subprogram bodies that come from source (wait for call to
-- analyze these). The reason for the come from source test is to
-- avoid catching task bodies.
-- For task bodies, we should really avoid these too, waiting for the
-- task activation, but that's too much trouble to catch for now, so
-- we go in unconditionally. This is not so terrible, it means the
-- error backtrace is not quite complete, and we are too eager to
-- scan bodies of tasks that are unused, but this is hardly very
-- significant.
elsif Nkind (N) = N_Subprogram_Body
and then Comes_From_Source (N)
then
return Skip;
elsif Nkind (N) = N_Assignment_Statement
and then Comes_From_Source (N)
then
Check_Elab_Assign (Name (N));
return OK;
else
return OK;
end if;
end Find_Elab_Reference;
Inst_Case : constant Boolean := Is_Generic_Unit (E);
Loc : constant Source_Ptr := Sloc (N);
Ebody : Entity_Id;
Sbody : Node_Id;
-- Start of processing for Check_Internal_Call_Continue
begin
-- Save outer level call if at outer level
if Elab_Call.Last = 0 then
Outer_Level_Sloc := Loc;
end if;
Elab_Visited.Append (E);
-- If the call is to a function that renames a literal, no check needed
if Ekind (E) = E_Enumeration_Literal then
return;
end if;
Sbody := Unit_Declaration_Node (E);
if not Nkind_In (Sbody, N_Subprogram_Body, N_Package_Body) then
Ebody := Corresponding_Body (Sbody);
if No (Ebody) then
return;
else
Sbody := Unit_Declaration_Node (Ebody);
end if;
end if;
-- If the body appears after the outer level call or instantiation then
-- we have an error case handled below.
if Earlier_In_Extended_Unit (Outer_Level_Sloc, Sloc (Sbody))
and then not In_Task_Activation
then
null;
-- If we have the instantiation case we are done, since we now
-- know that the body of the generic appeared earlier.
elsif Inst_Case then
return;
-- Otherwise we have a call, so we trace through the called body to see
-- if it has any problems.
else
pragma Assert (Nkind (Sbody) = N_Subprogram_Body);
Elab_Call.Append ((Cloc => Loc, Ent => E));
if Debug_Flag_LL then
Write_Str ("Elab_Call.Last = ");
Write_Int (Int (Elab_Call.Last));
Write_Str (" Ent = ");
Write_Name (Chars (E));
Write_Str (" at ");
Write_Location (Sloc (N));
Write_Eol;
end if;
-- Now traverse declarations and statements of subprogram body. Note
-- that we cannot simply Traverse (Sbody), since traverse does not
-- normally visit subprogram bodies.
declare
Decl : Node_Id;
begin
Decl := First (Declarations (Sbody));
while Present (Decl) loop
Traverse (Decl);
Next (Decl);
end loop;
end;
Traverse (Handled_Statement_Sequence (Sbody));
Elab_Call.Decrement_Last;
return;
end if;
-- Here is the case of calling a subprogram where the body has not yet
-- been encountered. A warning message is needed, except if this is the
-- case of appearing within an aspect specification that results in
-- a check call, we do not really have such a situation, so no warning
-- is needed (e.g. the case of a precondition, where the call appears
-- textually before the body, but in actual fact is moved to the
-- appropriate subprogram body and so does not need a check).
declare
P : Node_Id;
O : Node_Id;
begin
P := Parent (N);
loop
-- Keep looking at parents if we are still in the subexpression
if Nkind (P) in N_Subexpr then
P := Parent (P);
-- Here P is the parent of the expression, check for special case
else
O := Original_Node (P);
-- Definitely not the special case if orig node is not a pragma
exit when Nkind (O) /= N_Pragma;
-- Check we have an If statement or a null statement (happens
-- when the If has been expanded to be True).
exit when not Nkind_In (P, N_If_Statement, N_Null_Statement);
-- Our special case will be indicated either by the pragma
-- coming from an aspect ...
if Present (Corresponding_Aspect (O)) then
return;
-- Or, in the case of an initial condition, specifically by a
-- Check pragma specifying an Initial_Condition check.
elsif Pragma_Name (O) = Name_Check
and then
Chars
(Expression (First (Pragma_Argument_Associations (O)))) =
Name_Initial_Condition
then
return;
-- For anything else, we have an error
else
exit;
end if;
end if;
end loop;
end;
-- Not that special case, warning and dynamic check is required
-- If we have nothing in the call stack, then this is at the outer
-- level, and the ABE is bound to occur, unless it's a 'Access, or
-- it's a renaming.
if Elab_Call.Last = 0 then
Error_Msg_Warn := SPARK_Mode /= On;
declare
Insert_Check : Boolean := True;
-- This flag is set to True if an elaboration check should be
-- inserted.
begin
if Inst_Case then
Error_Msg_NE
("cannot instantiate& before body seen<<", N, Orig_Ent);
elsif Nkind (N) = N_Attribute_Reference then
Error_Msg_NE
("Access attribute of & before body seen<<", N, Orig_Ent);
Error_Msg_N ("\possible Program_Error on later references<", N);
Insert_Check := False;
elsif Nkind (Unit_Declaration_Node (Orig_Ent)) /=
N_Subprogram_Renaming_Declaration
then
Error_Msg_NE
("cannot call& before body seen<<", N, Orig_Ent);
elsif not Is_Generic_Actual_Subprogram (Orig_Ent) then
Insert_Check := False;
end if;
if Insert_Check then
Error_Msg_N ("\Program_Error [<<", N);
Insert_Elab_Check (N);
end if;
end;
-- Call is not at outer level
else
-- Deal with dynamic elaboration check
if not Elaboration_Checks_Suppressed (E) then
Set_Elaboration_Entity_Required (E);
-- Case of no elaboration entity allocated yet
if No (Elaboration_Entity (E)) then
-- Create object declaration for elaboration entity, and put it
-- just in front of the spec of the subprogram or generic unit,
-- in the same scope as this unit. The subprogram may be over-
-- loaded, so make the name of elaboration entity unique by
-- means of a numeric suffix.
declare
Loce : constant Source_Ptr := Sloc (E);
Ent : constant Entity_Id :=
Make_Defining_Identifier (Loc,
Chars => New_External_Name (Chars (E), 'E', -1));
begin
Set_Elaboration_Entity (E, Ent);
Push_Scope (Scope (E));
Insert_Action (Declaration_Node (E),
Make_Object_Declaration (Loce,
Defining_Identifier => Ent,
Object_Definition =>
New_Occurrence_Of (Standard_Short_Integer, Loce),
Expression =>
Make_Integer_Literal (Loc, Uint_0)));
-- Set elaboration flag at the point of the body
Set_Elaboration_Flag (Sbody, E);
-- Kill current value indication. This is necessary because
-- the tests of this flag are inserted out of sequence and
-- must not pick up bogus indications of the wrong constant
-- value. Also, this is never a true constant, since one way
-- or another, it gets reset.
Set_Current_Value (Ent, Empty);
Set_Last_Assignment (Ent, Empty);
Set_Is_True_Constant (Ent, False);
Pop_Scope;
end;
end if;
-- Generate check of the elaboration counter
Insert_Elab_Check (N,
Make_Attribute_Reference (Loc,
Attribute_Name => Name_Elaborated,
Prefix => New_Occurrence_Of (E, Loc)));
end if;
-- Generate the warning
if not Suppress_Elaboration_Warnings (E)
and then not Elaboration_Checks_Suppressed (E)
-- Suppress this warning if we have a function call that occurred
-- within an assertion expression, since we can get false warnings
-- in this case, due to the out of order handling in this case.
and then
(Nkind (Original_Node (N)) /= N_Function_Call
or else not In_Assertion_Expression_Pragma (Original_Node (N)))
then
Error_Msg_Warn := SPARK_Mode /= On;
if Inst_Case then
Error_Msg_NE
("instantiation of& may occur before body is seen<l<",
N, Orig_Ent);
else
-- A rather specific check. For Finalize/Adjust/Initialize,
-- if the type has Warnings_Off set, suppress the warning.
if Nam_In (Chars (E), Name_Adjust,
Name_Finalize,
Name_Initialize)
and then Present (First_Formal (E))
then
declare
T : constant Entity_Id := Etype (First_Formal (E));
begin
if Is_Controlled (T) then
if Warnings_Off (T)
or else (Ekind (T) = E_Private_Type
and then Warnings_Off (Full_View (T)))
then
goto Output;
end if;
end if;
end;
end if;
-- Go ahead and give warning if not this special case
Error_Msg_NE
("call to& may occur before body is seen<l<", N, Orig_Ent);
end if;
Error_Msg_N ("\Program_Error ]<l<", N);
-- There is no need to query the elaboration warning message flags
-- because the main message is an error, not a warning, therefore
-- all the clarification messages produces by Output_Calls must be
-- emitted unconditionally.
<<Output>>
Output_Calls (N, Check_Elab_Flag => False);
end if;
end if;
-- Set flag to suppress further warnings on same subprogram
-- unless in all errors mode
if not All_Errors_Mode then
Set_Suppress_Elaboration_Warnings (E);
end if;
end Check_Internal_Call_Continue;
---------------------------
-- Check_Task_Activation --
---------------------------
procedure Check_Task_Activation (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
Inter_Procs : constant Elist_Id := New_Elmt_List;
Intra_Procs : constant Elist_Id := New_Elmt_List;
Ent : Entity_Id;
P : Entity_Id;
Task_Scope : Entity_Id;
Cunit_SC : Boolean := False;
Decl : Node_Id;
Elmt : Elmt_Id;
Enclosing : Entity_Id;
procedure Add_Task_Proc (Typ : Entity_Id);
-- Add to Task_Procs the task body procedure(s) of task types in Typ.
-- For record types, this procedure recurses over component types.
procedure Collect_Tasks (Decls : List_Id);
-- Collect the types of the tasks that are to be activated in the given
-- list of declarations, in order to perform elaboration checks on the
-- corresponding task procedures that are called implicitly here.
function Outer_Unit (E : Entity_Id) return Entity_Id;
-- find enclosing compilation unit of Entity, ignoring subunits, or
-- else enclosing subprogram. If E is not a package, there is no need
-- for inter-unit elaboration checks.
-------------------
-- Add_Task_Proc --
-------------------
procedure Add_Task_Proc (Typ : Entity_Id) is
Comp : Entity_Id;
Proc : Entity_Id := Empty;
begin
if Is_Task_Type (Typ) then
Proc := Get_Task_Body_Procedure (Typ);
elsif Is_Array_Type (Typ)
and then Has_Task (Base_Type (Typ))
then
Add_Task_Proc (Component_Type (Typ));
elsif Is_Record_Type (Typ)
and then Has_Task (Base_Type (Typ))
then
Comp := First_Component (Typ);
while Present (Comp) loop
Add_Task_Proc (Etype (Comp));
Comp := Next_Component (Comp);
end loop;
end if;
-- If the task type is another unit, we will perform the usual
-- elaboration check on its enclosing unit. If the type is in the
-- same unit, we can trace the task body as for an internal call,
-- but we only need to examine other external calls, because at
-- the point the task is activated, internal subprogram bodies
-- will have been elaborated already. We keep separate lists for
-- each kind of task.
-- Skip this test if errors have occurred, since in this case
-- we can get false indications.
if Serious_Errors_Detected /= 0 then
return;
end if;
if Present (Proc) then
if Outer_Unit (Scope (Proc)) = Enclosing then
if No (Corresponding_Body (Unit_Declaration_Node (Proc)))
and then
(not Is_Generic_Instance (Scope (Proc))
or else Scope (Proc) = Scope (Defining_Identifier (Decl)))
then
Error_Msg_Warn := SPARK_Mode /= On;
Error_Msg_N
("task will be activated before elaboration of its body<<",
Decl);
Error_Msg_N ("\Program_Error [<<", Decl);
elsif Present
(Corresponding_Body (Unit_Declaration_Node (Proc)))
then
Append_Elmt (Proc, Intra_Procs);
end if;
else
-- No need for multiple entries of the same type
Elmt := First_Elmt (Inter_Procs);
while Present (Elmt) loop
if Node (Elmt) = Proc then
return;
end if;
Next_Elmt (Elmt);
end loop;
Append_Elmt (Proc, Inter_Procs);
end if;
end if;
end Add_Task_Proc;
-------------------
-- Collect_Tasks --
-------------------
procedure Collect_Tasks (Decls : List_Id) is
begin
if Present (Decls) then
Decl := First (Decls);
while Present (Decl) loop
if Nkind (Decl) = N_Object_Declaration
and then Has_Task (Etype (Defining_Identifier (Decl)))
then
Add_Task_Proc (Etype (Defining_Identifier (Decl)));
end if;
Next (Decl);
end loop;
end if;
end Collect_Tasks;
----------------
-- Outer_Unit --
----------------
function Outer_Unit (E : Entity_Id) return Entity_Id is
Outer : Entity_Id;
begin
Outer := E;
while Present (Outer) loop
if Elaboration_Checks_Suppressed (Outer) then
Cunit_SC := True;
end if;
exit when Is_Child_Unit (Outer)
or else Scope (Outer) = Standard_Standard
or else Ekind (Outer) /= E_Package;
Outer := Scope (Outer);
end loop;
return Outer;
end Outer_Unit;
-- Start of processing for Check_Task_Activation
begin
Enclosing := Outer_Unit (Current_Scope);
-- Find all tasks declared in the current unit
if Nkind (N) = N_Package_Body then
P := Unit_Declaration_Node (Corresponding_Spec (N));
Collect_Tasks (Declarations (N));
Collect_Tasks (Visible_Declarations (Specification (P)));
Collect_Tasks (Private_Declarations (Specification (P)));
elsif Nkind (N) = N_Package_Declaration then
Collect_Tasks (Visible_Declarations (Specification (N)));
Collect_Tasks (Private_Declarations (Specification (N)));
else
Collect_Tasks (Declarations (N));
end if;
-- We only perform detailed checks in all tasks that are library level
-- entities. If the master is a subprogram or task, activation will
-- depend on the activation of the master itself.
-- Should dynamic checks be added in the more general case???
if Ekind (Enclosing) /= E_Package then
return;
end if;
-- For task types defined in other units, we want the unit containing
-- the task body to be elaborated before the current one.
Elmt := First_Elmt (Inter_Procs);
while Present (Elmt) loop
Ent := Node (Elmt);
Task_Scope := Outer_Unit (Scope (Ent));
if not Is_Compilation_Unit (Task_Scope) then
null;
elsif Suppress_Elaboration_Warnings (Task_Scope)
or else Elaboration_Checks_Suppressed (Task_Scope)
then
null;
elsif Dynamic_Elaboration_Checks then
if not Elaboration_Checks_Suppressed (Ent)
and then not Cunit_SC
and then
not Restriction_Active (No_Entry_Calls_In_Elaboration_Code)
then
-- Runtime elaboration check required. Generate check of the
-- elaboration counter for the unit containing the entity.
Insert_Elab_Check (N,
Make_Attribute_Reference (Loc,
Attribute_Name => Name_Elaborated,
Prefix =>
New_Occurrence_Of (Spec_Entity (Task_Scope), Loc)));
end if;
else
-- Force the binder to elaborate other unit first
if not Suppress_Elaboration_Warnings (Ent)
and then not Elaboration_Checks_Suppressed (Ent)
and then Elab_Info_Messages
and then not Suppress_Elaboration_Warnings (Task_Scope)
and then not Elaboration_Checks_Suppressed (Task_Scope)
then
Error_Msg_Node_2 := Task_Scope;
Error_Msg_NE
("info: activation of an instance of task type&" &
" requires pragma Elaborate_All on &?$?", N, Ent);
end if;
Activate_Elaborate_All_Desirable (N, Task_Scope);
Set_Suppress_Elaboration_Warnings (Task_Scope);
end if;
Next_Elmt (Elmt);
end loop;
-- For tasks declared in the current unit, trace other calls within
-- the task procedure bodies, which are available.
In_Task_Activation := True;
Elmt := First_Elmt (Intra_Procs);
while Present (Elmt) loop
Ent := Node (Elmt);
Check_Internal_Call_Continue (N, Ent, Enclosing, Ent);
Next_Elmt (Elmt);
end loop;
In_Task_Activation := False;
end Check_Task_Activation;
-------------------------------
-- Is_Call_Of_Generic_Formal --
-------------------------------
function Is_Call_Of_Generic_Formal (N : Node_Id) return Boolean is
begin
return Nkind_In (N, N_Function_Call, N_Procedure_Call_Statement)
-- Always return False if debug flag -gnatd.G is set
and then not Debug_Flag_Dot_GG
-- For now, we detect this by looking for the strange identifier
-- node, whose Chars reflect the name of the generic formal, but
-- the Chars of the Entity references the generic actual.
and then Nkind (Name (N)) = N_Identifier
and then Chars (Name (N)) /= Chars (Entity (Name (N)));
end Is_Call_Of_Generic_Formal;
--------------------------------
-- Set_Elaboration_Constraint --
--------------------------------
procedure Set_Elaboration_Constraint
(Call : Node_Id;
Subp : Entity_Id;
Scop : Entity_Id)
is
Elab_Unit : Entity_Id;
-- Check whether this is a call to an Initialize subprogram for a
-- controlled type. Note that Call can also be a 'Access attribute
-- reference, which now generates an elaboration check.
Init_Call : constant Boolean :=
Nkind (Call) = N_Procedure_Call_Statement
and then Chars (Subp) = Name_Initialize
and then Comes_From_Source (Subp)
and then Present (Parameter_Associations (Call))
and then Is_Controlled (Etype (First_Actual (Call)));
begin
-- If the unit is mentioned in a with_clause of the current unit, it is
-- visible, and we can set the elaboration flag.
if Is_Immediately_Visible (Scop)
or else (Is_Child_Unit (Scop) and then Is_Visible_Lib_Unit (Scop))
then
Activate_Elaborate_All_Desirable (Call, Scop);
Set_Suppress_Elaboration_Warnings (Scop, True);
return;
end if;
-- If this is not an initialization call or a call using object notation
-- we know that the unit of the called entity is in the context, and
-- we can set the flag as well. The unit need not be visible if the call
-- occurs within an instantiation.
if Is_Init_Proc (Subp)
or else Init_Call
or else Nkind (Original_Node (Call)) = N_Selected_Component
then
null; -- detailed processing follows.
else
Activate_Elaborate_All_Desirable (Call, Scop);
Set_Suppress_Elaboration_Warnings (Scop, True);
return;
end if;
-- If the unit is not in the context, there must be an intermediate unit
-- that is, on which we need to place to elaboration flag. This happens
-- with init proc calls.
if Is_Init_Proc (Subp) or else Init_Call then
-- The initialization call is on an object whose type is not declared
-- in the same scope as the subprogram. The type of the object must
-- be a subtype of the type of operation. This object is the first
-- actual in the call.
declare
Typ : constant Entity_Id :=
Etype (First (Parameter_Associations (Call)));
begin
Elab_Unit := Scope (Typ);
while (Present (Elab_Unit))
and then not Is_Compilation_Unit (Elab_Unit)
loop
Elab_Unit := Scope (Elab_Unit);
end loop;
end;
-- If original node uses selected component notation, the prefix is
-- visible and determines the scope that must be elaborated. After
-- rewriting, the prefix is the first actual in the call.
elsif Nkind (Original_Node (Call)) = N_Selected_Component then
Elab_Unit := Scope (Etype (First (Parameter_Associations (Call))));
-- Not one of special cases above
else
-- Using previously computed scope. If the elaboration check is
-- done after analysis, the scope is not visible any longer, but
-- must still be in the context.
Elab_Unit := Scop;
end if;
Activate_Elaborate_All_Desirable (Call, Elab_Unit);
Set_Suppress_Elaboration_Warnings (Elab_Unit, True);
end Set_Elaboration_Constraint;
------------------------
-- Get_Referenced_Ent --
------------------------
function Get_Referenced_Ent (N : Node_Id) return Entity_Id is
Nam : Node_Id;
begin
if Nkind (N) in N_Has_Entity
and then Present (Entity (N))
and then Ekind (Entity (N)) = E_Variable
then
return Entity (N);
end if;
if Nkind (N) = N_Attribute_Reference then
Nam := Prefix (N);
else
Nam := Name (N);
end if;
if No (Nam) then
return Empty;
elsif Nkind (Nam) = N_Selected_Component then
return Entity (Selector_Name (Nam));
elsif not Is_Entity_Name (Nam) then
return Empty;
else
return Entity (Nam);
end if;
end Get_Referenced_Ent;
----------------------
-- Has_Generic_Body --
----------------------
function Has_Generic_Body (N : Node_Id) return Boolean is
Ent : constant Entity_Id := Get_Generic_Entity (N);
Decl : constant Node_Id := Unit_Declaration_Node (Ent);
Scop : Entity_Id;
function Find_Body_In (E : Entity_Id; N : Node_Id) return Node_Id;
-- Determine if the list of nodes headed by N and linked by Next
-- contains a package body for the package spec entity E, and if so
-- return the package body. If not, then returns Empty.
function Load_Package_Body (Nam : Unit_Name_Type) return Node_Id;
-- This procedure is called load the unit whose name is given by Nam.
-- This unit is being loaded to see whether it contains an optional
-- generic body. The returned value is the loaded unit, which is always
-- a package body (only package bodies can contain other entities in the
-- sense in which Has_Generic_Body is interested). We only attempt to
-- load bodies if we are generating code. If we are in semantics check
-- only mode, then it would be wrong to load bodies that are not
-- required from a semantic point of view, so in this case we return
-- Empty. The result is that the caller may incorrectly decide that a
-- generic spec does not have a body when in fact it does, but the only
-- harm in this is that some warnings on elaboration problems may be
-- lost in semantic checks only mode, which is not big loss. We also
-- return Empty if we go for a body and it is not there.
function Locate_Corresponding_Body (PE : Entity_Id) return Node_Id;
-- PE is the entity for a package spec. This function locates the
-- corresponding package body, returning Empty if none is found. The
-- package body returned is fully parsed but may not yet be analyzed,
-- so only syntactic fields should be referenced.
------------------
-- Find_Body_In --
------------------
function Find_Body_In (E : Entity_Id; N : Node_Id) return Node_Id is
Nod : Node_Id;
begin
Nod := N;
while Present (Nod) loop
-- If we found the package body we are looking for, return it
if Nkind (Nod) = N_Package_Body
and then Chars (Defining_Unit_Name (Nod)) = Chars (E)
then
return Nod;
-- If we found the stub for the body, go after the subunit,
-- loading it if necessary.
elsif Nkind (Nod) = N_Package_Body_Stub
and then Chars (Defining_Identifier (Nod)) = Chars (E)
then
if Present (Library_Unit (Nod)) then
return Unit (Library_Unit (Nod));
else
return Load_Package_Body (Get_Unit_Name (Nod));
end if;
-- If neither package body nor stub, keep looking on chain
else
Next (Nod);
end if;
end loop;
return Empty;
end Find_Body_In;
-----------------------
-- Load_Package_Body --
-----------------------
function Load_Package_Body (Nam : Unit_Name_Type) return Node_Id is
U : Unit_Number_Type;
begin
if Operating_Mode /= Generate_Code then
return Empty;
else
U :=
Load_Unit
(Load_Name => Nam,
Required => False,
Subunit => False,
Error_Node => N);
if U = No_Unit then
return Empty;
else
return Unit (Cunit (U));
end if;
end if;
end Load_Package_Body;
-------------------------------
-- Locate_Corresponding_Body --
-------------------------------
function Locate_Corresponding_Body (PE : Entity_Id) return Node_Id is
Spec : constant Node_Id := Declaration_Node (PE);
Decl : constant Node_Id := Parent (Spec);
Scop : constant Entity_Id := Scope (PE);
PBody : Node_Id;
begin
if Is_Library_Level_Entity (PE) then
-- If package is a library unit that requires a body, we have no
-- choice but to go after that body because it might contain an
-- optional body for the original generic package.
if Unit_Requires_Body (PE) then
-- Load the body. Note that we are a little careful here to use
-- Spec to get the unit number, rather than PE or Decl, since
-- in the case where the package is itself a library level
-- instantiation, Spec will properly reference the generic
-- template, which is what we really want.
return
Load_Package_Body
(Get_Body_Name (Unit_Name (Get_Source_Unit (Spec))));
-- But if the package is a library unit that does NOT require
-- a body, then no body is permitted, so we are sure that there
-- is no body for the original generic package.
else
return Empty;
end if;
-- Otherwise look and see if we are embedded in a further package
elsif Is_Package_Or_Generic_Package (Scop) then
-- If so, get the body of the enclosing package, and look in
-- its package body for the package body we are looking for.
PBody := Locate_Corresponding_Body (Scop);
if No (PBody) then
return Empty;
else
return Find_Body_In (PE, First (Declarations (PBody)));
end if;
-- If we are not embedded in a further package, then the body
-- must be in the same declarative part as we are.
else
return Find_Body_In (PE, Next (Decl));
end if;
end Locate_Corresponding_Body;
-- Start of processing for Has_Generic_Body
begin
if Present (Corresponding_Body (Decl)) then
return True;
elsif Unit_Requires_Body (Ent) then
return True;
-- Compilation units cannot have optional bodies
elsif Is_Compilation_Unit (Ent) then
return False;
-- Otherwise look at what scope we are in
else
Scop := Scope (Ent);
-- Case of entity is in other than a package spec, in this case
-- the body, if present, must be in the same declarative part.
if not Is_Package_Or_Generic_Package (Scop) then
declare
P : Node_Id;
begin
-- Declaration node may get us a spec, so if so, go to
-- the parent declaration.
P := Declaration_Node (Ent);
while not Is_List_Member (P) loop
P := Parent (P);
end loop;
return Present (Find_Body_In (Ent, Next (P)));
end;
-- If the entity is in a package spec, then we have to locate
-- the corresponding package body, and look there.
else
declare
PBody : constant Node_Id := Locate_Corresponding_Body (Scop);
begin
if No (PBody) then
return False;
else
return
Present
(Find_Body_In (Ent, (First (Declarations (PBody)))));
end if;
end;
end if;
end if;
end Has_Generic_Body;
-----------------------
-- Insert_Elab_Check --
-----------------------
procedure Insert_Elab_Check (N : Node_Id; C : Node_Id := Empty) is
Nod : Node_Id;
Loc : constant Source_Ptr := Sloc (N);
Chk : Node_Id;
-- The check (N_Raise_Program_Error) node to be inserted
begin
-- If expansion is disabled, do not generate any checks. Also
-- skip checks if any subunits are missing because in either
-- case we lack the full information that we need, and no object
-- file will be created in any case.
if not Expander_Active or else Subunits_Missing then
return;
end if;
-- If we have a generic instantiation, where Instance_Spec is set,
-- then this field points to a generic instance spec that has
-- been inserted before the instantiation node itself, so that
-- is where we want to insert a check.
if Nkind (N) in N_Generic_Instantiation
and then Present (Instance_Spec (N))
then
Nod := Instance_Spec (N);
else
Nod := N;
end if;
-- Build check node, possibly with condition
Chk :=
Make_Raise_Program_Error (Loc, Reason => PE_Access_Before_Elaboration);
if Present (C) then
Set_Condition (Chk, Make_Op_Not (Loc, Right_Opnd => C));
end if;
-- If we are inserting at the top level, insert in Aux_Decls
if Nkind (Parent (Nod)) = N_Compilation_Unit then
declare
ADN : constant Node_Id := Aux_Decls_Node (Parent (Nod));
begin
if No (Declarations (ADN)) then
Set_Declarations (ADN, New_List (Chk));
else
Append_To (Declarations (ADN), Chk);
end if;
Analyze (Chk);
end;
-- Otherwise just insert as an action on the node in question
else
Insert_Action (Nod, Chk);
end if;
end Insert_Elab_Check;
-------------------------------
-- Is_Finalization_Procedure --
-------------------------------
function Is_Finalization_Procedure (Id : Entity_Id) return Boolean is
begin
-- Check whether Id is a procedure with at least one parameter
if Ekind (Id) = E_Procedure and then Present (First_Formal (Id)) then
declare
Typ : constant Entity_Id := Etype (First_Formal (Id));
Deep_Fin : Entity_Id := Empty;
Fin : Entity_Id := Empty;
begin
-- If the type of the first formal does not require finalization
-- actions, then this is definitely not [Deep_]Finalize.
if not Needs_Finalization (Typ) then
return False;
end if;
-- At this point we have the following scenario:
-- procedure Name (Param1 : [in] [out] Ctrl[; Param2 : ...]);
-- Recover the two possible versions of [Deep_]Finalize using the
-- type of the first parameter and compare with the input.
Deep_Fin := TSS (Typ, TSS_Deep_Finalize);
if Is_Controlled (Typ) then
Fin := Find_Prim_Op (Typ, Name_Finalize);
end if;
return (Present (Deep_Fin) and then Id = Deep_Fin)
or else (Present (Fin) and then Id = Fin);
end;
end if;
return False;
end Is_Finalization_Procedure;
------------------
-- Output_Calls --
------------------
procedure Output_Calls
(N : Node_Id;
Check_Elab_Flag : Boolean)
is
function Emit (Flag : Boolean) return Boolean;
-- Determine whether to emit an error message based on the combination
-- of flags Check_Elab_Flag and Flag.
function Is_Printable_Error_Name return Boolean;
-- An internal function, used to determine if a name, stored in the
-- Name_Buffer, is either a non-internal name, or is an internal name
-- that is printable by the error message circuits (i.e. it has a single
-- upper case letter at the end).
----------
-- Emit --
----------
function Emit (Flag : Boolean) return Boolean is
begin
if Check_Elab_Flag then
return Flag;
else
return True;
end if;
end Emit;
-----------------------------
-- Is_Printable_Error_Name --
-----------------------------
function Is_Printable_Error_Name return Boolean is
begin
if not Is_Internal_Name then
return True;
elsif Name_Len = 1 then
return False;
else
Name_Len := Name_Len - 1;
return not Is_Internal_Name;
end if;
end Is_Printable_Error_Name;
-- Local variables
Ent : Entity_Id;
-- Start of processing for Output_Calls
begin
for J in reverse 1 .. Elab_Call.Last loop
Error_Msg_Sloc := Elab_Call.Table (J).Cloc;
Ent := Elab_Call.Table (J).Ent;
Get_Name_String (Chars (Ent));
-- Dynamic elaboration model, warnings controlled by -gnatwl
if Dynamic_Elaboration_Checks then
if Emit (Elab_Warnings) then
if Is_Generic_Unit (Ent) then
Error_Msg_NE ("\\?l?& instantiated #", N, Ent);
elsif Is_Init_Proc (Ent) then
Error_Msg_N ("\\?l?initialization procedure called #", N);
elsif Is_Printable_Error_Name then
Error_Msg_NE ("\\?l?& called #", N, Ent);
else
Error_Msg_N ("\\?l?called #", N);
end if;
end if;
-- Static elaboration model, info messages controlled by -gnatel
else
if Emit (Elab_Info_Messages) then
if Is_Generic_Unit (Ent) then
Error_Msg_NE ("\\?$?& instantiated #", N, Ent);
elsif Is_Init_Proc (Ent) then
Error_Msg_N ("\\?$?initialization procedure called #", N);
elsif Is_Printable_Error_Name then
Error_Msg_NE ("\\?$?& called #", N, Ent);
else
Error_Msg_N ("\\?$?called #", N);
end if;
end if;
end if;
end loop;
end Output_Calls;
----------------------------
-- Same_Elaboration_Scope --
----------------------------
function Same_Elaboration_Scope (Scop1, Scop2 : Entity_Id) return Boolean is
S1 : Entity_Id;
S2 : Entity_Id;
begin
-- Find elaboration scope for Scop1
-- This is either a subprogram or a compilation unit.
S1 := Scop1;
while S1 /= Standard_Standard
and then not Is_Compilation_Unit (S1)
and then Ekind_In (S1, E_Package, E_Protected_Type, E_Block)
loop
S1 := Scope (S1);
end loop;
-- Find elaboration scope for Scop2
S2 := Scop2;
while S2 /= Standard_Standard
and then not Is_Compilation_Unit (S2)
and then Ekind_In (S2, E_Package, E_Protected_Type, E_Block)
loop
S2 := Scope (S2);
end loop;
return S1 = S2;
end Same_Elaboration_Scope;
-----------------
-- Set_C_Scope --
-----------------
procedure Set_C_Scope is
begin
while not Is_Compilation_Unit (C_Scope) loop
C_Scope := Scope (C_Scope);
end loop;
end Set_C_Scope;
-----------------
-- Spec_Entity --
-----------------
function Spec_Entity (E : Entity_Id) return Entity_Id is
Decl : Node_Id;
begin
-- Check for case of body entity
-- Why is the check for E_Void needed???
if Ekind_In (E, E_Void, E_Subprogram_Body, E_Package_Body) then
Decl := E;
loop
Decl := Parent (Decl);
exit when Nkind (Decl) in N_Proper_Body;
end loop;
return Corresponding_Spec (Decl);
else
return E;
end if;
end Spec_Entity;
-------------------
-- Supply_Bodies --
-------------------
procedure Supply_Bodies (N : Node_Id) is
begin
if Nkind (N) = N_Subprogram_Declaration then
declare
Ent : constant Entity_Id := Defining_Unit_Name (Specification (N));
begin
-- Internal subprograms will already have a generated body, so
-- there is no need to provide a stub for them.
if No (Corresponding_Body (N)) then
declare
Loc : constant Source_Ptr := Sloc (N);
B : Node_Id;
Formals : constant List_Id := Copy_Parameter_List (Ent);
Nam : constant Entity_Id :=
Make_Defining_Identifier (Loc, Chars (Ent));
Spec : Node_Id;
Stats : constant List_Id :=
New_List
(Make_Raise_Program_Error (Loc,
Reason => PE_Access_Before_Elaboration));
begin
if Ekind (Ent) = E_Function then
Spec :=
Make_Function_Specification (Loc,
Defining_Unit_Name => Nam,
Parameter_Specifications => Formals,
Result_Definition =>
New_Copy_Tree
(Result_Definition (Specification (N))));
-- We cannot reliably make a return statement for this
-- body, but none is needed because the call raises
-- program error.
Set_Return_Present (Ent);
else
Spec :=
Make_Procedure_Specification (Loc,
Defining_Unit_Name => Nam,
Parameter_Specifications => Formals);
end if;
B := Make_Subprogram_Body (Loc,
Specification => Spec,
Declarations => New_List,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc, Stats));
Insert_After (N, B);
Analyze (B);
end;
end if;
end;
elsif Nkind (N) = N_Package_Declaration then
declare
Spec : constant Node_Id := Specification (N);
begin
Push_Scope (Defining_Unit_Name (Spec));
Supply_Bodies (Visible_Declarations (Spec));
Supply_Bodies (Private_Declarations (Spec));
Pop_Scope;
end;
end if;
end Supply_Bodies;
procedure Supply_Bodies (L : List_Id) is
Elmt : Node_Id;
begin
if Present (L) then
Elmt := First (L);
while Present (Elmt) loop
Supply_Bodies (Elmt);
Next (Elmt);
end loop;
end if;
end Supply_Bodies;
------------
-- Within --
------------
function Within (E1, E2 : Entity_Id) return Boolean is
Scop : Entity_Id;
begin
Scop := E1;
loop
if Scop = E2 then
return True;
elsif Scop = Standard_Standard then
return False;
else
Scop := Scope (Scop);
end if;
end loop;
end Within;
--------------------------
-- Within_Elaborate_All --
--------------------------
function Within_Elaborate_All
(Unit : Unit_Number_Type;
E : Entity_Id) return Boolean
is
type Unit_Number_Set is array (Main_Unit .. Last_Unit) of Boolean;
pragma Pack (Unit_Number_Set);
Seen : Unit_Number_Set := (others => False);
-- Seen (X) is True after we have seen unit X in the walk. This is used
-- to prevent processing the same unit more than once.
Result : Boolean := False;
procedure Helper (Unit : Unit_Number_Type);
-- This helper procedure does all the work for Within_Elaborate_All. It
-- walks the dependency graph, and sets Result to True if it finds an
-- appropriate Elaborate_All.
------------
-- Helper --
------------
procedure Helper (Unit : Unit_Number_Type) is
CU : constant Node_Id := Cunit (Unit);
Item : Node_Id;
Item2 : Node_Id;
Elab_Id : Entity_Id;
Par : Node_Id;
begin
if Seen (Unit) then
return;
else
Seen (Unit) := True;
end if;
-- First, check for Elaborate_Alls on this unit
Item := First (Context_Items (CU));
while Present (Item) loop
if Nkind (Item) = N_Pragma
and then Pragma_Name (Item) = Name_Elaborate_All
then
-- Return if some previous error on the pragma itself. The
-- pragma may be unanalyzed, because of a previous error, or
-- if it is the context of a subunit, inherited by its parent.
if Error_Posted (Item) or else not Analyzed (Item) then
return;
end if;
Elab_Id :=
Entity
(Expression (First (Pragma_Argument_Associations (Item))));
if E = Elab_Id then
Result := True;
return;
end if;
Par := Parent (Unit_Declaration_Node (Elab_Id));
Item2 := First (Context_Items (Par));
while Present (Item2) loop
if Nkind (Item2) = N_With_Clause
and then Entity (Name (Item2)) = E
and then not Limited_Present (Item2)
then
Result := True;
return;
end if;
Next (Item2);
end loop;
end if;
Next (Item);
end loop;
-- Second, recurse on with's. We could do this as part of the above
-- loop, but it's probably more efficient to have two loops, because
-- the relevant Elaborate_All is likely to be on the initial unit. In
-- other words, we're walking the with's breadth-first. This part is
-- only necessary in the dynamic elaboration model.
if Dynamic_Elaboration_Checks then
Item := First (Context_Items (CU));
while Present (Item) loop
if Nkind (Item) = N_With_Clause
and then not Limited_Present (Item)
then
-- Note: the following call to Get_Cunit_Unit_Number does a
-- linear search, which could be slow, but it's OK because
-- we're about to give a warning anyway. Also, there might
-- be hundreds of units, but not millions. If it turns out
-- to be a problem, we could store the Get_Cunit_Unit_Number
-- in each N_Compilation_Unit node, but that would involve
-- rearranging N_Compilation_Unit_Aux to make room.
Helper (Get_Cunit_Unit_Number (Library_Unit (Item)));
if Result then
return;
end if;
end if;
Next (Item);
end loop;
end if;
end Helper;
-- Start of processing for Within_Elaborate_All
begin
Helper (Unit);
return Result;
end Within_Elaborate_All;
end Sem_Elab;
|
with Ada.Text_IO;
with Moving;
procedure Main is
package Three_Average is new Moving (Max_Elements => 3, Number => Float);
package Five_Average is new Moving (Max_Elements => 5, Number => Float);
begin
for I in 1 .. 5 loop
Ada.Text_IO.Put_Line ("Inserting" & Integer'Image (I) &
" into max-3: " & Float'Image (Three_Average.Moving_Average (Float (I))));
Ada.Text_IO.Put_Line ("Inserting" & Integer'Image (I) &
" into max-5: " & Float'Image (Five_Average.Moving_Average (Float (I))));
end loop;
for I in reverse 1 .. 5 loop
Ada.Text_IO.Put_Line ("Inserting" & Integer'Image (I) &
" into max-3: " & Float'Image (Three_Average.Moving_Average (Float (I))));
Ada.Text_IO.Put_Line ("Inserting" & Integer'Image (I) &
" into max-5: " & Float'Image (Five_Average.Moving_Average (Float (I))));
end loop;
end Main;
|
-- package A_Legendre
--
-- Data structure for Associated Legendre Polynomials. Used by package
-- Clenshaw to generate the Associated Legendre functions via recurrance
-- relations.
--
-- The Norms of the functions are calculated separately from the functions.
-- That's so that calculation of the norms can be moved outside the inner
-- loop that generates the functions. Calculating the Norms may be
-- excessively expensive in time.
--
-- Function Norm is so slow it should be used to fill a table, rather
-- than called excessively.
--
-- Up to roughly order 900(?) is OK for k and m. Beyond that still more
-- tricks are needed, but the tricks vary with l and m, so I don't bother
-- with them.
--
-- If you enter k < 0, or m < 0, then Constraint_error is raised. If you
-- are using this data structure to make Spherical Harmonics, (which allow
-- m < 0), then first set m = Abs (m); the sign of m influences only the
-- Exp (i*m*Phi) part of the Spherical Harmonic.
--
-- (un-normalized) Associated Legendre (m, k): ( l = k + m )
--
-- Q_0 (m, X) = (-1)**m * Sqrt(1-X*X)**m
-- Q_1 (m, X) = X * (2*(m+1) - 1) * Q_0 (m, X) = Alpha*Q_0
-- Q_k (m, X) = X * ((2*(m+k) - 1) / k) * Q_k-1 (m, X)
-- -((k + 2*m - 1) / k) * Q_k-2 (m, X)
-- Alpha (k, m, X) = X * (2*(m+k) - 1) / k
-- Beta (k, m, X) = -(k + 2*m - 1) / k
--
-- Functions are orthogonal on the interval [-1,1] with
-- weight function W(X) = 1. Orthogonality is respect integration, not
-- summation of discrete data points. Normalizing integral:
--
-- Integral (Q_k(m, X) * Q_k(m, X) * W(X))
-- = (k+2*m)! / ((k + m + 0.5) * k! * (2m-1)!!**2)
--
-- The actual Assoc. Legendre Functions are usually defined with (2m-1)!! times
-- the Q_0 given above, but this leads to overflow, so it's put in the Norm.
-- The m values for the Assoc. Legendre Polys are always non-negative. When
-- you use Assoc. Legendre Polys to make spherical, (where m is in -l..l)
-- then use Abs(m) to make the Associated Legendre Functions.
--
-- Data structure for instantiation of Clenshaw:
--
generic
type Real is digits <>;
with function Sqrt (X : Real) return Real;
with function Exp (X : Real) return Real;
with function Log (X : Real) return Real;
type Base_Poly_ID is range <>;
-- Must include 0 in its range. This is checked???
package A_Legendre is
function X_Lower_Bound return Real; -- -1.0
function X_Upper_Bound return Real; -- +1.0
function Alpha (k : Base_Poly_ID; m : Real; X : Real) return Real;
function Beta (k : Base_Poly_ID; m : Real; X : Real) return Real;
function Q_0 (m : Real; X : Real) return Real;
function Normalization_Factor (k : Base_Poly_ID; m : Real) return Real;
-- Multiply the Q's by this to normalize.
function Normalization_Factor_0 (k : Base_Poly_ID; m : Real) return Real;
-- Alternative norm; for testing.
function Poly_Weight (X : Real) return Real;
end A_Legendre;
|
--PRÁCTICA 4: CÉSAR BORAO MORATINOS (Ordered_Maps_G, Test Program)
with Ada.Text_IO;
With Ada.Strings.Unbounded;
with Ordered_Maps_G;
procedure Ordered_Maps_Test is
package ASU renames Ada.Strings.Unbounded;
package ATI renames Ada.Text_IO;
package Maps is new Ordered_Maps_G (Key_Type => Natural,
Value_Type => Natural,
"=" => "=",
"<" => "<",
Max => 4);
procedure Print_Map (M : Maps.Map) is
C: Maps.Cursor := Maps.First(M);
begin
Ada.Text_IO.Put_Line ("Map");
Ada.Text_IO.Put_Line ("===");
while Maps.Has_Element(C) loop
Ada.Text_IO.Put_Line (Natural'Image(Maps.Element(C).Key) & " " &
Natural'Image(Maps.Element(C).Value));
Maps.Next(C);
nd loop;
end Print_Map;
procedure Do_Put (M: in out Maps.Map; K: Natural; V: Natural) is
begin
Ada.Text_IO.New_Line;
ATI.Put_Line("Putting" & Natural'Image(K));
Maps.Put (M, K, V);
Print_Map(M);
exception
when Maps.Full_Map =>
Ada.Text_IO.Put_Line("Full_Map");
end Do_Put;
procedure Do_Get (M: in out Maps.Map; K: Natural) is
V: Natural;
Success: Boolean;
begin
Ada.Text_IO.New_Line;
ATI.Put_Line("Getting" & Natural'Image(K));
Maps.Get (M, K, V, Success);
if Success then
Ada.Text_IO.Put_Line("Value:" & Natural'Image(V));
Print_Map(M);
else
Ada.Text_IO.Put_Line("Element not found!");
end if;
end Do_Get;
procedure Do_Delete (M: in out Maps.Map; K: Natural) is
Success: Boolean;
begin
Ada.Text_IO.New_Line;
ATI.Put_Line("Deleting" & Natural'Image(K));
Maps.Delete (M, K, Success);
if Success then
Ada.Text_IO.Put_Line("borrado");
Print_Map(M);
else
Ada.Text_IO.Put_Line("Element not found!");
end if;
end Do_Delete;
O_Map: Maps.Map;
begin
Do_Put (O_Map, 3, 3);
Do_Put (O_Map, 2, 2);
Do_Put (O_Map, 1, 1);
Do_Put (O_Map, 0, 0);
Do_Get (O_Map, 10000000);
Do_Get (O_Map, 2);
Do_Get (O_Map, 23);
Do_Get (O_Map, 3);
Do_Delete (O_Map, 10000000);
Do_Delete (O_Map, 2);
Do_Delete (O_Map, 0);
Do_Delete (O_Map, 3);
Do_Delete (O_Map, 1);
Do_Get (O_Map, 1);
Do_Put (O_Map, 1, 1);
Do_Get (O_Map, 1);
end Ordered_Maps_Test;
|
-- The Village of Vampire by YT, このソースコードはNYSLです
with Ada.Directories;
with Ada.Hierarchical_File_Names;
with Ada.IO_Exceptions;
with Ada.Streams.Stream_IO;
with YAML.Streams;
package body Tabula.Villages.Lists is
use Summary_Maps;
use User_Lists;
use type Ada.Strings.Unbounded.Unbounded_String;
use type YAML.Event_Type;
function Get_YAML_Type (Name : String) return String is
Result : Ada.Strings.Unbounded.Unbounded_String;
File : Ada.Streams.Stream_IO.File_Type :=
Ada.Streams.Stream_IO.Open (Ada.Streams.Stream_IO.In_File, Name => Name);
Parser : YAML.Parser :=
YAML.Streams.Create (Ada.Streams.Stream_IO.Stream (File));
begin
YAML.Get_Document_Start (Parser);
declare
Parsing_Entry : aliased YAML.Parsing_Entry_Type;
begin
YAML.Get (Parser, Parsing_Entry);
declare
Event : YAML.Event renames YAML.Value (Parsing_Entry);
begin
if Event.Event_Type /= YAML.Mapping_Start then
raise Ada.IO_Exceptions.Data_Error;
end if;
Result := +Event.Tag.all;
end;
end;
Ada.Streams.Stream_IO.Close (File);
if Result.Element (1) = '!' then
Ada.Strings.Unbounded.Delete (Result, 1, 1);
end if;
return Ada.Strings.Unbounded.To_String (Result);
end Get_YAML_Type;
function Get_Type_Index (List : Village_List; Type_Code : String)
return Positive is
begin
for I in 1 .. List.Registered_Type_Count loop
if List.Registered_Types (I).Type_Code.all = Type_Code then
return I;
end if;
end loop;
raise Ada.IO_Exceptions.Data_Error with "unknown type " & Type_Code;
end Get_Type_Index;
procedure Cache_Summaries (List : in Village_List) is
begin
-- create the directory
declare
Dir : constant String :=
Ada.Hierarchical_File_Names.Unchecked_Containing_Directory (
List.Cache_File_Name.all);
begin
if Dir'Length /= 0 then
Ada.Directories.Create_Path (Dir);
end if;
end;
-- write the file
declare
File : Ada.Streams.Stream_IO.File_Type :=
Ada.Streams.Stream_IO.Create (Name => List.Cache_File_Name.all);
begin
Summary_Maps.Map'Write (Ada.Streams.Stream_IO.Stream (File), List.Map);
Ada.Streams.Stream_IO.Close (File);
end;
end Cache_Summaries;
procedure Read_Summaries (
List : in out Village_List;
Update_Cache : in Boolean) is
begin
if not List.Map_Read then
if Ada.Directories.Exists (List.Cache_File_Name.all) then
declare
Cache_File : Ada.Streams.Stream_IO.File_Type :=
Ada.Streams.Stream_IO.Open (
Ada.Streams.Stream_IO.In_File,
Name => List.Cache_File_Name.all);
begin
Summary_Maps.Map'Read (Ada.Streams.Stream_IO.Stream (Cache_File), List.Map);
Ada.Streams.Stream_IO.Close (Cache_File);
end;
else
if Ada.Directories.Exists (List.Data_Directory.all) then
declare
Search : aliased Ada.Directories.Search_Type;
begin
Ada.Directories.Start_Search (Search, List.Data_Directory.all, "????");
while Ada.Directories.More_Entries (Search) loop
declare
File : Ada.Directories.Directory_Entry_Type
renames Ada.Directories.Look_Next_Entry (Search);
Id : String renames Ada.Directories.Simple_Name (File);
begin
if Id (Id'First) in '0' .. '9' then
declare
Type_Code : constant String :=
Get_YAML_Type (Ada.Directories.Full_Name (File));
Type_Index : constant Positive := Get_Type_Index (List, Type_Code);
Summary : Village_Summary
renames List.Registered_Types (Type_Index).Load_Summary (List, Id);
begin
Insert (List.Map, Id, Summary);
end;
end if;
end;
Ada.Directories.Skip_Next_Entry (Search);
end loop;
Ada.Directories.End_Search (Search);
end;
end if;
if Update_Cache then
Cache_Summaries (List);
end if;
end if;
List.Map_Read := True;
end if;
end Read_Summaries;
function Summary (Type_Code : String; Village : Village_Type'Class)
return Village_Summary
is
State : Village_State;
Today : Natural;
begin
Get_State (Village, State, Today);
return Result : Village_Summary := (
Type_Code => +Type_Code,
Name => Village.Name,
By => Village.By,
Term => Village.Term,
Today => Today,
State => State,
People => Empty_List)
do
declare
procedure Process (Index : in Person_Index; Item : in Person_Type'Class) is
begin
Append (Result.People, Item.Id.Constant_Reference);
end Process;
begin
Iterate_People (Village, Process'Access);
end;
end return;
end Summary;
function Create (
Data_Directory : not null Static_String_Access;
HTML_Directory : not null Static_String_Access;
Blocking_Short_Term_File_Name : not null Static_String_Access;
Cache_File_Name : not null Static_String_Access;
Create_Index : not null Create_Index_Procedure;
Types : Registered_Type_Array)
return Village_List is
begin
return (
Data_Directory => Data_Directory,
HTML_Directory => HTML_Directory,
Blocking_Short_Term_File_Name => Blocking_Short_Term_File_Name,
Cache_File_Name => Cache_File_Name,
Create_Index => Create_Index,
Map => Empty_Map,
Map_Read => False,
Registered_Type_Count => Types'Length,
Registered_Types =>
Types
& Registered_Type_Array'(1 .. Registered_Type_Capacity - Types'Length => <>));
end Create;
function File_Name (List : Village_List; Id : Village_Id) return String is
begin
return Ada.Hierarchical_File_Names.Compose (
Directory => List.Data_Directory.all,
Relative_Name => Id);
end File_Name;
function HTML_File_Name (List : Village_List; Id : Village_Id; Day : Natural)
return String is
begin
return Ada.Hierarchical_File_Names.Compose (
Directory => List.HTML_Directory.all,
Relative_Name => Id & "-" & Image (Day),
Extension => "html");
end HTML_File_Name;
function Exists (List : Village_List; Id : Village_Id) return Boolean is
begin
return Ada.Directories.Exists (File_Name (List, Id));
end Exists;
function New_Village_Id (List : Village_List) return Village_Id is
Next : Integer := 0;
begin
if Ada.Directories.Exists (List.Data_Directory.all) then
declare
Search : aliased Ada.Directories.Search_Type;
begin
Ada.Directories.Start_Search (Search, List.Data_Directory.all, "????");
while Ada.Directories.More_Entries (Search) loop
declare
File : Ada.Directories.Directory_Entry_Type
renames Ada.Directories.Look_Next_Entry (Search);
File_Name : constant String :=
Ada.Directories.Simple_Name (File);
begin
declare
Num : constant Integer := Integer'Value (File_Name);
begin
if Num >= Next then
Next := Num + 1;
end if;
end;
exception
when Constraint_Error => null;
end;
Ada.Directories.Skip_Next_Entry (Search);
end loop;
Ada.Directories.End_Search (Search);
end;
end if;
declare
function Image_04d is
new Ada.Formatting.Integer_Image (
Natural,
Signs => Ada.Formatting.Triming_Sign_Marks,
Digits_Width => 4);
begin
return Image_04d (Next);
end;
end New_Village_Id;
procedure Get_Summaries (
List : in out Village_List;
Result : out Summary_Maps.Map) is
begin
Read_Summaries (List, True);
List.Create_Index (List.Map, Update => False);
Result := List.Map;
end Get_Summaries;
function Exists_Opened_By (
Summaries : Summary_Maps.Map;
User_Id : String;
Excluding : Village_Id := Invalid_Village_Id)
return Boolean is
begin
for I in Summaries.Iterate loop
declare
V : Village_Summary renames Summaries.Constant_Reference (I);
begin
if V.State <= Playing
and then V.By = User_Id
and then Summary_Maps.Key (I) /= Excluding
then
return True;
end if;
end;
end loop;
return False;
end Exists_Opened_By;
function Count_Joined_By (
Summaries : Summary_Maps.Map;
User_Id : String;
Filter : Village_State_Set;
Long_Only : Boolean := False;
Including_Escaped : Boolean := False) -- unimplemented
return Natural
is
Result : Natural := 0;
begin
for I in Summaries.Iterate loop
declare
V : Village_Summary renames Summaries.Constant_Reference(I);
begin
if not Long_Only or else V.Term = Long then
if Filter (V.State) then
if V.People.Contains (User_Id) then
Result := Result + 1;
end if;
end if;
end if;
end;
end loop;
return Result;
end Count_Joined_By;
procedure Update (
List : in out Village_List;
Id : Village_Id;
Summary : Village_Summary) is
begin
Read_Summaries (List, False);
Include (List.Map, Id, Summary);
if Summary.State = Closed
and then not Ada.Directories.Exists (HTML_File_Name (List, Id, 0))
then
declare
Type_Index : constant Positive :=
Get_Type_Index (List, Summary.Type_Code.Constant_Reference);
begin
List.Registered_Types (Type_Index).Create_Log (List, Id);
end;
List.Create_Index (List.Map, Update => True);
end if;
Cache_Summaries (List);
end Update;
procedure Refresh (List : in out Village_List) is
Search : aliased Ada.Directories.Search_Type;
begin
-- delete cache
if Ada.Directories.Exists (List.Cache_File_Name.all) then
Ada.Directories.Delete_File (List.Cache_File_Name.all);
end if;
List.Map_Read := False;
-- delete html
Ada.Directories.Start_Search (Search, List.HTML_Directory.all, "*.html");
while Ada.Directories.More_Entries (Search) loop
declare
File : Ada.Directories.Directory_Entry_Type
renames Ada.Directories.Look_Next_Entry (Search);
File_Name : constant String := Ada.Directories.Full_Name (File);
begin
Ada.Directories.Delete_File (File_Name);
end;
Ada.Directories.Skip_Next_Entry (Search);
end loop;
Ada.Directories.End_Search (Search);
-- remake cache
Read_Summaries (List, True);
-- remake html
for I in List.Map.Iterate loop
declare
Id : String renames Summary_Maps.Key (I);
Summary : Village_Summary renames List.Map.Constant_Reference (I);
begin
if Summary.State = Closed then
declare
Type_Code : constant String := Get_YAML_Type (File_Name (List, Id));
Type_Index : constant Positive := Get_Type_Index (List, Type_Code);
begin
List.Registered_Types (Type_Index).Create_Log (List, Id);
end;
end if;
end;
end loop;
-- remake index
List.Create_Index (List.Map, Update => True);
end Refresh;
function Blocking_Short_Term (List : Village_List) return Boolean is
begin
return Ada.Directories.Exists (List.Blocking_Short_Term_File_Name.all);
end Blocking_Short_Term;
end Tabula.Villages.Lists;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.