text
stringlengths 437
491k
| meta
dict |
---|---|
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;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
package body ST7735R is
---------------------------
-- Register definitions --
---------------------------
type MADCTL is record
Reserved1, Reserved2 : Boolean;
MH : Horizontal_Refresh_Order;
RGB : RGB_BGR_Order;
ML : Vertical_Refresh_Order;
MV : Boolean;
MX : Column_Address_Order;
MY : Row_Address_Order;
end record with Size => 8, Bit_Order => System.Low_Order_First;
for MADCTL use record
Reserved1 at 0 range 0 .. 0;
Reserved2 at 0 range 1 .. 1;
MH at 0 range 2 .. 2;
RGB at 0 range 3 .. 3;
ML at 0 range 4 .. 4;
MV at 0 range 5 .. 5;
MX at 0 range 6 .. 6;
MY at 0 range 7 .. 7;
end record;
function To_UInt8 is new Ada.Unchecked_Conversion (MADCTL, UInt8);
procedure Write_Command (LCD : ST7735R_Screen'Class;
Cmd : UInt8);
procedure Write_Command (LCD : ST7735R_Screen'Class;
Cmd : UInt8;
Data : HAL.UInt8_Array);
procedure Write_Pix_Repeat (LCD : ST7735R_Screen'Class;
Data : UInt16;
Count : Natural);
-- Send the same pixel data Count times. This is used to fill an area with
-- the same color without allocating a buffer.
procedure Write_Data (LCD : ST7735R_Screen'Class;
Data : HAL.UInt8_Array);
procedure Read_Data (LCD : ST7735R_Screen'Class;
Data : out UInt16);
procedure Set_Command_Mode (LCD : ST7735R_Screen'Class);
procedure Set_Data_Mode (LCD : ST7735R_Screen'Class);
procedure Start_Transaction (LCD : ST7735R_Screen'Class);
procedure End_Transaction (LCD : ST7735R_Screen'Class);
----------------------
-- Set_Command_Mode --
----------------------
procedure Set_Command_Mode (LCD : ST7735R_Screen'Class) is
begin
LCD.RS.Clear;
end Set_Command_Mode;
-------------------
-- Set_Data_Mode --
-------------------
procedure Set_Data_Mode (LCD : ST7735R_Screen'Class) is
begin
LCD.RS.Set;
end Set_Data_Mode;
-----------------------
-- Start_Transaction --
-----------------------
procedure Start_Transaction (LCD : ST7735R_Screen'Class) is
begin
LCD.CS.Clear;
end Start_Transaction;
---------------------
-- End_Transaction --
---------------------
procedure End_Transaction (LCD : ST7735R_Screen'Class) is
begin
LCD.CS.Set;
end End_Transaction;
-------------------
-- Write_Command --
-------------------
procedure Write_Command (LCD : ST7735R_Screen'Class;
Cmd : UInt8)
is
Status : SPI_Status;
begin
Start_Transaction (LCD);
Set_Command_Mode (LCD);
LCD.Port.Transmit (SPI_Data_8b'(1 => Cmd),
Status);
End_Transaction (LCD);
if Status /= Ok then
-- No error handling...
raise Program_Error;
end if;
end Write_Command;
-------------------
-- Write_Command --
-------------------
procedure Write_Command (LCD : ST7735R_Screen'Class;
Cmd : UInt8;
Data : HAL.UInt8_Array)
is
begin
Write_Command (LCD, Cmd);
Write_Data (LCD, Data);
end Write_Command;
----------------
-- Write_Data --
----------------
procedure Write_Data (LCD : ST7735R_Screen'Class;
Data : HAL.UInt8_Array)
is
Status : SPI_Status;
begin
Start_Transaction (LCD);
Set_Data_Mode (LCD);
LCD.Port.Transmit (SPI_Data_8b (Data), Status);
if Status /= Ok then
-- No error handling...
raise Program_Error;
end if;
End_Transaction (LCD);
end Write_Data;
----------------------
-- Write_Pix_Repeat --
----------------------
procedure Write_Pix_Repeat (LCD : ST7735R_Screen'Class;
Data : UInt16;
Count : Natural)
is
Status : SPI_Status;
Data8 : constant SPI_Data_8b :=
SPI_Data_8b'(1 => UInt8 (Shift_Right (Data, 8) and 16#FF#),
2 => UInt8 (Data and 16#FF#));
begin
Write_Command (LCD, 16#2C#);
Start_Transaction (LCD);
Set_Data_Mode (LCD);
for X in 1 .. Count loop
LCD.Port.Transmit (Data8, Status);
if Status /= Ok then
-- No error handling...
raise Program_Error;
end if;
end loop;
End_Transaction (LCD);
end Write_Pix_Repeat;
---------------
-- Read_Data --
---------------
procedure Read_Data (LCD : ST7735R_Screen'Class;
Data : out UInt16)
is
SPI_Data : SPI_Data_16b (1 .. 1);
Status : SPI_Status;
begin
Start_Transaction (LCD);
Set_Data_Mode (LCD);
LCD.Port.Receive (SPI_Data, Status);
if Status /= Ok then
-- No error handling...
raise Program_Error;
end if;
End_Transaction (LCD);
Data := SPI_Data (SPI_Data'First);
end Read_Data;
----------------
-- Initialize --
----------------
procedure Initialize (LCD : in out ST7735R_Screen) is
begin
LCD.Layer.LCD := LCD'Unchecked_Access;
LCD.RST.Clear;
LCD.Time.Delay_Milliseconds (100);
LCD.RST.Set;
LCD.Time.Delay_Milliseconds (100);
-- Sleep Exit
Write_Command (LCD, 16#11#);
LCD.Time.Delay_Milliseconds (100);
LCD.Initialized := True;
end Initialize;
-----------------
-- Initialized --
-----------------
overriding
function Initialized (LCD : ST7735R_Screen) return Boolean is
(LCD.Initialized);
-------------
-- Turn_On --
-------------
procedure Turn_On (LCD : ST7735R_Screen) is
begin
Write_Command (LCD, 16#29#);
end Turn_On;
--------------
-- Turn_Off --
--------------
procedure Turn_Off (LCD : ST7735R_Screen) is
begin
Write_Command (LCD, 16#28#);
end Turn_Off;
--------------------------
-- Display_Inversion_On --
--------------------------
procedure Display_Inversion_On (LCD : ST7735R_Screen) is
begin
Write_Command (LCD, 16#21#);
end Display_Inversion_On;
---------------------------
-- Display_Inversion_Off --
---------------------------
procedure Display_Inversion_Off (LCD : ST7735R_Screen) is
begin
Write_Command (LCD, 16#20#);
end Display_Inversion_Off;
---------------
-- Gamma_Set --
---------------
procedure Gamma_Set (LCD : ST7735R_Screen; Gamma_Curve : UInt4) is
begin
Write_Command (LCD, 16#26#, (0 => UInt8 (Gamma_Curve)));
end Gamma_Set;
----------------------
-- Set_Pixel_Format --
----------------------
procedure Set_Pixel_Format (LCD : ST7735R_Screen; Pix_Fmt : Pixel_Format) is
Value : constant UInt8 := (case Pix_Fmt is
when Pixel_12bits => 2#011#,
when Pixel_16bits => 2#101#,
when Pixel_18bits => 2#110#);
begin
Write_Command (LCD, 16#3A#, (0 => Value));
end Set_Pixel_Format;
----------------------------
-- Set_Memory_Data_Access --
----------------------------
procedure Set_Memory_Data_Access
(LCD : ST7735R_Screen;
Color_Order : RGB_BGR_Order;
Vertical : Vertical_Refresh_Order;
Horizontal : Horizontal_Refresh_Order;
Row_Addr_Order : Row_Address_Order;
Column_Addr_Order : Column_Address_Order;
Row_Column_Exchange : Boolean)
is
Value : MADCTL;
begin
Value.MY := Row_Addr_Order;
Value.MX := Column_Addr_Order;
Value.MV := Row_Column_Exchange;
Value.ML := Vertical;
Value.RGB := Color_Order;
Value.MH := Horizontal;
Write_Command (LCD, 16#36#, (0 => To_UInt8 (Value)));
end Set_Memory_Data_Access;
---------------------------
-- Set_Frame_Rate_Normal --
---------------------------
procedure Set_Frame_Rate_Normal
(LCD : ST7735R_Screen;
RTN : UInt4;
Front_Porch : UInt6;
Back_Porch : UInt6)
is
begin
Write_Command (LCD, 16#B1#,
(UInt8 (RTN), UInt8 (Front_Porch), UInt8 (Back_Porch)));
end Set_Frame_Rate_Normal;
-------------------------
-- Set_Frame_Rate_Idle --
-------------------------
procedure Set_Frame_Rate_Idle
(LCD : ST7735R_Screen;
RTN : UInt4;
Front_Porch : UInt6;
Back_Porch : UInt6)
is
begin
Write_Command (LCD, 16#B2#,
(UInt8 (RTN), UInt8 (Front_Porch), UInt8 (Back_Porch)));
end Set_Frame_Rate_Idle;
---------------------------------
-- Set_Frame_Rate_Partial_Full --
---------------------------------
procedure Set_Frame_Rate_Partial_Full
(LCD : ST7735R_Screen;
RTN_Part : UInt4;
Front_Porch_Part : UInt6;
Back_Porch_Part : UInt6;
RTN_Full : UInt4;
Front_Porch_Full : UInt6;
Back_Porch_Full : UInt6)
is
begin
Write_Command (LCD, 16#B3#,
(UInt8 (RTN_Part),
UInt8 (Front_Porch_Part),
UInt8 (Back_Porch_Part),
UInt8 (RTN_Full),
UInt8 (Front_Porch_Full),
UInt8 (Back_Porch_Full)));
end Set_Frame_Rate_Partial_Full;
---------------------------
-- Set_Inversion_Control --
---------------------------
procedure Set_Inversion_Control
(LCD : ST7735R_Screen;
Normal, Idle, Full_Partial : Inversion_Control)
is
Value : UInt8 := 0;
begin
if Normal = Line_Inversion then
Value := Value or 2#100#;
end if;
if Idle = Line_Inversion then
Value := Value or 2#010#;
end if;
if Full_Partial = Line_Inversion then
Value := Value or 2#001#;
end if;
Write_Command (LCD, 16#B4#, (0 => Value));
end Set_Inversion_Control;
-------------------------
-- Set_Power_Control_1 --
-------------------------
procedure Set_Power_Control_1
(LCD : ST7735R_Screen;
AVDD : UInt3;
VRHP : UInt5;
VRHN : UInt5;
MODE : UInt2)
is
P1, P2, P3 : UInt8;
begin
P1 := Shift_Left (UInt8 (AVDD), 5) or UInt8 (VRHP);
P2 := UInt8 (VRHN);
P3 := Shift_Left (UInt8 (MODE), 6) or 2#00_0100#;
Write_Command (LCD, 16#C0#, (P1, P2, P3));
end Set_Power_Control_1;
-------------------------
-- Set_Power_Control_2 --
-------------------------
procedure Set_Power_Control_2
(LCD : ST7735R_Screen;
VGH25 : UInt2;
VGSEL : UInt2;
VGHBT : UInt2)
is
P1 : UInt8;
begin
P1 := Shift_Left (UInt8 (VGH25), 6) or
Shift_Left (UInt8 (VGSEL), 2) or
UInt8 (VGHBT);
Write_Command (LCD, 16#C1#, (0 => P1));
end Set_Power_Control_2;
-------------------------
-- Set_Power_Control_3 --
-------------------------
procedure Set_Power_Control_3
(LCD : ST7735R_Screen;
P1, P2 : UInt8)
is
begin
Write_Command (LCD, 16#C2#, (P1, P2));
end Set_Power_Control_3;
-------------------------
-- Set_Power_Control_4 --
-------------------------
procedure Set_Power_Control_4
(LCD : ST7735R_Screen;
P1, P2 : UInt8)
is
begin
Write_Command (LCD, 16#C3#, (P1, P2));
end Set_Power_Control_4;
-------------------------
-- Set_Power_Control_5 --
-------------------------
procedure Set_Power_Control_5
(LCD : ST7735R_Screen;
P1, P2 : UInt8)
is
begin
Write_Command (LCD, 16#C4#, (P1, P2));
end Set_Power_Control_5;
--------------
-- Set_Vcom --
--------------
procedure Set_Vcom (LCD : ST7735R_Screen; VCOMS : UInt6) is
begin
Write_Command (LCD, 16#C5#, (0 => UInt8 (VCOMS)));
end Set_Vcom;
------------------------
-- Set_Column_Address --
------------------------
procedure Set_Column_Address (LCD : ST7735R_Screen; X_Start, X_End : UInt16)
is
P1, P2, P3, P4 : UInt8;
begin
P1 := UInt8 (Shift_Right (X_Start and 16#FF#, 8));
P2 := UInt8 (X_Start and 16#FF#);
P3 := UInt8 (Shift_Right (X_End and 16#FF#, 8));
P4 := UInt8 (X_End and 16#FF#);
Write_Command (LCD, 16#2A#, (P1, P2, P3, P4));
end Set_Column_Address;
---------------------
-- Set_Row_Address --
---------------------
procedure Set_Row_Address (LCD : ST7735R_Screen; Y_Start, Y_End : UInt16)
is
P1, P2, P3, P4 : UInt8;
begin
P1 := UInt8 (Shift_Right (Y_Start and 16#FF#, 8));
P2 := UInt8 (Y_Start and 16#FF#);
P3 := UInt8 (Shift_Right (Y_End and 16#FF#, 8));
P4 := UInt8 (Y_End and 16#FF#);
Write_Command (LCD, 16#2B#, (P1, P2, P3, P4));
end Set_Row_Address;
-----------------
-- Set_Address --
-----------------
procedure Set_Address (LCD : ST7735R_Screen;
X_Start, X_End, Y_Start, Y_End : UInt16)
is
begin
Set_Column_Address (LCD, X_Start, X_End);
Set_Row_Address (LCD, Y_Start, Y_End);
end Set_Address;
---------------
-- Set_Pixel --
---------------
procedure Set_Pixel (LCD : ST7735R_Screen;
X, Y : UInt16;
Color : UInt16)
is
Data : HAL.UInt16_Array (1 .. 1) := (1 => Color);
begin
Set_Address (LCD, X, X + 1, Y, Y + 1);
Write_Raw_Pixels (LCD, Data);
end Set_Pixel;
-----------
-- Pixel --
-----------
function Pixel (LCD : ST7735R_Screen;
X, Y : UInt16)
return UInt16
is
Ret : UInt16;
begin
Set_Address (LCD, X, X + 1, Y, Y + 1);
Read_Data (LCD, Ret);
return Ret;
end Pixel;
----------------------
-- Write_Raw_Pixels --
----------------------
procedure Write_Raw_Pixels (LCD : ST7735R_Screen;
Data : in out HAL.UInt8_Array)
is
Index : Natural := Data'First + 1;
Tmp : UInt8;
begin
-- The ST7735R uses a different endianness than our bitmaps
while Index <= Data'Last loop
Tmp := Data (Index);
Data (Index) := Data (Index - 1);
Data (Index - 1) := Tmp;
Index := Index + 1;
end loop;
Write_Command (LCD, 16#2C#);
Write_Data (LCD, Data);
end Write_Raw_Pixels;
----------------------
-- Write_Raw_Pixels --
----------------------
procedure Write_Raw_Pixels (LCD : ST7735R_Screen;
Data : in out HAL.UInt16_Array)
is
Data_8b : HAL.UInt8_Array (1 .. Data'Length * 2)
with Address => Data'Address;
begin
Write_Raw_Pixels (LCD, Data_8b);
end Write_Raw_Pixels;
--------------------
-- Get_Max_Layers --
--------------------
overriding
function Max_Layers
(Display : ST7735R_Screen) return Positive is (1);
------------------
-- Is_Supported --
------------------
overriding
function Supported
(Display : ST7735R_Screen;
Mode : FB_Color_Mode) return Boolean is
(Mode = HAL.Bitmap.RGB_565);
---------------------
-- Set_Orientation --
---------------------
overriding
procedure Set_Orientation
(Display : in out ST7735R_Screen;
Orientation : Display_Orientation)
is
begin
null;
end Set_Orientation;
--------------
-- Set_Mode --
--------------
overriding
procedure Set_Mode
(Display : in out ST7735R_Screen;
Mode : Wait_Mode)
is
begin
null;
end Set_Mode;
---------------
-- Get_Width --
---------------
overriding
function Width
(Display : ST7735R_Screen) return Positive is (Screen_Width);
----------------
-- Get_Height --
----------------
overriding
function Height
(Display : ST7735R_Screen) return Positive is (Screen_Height);
----------------
-- Is_Swapped --
----------------
overriding
function Swapped
(Display : ST7735R_Screen) return Boolean is (False);
--------------------
-- Set_Background --
--------------------
overriding
procedure Set_Background
(Display : ST7735R_Screen; R, G, B : UInt8)
is
begin
-- Does it make sense when there's no alpha channel...
raise Program_Error;
end Set_Background;
----------------------
-- Initialize_Layer --
----------------------
overriding
procedure Initialize_Layer
(Display : in out ST7735R_Screen;
Layer : Positive;
Mode : FB_Color_Mode;
X : Natural := 0;
Y : Natural := 0;
Width : Positive := Positive'Last;
Height : Positive := Positive'Last)
is
pragma Unreferenced (X, Y);
begin
if Layer /= 1 or else Mode /= RGB_565 then
raise Program_Error;
end if;
Display.Layer.Width := Width;
Display.Layer.Height := Height;
end Initialize_Layer;
-----------------
-- Initialized --
-----------------
overriding
function Initialized
(Display : ST7735R_Screen;
Layer : Positive) return Boolean
is
pragma Unreferenced (Display);
begin
return Layer = 1;
end Initialized;
------------------
-- Update_Layer --
------------------
overriding
procedure Update_Layer
(Display : in out ST7735R_Screen;
Layer : Positive;
Copy_Back : Boolean := False)
is
pragma Unreferenced (Copy_Back, Display);
begin
if Layer /= 1 then
raise Program_Error;
end if;
end Update_Layer;
-------------------
-- Update_Layers --
-------------------
overriding
procedure Update_Layers
(Display : in out ST7735R_Screen)
is
begin
Display.Update_Layer (1);
end Update_Layers;
--------------------
-- Get_Color_Mode --
--------------------
overriding
function Color_Mode
(Display : ST7735R_Screen;
Layer : Positive) return FB_Color_Mode
is
pragma Unreferenced (Display);
begin
if Layer /= 1 then
raise Program_Error;
end if;
return RGB_565;
end Color_Mode;
-----------------------
-- Get_Hidden_Buffer --
-----------------------
overriding
function Hidden_Buffer
(Display : in out ST7735R_Screen;
Layer : Positive) return not null HAL.Bitmap.Any_Bitmap_Buffer
is
begin
if Layer /= 1 then
raise Program_Error;
end if;
return Display.Layer'Unchecked_Access;
end Hidden_Buffer;
----------------
-- Pixel_Size --
----------------
overriding
function Pixel_Size
(Display : ST7735R_Screen;
Layer : Positive) return Positive is (16);
----------------
-- Set_Source --
----------------
overriding
procedure Set_Source (Buffer : in out ST7735R_Bitmap_Buffer;
Native : UInt32)
is
begin
Buffer.Native_Source := Native;
end Set_Source;
------------
-- Source --
------------
overriding
function Source
(Buffer : ST7735R_Bitmap_Buffer)
return UInt32
is
begin
return Buffer.Native_Source;
end Source;
---------------
-- Set_Pixel --
---------------
overriding
procedure Set_Pixel
(Buffer : in out ST7735R_Bitmap_Buffer;
Pt : Point)
is
begin
Buffer.LCD.Set_Pixel (UInt16 (Pt.X), UInt16 (Pt.Y),
UInt16 (Buffer.Native_Source));
end Set_Pixel;
---------------------
-- Set_Pixel_Blend --
---------------------
overriding
procedure Set_Pixel_Blend
(Buffer : in out ST7735R_Bitmap_Buffer;
Pt : Point) renames Set_Pixel;
-----------
-- Pixel --
-----------
overriding
function Pixel
(Buffer : ST7735R_Bitmap_Buffer;
Pt : Point)
return UInt32
is (UInt32 (Buffer.LCD.Pixel (UInt16 (Pt.X), UInt16 (Pt.Y))));
----------
-- Fill --
----------
overriding
procedure Fill
(Buffer : in out ST7735R_Bitmap_Buffer)
is
begin
-- Set the drawing area over the entire layer
Set_Address (Buffer.LCD.all,
0, UInt16 (Buffer.Width - 1),
0, UInt16 (Buffer.Height - 1));
-- Fill the drawing area with a single color
Write_Pix_Repeat (Buffer.LCD.all,
UInt16 (Buffer.Native_Source and 16#FFFF#),
Buffer.Width * Buffer.Height);
end Fill;
---------------
-- Fill_Rect --
---------------
overriding
procedure Fill_Rect
(Buffer : in out ST7735R_Bitmap_Buffer;
Area : Rect)
is
begin
-- Set the drawing area coresponding to the rectangle to draw
Set_Address (Buffer.LCD.all,
UInt16 (Area.Position.X),
UInt16 (Area.Position.X + Area.Width - 1),
UInt16 (Area.Position.Y),
UInt16 (Area.Position.Y + Area.Height - 1));
-- Fill the drawing area with a single color
Write_Pix_Repeat (Buffer.LCD.all,
UInt16 (Buffer.Native_Source and 16#FFFF#),
Area.Width * Area.Height);
end Fill_Rect;
------------------------
-- Draw_Vertical_Line --
------------------------
overriding
procedure Draw_Vertical_Line
(Buffer : in out ST7735R_Bitmap_Buffer;
Pt : Point;
Height : Integer)
is
begin
-- Set the drawing area coresponding to the line to draw
Set_Address (Buffer.LCD.all,
UInt16 (Pt.X),
UInt16 (Pt.X),
UInt16 (Pt.Y),
UInt16 (Pt.Y + Height - 1));
-- Fill the drawing area with a single color
Write_Pix_Repeat (Buffer.LCD.all,
UInt16 (Buffer.Native_Source and 16#FFFF#),
Height);
end Draw_Vertical_Line;
--------------------------
-- Draw_Horizontal_Line --
--------------------------
overriding
procedure Draw_Horizontal_Line
(Buffer : in out ST7735R_Bitmap_Buffer;
Pt : Point;
Width : Integer)
is
begin
-- Set the drawing area coresponding to the line to draw
Set_Address (Buffer.LCD.all,
UInt16 (Pt.X),
UInt16 (Pt.X + Width),
UInt16 (Pt.Y),
UInt16 (Pt.Y));
-- Fill the drawing area with a single color
Write_Pix_Repeat (Buffer.LCD.all,
UInt16 (Buffer.Native_Source and 16#FFFF#),
Width);
end Draw_Horizontal_Line;
end ST7735R;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--*
-- OBJECTIVE:
-- CHECK THAT AN UNCONSTRAINED ARRAY TYPE OR A RECORD WITHOUT
-- DEFAULT DISCRIMINANTS CAN BE USED IN AN ACCESS_TYPE_DEFINITION
-- WITHOUT AN INDEX OR DISCRIMINANT CONSTRAINT.
--
-- CHECK THAT (NON-STATIC) INDEX OR DISCRIMINANT CONSTRAINTS CAN
-- SUBSEQUENTLY BE IMPOSED WHEN THE TYPE IS USED IN AN OBJECT
-- DECLARATION, ARRAY COMPONENT DECLARATION, RECORD COMPONENT
-- DECLARATION, ACCESS TYPE DECLARATION, PARAMETER DECLARATION,
-- DERIVED TYPE DEFINITION, PRIVATE TYPE.
--
-- CHECK FOR UNCONSTRAINED GENERIC FORMAL TYPE.
-- HISTORY:
-- AH 09/02/86 CREATED ORIGINAL TEST.
-- DHH 08/16/88 REVISED HEADER AND ENTERED COMMENTS FOR PRIVATE TYPE
-- AND CORRECTED INDENTATION.
-- BCB 04/12/90 ADDED CHECKS FOR AN ARRAY AS A SUBPROGRAM RETURN
-- TYPE AND AN ARRAY AS A FORMAL PARAMETER.
-- LDC 10/01/90 ADDED CODE SO F, FPROC, G, GPROC AREN'T OPTIMIZED
-- AWAY
WITH REPORT; USE REPORT;
PROCEDURE C38002A IS
BEGIN
TEST ("C38002A", "NON-STATIC CONSTRAINTS CAN BE IMPOSED " &
"ON ACCESS TYPES ACCESSING PREVIOUSLY UNCONSTRAINED " &
"ARRAY OR RECORD TYPES");
DECLARE
C3 : CONSTANT INTEGER := IDENT_INT(3);
TYPE ARR IS ARRAY (INTEGER RANGE <>) OF INTEGER;
TYPE ARR_NAME IS ACCESS ARR;
SUBTYPE ARR_NAME_3 IS ARR_NAME(1..3);
TYPE REC(DISC : INTEGER) IS
RECORD
COMP : ARR_NAME(1..DISC);
END RECORD;
TYPE REC_NAME IS ACCESS REC;
OBJ : REC_NAME(C3);
TYPE ARR2 IS ARRAY (1..10) OF REC_NAME(C3);
TYPE REC2 IS
RECORD
COMP2 : REC_NAME(C3);
END RECORD;
TYPE NAME_REC_NAME IS ACCESS REC_NAME(C3);
TYPE DERIV IS NEW REC_NAME(C3);
SUBTYPE REC_NAME_3 IS REC_NAME(C3);
FUNCTION F (PARM : REC_NAME_3) RETURN REC_NAME_3 IS
BEGIN
IF NOT EQUAL(IDENT_INT(3), 1 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE F AWAY");
END IF;
RETURN PARM;
END;
PROCEDURE FPROC (PARM : REC_NAME_3) IS
BEGIN
IF NOT EQUAL(IDENT_INT(4), 2 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE FPROC AWAY");
END IF;
END FPROC;
FUNCTION G (PA : ARR_NAME_3) RETURN ARR_NAME_3 IS
BEGIN
IF NOT EQUAL(IDENT_INT(5), 3 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE G AWAY");
END IF;
RETURN PA;
END G;
PROCEDURE GPROC (PA : ARR_NAME_3) IS
BEGIN
IF NOT EQUAL(IDENT_INT(6), 4 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE GPROC AWAY");
END IF;
END GPROC;
BEGIN
DECLARE
R : REC_NAME;
BEGIN
R := NEW REC'(DISC => 3, COMP => NEW ARR'(1..3 => 5));
R := F(R);
R := NEW REC'(DISC => 4, COMP => NEW ARR'(1..4 => 5));
R := F(R);
FAILED ("INCOMPATIBLE CONSTRAINT ON ACCESS VALUE " &
"ACCEPTED BY FUNCTION FOR RECORD");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF R = NULL OR ELSE R.DISC /= 4 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT OF " &
"ACCESS VALUE - RECORD,FUNCTION");
END IF;
END;
DECLARE
R : REC_NAME;
BEGIN
R := NEW REC'(DISC => 3, COMP => NEW ARR'(1..3 => 5));
FPROC(R);
R := NEW REC'(DISC => 4, COMP => NEW ARR'(1..4 => 5));
FPROC(R);
FAILED ("INCOMPATIBLE CONSTRAINT ON ACCESS VALUE " &
"ACCEPTED BY PROCEDURE FOR RECORD");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF R = NULL OR ELSE R.DISC /= 4 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT OF " &
"ACCESS VALUE - RECORD,PROCEDURE");
END IF;
END;
DECLARE
A : ARR_NAME;
BEGIN
A := NEW ARR'(1..3 => 5);
A := G(A);
A := NEW ARR'(1..4 => 6);
A := G(A);
FAILED ("INCOMPATIBLE CONSTRAINT ON ACCESS VALUE " &
"ACCEPTED BY FUNCTION FOR ARRAY");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF A = NULL OR ELSE A(4) /= 6 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT OF " &
"ACCESS VALUE - ARRAY,FUNCTION");
END IF;
END;
DECLARE
A : ARR_NAME;
BEGIN
A := NEW ARR'(1..3 => 5);
GPROC(A);
A := NEW ARR'(1..4 => 6);
GPROC(A);
FAILED ("INCOMPATIBLE CONSTRAINT ON ACCESS VALUE " &
"ACCEPTED BY PROCEDURE FOR ARRAY");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF A = NULL OR ELSE A(4) /= 6 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT OF " &
"ACCESS VALUE - ARRAY,PROCEDURE");
END IF;
END;
END;
DECLARE
C3 : CONSTANT INTEGER := IDENT_INT(3);
TYPE REC (DISC : INTEGER) IS
RECORD
NULL;
END RECORD;
TYPE P_ARR IS ARRAY (INTEGER RANGE <>) OF INTEGER;
TYPE P_ARR_NAME IS ACCESS P_ARR;
TYPE P_REC_NAME IS ACCESS REC;
GENERIC
TYPE UNCON_ARR IS ARRAY (INTEGER RANGE <>) OF INTEGER;
PACKAGE P IS
TYPE ACC_REC IS ACCESS REC;
TYPE ACC_ARR IS ACCESS UNCON_ARR;
TYPE ACC_P_ARR IS ACCESS P_ARR;
SUBTYPE ACC_P_ARR_3 IS ACC_P_ARR(1..3);
OBJ : ACC_REC(C3);
TYPE ARR2 IS ARRAY (1..10) OF ACC_REC(C3);
TYPE REC1 IS
RECORD
COMP1 : ACC_REC(C3);
END RECORD;
TYPE REC2 IS
RECORD
COMP2 : ACC_ARR(1..C3);
END RECORD;
SUBTYPE ACC_REC_3 IS ACC_REC(C3);
FUNCTION F (PARM : ACC_REC_3) RETURN ACC_REC_3;
PROCEDURE FPROC (PARM : ACC_REC_3);
FUNCTION G (PA : ACC_P_ARR_3) RETURN ACC_P_ARR_3;
PROCEDURE GPROC (PA : ACC_P_ARR_3);
TYPE ACC1 IS PRIVATE;
TYPE ACC2 IS PRIVATE;
TYPE DER1 IS PRIVATE;
TYPE DER2 IS PRIVATE;
PRIVATE
TYPE ACC1 IS ACCESS ACC_REC(C3);
TYPE ACC2 IS ACCESS ACC_ARR(1..C3);
TYPE DER1 IS NEW ACC_REC(C3);
TYPE DER2 IS NEW ACC_ARR(1..C3);
END P;
PACKAGE BODY P IS
FUNCTION F (PARM : ACC_REC_3) RETURN ACC_REC_3 IS
BEGIN
IF NOT EQUAL(IDENT_INT(3), 1 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE F AWAY");
END IF;
RETURN PARM;
END;
PROCEDURE FPROC (PARM : ACC_REC_3) IS
BEGIN
IF NOT EQUAL(IDENT_INT(4), 2 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE FPROC AWAY");
END IF;
END FPROC;
FUNCTION G (PA : ACC_P_ARR_3) RETURN ACC_P_ARR_3 IS
BEGIN
IF NOT EQUAL(IDENT_INT(5), 3 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE G AWAY");
END IF;
RETURN PA;
END;
PROCEDURE GPROC (PA : ACC_P_ARR_3) IS
BEGIN
IF NOT EQUAL(IDENT_INT(6), 4 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE GPROC AWAY");
END IF;
END GPROC;
END P;
PACKAGE NP IS NEW P (UNCON_ARR => P_ARR);
USE NP;
BEGIN
DECLARE
R : ACC_REC;
BEGIN
R := NEW REC(DISC => 3);
R := F(R);
R := NEW REC(DISC => 4);
R := F(R);
FAILED ("INCOMPATIBLE CONSTRAINT ON ACCESS VALUE " &
"ACCEPTED BY FUNCTION FOR A RECORD -GENERIC");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF R = NULL OR ELSE R.DISC /= 4 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT " &
"OF ACCESS VALUE - RECORD," &
"FUNCTION -GENERIC");
END IF;
END;
DECLARE
R : ACC_REC;
BEGIN
R := NEW REC(DISC => 3);
FPROC(R);
R := NEW REC(DISC => 4);
FPROC(R);
FAILED ("INCOMPATIBLE CONSTRAINT ON ACCESS VALUE " &
"ACCEPTED BY PROCEDURE FOR A RECORD -GENERIC");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF R = NULL OR ELSE R.DISC /= 4 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT " &
"OF ACCESS VALUE - RECORD," &
"PROCEDURE -GENERIC");
END IF;
END;
DECLARE
A : ACC_P_ARR;
BEGIN
A := NEW P_ARR'(1..3 => 5);
A := G(A);
A := NEW P_ARR'(1..4 => 6);
A := G(A);
FAILED ("INCOMPATIBLE CONSTRAINT ON ACCESS VALUE " &
"ACCEPTED BY FUNCTION FOR AN ARRAY -GENERIC");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF A = NULL OR ELSE A(4) /= 6 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT " &
"OF ACCESS VALUE - ARRAY," &
"FUNCTION -GENERIC");
END IF;
END;
DECLARE
A : ACC_P_ARR;
BEGIN
A := NEW P_ARR'(1..3 => 5);
GPROC(A);
A := NEW P_ARR'(1..4 => 6);
GPROC(A);
FAILED ("INCOMPATIBLE CONSTRAINT ON ACCESS VALUE " &
"ACCEPTED BY PROCEDURE FOR AN ARRAY -GENERIC");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF A = NULL OR ELSE A(4) /= 6 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT " &
"OF ACCESS VALUE - ARRAY," &
"PROCEDURE -GENERIC");
END IF;
END;
END;
DECLARE
TYPE CON_INT IS RANGE 1..10;
GENERIC
TYPE UNCON_INT IS RANGE <>;
PACKAGE P2 IS
SUBTYPE NEW_INT IS UNCON_INT RANGE 1..5;
FUNCTION FUNC_INT (PARM : NEW_INT) RETURN NEW_INT;
PROCEDURE PROC_INT (PARM : NEW_INT);
END P2;
PACKAGE BODY P2 IS
FUNCTION FUNC_INT (PARM : NEW_INT) RETURN NEW_INT IS
BEGIN
IF NOT EQUAL(IDENT_INT(3), 1 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE F AWAY");
END IF;
RETURN PARM;
END FUNC_INT;
PROCEDURE PROC_INT (PARM : NEW_INT) IS
BEGIN
IF NOT EQUAL(IDENT_INT(4), 2 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE FPROC AWAY");
END IF;
END PROC_INT;
END P2;
PACKAGE NP2 IS NEW P2 (UNCON_INT => CON_INT);
USE NP2;
BEGIN
DECLARE
R : CON_INT;
BEGIN
R := 2;
R := FUNC_INT(R);
R := 8;
R := FUNC_INT(R);
FAILED ("INCOMPATIBLE CONSTRAINT ON VALUE " &
"ACCEPTED BY FUNCTION -GENERIC");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF R /= 8 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT " &
"OF VALUE -FUNCTION, GENERIC");
END IF;
END;
DECLARE
R : CON_INT;
BEGIN
R := 2;
PROC_INT(R);
R := 9;
PROC_INT(R);
FAILED ("INCOMPATIBLE CONSTRAINT ON ACCESS VALUE " &
"ACCEPTED BY PROCEDURE -GENERIC");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF R /= 9 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT " &
"OF ACCESS VALUE - PROCEDURE, " &
"GENERIC");
END IF;
END;
END;
RESULT;
END C38002A;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
------------------------------------------------------------------------------
with Ada.Containers.Hash_Tables;
with Ada.Streams;
with Ada.Finalization;
generic
type Key_Type (<>) is private;
type Element_Type (<>) is private;
with function Hash (Key : Key_Type) return Hash_Type;
with function Equivalent_Keys (Left, Right : Key_Type) return Boolean;
with function "=" (Left, Right : Element_Type) return Boolean is <>;
package Ada.Containers.Indefinite_Hashed_Maps is
pragma Preelaborate;
type Map is tagged private;
pragma Preelaborable_Initialization (Map);
type Cursor is private;
pragma Preelaborable_Initialization (Cursor);
Empty_Map : constant Map;
No_Element : constant Cursor;
function "=" (Left, Right : Map) return Boolean;
function Capacity (Container : Map) return Count_Type;
procedure Reserve_Capacity
(Container : in out Map;
Capacity : Count_Type);
function Length (Container : Map) return Count_Type;
function Is_Empty (Container : Map) return Boolean;
procedure Clear (Container : in out Map);
function Key (Position : Cursor) return Key_Type;
function Element (Position : Cursor) return Element_Type;
procedure Replace_Element
(Container : in out Map;
Position : Cursor;
New_Item : Element_Type);
procedure Query_Element
(Position : Cursor;
Process : not null access procedure (Key : Key_Type;
Element : Element_Type));
procedure Update_Element
(Container : in out Map;
Position : Cursor;
Process : not null access procedure (Key : Key_Type;
Element : in out Element_Type));
procedure Move (Target : in out Map; Source : in out Map);
procedure Insert
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type;
Position : out Cursor;
Inserted : out Boolean);
procedure Insert
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type);
procedure Include
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type);
procedure Replace
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type);
procedure Exclude (Container : in out Map; Key : Key_Type);
procedure Delete (Container : in out Map; Key : Key_Type);
procedure Delete (Container : in out Map; Position : in out Cursor);
function First (Container : Map) return Cursor;
function Next (Position : Cursor) return Cursor;
procedure Next (Position : in out Cursor);
function Find (Container : Map; Key : Key_Type) return Cursor;
function Contains (Container : Map; Key : Key_Type) return Boolean;
function Element (Container : Map; Key : Key_Type) return Element_Type;
function Has_Element (Position : Cursor) return Boolean;
function Equivalent_Keys (Left, Right : Cursor) return Boolean;
function Equivalent_Keys (Left : Cursor; Right : Key_Type) return Boolean;
function Equivalent_Keys (Left : Key_Type; Right : Cursor) return Boolean;
procedure Iterate
(Container : Map;
Process : not null access procedure (Position : Cursor));
private
pragma Inline ("=");
pragma Inline (Length);
pragma Inline (Is_Empty);
pragma Inline (Clear);
pragma Inline (Key);
pragma Inline (Element);
pragma Inline (Move);
pragma Inline (Contains);
pragma Inline (Capacity);
pragma Inline (Reserve_Capacity);
pragma Inline (Has_Element);
pragma Inline (Equivalent_Keys);
type Node_Type;
type Node_Access is access Node_Type;
type Key_Access is access Key_Type;
type Element_Access is access Element_Type;
type Node_Type is limited record
Key : Key_Access;
Element : Element_Access;
Next : Node_Access;
end record;
package HT_Types is new Hash_Tables.Generic_Hash_Table_Types
(Node_Type,
Node_Access);
type Map is new Ada.Finalization.Controlled with record
HT : HT_Types.Hash_Table_Type;
end record;
use HT_Types;
use Ada.Finalization;
use Ada.Streams;
procedure Adjust (Container : in out Map);
procedure Finalize (Container : in out Map);
type Map_Access is access constant Map;
for Map_Access'Storage_Size use 0;
type Cursor is
record
Container : Map_Access;
Node : Node_Access;
end record;
procedure Write
(Stream : access Root_Stream_Type'Class;
Item : Cursor);
for Cursor'Write use Write;
procedure Read
(Stream : access Root_Stream_Type'Class;
Item : out Cursor);
for Cursor'Read use Read;
No_Element : constant Cursor :=
(Container => null,
Node => null);
procedure Write
(Stream : access Root_Stream_Type'Class;
Container : Map);
for Map'Write use Write;
procedure Read
(Stream : access Root_Stream_Type'Class;
Container : out Map);
for Map'Read use Read;
Empty_Map : constant Map := (Controlled with HT => (null, 0, 0, 0));
end Ada.Containers.Indefinite_Hashed_Maps;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
with Util.Log.Loggers;
with ASF.Cookies;
with AWA.Users.Services;
with AWA.Users.Modules;
package body AWA.Users.Filters is
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Users.Filters");
-- ------------------------------
-- Set the user principal on the session associated with the ASF request.
-- ------------------------------
procedure Set_Session_Principal (Request : in out ASF.Requests.Request'Class;
Principal : in Principals.Principal_Access) is
Session : ASF.Sessions.Session := Request.Get_Session (Create => True);
begin
Session.Set_Principal (Principal.all'Access);
end Set_Session_Principal;
-- ------------------------------
-- Initialize the filter and configure the redirection URIs.
-- ------------------------------
procedure Initialize (Filter : in out Auth_Filter;
Context : in ASF.Servlets.Servlet_Registry'Class) is
URI : constant String := Context.Get_Init_Parameter (AUTH_FILTER_REDIRECT_PARAM);
begin
Log.Info ("Using login URI: {0}", URI);
if URI = "" then
Log.Error ("The login URI is empty. Redirection to the login page will not work.");
end if;
Filter.Login_URI := To_Unbounded_String (URI);
ASF.Security.Filters.Auth_Filter (Filter).Initialize (Context);
end Initialize;
procedure Authenticate (F : in Auth_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class;
Session : in ASF.Sessions.Session;
Auth_Id : in String;
Principal : out ASF.Principals.Principal_Access) is
pragma Unreferenced (F, Session);
use AWA.Users.Modules;
use AWA.Users.Services;
Manager : constant User_Service_Access := AWA.Users.Modules.Get_User_Manager;
P : AWA.Users.Principals.Principal_Access;
begin
Manager.Authenticate (Cookie => Auth_Id,
Ip_Addr => "",
Principal => P);
Principal := P.all'Access;
-- Setup a new AID cookie with the new connection session.
declare
Cookie : constant String := Manager.Get_Authenticate_Cookie (P.Get_Session_Identifier);
C : ASF.Cookies.Cookie := ASF.Cookies.Create (ASF.Security.Filters.AID_COOKIE,
Cookie);
begin
ASF.Cookies.Set_Path (C, Request.Get_Context_Path);
ASF.Cookies.Set_Max_Age (C, 15 * 86400);
Response.Add_Cookie (Cookie => C);
end;
exception
when Not_Found =>
Principal := null;
end Authenticate;
-- ------------------------------
-- Display or redirects the user to the login page. This procedure is called when
-- the user is not authenticated.
-- ------------------------------
overriding
procedure Do_Login (Filter : in Auth_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class) is
URI : constant String := To_String (Filter.Login_URI);
begin
Log.Info ("User is not logged, redirecting to {0}", URI);
if Request.Get_Header ("X-Requested-With") = "" then
Response.Send_Redirect (Location => URI);
else
Response.Send_Error (ASF.Responses.SC_UNAUTHORIZED);
end if;
end Do_Login;
-- ------------------------------
-- Initialize the filter and configure the redirection URIs.
-- ------------------------------
overriding
procedure Initialize (Filter : in out Verify_Filter;
Context : in ASF.Servlets.Servlet_Registry'Class) is
URI : constant String := Context.Get_Init_Parameter (VERIFY_FILTER_REDIRECT_PARAM);
begin
Filter.Invalid_Key_URI := To_Unbounded_String (URI);
end Initialize;
-- ------------------------------
-- Filter a request which contains an access key and verify that the
-- key is valid and identifies a user. Once the user is known, create
-- a session and setup the user principal.
--
-- If the access key is missing or invalid, redirect to the
-- <b>Invalid_Key_URI</b> associated with the filter.
-- ------------------------------
overriding
procedure Do_Filter (Filter : in Verify_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class;
Chain : in out ASF.Servlets.Filter_Chain) is
Key : constant String := Request.Get_Parameter (PARAM_ACCESS_KEY);
Manager : constant Users.Services.User_Service_Access := Users.Modules.Get_User_Manager;
Principal : AWA.Users.Principals.Principal_Access;
begin
Log.Info ("Verify access key {0}", Key);
Manager.Verify_User (Key => Key,
IpAddr => "",
Principal => Principal);
Set_Session_Principal (Request, Principal);
-- Request is authorized, proceed to the next filter.
ASF.Servlets.Do_Filter (Chain => Chain,
Request => Request,
Response => Response);
exception
when AWA.Users.Services.Not_Found =>
declare
URI : constant String := To_String (Filter.Invalid_Key_URI);
begin
Log.Info ("Invalid access key {0}, redirecting to {1}", Key, URI);
Response.Send_Redirect (Location => URI);
end;
end Do_Filter;
end AWA.Users.Filters;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Opt; use Opt;
with Tree_IO; use Tree_IO;
package body Osint.C is
Output_Object_File_Name : String_Ptr;
-- Argument of -o compiler option, if given. This is needed to verify
-- consistency with the ALI file name.
procedure Adjust_OS_Resource_Limits;
pragma Import (C, Adjust_OS_Resource_Limits,
"__gnat_adjust_os_resource_limits");
-- Procedure to make system specific adjustments to make GNAT run better
function Create_Auxiliary_File
(Src : File_Name_Type;
Suffix : String) return File_Name_Type;
-- Common processing for Create_List_File, Create_Repinfo_File and
-- Create_Debug_File. Src is the file name used to create the required
-- output file and Suffix is the desired suffix (dg/rep/xxx for debug/
-- repinfo/list file where xxx is specified extension.
------------------
-- Close_C_File --
------------------
procedure Close_C_File is
Status : Boolean;
begin
Close (Output_FD, Status);
if not Status then
Fail
("error while closing file "
& Get_Name_String (Output_File_Name));
end if;
end Close_C_File;
----------------------
-- Close_Debug_File --
----------------------
procedure Close_Debug_File is
Status : Boolean;
begin
Close (Output_FD, Status);
if not Status then
Fail
("error while closing expanded source file "
& Get_Name_String (Output_File_Name));
end if;
end Close_Debug_File;
------------------
-- Close_H_File --
------------------
procedure Close_H_File is
Status : Boolean;
begin
Close (Output_FD, Status);
if not Status then
Fail
("error while closing file "
& Get_Name_String (Output_File_Name));
end if;
end Close_H_File;
---------------------
-- Close_List_File --
---------------------
procedure Close_List_File is
Status : Boolean;
begin
Close (Output_FD, Status);
if not Status then
Fail
("error while closing list file "
& Get_Name_String (Output_File_Name));
end if;
end Close_List_File;
-------------------------------
-- Close_Output_Library_Info --
-------------------------------
procedure Close_Output_Library_Info is
Status : Boolean;
begin
Close (Output_FD, Status);
if not Status then
Fail
("error while closing ALI file "
& Get_Name_String (Output_File_Name));
end if;
end Close_Output_Library_Info;
------------------------
-- Close_Repinfo_File --
------------------------
procedure Close_Repinfo_File is
Status : Boolean;
begin
Close (Output_FD, Status);
if not Status then
Fail
("error while closing representation info file "
& Get_Name_String (Output_File_Name));
end if;
end Close_Repinfo_File;
---------------------------
-- Create_Auxiliary_File --
---------------------------
function Create_Auxiliary_File
(Src : File_Name_Type;
Suffix : String) return File_Name_Type
is
Result : File_Name_Type;
begin
Get_Name_String (Src);
Name_Buffer (Name_Len + 1) := '.';
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len + 1 .. Name_Len + Suffix'Length) := Suffix;
Name_Len := Name_Len + Suffix'Length;
if Output_Object_File_Name /= null then
for Index in reverse Output_Object_File_Name'Range loop
if Output_Object_File_Name (Index) = Directory_Separator then
declare
File_Name : constant String := Name_Buffer (1 .. Name_Len);
begin
Name_Len := Index - Output_Object_File_Name'First + 1;
Name_Buffer (1 .. Name_Len) :=
Output_Object_File_Name
(Output_Object_File_Name'First .. Index);
Name_Buffer (Name_Len + 1 .. Name_Len + File_Name'Length) :=
File_Name;
Name_Len := Name_Len + File_Name'Length;
end;
exit;
end if;
end loop;
end if;
Result := Name_Find;
Name_Buffer (Name_Len + 1) := ASCII.NUL;
Create_File_And_Check (Output_FD, Text);
return Result;
end Create_Auxiliary_File;
-------------------
-- Create_C_File --
-------------------
procedure Create_C_File is
Dummy : Boolean;
begin
Set_File_Name ("c");
Delete_File (Name_Buffer (1 .. Name_Len), Dummy);
Create_File_And_Check (Output_FD, Text);
end Create_C_File;
-----------------------
-- Create_Debug_File --
-----------------------
function Create_Debug_File (Src : File_Name_Type) return File_Name_Type is
begin
return Create_Auxiliary_File (Src, "dg");
end Create_Debug_File;
-------------------
-- Create_H_File --
-------------------
procedure Create_H_File is
Dummy : Boolean;
begin
Set_File_Name ("h");
Delete_File (Name_Buffer (1 .. Name_Len), Dummy);
Create_File_And_Check (Output_FD, Text);
end Create_H_File;
----------------------
-- Create_List_File --
----------------------
procedure Create_List_File (S : String) is
Dummy : File_Name_Type;
begin
if S (S'First) = '.' then
Dummy :=
Create_Auxiliary_File (Current_Main, S (S'First + 1 .. S'Last));
else
Name_Buffer (1 .. S'Length) := S;
Name_Len := S'Length + 1;
Name_Buffer (Name_Len) := ASCII.NUL;
Create_File_And_Check (Output_FD, Text);
end if;
end Create_List_File;
--------------------------------
-- Create_Output_Library_Info --
--------------------------------
procedure Create_Output_Library_Info is
Dummy : Boolean;
begin
Set_File_Name (ALI_Suffix.all);
Delete_File (Name_Buffer (1 .. Name_Len), Dummy);
Create_File_And_Check (Output_FD, Text);
end Create_Output_Library_Info;
------------------------------
-- Open_Output_Library_Info --
------------------------------
procedure Open_Output_Library_Info is
begin
Set_File_Name (ALI_Suffix.all);
Open_File_To_Append_And_Check (Output_FD, Text);
end Open_Output_Library_Info;
-------------------------
-- Create_Repinfo_File --
-------------------------
procedure Create_Repinfo_File (Src : String) is
Discard : File_Name_Type;
begin
Name_Buffer (1 .. Src'Length) := Src;
Name_Len := Src'Length;
Discard := Create_Auxiliary_File (Name_Find, "rep");
return;
end Create_Repinfo_File;
---------------------------
-- Debug_File_Eol_Length --
---------------------------
function Debug_File_Eol_Length return Nat is
begin
-- There has to be a cleaner way to do this ???
if Directory_Separator = '/' then
return 1;
else
return 2;
end if;
end Debug_File_Eol_Length;
-------------------
-- Delete_C_File --
-------------------
procedure Delete_C_File is
Dummy : Boolean;
begin
Set_File_Name ("c");
Delete_File (Name_Buffer (1 .. Name_Len), Dummy);
end Delete_C_File;
-------------------
-- Delete_H_File --
-------------------
procedure Delete_H_File is
Dummy : Boolean;
begin
Set_File_Name ("h");
Delete_File (Name_Buffer (1 .. Name_Len), Dummy);
end Delete_H_File;
---------------------------------
-- Get_Output_Object_File_Name --
---------------------------------
function Get_Output_Object_File_Name return String is
begin
pragma Assert (Output_Object_File_Name /= null);
return Output_Object_File_Name.all;
end Get_Output_Object_File_Name;
-----------------------
-- More_Source_Files --
-----------------------
function More_Source_Files return Boolean renames More_Files;
----------------------
-- Next_Main_Source --
----------------------
function Next_Main_Source return File_Name_Type renames Next_Main_File;
-----------------------
-- Read_Library_Info --
-----------------------
procedure Read_Library_Info
(Name : out File_Name_Type;
Text : out Text_Buffer_Ptr)
is
begin
Set_File_Name (ALI_Suffix.all);
-- Remove trailing NUL that comes from Set_File_Name above. This is
-- needed for consistency with names that come from Scan_ALI and thus
-- preventing repeated scanning of the same file.
pragma Assert (Name_Len > 1 and then Name_Buffer (Name_Len) = ASCII.NUL);
Name_Len := Name_Len - 1;
Name := Name_Find;
Text := Read_Library_Info (Name, Fatal_Err => False);
end Read_Library_Info;
-------------------
-- Set_File_Name --
-------------------
procedure Set_File_Name (Ext : String) is
Dot_Index : Natural;
begin
Get_Name_String (Current_Main);
-- Find last dot since we replace the existing extension by .ali. The
-- initialization to Name_Len + 1 provides for simply adding the .ali
-- extension if the source file name has no extension.
Dot_Index := Name_Len + 1;
for J in reverse 1 .. Name_Len loop
if Name_Buffer (J) = '.' then
Dot_Index := J;
exit;
end if;
end loop;
-- Make sure that the output file name matches the source file name.
-- To compare them, remove file name directories and extensions.
if Output_Object_File_Name /= null then
-- Make sure there is a dot at Dot_Index. This may not be the case
-- if the source file name has no extension.
Name_Buffer (Dot_Index) := '.';
-- If we are in multiple unit per file mode, then add ~nnn
-- extension to the name before doing the comparison.
if Multiple_Unit_Index /= 0 then
declare
Exten : constant String := Name_Buffer (Dot_Index .. Name_Len);
begin
Name_Len := Dot_Index - 1;
Add_Char_To_Name_Buffer (Multi_Unit_Index_Character);
Add_Nat_To_Name_Buffer (Multiple_Unit_Index);
Dot_Index := Name_Len + 1;
Add_Str_To_Name_Buffer (Exten);
end;
end if;
-- Remove extension preparing to replace it
declare
Name : String := Name_Buffer (1 .. Dot_Index);
First : Positive;
begin
Name_Buffer (1 .. Output_Object_File_Name'Length) :=
Output_Object_File_Name.all;
-- Put two names in canonical case, to allow object file names
-- with upper-case letters on Windows.
Canonical_Case_File_Name (Name);
Canonical_Case_File_Name
(Name_Buffer (1 .. Output_Object_File_Name'Length));
Dot_Index := 0;
for J in reverse Output_Object_File_Name'Range loop
if Name_Buffer (J) = '.' then
Dot_Index := J;
exit;
end if;
end loop;
-- Dot_Index should not be zero now (we check for extension
-- elsewhere).
pragma Assert (Dot_Index /= 0);
-- Look for first character of file name
First := Dot_Index;
while First > 1
and then Name_Buffer (First - 1) /= Directory_Separator
and then Name_Buffer (First - 1) /= '/'
loop
First := First - 1;
end loop;
-- Check name of object file is what we expect
if Name /= Name_Buffer (First .. Dot_Index) then
Fail ("incorrect object file name");
end if;
end;
end if;
Name_Buffer (Dot_Index) := '.';
Name_Buffer (Dot_Index + 1 .. Dot_Index + Ext'Length) := Ext;
Name_Buffer (Dot_Index + Ext'Length + 1) := ASCII.NUL;
Name_Len := Dot_Index + Ext'Length + 1;
end Set_File_Name;
---------------------------------
-- Set_Output_Object_File_Name --
---------------------------------
procedure Set_Output_Object_File_Name (Name : String) is
Ext : constant String := Target_Object_Suffix;
NL : constant Natural := Name'Length;
EL : constant Natural := Ext'Length;
begin
-- Make sure that the object file has the expected extension
if NL <= EL
or else
(Name (NL - EL + Name'First .. Name'Last) /= Ext
and then Name (NL - 2 + Name'First .. Name'Last) /= ".o"
and then
(not Generate_C_Code
or else Name (NL - 2 + Name'First .. Name'Last) /= ".c"))
then
Fail ("incorrect object file extension");
end if;
Output_Object_File_Name := new String'(Name);
end Set_Output_Object_File_Name;
----------------
-- Tree_Close --
----------------
procedure Tree_Close is
Status : Boolean;
begin
Tree_Write_Terminate;
Close (Output_FD, Status);
if not Status then
Fail
("error while closing tree file "
& Get_Name_String (Output_File_Name));
end if;
end Tree_Close;
-----------------
-- Tree_Create --
-----------------
procedure Tree_Create is
Dot_Index : Natural;
begin
Get_Name_String (Current_Main);
-- If an object file has been specified, then the ALI file
-- will be in the same directory as the object file;
-- so, we put the tree file in this same directory,
-- even though no object file needs to be generated.
if Output_Object_File_Name /= null then
Name_Len := Output_Object_File_Name'Length;
Name_Buffer (1 .. Name_Len) := Output_Object_File_Name.all;
end if;
Dot_Index := Name_Len + 1;
for J in reverse 1 .. Name_Len loop
if Name_Buffer (J) = '.' then
Dot_Index := J;
exit;
end if;
end loop;
-- Should be impossible to not have an extension
pragma Assert (Dot_Index /= 0);
-- Change extension to adt
Name_Buffer (Dot_Index) := '.';
Name_Buffer (Dot_Index + 1) := 'a';
Name_Buffer (Dot_Index + 2) := 'd';
Name_Buffer (Dot_Index + 3) := 't';
Name_Buffer (Dot_Index + 4) := ASCII.NUL;
Name_Len := Dot_Index + 3;
Create_File_And_Check (Output_FD, Binary);
Tree_Write_Initialize (Output_FD);
end Tree_Create;
-----------------------
-- Write_Debug_Info --
-----------------------
procedure Write_Debug_Info (Info : String) renames Write_Info;
------------------------
-- Write_Library_Info --
------------------------
procedure Write_Library_Info (Info : String) renames Write_Info;
---------------------
-- Write_List_Info --
---------------------
procedure Write_List_Info (S : String) is
begin
Write_With_Check (S'Address, S'Length);
end Write_List_Info;
------------------------
-- Write_Repinfo_Line --
------------------------
procedure Write_Repinfo_Line (Info : String) renames Write_Info;
begin
Adjust_OS_Resource_Limits;
Opt.Create_Repinfo_File_Access := Create_Repinfo_File'Access;
Opt.Write_Repinfo_Line_Access := Write_Repinfo_Line'Access;
Opt.Close_Repinfo_File_Access := Close_Repinfo_File'Access;
Opt.Create_List_File_Access := Create_List_File'Access;
Opt.Write_List_Info_Access := Write_List_Info'Access;
Opt.Close_List_File_Access := Close_List_File'Access;
Set_Program (Compiler);
end Osint.C;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with ADO.Objects;
with ADO.Schemas;
with ADO.Queries;
with Util.Beans.Objects;
with Util.Beans.Basic;
with AWA.Counters.Modules;
with AWA.Counters.Models;
-- == Counter Bean ==
-- The <b>Counter_Bean</b> allows to represent a counter associated with some database
-- entity and allows its control by the <awa:counter> component.
--
package AWA.Counters.Beans is
type Counter_Bean (Of_Type : ADO.Objects.Object_Key_Type;
Of_Class : ADO.Schemas.Class_Mapping_Access) is
new Util.Beans.Basic.Readonly_Bean with record
Counter : Counter_Index_Type;
Value : Integer := -1;
Object : ADO.Objects.Object_Key (Of_Type, Of_Class);
end record;
type Counter_Bean_Access is access all Counter_Bean'Class;
-- Get the value identified by the name.
overriding
function Get_Value (From : in Counter_Bean;
Name : in String) return Util.Beans.Objects.Object;
type Counter_Stat_Bean is new AWA.Counters.Models.Stat_List_Bean with record
Module : AWA.Counters.Modules.Counter_Module_Access;
Stats : aliased AWA.Counters.Models.Stat_Info_List_Bean;
Stats_Bean : AWA.Counters.Models.Stat_Info_List_Bean_Access;
end record;
type Counter_Stat_Bean_Access is access all Counter_Stat_Bean'Class;
-- Get the query definition to collect the counter statistics.
function Get_Query (From : in Counter_Stat_Bean) return ADO.Queries.Query_Definition_Access;
overriding
function Get_Value (List : in Counter_Stat_Bean;
Name : in String) return Util.Beans.Objects.Object;
-- Set the value identified by the name.
overriding
procedure Set_Value (From : in out Counter_Stat_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object);
-- Load the statistics information.
overriding
procedure Load (List : in out Counter_Stat_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
-- Create the Blog_Stat_Bean bean instance.
function Create_Counter_Stat_Bean (Module : in AWA.Counters.Modules.Counter_Module_Access)
return Util.Beans.Basic.Readonly_Bean_Access;
end AWA.Counters.Beans;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
With
Ada.Streams,
Ada.Strings.Less_Case_Insensitive,
Ada.Strings.Equal_Case_Insensitive,
Ada.Containers.Indefinite_Ordered_Maps;
Package INI with Preelaborate, Elaborate_Body is
Type Value_Type is ( vt_String, vt_Float, vt_Integer, vt_Boolean );
Type Instance(Convert : Boolean) is private;
Function Exists( Object : in Instance;
Key : in String;
Section: in String:= ""
) return Boolean;
-- Return the type of the associated value.
Function Value( Object : in Instance;
Key : in String;
Section: in String:= ""
) return Value_Type
with Pre => Exists(Object, Key, Section);
-- Return the value associated with the key in the indicated section.
Function Value( Object : in Instance;
Key : in String;
Section: in String:= ""
) return String
with Pre => Exists(Object, Key, Section);
Function Value( Object : in Instance;
Key : in String;
Section: in String:= ""
) return Float
with Pre => Exists(Object, Key, Section);
Function Value( Object : in Instance;
Key : in String;
Section: in String:= ""
) return Integer
with Pre => Exists(Object, Key, Section);
Function Value( Object : in Instance;
Key : in String;
Section: in String:= ""
) return Boolean
with Pre => Exists(Object, Key, Section);
-- Associates a value with the given key in the indicated section.
Procedure Value( Object : in out Instance;
Key : in String;
Value : in String;
Section: in String:= ""
)
with Post => Exists(Object, Key, Section);
Procedure Value( Object : in out Instance;
Key : in String;
Value : in Float;
Section: in String:= ""
)
with Post => Exists(Object, Key, Section);
Procedure Value( Object : in out Instance;
Key : in String;
Value : in Integer;
Section: in String:= ""
)
with Post => Exists(Object, Key, Section);
Procedure Value( Object : in out Instance;
Key : in String;
Value : in Boolean;
Section: in String:= ""
)
with Post => Exists(Object, Key, Section);
-- This value sets the Convert discriminant for the object that is generated
-- by the 'Input attribute.
Default_Conversion : Boolean := False;
Empty : Constant Instance;
Private
Type Value_Object( Kind : Value_Type; Length : Natural ) ;
Function "ABS"( Object : Value_Object ) return String;
Function "="(Left, Right : Value_Object) return Boolean;
Package Object_Package is
procedure Value_Output(
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : in Value_Object
) is null;
function Value_Input(
Stream : not null access Ada.Streams.Root_Stream_Type'Class
) return Value_Object;
End Object_Package;
Type Value_Object( Kind : Value_Type; Length : Natural ) is record
case Kind is
when vt_String => String_Value : String(1..Length):= (Others=>' ');
when vt_Float => Float_Value : Float := 0.0;
when vt_Integer => Integer_Value: Integer := 0;
when vt_Boolean => Boolean_Value: Boolean := False;
end case;
end record;
-- with Input => Object_Package.Value_Input,
-- Output => Object_Package.Value_Output;
Package KEY_VALUE_MAP is new Ada.Containers.Indefinite_Ordered_Maps(
-- "=" => ,
"<" => Ada.Strings.Less_Case_Insensitive,
Key_Type => String,
Element_Type => Value_Object
);
Function "="(Left, Right : KEY_VALUE_MAP.Map) return Boolean;
Package KEY_SECTION_MAP is new Ada.Containers.Indefinite_Ordered_Maps(
"=" => "=",
"<" => Ada.Strings.Less_Case_Insensitive,
Key_Type => String,
Element_Type => KEY_VALUE_MAP.Map
);
procedure INI_Output(
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : in Instance
);
function INI_Input(
Stream : not null access Ada.Streams.Root_Stream_Type'Class
) return Instance;
Type Instance(Convert : Boolean) is new KEY_SECTION_MAP.Map
with null record
with Input => INI_Input, Output => INI_Output;
overriding
function Copy (Source : Instance) return Instance is
( Source );
Empty : Constant Instance:=
(KEY_SECTION_MAP.map with Convert => True, others => <>);
End INI;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
with Util.Properties;
with Util.Log.Loggers;
with Bbox.API;
with Druss.Gateways;
with Ada.Strings.Unbounded;
package body Druss.Commands.Ping is
use Ada.Strings.Unbounded;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Druss.Commands.Ping");
-- ------------------------------
-- Execute the wifi 'status' command to print the Wifi current status.
-- ------------------------------
procedure Do_Ping (Command : in Command_Type;
Args : in Argument_List'Class;
Selector : in Device_Selector_Type;
Context : in out Context_Type) is
pragma Unreferenced (Command, Args);
procedure Do_Ping (Gateway : in out Druss.Gateways.Gateway_Type);
procedure Box_Status (Gateway : in out Druss.Gateways.Gateway_Type);
Console : constant Druss.Commands.Consoles.Console_Access := Context.Console;
procedure Do_Ping (Gateway : in out Druss.Gateways.Gateway_Type) is
procedure Ping_Device (Manager : in Util.Properties.Manager;
Name : in String);
Box : Bbox.API.Client_Type;
procedure Ping_Device (Manager : in Util.Properties.Manager;
Name : in String) is
Id : constant String := Manager.Get (Name & ".id", "");
begin
case Selector is
when DEVICE_ALL =>
null;
when DEVICE_ACTIVE =>
if Manager.Get (Name & ".active", "") = "0" then
return;
end if;
when DEVICE_INACTIVE =>
if Manager.Get (Name & ".active", "") = "1" then
return;
end if;
end case;
Log.Info ("Ping command on {0}", Manager.Get (Name & ".ipaddress", ""));
Box.Post ("hosts/" & Id, "action=ping");
end Ping_Device;
begin
if Ada.Strings.Unbounded.Length (Gateway.Passwd) = 0 then
return;
end if;
Gateway.Refresh;
Box.Set_Server (To_String (Gateway.Ip));
Box.Login (To_String (Gateway.Passwd));
Bbox.API.Iterate (Gateway.Hosts, "hosts.list", Ping_Device'Access);
end Do_Ping;
procedure Box_Status (Gateway : in out Druss.Gateways.Gateway_Type) is
procedure Print_Device (Manager : in Util.Properties.Manager;
Name : in String);
procedure Print_Device (Manager : in Util.Properties.Manager;
Name : in String) is
Link : constant String := Manager.Get (Name & ".link", "");
begin
if Manager.Get (Name & ".active", "") = "0" then
return;
end if;
Console.Start_Row;
Console.Print_Field (F_BBOX_IP_ADDR, Gateway.Ip);
Console.Print_Field (F_IP_ADDR, Manager.Get (Name & ".ipaddress", ""));
Console.Print_Field (F_HOSTNAME, Manager.Get (Name & ".hostname", ""));
Print_Perf (Console, F_ACTIVE, Manager.Get (Name & ".ping.average", ""));
if Link = "Ethernet" then
Console.Print_Field (F_LINK, Link & " port "
& Manager.Get (Name & ".ethernet.logicalport", ""));
else
Console.Print_Field (F_LINK, Link & " RSSI "
& Manager.Get (Name & ".wireless.rssi0", ""));
end if;
Console.End_Row;
end Print_Device;
begin
Gateway.Refresh;
Bbox.API.Iterate (Gateway.Hosts, "hosts.list", Print_Device'Access);
end Box_Status;
begin
Druss.Gateways.Iterate (Context.Gateways, Gateways.ITER_ENABLE, Do_Ping'Access);
delay 5.0;
Console.Start_Title;
Console.Print_Title (F_BBOX_IP_ADDR, "Bbox IP", 16);
Console.Print_Title (F_IP_ADDR, "Device IP", 16);
Console.Print_Title (F_HOSTNAME, "Hostname", 28);
Console.Print_Title (F_ACTIVE, "Ping", 15);
Console.Print_Title (F_LINK, "Link", 18);
Console.End_Title;
Druss.Gateways.Iterate (Context.Gateways, Gateways.ITER_ENABLE, Box_Status'Access);
end Do_Ping;
-- ------------------------------
-- Execute a ping from the gateway to each device.
-- ------------------------------
overriding
procedure Execute (Command : in out Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is
pragma Unreferenced (Name);
begin
if Args.Get_Count > 1 then
Context.Console.Notice (N_USAGE, "Too many arguments to the command");
Druss.Commands.Driver.Usage (Args, Context);
elsif Args.Get_Count = 0 then
Command.Do_Ping (Args, DEVICE_ALL, Context);
elsif Args.Get_Argument (1) = "all" then
Command.Do_Ping (Args, DEVICE_ALL, Context);
elsif Args.Get_Argument (1) = "active" then
Command.Do_Ping (Args, DEVICE_ACTIVE, Context);
elsif Args.Get_Argument (1) = "inactive" then
Command.Do_Ping (Args, DEVICE_INACTIVE, Context);
else
Context.Console.Notice (N_USAGE, "Invalid argument: " & Args.Get_Argument (1));
Druss.Commands.Driver.Usage (Args, Context);
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 (Command);
Console : constant Druss.Commands.Consoles.Console_Access := Context.Console;
begin
Console.Notice (N_HELP, "ping: Ask the Bbox to ping the devices");
Console.Notice (N_HELP, "Usage: ping [all | active | inactive]");
Console.Notice (N_HELP, "");
Console.Notice (N_HELP, " Ask the Bbox to ping the devices. By default it will ping");
Console.Notice (N_HELP, " all the devices that have been discovered by the Bbox.");
Console.Notice (N_HELP, " The command will wait 5 seconds and it will list the active");
Console.Notice (N_HELP, " devices with their ping performance.");
Console.Notice (N_HELP, "");
Console.Notice (N_HELP, " all Ping all the devices");
Console.Notice (N_HELP, " active Ping the active devices only");
Console.Notice (N_HELP, " inative Ping the inactive devices only");
end Help;
end Druss.Commands.Ping;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
------------------------------------------------------------------------------
with System.Machine_Code; use System.Machine_Code;
with Cortex_M_SVD.SCB; use Cortex_M_SVD.SCB;
with AGATE.Traces;
with AGATE.Arch.ArmvX_m; use AGATE.Arch.ArmvX_m;
package body AGATE.Scheduler.Context_Switch is
procedure Context_Switch_Handler;
pragma Machine_Attribute (Context_Switch_Handler, "naked");
pragma Export (C, Context_Switch_Handler, "PendSV_Handler");
------------
-- Switch --
------------
procedure Switch is
begin
-- Trigger PendSV
SCB_Periph.ICSR.PENDSVSET := True;
end Switch;
----------------------------
-- Context_Switch_Handler --
----------------------------
procedure Context_Switch_Handler is
begin
Asm (Template =>
"push {lr}" & ASCII.LF &
"bl current_task_context" & ASCII.LF &
"stm r0, {r4-r12}", -- Save extra context
Volatile => True);
SCB_Periph.ICSR.PENDSVCLR := True;
Running_Task.Stack_Pointer := PSP;
Set_PSP (Ready_Tasks.Stack_Pointer);
Traces.Context_Switch (Task_ID (Running_Task),
Task_ID (Ready_Tasks));
Running_Task := Ready_Tasks;
Running_Task.Status := Running;
Traces.Running (Current_Task);
Asm (Template =>
"bl current_task_context" & ASCII.LF &
"ldm r0, {r4-r12}" & ASCII.LF & -- Load extra context
"pop {pc}",
Volatile => True);
end Context_Switch_Handler;
end AGATE.Scheduler.Context_Switch;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Common_Formal_Containers; use Common_Formal_Containers;
package afrl.impact.ImpactAutomationRequest.SPARK_Boundary with SPARK_Mode is
pragma Annotate (GNATprove, Terminating, SPARK_Boundary);
function Get_EntityList_From_TrialRequest
(Request : ImpactAutomationRequest) return Int64_Vect
with Global => null;
function Get_OperatingRegion_From_TrialRequest
(Request : ImpactAutomationRequest) return Int64
with Global => null;
function Get_TaskList_From_TrialRequest
(Request : ImpactAutomationRequest) return Int64_Vect
with Global => null;
end afrl.impact.ImpactAutomationRequest.SPARK_Boundary;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
-- 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). --
-- --
------------------------------------------------------------------------------
with Interfaces.C;
-- Used for Size_t;
with Interfaces.C.Pthreads;
-- Used for, size_t,
-- pthread_mutex_t,
-- pthread_cond_t,
-- pthread_t
with Interfaces.C.POSIX_RTE;
-- Used for, Signal,
-- siginfo_ptr,
with System.Task_Clock;
-- Used for, Stimespec
with Unchecked_Conversion;
pragma Elaborate_All (Interfaces.C.Pthreads);
with System.Task_Info;
package System.Task_Primitives is
-- Low level Task size and state definition
type LL_Task_Procedure_Access is access procedure (Arg : System.Address);
type Pre_Call_State is new System.Address;
type Task_Storage_Size is new Interfaces.C.size_t;
type Machine_Exceptions is new Interfaces.C.POSIX_RTE.Signal;
type Error_Information is new Interfaces.C.POSIX_RTE.siginfo_ptr;
type Lock is private;
type Condition_Variable is private;
-- The above types should both be limited. They are not due to a hack in
-- ATCB allocation which allocates a block of the correct size and then
-- assigns an initialized ATCB to it. This won't work with limited types.
-- When allocation is done with new, these can become limited once again.
-- ???
type Task_Control_Block is record
LL_Entry_Point : LL_Task_Procedure_Access;
LL_Arg : System.Address;
Thread : aliased Interfaces.C.Pthreads.pthread_t;
Stack_Size : Task_Storage_Size;
Stack_Limit : System.Address;
end record;
type TCB_Ptr is access all Task_Control_Block;
-- Task ATCB related and variables.
function Address_To_TCB_Ptr is new
Unchecked_Conversion (System.Address, TCB_Ptr);
procedure Initialize_LL_Tasks (T : TCB_Ptr);
-- Initialize GNULLI. T points to the Task Control Block that should
-- be initialized for use by the environment task.
function Self return TCB_Ptr;
-- Return a pointer to the Task Control Block of the calling task.
procedure Initialize_Lock (Prio : System.Any_Priority; L : in out Lock);
-- Initialize a lock object. Prio is the ceiling priority associated
-- with the lock.
procedure Finalize_Lock (L : in out Lock);
-- Finalize a lock object, freeing any resources allocated by the
-- corresponding Initialize_Lock.
procedure Write_Lock (L : in out Lock; Ceiling_Violation : out Boolean);
pragma Inline (Write_Lock);
-- Lock a lock object for write access to a critical section. After
-- this operation returns, the calling task owns the lock, and
-- no other Write_Lock or Read_Lock operation on the same object will
-- return the owner executes an Unlock operation on the same object.
procedure Read_Lock (L : in out Lock; Ceiling_Violation : out Boolean);
pragma Inline (Read_Lock);
-- Lock a lock object for read access to a critical section. After
-- this operation returns, the calling task owns the lock, and
-- no other Write_Lock operation on the same object will return until
-- the owner(s) execute Unlock operation(s) on the same object.
-- A Read_Lock to an owned lock object may return while the lock is
-- still owned, though an implementation may also implement
-- Read_Lock to have the same semantics.
procedure Unlock (L : in out Lock);
pragma Inline (Unlock);
-- Unlock a locked lock object. The results are undefined if the
-- calling task does not own the lock. Lock/Unlock operations must
-- be nested, that is, the argument to Unlock must be the object
-- most recently locked.
procedure Initialize_Cond (Cond : in out Condition_Variable);
-- Initialize a condition variable object.
procedure Finalize_Cond (Cond : in out Condition_Variable);
-- Finalize a condition variable object, recovering any resources
-- allocated for it by Initialize_Cond.
procedure Cond_Wait (Cond : in out Condition_Variable; L : in out Lock);
pragma Inline (Cond_Wait);
-- Wait on a condition variable. The mutex object L is unlocked
-- atomically, such that another task that is able to lock the mutex
-- can be assured that the wait has actually commenced, and that
-- a Cond_Signal operation will cause the waiting task to become
-- eligible for execution once again. Before Cond_Wait returns,
-- the waiting task will again lock the mutex. The waiting task may become
-- eligible for execution at any time, but will become eligible for
-- execution when a Cond_Signal operation is performed on the
-- same condition variable object. The effect of more than one
-- task waiting on the same condition variable is unspecified.
procedure Cond_Timed_Wait
(Cond : in out Condition_Variable;
L : in out Lock; Abs_Time : System.Task_Clock.Stimespec;
Timed_Out : out Boolean);
pragma Inline (Cond_Timed_Wait);
-- Wait on a condition variable, as for Cond_Wait, above. In addition,
-- the waiting task will become eligible for execution again
-- when the absolute time specified by Timed_Out arrives.
procedure Cond_Signal (Cond : in out Condition_Variable);
pragma Inline (Cond_Signal);
-- Wake up a task waiting on the condition variable object specified
-- by Cond, making it eligible for execution once again.
procedure Set_Priority (T : TCB_Ptr; Prio : System.Any_Priority);
pragma Inline (Set_Priority);
-- Set the priority of the task specified by T to P.
procedure Set_Own_Priority (Prio : System.Any_Priority);
pragma Inline (Set_Own_Priority);
-- Set the priority of the calling task to P.
function Get_Priority (T : TCB_Ptr) return System.Any_Priority;
pragma Inline (Get_Priority);
-- Return the priority of the task specified by T.
function Get_Own_Priority return System.Any_Priority;
pragma Inline (Get_Own_Priority);
-- Return the priority of the calling task.
procedure Create_LL_Task
(Priority : System.Any_Priority;
Stack_Size : Task_Storage_Size;
Task_Info : System.Task_Info.Task_Info_Type;
LL_Entry_Point : LL_Task_Procedure_Access;
Arg : System.Address;
T : TCB_Ptr);
-- Create a new low-level task with priority Priority. A new thread
-- of control is created with a stack size of at least Stack_Size,
-- and the procedure LL_Entry_Point is called with the argument Arg
-- from this new thread of control. The Task Control Block pointed
-- to by T is initialized to refer to this new task.
procedure Exit_LL_Task;
-- Exit a low-level task. The resources allocated for the task
-- by Create_LL_Task are recovered. The task no longer executes, and
-- the effects of further operations on task are unspecified.
procedure Abort_Task (T : TCB_Ptr);
-- Abort the task specified by T (the target task). This causes
-- the target task to asynchronously execute the handler procedure
-- installed by the target task using Install_Abort_Handler. The
-- effect of this operation is unspecified if there is no abort
-- handler procedure for the target task.
procedure Test_Abort;
-- ??? Obsolete? This is intended to allow implementation of
-- abortion and ATC in the absence of an asynchronous Abort_Task,
-- but I think that we decided that GNARL can handle this on
-- its own by making sure that there is an Undefer_Abortion at
-- every abortion synchronization point.
type Abort_Handler_Pointer is access procedure (Context : Pre_Call_State);
procedure Install_Abort_Handler (Handler : Abort_Handler_Pointer);
-- Install an abort handler procedure. This procedure is called
-- asynchronously by the calling task whenever a call to Abort_Task
-- specifies the calling task as the target. If the abort handler
-- procedure is asynchronously executed during a GNULLI operation
-- and then calls some other GNULLI operation, the effect is unspecified.
procedure Install_Error_Handler (Handler : System.Address);
-- Install an error handler for the calling task. The handler will
-- be called synchronously if an error is encountered during the
-- execution of the calling task.
procedure LL_Assert (B : Boolean; M : String);
-- If B is False, print the string M to the console and halt the
-- program.
Task_Wrapper_Frame : constant Integer := 72;
-- This is the size of the frame for the Pthread_Wrapper procedure.
type Proc is access procedure (Addr : System.Address);
-- Test and Set support
type TAS_Cell is private;
-- On some systems we can not assume that an arbitrary memory location
-- can be used in an atomic test and set instruction (e.g. on some
-- multiprocessor machines, only memory regions are cache interlocked).
-- TAS_Cell is private to facilitate adaption to a variety of
-- implementations.
procedure Initialize_TAS_Cell (Cell : out TAS_Cell);
pragma Inline (Initialize_TAS_Cell);
-- Initialize a Test And Set Cell. On some targets this will allocate
-- a system-level lock object from a special pool. For most systems,
-- this is a nop.
procedure Finalize_TAS_Cell (Cell : in out TAS_Cell);
pragma Inline (Finalize_TAS_Cell);
-- Finalize a Test and Set cell, freeing any resources allocated by the
-- corresponding Initialize_TAS_Cell.
procedure Clear (Cell : in out TAS_Cell);
pragma Inline (Clear);
-- Set the state of the named TAS_Cell such that a subsequent call to
-- Is_Set will return False. This operation must be atomic with
-- respect to the Is_Set and Test_And_Set operations for the same
-- cell.
procedure Test_And_Set (Cell : in out TAS_Cell; Result : out Boolean);
pragma Inline (Test_And_Set);
-- Modify the state of the named TAS_Cell such that a subsequent call
-- to Is_Set will return True. Result is set to True if Is_Set
-- was False prior to the call, False otherwise. This operation must
-- be atomic with respect to the Clear and Is_Set operations for the
-- same cell.
function Is_Set (Cell : in TAS_Cell) return Boolean;
pragma Inline (Is_Set);
-- Returns the current value of the named TAS_Cell. This operation
-- must be atomic with respect to the Clear and Test_And_Set operations
-- for the same cell.
private
type Lock is
record
mutex : aliased Interfaces.C.Pthreads.pthread_mutex_t;
end record;
type Condition_Variable is
record
CV : aliased Interfaces.C.Pthreads.pthread_cond_t;
end record;
type TAS_Cell is
record
Value : aliased Interfaces.C.unsigned := 0;
end record;
end System.Task_Primitives;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- SOFTWARE.
--------------------------------------------------------------------------------
with Vulkan.Math.GenFType;
with Vulkan.Math.GenDType;
with Vulkan.Math.Vec3;
with Vulkan.Math.Dvec3;
use Vulkan.Math.GenFType;
use Vulkan.Math.GenDType;
use Vulkan.Math.Vec3;
use Vulkan.Math.Dvec3;
--------------------------------------------------------------------------------
--< @group Vulkan Math Functions
--------------------------------------------------------------------------------
--< @summary
--< This package provides GLSL Geometry Built-in functions.
--<
--< @description
--< All geometry functions operate on vectors as objects.
--------------------------------------------------------------------------------
package Vulkan.Math.Geometry is
pragma Preelaborate;
pragma Pure;
----------------------------------------------------------------------------
--< @summary
--< Calculate the magnitude of the vector.
--<
--< @description
--< Calculate the magnitude of the GenFType vector, using the formula:
--<
--< Magnitude = sqrt(sum(x0^2, ..., xn^2))
--<
--< @param x
--< The vector to determine the magnitude for.
--<
--< @return
--< The magnitude of the vector.
----------------------------------------------------------------------------
function Mag (x : in Vkm_GenFType) return Vkm_Float;
----------------------------------------------------------------------------
--< @summary
--< Calculate the magnitude of the vector.
--<
--< @description
--< Calculate the magnitude of the Vkm_GenDType vector, using the formula:
--<
--< Magnitude = sqrt(sum(x0^2, ..., xn^2))
--<
--< @param x
--< The vector to determine the magnitude for.
--<
--< @return
--< The magnitude of the vector.
----------------------------------------------------------------------------
function Mag (x : in Vkm_GenDType) return Vkm_Double;
----------------------------------------------------------------------------
--< @summary
--< Calculate the distance between two points, p0 and p1.
--<
--< @description
--< Calculate the distance between two GenFType vectors representing points p0
--< and p1, using the formula:
--<
--< Distance = Magnitude(p0 - p1)
--<
--< @param p0
--< A vector which represents the first point.
--<
--< @param p1
--< A vector which represents the seconds point.
--<
--< @return
--< The distance between the two points.
----------------------------------------------------------------------------
function Distance (p0, p1 : in Vkm_GenFType) return Vkm_Float is
(Mag(p0 - p1)) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Calculate the distance between two points, p0 and p1.
--<
--< @description
--< Calculate the distance between two GenDType vectors representing points p0
--< and p1, using the formula:
--<
--< Distance = Magnitude(p0 - p1)
--<
--< @param p0
--< A vector which represents the first point.
--<
--< @param p1
--< A vector which represents the seconds point.
--<
--< @return
--< The distance between the two points.
----------------------------------------------------------------------------
function Distance (p0, p1 : in Vkm_GenDType) return Vkm_Double is
(Mag(p0 - p1)) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Calculate the dot product between two vectors.
--<
--< @description
--< Calculate the dot product between two GenFType vectors.
--<
--< x dot y =
--< \ [x1 ... xN] . | y1 | = x1*y1 + ... xN * yN
--< \ | ... |
--< \ | yN |
--<
--< @param x
--< The left vector in the dot product operation.
--<
--< @param y
--< The right vector in the dot product operation.
--<
--<
--< @return The dot product of the two vectors.
----------------------------------------------------------------------------
function Dot (x, y : in Vkm_GenFType) return Vkm_Float;
----------------------------------------------------------------------------
--< @summary
--< Calculate the dot product between two vectors.
--<
--< @description
--< Calculate the dot product between the two GenDType vectors.
--<
--< x dot y =
--< \ [x1 ... xN] . | y1 | = x1*y1 + ... xN * yN
--< \ | ... |
--< \ | yN |
--<
--< @param x
--< The left vector in the dot product operation.
--<
--< @param y
--< The right vector in the dot product operation.
--<
--< @return
--< The dot product of the two vectors.
----------------------------------------------------------------------------
function Dot (x, y : in Vkm_GenDType) return Vkm_Double;
----------------------------------------------------------------------------
--< @summary
--< Calculate the cross product between two 3 dimmensional vectors.
--<
--< @description
--< Calculate the cross product between two 3 dimmensional GenFType vectors.
--<
--< x cross y =
--< \ | i j k | = i | x1 x2 | -j | x0 x2 | +k | x0 x1 | = | +(x1*y2 - x2*y1) |
--< \ | x0 x1 x2 | | y1 y2 | | y0 y2 | | y0 y1 | | -(x0*y2 - x2*y1) |
--< \ | y0 y1 y2 | | +(x0*y1 - x1*y0) |
--<
--< @param x
--< The left vector in the cross product operation.
--<
--< @param y
--< The right vector in the cross product operation.
--<
--< @return
--< The cross product of the two vectors.
----------------------------------------------------------------------------
function Cross (x, y : in Vkm_Vec3 ) return Vkm_Vec3;
----------------------------------------------------------------------------
--< @summary
--< Calculate the cross product between two 3 dimmensional vectors.
--<
--< @description
--< Calculate the cross product between two 3 dimmensional GenDType vectors.
--<
--< x cross y =
--< \ | i j k | = i | x1 x2 | -j | x0 x2 | +k | x0 x1 | = | +(x1*y2 - x2*y1) |
--< \ | x0 x1 x2 | | y1 y2 | | y0 y2 | | y0 y1 | | -(x0*y2 - x2*y1) |
--< \ | y0 y1 y2 | | +(x0*y1 - x1*y0) |
--<
--< @param x
--< The left vector in the cross product operation.
--<
--< @param y
--< The right vector in the cross product operation.
--<
--< @return
--< The cross product of the two vectors.
----------------------------------------------------------------------------
function Cross (x, y : in Vkm_Dvec3) return Vkm_Dvec3;
----------------------------------------------------------------------------
--< @summary
--< Normalize a vector.
--<
--< @description
--< Normalize the GenFType vector so that it has a magnitude of 1.
--<
--< @param x
--< The vector to normalize.
--<
--< @return
--< The normalized vector.
----------------------------------------------------------------------------
function Normalize(x : in Vkm_GenFType) return Vkm_GenFType is
(x / Mag(x)) with inline;
----------------------------------------------------------------------------
--< @summary
--< Normalize a vector.
--<
--< @description
--< Normalize the GenDType vector so that it has a magnitude of 1.
--<
--< @param x
--< The vector to normalize.
--<
--< @return
--< The normalized vector.
----------------------------------------------------------------------------
function Normalize(x : in Vkm_GenDType) return Vkm_GenDType is
(x / Mag(x)) with inline;
----------------------------------------------------------------------------
--< @summary
--< Force a normal vector to face an incident vector.
--<
--< @description
--< Return a normal vector N as-is if an incident vector I points in the opposite
--< direction of a reference normal vector, Nref. Otherwise, if I is pointing
--< in the same direction as the reference normal, flip the normal vector N.
--<
--< - If Nref dot I is negative, these vectors are not facing the same direction.
--< - If Nref dot I is positive, these vectors are facing in the same direction.
--< - If Nref dot I is zero, these two vectors are orthogonal to each other.
--<
--< @param n
--< The normal vector N
--<
--< @param i
--< The incident vector I
--<
--< @param nref
--< The reference normal vector Nref
--<
--< @return
--< If I dot Nref < 0, return N. Otherwise return -N.
----------------------------------------------------------------------------
function Face_Forward(n, i, nref : in Vkm_GenFType) return Vkm_GenFType is
(if Dot(nref,i) < 0.0 then n else -n) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Force a normal vector to face an incident vector.
--<
--< @description
--< Return a normal vector N as-is if an incident vector I points in the opposite
--< direction of a reference normal vector, Nref. Otherwise, if I is pointing
--< in the same direction as the reference normal, flip the normal vector N.
--<
--< - If Nref dot I is negative, these vectors are not facing the same direction.
--< - If Nref dot I is positive, these vectors are facing in the same direction.
--< - If Nref dot I is zero, these two vectors are orthogonal to each other.
--<
--< @param n
--< The normal vector N
--<
--< @param i
--< The incident vector I
--<
--< @param nref
--< The reference normal vector Nref
--<
--< @return
--< If I dot Nref < 0, return N. Otherwise return -N.
----------------------------------------------------------------------------
function Face_Forward(n, i, nref : in Vkm_GenDType) return Vkm_GenDType is
(if Dot(nref,i) < 0.0 then n else -n) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Calculate the reflection of an incident vector using the normal vector
--< for the surface.
--<
--< @description
--< For the incident vector I and surface orientation N, returns the reflection
--< direction:
--<
--< I - 2 * ( N dot I ) * N.
--<
--< @param i
--< The incident vector I.
--<
--< @param n
--< The normal vector N. N should already be normalized.
--<
--< @return The reflection direction.
----------------------------------------------------------------------------
function Reflect(i, n : in Vkm_GenFType) return Vkm_GenFType is
(i - 2.0 * Dot(n, i) * n) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Calculate the reflection of an incident vector using the normal vector
--< for the surface.
--<
--< @description
--< For the incident vector I and surface orientation N, returns the reflection
--< direction:
--<
--< I - 2 * ( N dot I ) * N.
--<
--< @param i
--< The incident vector I.
--<
--< @param n
--< The normal vector N. N should already be normalized.
--<
--< @return The reflection direction.
----------------------------------------------------------------------------
function Reflect(i, n : in Vkm_GenDType) return Vkm_GenDType is
(i - 2.0 * Dot(n, i) * n) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Calculate the refraction vector for the incident vector I travelling
--< through the surface with normal N and a ratio of refraction eta.
--<
--< @description
--< For the indident vector I and surface normal N, and the ratio of refraction
--< eta, calculate the refraction vector.
--<
--< k = 1.0 - eta^2 (1.0 - dot(N,I)^2)
--< If k < 0, the result is a vector of all zeros.
--< Else , the result is: eta*I - (eta*dot(N,I) + sqrt(k))*N
--<
--< @param i
--< The incident vector I.
--<
--< @param n
--< The surface normal vector N.
--<
--< @param eta
--< The indices of refraction.
--<
--< @return
--< The refraction vector.
----------------------------------------------------------------------------
function Refract(i, n : in Vkm_GenFType;
eta : in Vkm_Float ) return Vkm_GenFType;
----------------------------------------------------------------------------
--< @summary
--< Calculate the refraction vector for the incident vector I travelling
--< through the surface with normal N and a ratio of refraction eta.
--<
--< @description
--< For the indident vector I and surface normal N, and the ratio of refraction
--< eta, calculate the refraction vector.
--<
--< k = 1.0 - eta^2 (1.0 - dot(N,I)^2)
--< If k < 0, the result is a vector of all zeros.
--< Else , the result is: eta*I - (eta*dot(N,I) + sqrt(k))*N
--<
--< @param i
--< The incident vector I.
--<
--< @param n
--< The surface normal vector N.
--<
--< @param eta
--< The indices of refraction.
--<
--< @return
--< The refraction vector.
----------------------------------------------------------------------------
function Refract(i, n : in Vkm_GenDType;
eta : in Vkm_Double ) return Vkm_GenDType;
end Vulkan.Math.Geometry;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--
--*
-- * A three channel color struct.
--
type TCOD_ColorRGB is record
r : aliased unsigned_char; -- color.h:47
g : aliased unsigned_char; -- color.h:48
b : aliased unsigned_char; -- color.h:49
end record
with Convention => C_Pass_By_Copy; -- color.h:42
subtype TCOD_color_t is TCOD_ColorRGB; -- color.h:51
--*
-- * A four channel color struct.
--
type TCOD_ColorRGBA is record
r : aliased unsigned_char; -- color.h:63
g : aliased unsigned_char; -- color.h:64
b : aliased unsigned_char; -- color.h:65
a : aliased unsigned_char; -- color.h:66
end record
with Convention => C_Pass_By_Copy; -- color.h:56
-- constructors
function TCOD_color_RGB
(r : unsigned_char;
g : unsigned_char;
b : unsigned_char) return TCOD_color_t -- color.h:73
with Import => True,
Convention => C,
External_Name => "TCOD_color_RGB";
function TCOD_color_HSV
(hue : float;
saturation : float;
value : float) return TCOD_color_t -- color.h:74
with Import => True,
Convention => C,
External_Name => "TCOD_color_HSV";
-- basic operations
function TCOD_color_equals (c1 : TCOD_color_t; c2 : TCOD_color_t) return Extensions.bool -- color.h:76
with Import => True,
Convention => C,
External_Name => "TCOD_color_equals";
function TCOD_color_add (c1 : TCOD_color_t; c2 : TCOD_color_t) return TCOD_color_t -- color.h:77
with Import => True,
Convention => C,
External_Name => "TCOD_color_add";
function TCOD_color_subtract (c1 : TCOD_color_t; c2 : TCOD_color_t) return TCOD_color_t -- color.h:78
with Import => True,
Convention => C,
External_Name => "TCOD_color_subtract";
function TCOD_color_multiply (c1 : TCOD_color_t; c2 : TCOD_color_t) return TCOD_color_t -- color.h:79
with Import => True,
Convention => C,
External_Name => "TCOD_color_multiply";
function TCOD_color_multiply_scalar (c1 : TCOD_color_t; value : float) return TCOD_color_t -- color.h:80
with Import => True,
Convention => C,
External_Name => "TCOD_color_multiply_scalar";
function TCOD_color_lerp
(c1 : TCOD_color_t;
c2 : TCOD_color_t;
coef : float) return TCOD_color_t -- color.h:81
with Import => True,
Convention => C,
External_Name => "TCOD_color_lerp";
--*
-- * Blend `src` into `dst` as an alpha blending operation.
-- * \rst
-- * .. versionadded:: 1.16
-- * \endrst
--
procedure TCOD_color_alpha_blend (dst : access TCOD_ColorRGBA; src : access constant TCOD_ColorRGBA) -- color.h:88
with Import => True,
Convention => C,
External_Name => "TCOD_color_alpha_blend";
-- HSV transformations
procedure TCOD_color_set_HSV
(color : access TCOD_color_t;
hue : float;
saturation : float;
value : float) -- color.h:91
with Import => True,
Convention => C,
External_Name => "TCOD_color_set_HSV";
procedure TCOD_color_get_HSV
(color : TCOD_color_t;
hue : access float;
saturation : access float;
value : access float) -- color.h:92
with Import => True,
Convention => C,
External_Name => "TCOD_color_get_HSV";
function TCOD_color_get_hue (color : TCOD_color_t) return float -- color.h:93
with Import => True,
Convention => C,
External_Name => "TCOD_color_get_hue";
procedure TCOD_color_set_hue (color : access TCOD_color_t; hue : float) -- color.h:94
with Import => True,
Convention => C,
External_Name => "TCOD_color_set_hue";
function TCOD_color_get_saturation (color : TCOD_color_t) return float -- color.h:95
with Import => True,
Convention => C,
External_Name => "TCOD_color_get_saturation";
procedure TCOD_color_set_saturation (color : access TCOD_color_t; saturation : float) -- color.h:96
with Import => True,
Convention => C,
External_Name => "TCOD_color_set_saturation";
function TCOD_color_get_value (color : TCOD_color_t) return float -- color.h:97
with Import => True,
Convention => C,
External_Name => "TCOD_color_get_value";
procedure TCOD_color_set_value (color : access TCOD_color_t; value : float) -- color.h:98
with Import => True,
Convention => C,
External_Name => "TCOD_color_set_value";
procedure TCOD_color_shift_hue (color : access TCOD_color_t; shift : float) -- color.h:99
with Import => True,
Convention => C,
External_Name => "TCOD_color_shift_hue";
procedure TCOD_color_scale_HSV
(color : access TCOD_color_t;
saturation_coef : float;
value_coef : float) -- color.h:100
with Import => True,
Convention => C,
External_Name => "TCOD_color_scale_HSV";
-- color map
procedure TCOD_color_gen_map
(map : access TCOD_color_t;
nb_key : int;
key_color : access constant TCOD_color_t;
key_index : access int) -- color.h:102
with Import => True,
Convention => C,
External_Name => "TCOD_color_gen_map";
end color_h;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-------------------------------------------------------------
with Program.Elements.Declarations;
with Program.Lexical_Elements;
with Program.Elements.Defining_Names;
with Program.Elements.Parameter_Specifications;
with Program.Elements.Expressions;
with Program.Elements.Aspect_Specifications;
package Program.Elements.Function_Renaming_Declarations is
pragma Pure (Program.Elements.Function_Renaming_Declarations);
type Function_Renaming_Declaration is
limited interface and Program.Elements.Declarations.Declaration;
type Function_Renaming_Declaration_Access is
access all Function_Renaming_Declaration'Class with Storage_Size => 0;
not overriding function Name
(Self : Function_Renaming_Declaration)
return not null Program.Elements.Defining_Names.Defining_Name_Access
is abstract;
not overriding function Parameters
(Self : Function_Renaming_Declaration)
return Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access is abstract;
not overriding function Result_Subtype
(Self : Function_Renaming_Declaration)
return not null Program.Elements.Element_Access is abstract;
not overriding function Renamed_Function
(Self : Function_Renaming_Declaration)
return Program.Elements.Expressions.Expression_Access is abstract;
not overriding function Aspects
(Self : Function_Renaming_Declaration)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access is abstract;
not overriding function Has_Not
(Self : Function_Renaming_Declaration)
return Boolean is abstract;
not overriding function Has_Overriding
(Self : Function_Renaming_Declaration)
return Boolean is abstract;
not overriding function Has_Not_Null
(Self : Function_Renaming_Declaration)
return Boolean is abstract;
type Function_Renaming_Declaration_Text is limited interface;
type Function_Renaming_Declaration_Text_Access is
access all Function_Renaming_Declaration_Text'Class
with Storage_Size => 0;
not overriding function To_Function_Renaming_Declaration_Text
(Self : aliased in out Function_Renaming_Declaration)
return Function_Renaming_Declaration_Text_Access is abstract;
not overriding function Not_Token
(Self : Function_Renaming_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Overriding_Token
(Self : Function_Renaming_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Function_Token
(Self : Function_Renaming_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Left_Bracket_Token
(Self : Function_Renaming_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Right_Bracket_Token
(Self : Function_Renaming_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Return_Token
(Self : Function_Renaming_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Not_Token_2
(Self : Function_Renaming_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Null_Token
(Self : Function_Renaming_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Renames_Token
(Self : Function_Renaming_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function With_Token
(Self : Function_Renaming_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Semicolon_Token
(Self : Function_Renaming_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Function_Renaming_Declarations;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
package body EL.Contexts.TLS is
Context : EL.Contexts.ELContext_Access := null;
pragma Thread_Local_Storage (Context);
-- ------------------------------
-- Get the current EL context associated with the current thread.
-- ------------------------------
function Current return EL.Contexts.ELContext_Access is
begin
return Context;
end Current;
-- ------------------------------
-- Initialize and setup a new per-thread EL context.
-- ------------------------------
overriding
procedure Initialize (Obj : in out TLS_Context) is
begin
Obj.Previous := Context;
Context := Obj'Unchecked_Access;
EL.Contexts.Default.Default_Context (Obj).Initialize;
end Initialize;
-- ------------------------------
-- Restore the previouse per-thread EL context.
-- ------------------------------
overriding
procedure Finalize (Obj : in out TLS_Context) is
begin
Context := Obj.Previous;
EL.Contexts.Default.Default_Context (Obj).Finalize;
end Finalize;
end EL.Contexts.TLS;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
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;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
package GBA.Audio is
type Sweep_Shift_Type is range 0 .. 7;
type Frequency_Direction is
( Increasing
, Decreasing
);
for Frequency_Direction use
( Increasing => 0
, Decreasing => 1
);
type Sweep_Duration_Type is range 0 .. 7;
type Sweep_Control_Info is
record
Shift : Sweep_Shift_Type;
Frequency_Change : Frequency_Direction;
Duration : Sweep_Duration_Type;
end record
with Size => 16;
for Sweep_Control_Info use
record
Shift at 0 range 0 .. 2;
Frequency_Change at 0 range 3 .. 3;
Duration at 0 range 4 .. 6;
end record;
type Sound_Duration_Type is range 0 .. 63;
type Wave_Pattern_Duty_Type is range 0 .. 3;
type Envelope_Step_Type is range 0 .. 7;
type Envelope_Direction is
( Increasing
, Decreasing
);
for Envelope_Direction use
( Increasing => 1
, Decreasing => 0
);
type Initial_Volume_Type is range 0 .. 15;
type Duty_Length_Info is
record
Duration : Sound_Duration_Type;
Wave_Pattern_Duty : Wave_Pattern_Duty_Type;
Envelope_Step_Time : Envelope_Step_Type;
Envelope_Change : Envelope_Direction;
Initial_Volume : Initial_Volume_Type;
end record
with Size => 16;
for Duty_Length_Info use
record
Duration at 0 range 0 .. 5;
Wave_Pattern_Duty at 0 range 6 .. 7;
Envelope_Step_Time at 0 range 8 .. 10;
Envelope_Direction at 0 range 11 .. 11;
Initial_Volume at 0 range 12 .. 15;
end record;
type Frequency_Type is range 0 .. 2047;
type Frequency_Control_Info is
record
Frequency : Frequency_Type;
Use_Duration : Boolean;
Initial : Boolean;
end record
with Size => 16;
for Frequency_Control_Info use
record
Frequency at 0 range 0 .. 10;
Use_Duration at 0 range 14 .. 14;
Initial at 0 range 15 .. 15;
end record;
end GBA.Audio;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-------------------------------------------------------------
with Program.Elements.Declarations;
with Program.Lexical_Elements;
with Program.Elements.Defining_Identifiers;
with Program.Elements.Parameter_Specifications;
with Program.Elements.Aspect_Specifications;
package Program.Elements.Procedure_Body_Stubs is
pragma Pure (Program.Elements.Procedure_Body_Stubs);
type Procedure_Body_Stub is
limited interface and Program.Elements.Declarations.Declaration;
type Procedure_Body_Stub_Access is access all Procedure_Body_Stub'Class
with Storage_Size => 0;
not overriding function Name
(Self : Procedure_Body_Stub)
return not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access is abstract;
not overriding function Parameters
(Self : Procedure_Body_Stub)
return Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access is abstract;
not overriding function Aspects
(Self : Procedure_Body_Stub)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access is abstract;
not overriding function Has_Not (Self : Procedure_Body_Stub) return Boolean
is abstract;
not overriding function Has_Overriding
(Self : Procedure_Body_Stub)
return Boolean is abstract;
type Procedure_Body_Stub_Text is limited interface;
type Procedure_Body_Stub_Text_Access is
access all Procedure_Body_Stub_Text'Class with Storage_Size => 0;
not overriding function To_Procedure_Body_Stub_Text
(Self : aliased in out Procedure_Body_Stub)
return Procedure_Body_Stub_Text_Access is abstract;
not overriding function Not_Token
(Self : Procedure_Body_Stub_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Overriding_Token
(Self : Procedure_Body_Stub_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Procedure_Token
(Self : Procedure_Body_Stub_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Left_Bracket_Token
(Self : Procedure_Body_Stub_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Right_Bracket_Token
(Self : Procedure_Body_Stub_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Is_Token
(Self : Procedure_Body_Stub_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Separate_Token
(Self : Procedure_Body_Stub_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function With_Token
(Self : Procedure_Body_Stub_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Semicolon_Token
(Self : Procedure_Body_Stub_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Procedure_Body_Stubs;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--*
-- CHECK THAT A CASE_STATEMENT CORRECTLY HANDLES A SMALL RANGE OF
-- POTENTIAL VALUES OF TYPE INTEGER, SITUATED FAR FROM 0 AND
-- GROUPED INTO A SMALL NUMBER OF ALTERNATIVES.
-- (OPTIMIZATION TEST -- BIASED JUMP TABLE.)
-- RM 03/26/81
WITH REPORT;
PROCEDURE C54A42E IS
USE REPORT ;
BEGIN
TEST( "C54A42E" , "TEST THAT A CASE_STATEMENT HANDLES CORRECTLY" &
" A SMALL, FAR RANGE OF POTENTIAL VALUES OF" &
" TYPE INTEGER" );
DECLARE
NUMBER : CONSTANT := 4001 ;
LITEXPR : CONSTANT := NUMBER + 5 ;
STATCON : CONSTANT INTEGER RANGE 4000..4010 := 4009 ;
DYNVAR : INTEGER RANGE 4000..4010 :=
IDENT_INT( 4010 );
DYNCON : CONSTANT INTEGER RANGE 4000..4010 :=
IDENT_INT( 4002 );
BEGIN
CASE INTEGER'(4000) IS
WHEN 4001 | 4004 => FAILED("WRONG ALTERNATIVE F1");
WHEN 4009 | 4002 => FAILED("WRONG ALTERNATIVE F2");
WHEN 4005 => FAILED("WRONG ALTERNATIVE F3");
WHEN 4003 |
4007..4008 => FAILED("WRONG ALTERNATIVE F4");
WHEN 4006 => FAILED("WRONG ALTERNATIVE F5");
WHEN OTHERS => NULL ;
END CASE;
CASE IDENT_INT(NUMBER) IS
WHEN 4001 | 4004 => NULL ;
WHEN 4009 | 4002 => FAILED("WRONG ALTERNATIVE G2");
WHEN 4005 => FAILED("WRONG ALTERNATIVE G3");
WHEN 4003 |
4007..4008 => FAILED("WRONG ALTERNATIVE G4");
WHEN 4006 => FAILED("WRONG ALTERNATIVE G5");
WHEN OTHERS => FAILED("WRONG ALTERNATIVE G6");
END CASE;
CASE IDENT_INT(LITEXPR) IS
WHEN 4001 | 4004 => FAILED("WRONG ALTERNATIVE H1");
WHEN 4009 | 4002 => FAILED("WRONG ALTERNATIVE H2");
WHEN 4005 => FAILED("WRONG ALTERNATIVE H3");
WHEN 4003 |
4007..4008 => FAILED("WRONG ALTERNATIVE H4");
WHEN 4006 => NULL ;
WHEN OTHERS => FAILED("WRONG ALTERNATIVE H6");
END CASE;
CASE STATCON IS
WHEN 4001 | 4004 => FAILED("WRONG ALTERNATIVE I1");
WHEN 4009 | 4002 => NULL ;
WHEN 4005 => FAILED("WRONG ALTERNATIVE I3");
WHEN 4003 |
4007..4008 => FAILED("WRONG ALTERNATIVE I4");
WHEN 4006 => FAILED("WRONG ALTERNATIVE I5");
WHEN OTHERS => FAILED("WRONG ALTERNATIVE I6");
END CASE;
CASE DYNVAR IS
WHEN 4001 | 4004 => FAILED("WRONG ALTERNATIVE J1");
WHEN 4009 | 4002 => FAILED("WRONG ALTERNATIVE J2");
WHEN 4005 => FAILED("WRONG ALTERNATIVE J3");
WHEN 4003 |
4007..4008 => FAILED("WRONG ALTERNATIVE J4");
WHEN 4006 => FAILED("WRONG ALTERNATIVE J5");
WHEN OTHERS => NULL ;
END CASE;
CASE DYNCON IS
WHEN 4001 | 4004 => FAILED("WRONG ALTERNATIVE K1");
WHEN 4009 | 4002 => NULL ;
WHEN 4005 => FAILED("WRONG ALTERNATIVE K3");
WHEN 4003 |
4007..4008 => FAILED("WRONG ALTERNATIVE K4");
WHEN 4006 => FAILED("WRONG ALTERNATIVE K5");
WHEN OTHERS => FAILED("WRONG ALTERNATIVE K6");
END CASE;
END ;
RESULT ;
END C54A42E ;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Orka.Futures;
with Orka.Jobs.Queues;
with Orka.Resources.Locations;
with Orka.Resources.Loaders;
generic
with package Queues is new Orka.Jobs.Queues (<>);
Job_Queue : Queues.Queue_Ptr;
Maximum_Requests : Positive;
-- Maximum number of resources waiting to be read from a file system
-- or archive. Resources are read sequentially, but may be processed
-- concurrently. This number depends on how fast the hardware can read
-- the requested resources.
Task_Name : String := "Resource Loader";
package Orka.Resources.Loader is
procedure Add_Location (Location : Locations.Location_Ptr; Loader : Loaders.Loader_Ptr);
-- Add a location that contains files that can be loaded by the
-- given loader. Multiple loaders can be registered for a specific
-- location and multiple locations can be registered for a specific
-- loader.
--
-- A loader can only load resources that have a specific extension.
-- The extension can be queried by calling the Loader.Extension function.
function Load (Path : String) return Futures.Pointers.Mutable_Pointer;
-- Load the given resource from a file system or archive and return
-- a handle for querying the processing status of the resource. Calling
-- this function may block until there is a free slot available for
-- processing the data.
procedure Shutdown;
private
task Loader;
end Orka.Resources.Loader;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- Zip.Compress
-- ------------
--
-- This package facilitates the storage or compression of data.
--
-- Note that unlike decompression where the decoding is unique,
-- there is a quasi indefinite number of ways of compressing data into
-- most Zip-supported formats, including LZW (Shrink), Reduce, Deflate, or LZMA.
-- As a result, you may want to use your own way for compressing data.
-- This package is a portable one and doesn't claim to be the "best".
-- The term "best" is relative to the needs, since there are at least
-- two criteria that usually go in opposite directions: speed and
-- compression ratio, a bit like risk and return in finance.
with DCF.Streams;
package DCF.Zip.Compress is
pragma Preelaborate;
-- Compression_Method is actually reflecting the way of compressing
-- data, not only the final compression format called "method" in
-- Zip specifications.
type Compression_Method is
-- No compression:
(Store,
-- Deflate combines LZ and Huffman encoding; 4 strengths available:
Deflate_Fixed, Deflate_1, Deflate_2, Deflate_3);
type Method_To_Format_Type is array (Compression_Method) of Pkzip_Method;
Method_To_Format : constant Method_To_Format_Type;
-- Deflate_Fixed compresses the data into a single block and with predefined
-- ("fixed") compression structures. The data are basically LZ-compressed
-- only, since the Huffman code sets are flat and not tailored for the data.
subtype Deflation_Method is Compression_Method range Deflate_Fixed .. Deflate_3;
-- The multi-block Deflate methods use refined techniques to decide when to
-- start a new block and what sort of block to put next.
subtype Taillaule_Deflation_Method is Compression_Method range Deflate_1 .. Deflate_3;
User_Abort : exception;
-- Compress data from an input stream to an output stream until
-- End_Of_File(input) = True, or number of input bytes = input_size.
-- If password /= "", an encryption header is written.
procedure Compress_Data
(Input, Output : in out DCF.Streams.Root_Zipstream_Type'Class;
Input_Size : File_Size_Type;
Method : Compression_Method;
Feedback : Feedback_Proc;
CRC : out Unsigned_32;
Output_Size : out File_Size_Type;
Zip_Type : out Unsigned_16);
-- ^ code corresponding to the compression method actually used
private
Method_To_Format : constant Method_To_Format_Type :=
(Store => Store, Deflation_Method => Deflate);
end DCF.Zip.Compress;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
package body getter.macros is
function get return character is
c : character;
procedure rem_var (cur : in params_t.cursor) is
begin
environment.delete(environment_t.key(params_t.element(cur)));
end rem_var;
begin
if current_called.last > unb.length(current_macros.code) then
params_t.iterate(current_called.params, rem_var'access);
stack.delete_last;
if not stack_t.is_empty(stack) then
current_called := stack_t.element(stack_t.last(stack));
current_macros := macroses_t.element(current_called.macros_cursor);
end if;
pop;
return ' ';
end if;
c := unb.element(current_macros.code, current_called.last);
inc(current_called.last);
return c;
end get;
procedure define (name, params : string) is
eqs : natural := 1;
c : character;
tmp_macros : macros_t;
len_end : constant natural := end_macros_statement'length;
start_pos : natural := 1;
cur_pos : natural := 1;
mustbe_only_default : boolean := false;
t_param : param_t;
begin
loop
c := getter.get(false);
if c = ascii.nul then
raise ERROR_NO_CLOSED;
end if;
if end_macros_statement(eqs) = c and then unb.element(tmp_macros.code, unb.length(tmp_macros.code) - eqs + 1) in ' '|ascii.lf then
inc(eqs);
if eqs > len_end then
unb.delete(tmp_macros.code, unb.length(tmp_macros.code) - (end_macros_statement'length - 2), unb.length(tmp_macros.code));
exit;
end if;
else
eqs := 1;
end if;
unb.append(tmp_macros.code, c);
end loop;
for i in params'range loop
c := params(i);
if c in ' '|ascii.lf then
if start_pos /= cur_pos then
declare
param : constant string := params(start_pos..(cur_pos - 1));
assignment_pos : natural := fix.index(param, "=");
begin
if assignment_pos > 0 then
mustbe_only_default := true;
if assignment_pos = param'last or assignment_pos = param'first or
not validate_variable(param(param'first..(assignment_pos - 1))) or
not validate_word(param((assignment_pos + 1)..param'last)) then
raise ERROR_PARAM with param;
end if;
t_param.name := unb.to_unbounded_string(param(param'first..(assignment_pos - 1)));
t_param.default_val := value(param((assignment_pos + 1)..param'last));
t_param.has_default := true;
elsif mustbe_only_default then
raise ERROR_NONDEFAULT_AFTER_DEFAULT with param;
elsif not validate_variable(param) then
raise ERROR_PARAM with param;
else
inc(tmp_macros.num_required_params);
t_param.name := unb.to_unbounded_string(param);
end if;
end;
tmp_macros.param_names.append(t_param);
end if;
start_pos := cur_pos + 1;
end if;
inc(cur_pos);
end loop;
macroses.insert(name, tmp_macros);
end define;
procedure call (name, params : string) is
t_i : positive := 1;
param_i : param_names_t.cursor;
tmp_env_cur : environment_t.cursor;
tb : boolean;
num_req : natural;
tmp_n : natural;
mustbe_only_default : boolean := false;
t_param : param_t;
begin
if not macroses_t.contains(macroses, name) then
raise ERROR_NO_DEFINED;
end if;
if not stack_t.is_empty(stack) then
stack.replace_element(stack_t.last(stack), current_called);
end if;
current_called.last := 1;
current_called.cur_line := 1;
current_called.params.clear;
current_called.macros_cursor := macroses_t.find(macroses, name);
current_macros := macroses_t.element(current_called.macros_cursor);
num_req := current_macros.num_required_params;
stack.append(current_called);
param_i := param_names_t.first(current_macros.param_names);
for i in params'range loop
if params(i) = ' ' then
declare
param_raw : constant string := params(t_i..i - 1);
assignment_pos : natural := fix.index(param_raw, "=");
name : constant string := param_raw(param_raw'first..(assignment_pos - 1));
param : constant string := param_raw(natural'max((assignment_pos + 1), param_raw'first)..param_raw'last);
begin
if assignment_pos > 0 then
if assignment_pos = param_raw'first or assignment_pos = param_raw'last then
raise ERROR_PARAM with param;
end if;
mustbe_only_default := true;
param_i := param_names_t.first(current_macros.param_names);
while param_names_t.has_element(param_i) loop
t_param := param_names_t.element(param_i);
if t_param.name = name then
if not t_param.has_default then
if num_req = 0 then
raise ERROR_COUNT_PARAMS with params;
end if;
dec(num_req);
end if;
exit;
end if;
param_names_t.next(param_i);
end loop;
if not param_names_t.has_element(param_i) then
raise ERROR_UNEXPECTED_NAME with name;
end if;
environment.insert(name, value(param), tmp_env_cur, tb);
elsif mustbe_only_default then
raise ERROR_NONDEFAULT_AFTER_DEFAULT with params;
else
if num_req > 0 then
dec(num_req);
end if;
environment.insert(unb.to_string(param_names_t.element(param_i).name), value(param), tmp_env_cur, tb);
param_names_t.next(param_i);
end if;
if not tb then
raise ERROR_ALREADY_DEFINED;
end if;
end;
current_called.params.append(tmp_env_cur);
t_i := i + 1;
end if;
end loop;
if num_req > 0 then
raise ERROR_COUNT_PARAMS with params;
end if;
param_i := param_names_t.first(current_macros.param_names);
while param_names_t.has_element(param_i) loop
t_param := param_names_t.element(param_i);
if t_param.has_default then
environment.insert(unb.to_string(param_names_t.element(param_i).name), t_param.default_val, tmp_env_cur, tb);
if tb then
current_called.params.append(tmp_env_cur);
end if;
end if;
param_names_t.next(param_i);
end loop;
getter.push(get'access);
end call;
end getter.macros;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.IO_Exceptions;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with System.Strings; use System.Strings;
with System.Mmap.OS_Interface; use System.Mmap.OS_Interface;
package body System.Mmap is
type Mapped_File_Record is record
Current_Region : Mapped_Region;
-- The legacy API enables only one region to be mapped, directly
-- associated with the mapped file. This references this region.
File : System_File;
-- Underlying OS-level file
end record;
type Mapped_Region_Record is record
File : Mapped_File;
-- The file this region comes from. Be careful: for reading file, it is
-- valid to have it closed before one of its regions is free'd.
Write : Boolean;
-- Whether the file this region comes from is open for writing.
Data : Str_Access;
-- Unbounded access to the mapped content.
System_Offset : File_Size;
-- Position in the file of the first byte actually mapped in memory
User_Offset : File_Size;
-- Position in the file of the first byte requested by the user
System_Size : File_Size;
-- Size of the region actually mapped in memory
User_Size : File_Size;
-- Size of the region requested by the user
Mapped : Boolean;
-- Whether this region is actually memory mapped
Mutable : Boolean;
-- If the file is opened for reading, wheter this region is writable
Buffer : System.Strings.String_Access;
-- When this region is not actually memory mapped, contains the
-- requested bytes.
Mapping : System_Mapping;
-- Underlying OS-level data for the mapping, if any
end record;
Invalid_Mapped_Region_Record : constant Mapped_Region_Record :=
(null, False, null, 0, 0, 0, 0, False, False, null,
Invalid_System_Mapping);
Invalid_Mapped_File_Record : constant Mapped_File_Record :=
(Invalid_Mapped_Region, Invalid_System_File);
Empty_String : constant String := "";
-- Used to provide a valid empty Data for empty files, for instanc.
procedure Dispose is new Ada.Unchecked_Deallocation
(Mapped_File_Record, Mapped_File);
procedure Dispose is new Ada.Unchecked_Deallocation
(Mapped_Region_Record, Mapped_Region);
function Convert is new Ada.Unchecked_Conversion
(Standard.System.Address, Str_Access);
procedure Compute_Data (Region : Mapped_Region);
-- Fill the Data field according to system and user offsets. The region
-- must actually be mapped or bufferized.
procedure From_Disk (Region : Mapped_Region);
-- Read a region of some file from the disk
procedure To_Disk (Region : Mapped_Region);
-- Write the region of the file back to disk if necessary, and free memory
----------------------------
-- Open_Read_No_Exception --
----------------------------
function Open_Read_No_Exception
(Filename : String;
Use_Mmap_If_Available : Boolean := True) return Mapped_File
is
File : constant System_File :=
Open_Read (Filename, Use_Mmap_If_Available);
begin
if File = Invalid_System_File then
return Invalid_Mapped_File;
end if;
return new Mapped_File_Record'
(Current_Region => Invalid_Mapped_Region,
File => File);
end Open_Read_No_Exception;
---------------
-- Open_Read --
---------------
function Open_Read
(Filename : String;
Use_Mmap_If_Available : Boolean := True) return Mapped_File
is
Res : constant Mapped_File :=
Open_Read_No_Exception (Filename, Use_Mmap_If_Available);
begin
if Res = Invalid_Mapped_File then
raise Ada.IO_Exceptions.Name_Error
with "Cannot open " & Filename;
else
return Res;
end if;
end Open_Read;
----------------
-- Open_Write --
----------------
function Open_Write
(Filename : String;
Use_Mmap_If_Available : Boolean := True) return Mapped_File
is
File : constant System_File :=
Open_Write (Filename, Use_Mmap_If_Available);
begin
if File = Invalid_System_File then
raise Ada.IO_Exceptions.Name_Error
with "Cannot open " & Filename;
else
return new Mapped_File_Record'
(Current_Region => Invalid_Mapped_Region,
File => File);
end if;
end Open_Write;
-----------
-- Close --
-----------
procedure Close (File : in out Mapped_File) is
begin
-- Closing a closed file is allowed and should do nothing
if File = Invalid_Mapped_File then
return;
end if;
if File.Current_Region /= null then
Free (File.Current_Region);
end if;
if File.File /= Invalid_System_File then
Close (File.File);
end if;
Dispose (File);
end Close;
----------
-- Free --
----------
procedure Free (Region : in out Mapped_Region) is
Ignored : Integer;
pragma Unreferenced (Ignored);
begin
-- Freeing an already free'd file is allowed and should do nothing
if Region = Invalid_Mapped_Region then
return;
end if;
if Region.Mapping /= Invalid_System_Mapping then
Dispose_Mapping (Region.Mapping);
end if;
To_Disk (Region);
Dispose (Region);
end Free;
----------
-- Read --
----------
procedure Read
(File : Mapped_File;
Region : in out Mapped_Region;
Offset : File_Size := 0;
Length : File_Size := 0;
Mutable : Boolean := False)
is
File_Length : constant File_Size := Mmap.Length (File);
Req_Offset : constant File_Size := Offset;
Req_Length : File_Size := Length;
-- Offset and Length of the region to map, used to adjust mapping
-- bounds, reflecting what the user will see.
Region_Allocated : Boolean := False;
begin
-- If this region comes from another file, or simply if the file is
-- writeable, we cannot re-use this mapping: free it first.
if Region /= Invalid_Mapped_Region
and then
(Region.File /= File or else File.File.Write)
then
Free (Region);
end if;
if Region = Invalid_Mapped_Region then
Region := new Mapped_Region_Record'(Invalid_Mapped_Region_Record);
Region_Allocated := True;
end if;
Region.File := File;
if Req_Offset >= File_Length then
-- If the requested offset goes beyond file size, map nothing
Req_Length := 0;
elsif Length = 0
or else
Length > File_Length - Req_Offset
then
-- If Length is 0 or goes beyond file size, map till end of file
Req_Length := File_Length - Req_Offset;
else
Req_Length := Length;
end if;
-- Past this point, the offset/length the user will see is fixed. On the
-- other hand, the system offset/length is either already defined, from
-- a previous mapping, or it is set to 0. In the latter case, the next
-- step will set them according to the mapping.
Region.User_Offset := Req_Offset;
Region.User_Size := Req_Length;
-- If the requested region is inside an already mapped region, adjust
-- user-requested data and do nothing else.
if (File.File.Write or else Region.Mutable = Mutable)
and then
Req_Offset >= Region.System_Offset
and then
(Req_Offset + Req_Length
<= Region.System_Offset + Region.System_Size)
then
Region.User_Offset := Req_Offset;
Compute_Data (Region);
return;
elsif Region.Buffer /= null then
-- Otherwise, as we are not going to re-use the buffer, free it
System.Strings.Free (Region.Buffer);
Region.Buffer := null;
elsif Region.Mapping /= Invalid_System_Mapping then
-- Otherwise, there is a memory mapping that we need to unmap.
Dispose_Mapping (Region.Mapping);
end if;
-- mmap() will sometimes return NULL when the file exists but is empty,
-- which is not what we want, so in the case of a zero length file we
-- fall back to read(2)/write(2)-based mode.
if File_Length > 0 and then File.File.Mapped then
Region.System_Offset := Req_Offset;
Region.System_Size := Req_Length;
Create_Mapping
(File.File,
Region.System_Offset, Region.System_Size,
Mutable,
Region.Mapping);
Region.Mapped := True;
Region.Mutable := Mutable;
else
-- There is no alignment requirement when manually reading the file.
Region.System_Offset := Req_Offset;
Region.System_Size := Req_Length;
Region.Mapped := False;
Region.Mutable := True;
From_Disk (Region);
end if;
Region.Write := File.File.Write;
Compute_Data (Region);
exception
when others =>
-- Before propagating any exception, free any region we allocated
-- here.
if Region_Allocated then
Dispose (Region);
end if;
raise;
end Read;
----------
-- Read --
----------
procedure Read
(File : Mapped_File;
Offset : File_Size := 0;
Length : File_Size := 0;
Mutable : Boolean := False)
is
begin
Read (File, File.Current_Region, Offset, Length, Mutable);
end Read;
----------
-- Read --
----------
function Read
(File : Mapped_File;
Offset : File_Size := 0;
Length : File_Size := 0;
Mutable : Boolean := False) return Mapped_Region
is
Region : Mapped_Region := Invalid_Mapped_Region;
begin
Read (File, Region, Offset, Length, Mutable);
return Region;
end Read;
------------
-- Length --
------------
function Length (File : Mapped_File) return File_Size is
begin
return File.File.Length;
end Length;
------------
-- Offset --
------------
function Offset (Region : Mapped_Region) return File_Size is
begin
return Region.User_Offset;
end Offset;
------------
-- Offset --
------------
function Offset (File : Mapped_File) return File_Size is
begin
return Offset (File.Current_Region);
end Offset;
----------
-- Last --
----------
function Last (Region : Mapped_Region) return Integer is
begin
return Integer (Region.User_Size);
end Last;
----------
-- Last --
----------
function Last (File : Mapped_File) return Integer is
begin
return Last (File.Current_Region);
end Last;
-------------------
-- To_Str_Access --
-------------------
function To_Str_Access
(Str : System.Strings.String_Access) return Str_Access is
begin
if Str = null then
return null;
else
return Convert (Str.all'Address);
end if;
end To_Str_Access;
----------
-- Data --
----------
function Data (Region : Mapped_Region) return Str_Access is
begin
return Region.Data;
end Data;
----------
-- Data --
----------
function Data (File : Mapped_File) return Str_Access is
begin
return Data (File.Current_Region);
end Data;
----------------
-- Is_Mutable --
----------------
function Is_Mutable (Region : Mapped_Region) return Boolean is
begin
return Region.Mutable or Region.Write;
end Is_Mutable;
----------------
-- Is_Mmapped --
----------------
function Is_Mmapped (File : Mapped_File) return Boolean is
begin
return File.File.Mapped;
end Is_Mmapped;
-------------------
-- Get_Page_Size --
-------------------
function Get_Page_Size return Integer is
Result : constant File_Size := Get_Page_Size;
begin
return Integer (Result);
end Get_Page_Size;
---------------------
-- Read_Whole_File --
---------------------
function Read_Whole_File
(Filename : String;
Empty_If_Not_Found : Boolean := False)
return System.Strings.String_Access
is
File : Mapped_File := Open_Read (Filename);
Region : Mapped_Region renames File.Current_Region;
Result : String_Access;
begin
Read (File);
if Region.Data /= null then
Result := new String'(String
(Region.Data (1 .. Last (Region))));
elsif Region.Buffer /= null then
Result := Region.Buffer;
Region.Buffer := null; -- So that it is not deallocated
end if;
Close (File);
return Result;
exception
when Ada.IO_Exceptions.Name_Error =>
if Empty_If_Not_Found then
return new String'("");
else
return null;
end if;
when others =>
Close (File);
return null;
end Read_Whole_File;
---------------
-- From_Disk --
---------------
procedure From_Disk (Region : Mapped_Region) is
begin
pragma Assert (Region.File.all /= Invalid_Mapped_File_Record);
pragma Assert (Region.Buffer = null);
Region.Buffer := Read_From_Disk
(Region.File.File, Region.User_Offset, Region.User_Size);
Region.Mapped := False;
end From_Disk;
-------------
-- To_Disk --
-------------
procedure To_Disk (Region : Mapped_Region) is
begin
if Region.Write and then Region.Buffer /= null then
pragma Assert (Region.File.all /= Invalid_Mapped_File_Record);
Write_To_Disk
(Region.File.File,
Region.User_Offset, Region.User_Size,
Region.Buffer);
end if;
System.Strings.Free (Region.Buffer);
Region.Buffer := null;
end To_Disk;
------------------
-- Compute_Data --
------------------
procedure Compute_Data (Region : Mapped_Region) is
Base_Data : Str_Access;
-- Address of the first byte actually mapped in memory
Data_Shift : constant Integer :=
Integer (Region.User_Offset - Region.System_Offset);
begin
if Region.User_Size = 0 then
Region.Data := Convert (Empty_String'Address);
return;
elsif Region.Mapped then
Base_Data := Convert (Region.Mapping.Address);
else
Base_Data := Convert (Region.Buffer.all'Address);
end if;
Region.Data := Convert (Base_Data (Data_Shift + 1)'Address);
end Compute_Data;
end System.Mmap;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Text_IO;
procedure Test_For_Primes is
type Pascal_Triangle_Type is array (Natural range <>) of Long_Long_Integer;
function Calculate_Pascal_Triangle (N : in Natural) return Pascal_Triangle_Type is
Pascal_Triangle : Pascal_Triangle_Type (0 .. N);
begin
Pascal_Triangle (0) := 1;
for I in Pascal_Triangle'First .. Pascal_Triangle'Last - 1 loop
Pascal_Triangle (1 + I) := 1;
for J in reverse 1 .. I loop
Pascal_Triangle (J) := Pascal_Triangle (J - 1) - Pascal_Triangle (J);
end loop;
Pascal_Triangle (0) := -Pascal_Triangle (0);
end loop;
return Pascal_Triangle;
end Calculate_Pascal_Triangle;
function Is_Prime (N : Integer) return Boolean is
I : Integer;
Result : Boolean := True;
Pascal_Triangle : constant Pascal_Triangle_Type := Calculate_Pascal_Triangle (N);
begin
I := N / 2;
while Result and I > 1 loop
Result := Result and Pascal_Triangle (I) mod Long_Long_Integer (N) = 0;
I := I - 1;
end loop;
return Result;
end Is_Prime;
function Image (N : in Long_Long_Integer;
Sign : in Boolean := False) return String is
Image : constant String := N'Image;
begin
if N < 0 then
return Image;
else
if Sign then
return "+" & Image (Image'First + 1 .. Image'Last);
else
return Image (Image'First + 1 .. Image'Last);
end if;
end if;
end Image;
procedure Show (Triangle : in Pascal_Triangle_Type) is
use Ada.Text_IO;
Begin
for I in reverse Triangle'Range loop
Put (Image (Triangle (I), Sign => True));
Put ("x^");
Put (Image (Long_Long_Integer (I)));
Put (" ");
end loop;
end Show;
procedure Show_Pascal_Triangles is
use Ada.Text_IO;
begin
for N in 0 .. 9 loop
declare
Pascal_Triangle : constant Pascal_Triangle_Type := Calculate_Pascal_Triangle (N);
begin
Put ("(x-1)^" & Image (Long_Long_Integer (N)) & " = ");
Show (Pascal_Triangle);
New_Line;
end;
end loop;
end Show_Pascal_Triangles;
procedure Show_Primes is
use Ada.Text_IO;
begin
for N in 2 .. 63 loop
if Is_Prime (N) then
Put (N'Image);
end if;
end loop;
New_Line;
end Show_Primes;
begin
Show_Pascal_Triangles;
Show_Primes;
end Test_For_Primes;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Package containing the routines to process a list of discrete choices.
-- Such lists can occur in two different constructs: case statements and
-- record variants. We have factorized what used to be two very similar
-- sets of routines in one place. These are not currently used for the
-- aggregate case, since issues with nested aggregates make that case
-- substantially different.
-- The following processing is required for such cases:
-- 1. Analysis of names of subtypes, constants, expressions appearing within
-- the choices. This must be done when the construct is encountered to get
-- proper visibility of names.
-- 2. Checking for semantic correctness of the choices. A lot of this could
-- be done at the time when the construct is encountered, but not all, since
-- in the case of variants, statically predicated subtypes won't be frozen
-- (and the choice sets known) till the enclosing record type is frozen. So
-- at least the check for no overlaps and covering the range must be delayed
-- till the freeze point in this case.
-- 3. Set the Others_Discrete_Choices list for an others choice. This is
-- used in various ways, e.g. to construct the disriminant checking function
-- for the case of a variant with an others choice.
-- 4. In the case of static predicates, we need to expand out choices that
-- correspond to the predicate for the back end. This expansion destroys
-- the list of choices, so it should be delayed to expansion time.
-- Step 1 is performed by the generic procedure Analyze_Choices, which is
-- called when the variant record or case statement/expression is first
-- encountered.
-- Step 2 is performed by the generic procedure Check_Choices. We decide to
-- do all semantic checking in that step, since as noted above some of this
-- has to be deferred to the freeze point in any case for variants. For case
-- statements and expressions, this procedure can be called at the time the
-- case construct is encountered (after calling Analyze_Choices).
-- Step 3 is also performed by Check_Choices, since we need the static ranges
-- for predicated subtypes to accurately construct this.
-- Step 4 is performed by the procedure Expand_Static_Predicates_In_Choices.
-- For case statements, this call only happens during expansion. The reason
-- we do the expansion unconditionally for variants is that other processing,
-- for example for aggregates, relies on having a complete list of choices.
-- Historical note: We used to perform all four of these functions at once in
-- a single procedure called Analyze_Choices. This routine was called at the
-- time the construct was first encountered. That seemed to work OK up to Ada
-- 2005, but the introduction of statically predicated subtypes with delayed
-- evaluation of the static ranges made this completely wrong, both because
-- the ASIS tree got destroyed by step 4, and steps 2 and 3 were too early
-- in the variant record case.
with Types; use Types;
package Sem_Case is
procedure No_OP (C : Node_Id);
-- The no-operation routine. Does mostly nothing. Can be used
-- in the following generics for the parameters Process_Empty_Choice,
-- or Process_Associated_Node. In the case of an empty range choice,
-- routine emits a warning when Warn_On_Redundant_Constructs is enabled.
generic
with procedure Process_Associated_Node (A : Node_Id);
-- Associated with each case alternative or record variant A there is
-- a node or list of nodes that need additional processing. This routine
-- implements that processing.
package Generic_Analyze_Choices is
procedure Analyze_Choices
(Alternatives : List_Id;
Subtyp : Entity_Id);
-- From a case expression, case statement, or record variant, this
-- routine analyzes the corresponding list of discrete choices which
-- appear in each element of the list Alternatives (for the variant
-- part case, this is the variants, for a case expression or statement,
-- this is the Alternatives).
--
-- Subtyp is the subtype of the discrete choices. The type against which
-- the discrete choices must be resolved is its base type.
end Generic_Analyze_Choices;
generic
with procedure Process_Empty_Choice (Choice : Node_Id);
-- Processing to carry out for an empty Choice. Set to No_Op (declared
-- above) if no such processing is required.
with procedure Process_Non_Static_Choice (Choice : Node_Id);
-- Processing to carry out for a non static Choice (gives an error msg)
with procedure Process_Associated_Node (A : Node_Id);
-- Associated with each case alternative or record variant A there is
-- a node or list of nodes that need semantic processing. This routine
-- implements that processing.
package Generic_Check_Choices is
procedure Check_Choices
(N : Node_Id;
Alternatives : List_Id;
Subtyp : Entity_Id;
Others_Present : out Boolean);
-- From a case expression, case statement, or record variant N, this
-- routine analyzes the corresponding list of discrete choices which
-- appear in each element of the list Alternatives (for the variant
-- part case, this is the variants, for a case expression or statement,
-- this is the Alternatives).
--
-- Subtyp is the subtype of the discrete choices. The type against which
-- the discrete choices must be resolved is its base type.
--
-- Others_Present is set to True if an Others choice is present in the
-- list of choices, and in this case Others_Discrete_Choices is set in
-- the N_Others_Choice node.
--
-- If a Discrete_Choice list contains at least one instance of a subtype
-- with a static predicate, then the Has_SP_Choice flag is set true in
-- the parent node (N_Variant, N_Case_Expression/Statement_Alternative).
end Generic_Check_Choices;
end Sem_Case;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Measure_Units; use Measure_Units;
with Ada.Text_IO; use Ada.Text_IO;
procedure Aviotest0 is
Avg_Speed : Kn := 350.0;
Travel_Time : Duration := 2.0 * 3600.0; -- two hours
CR : Climb_Rate := 1500.0;
Climb_Time : Duration := 60.0 * 20; -- 2 minutes
Alt0 : Ft := 50_000.0; -- from here
Alt1 : Ft := 20_000.0; -- to here
Sink_Time : Duration := 60.0 * 10; -- in 10 minutes
begin
Put_Line ("avg speed (kt): " & Avg_Speed);
Put_Line ("avg speed (m/s): " & To_Mps (Avg_Speed));
Put_Line ("flight duration (s): " & Duration'Image (Travel_Time));
Put_Line ("distance (NM): " & (Avg_Speed * Travel_Time));
Put_Line ("distance (m): " & To_Meters (Avg_Speed * Travel_Time));
Put_Line ("climb rate (ft/min): " & CR);
Put_Line ("alt (ft) after "
& Duration'Image (Climb_Time)
& " s: "
& (CR * Climb_Time));
Put_Line ("change alt rate (ft/m): " & ((Alt1 - Alt0) / Sink_Time));
end Aviotest0;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
-- --
-- This file is based on: --
-- --
-- @file stm32f4xx_hal_adc.c --
-- @author MCD Application Team --
-- @version V1.3.1 --
-- @date 25-March-2015 --
-- @brief Header file of ADC HAL module. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
with STM32_SVD.ADC; use STM32_SVD.ADC;
package body STM32.ADC is
procedure Set_Sequence_Position
(This : in out Analog_To_Digital_Converter;
Channel : Analog_Input_Channel;
Rank : Regular_Channel_Rank)
with Inline;
procedure Set_Sampling_Time
(This : in out Analog_To_Digital_Converter;
Channel : Analog_Input_Channel;
Sample_Time : Channel_Sampling_Times)
with Inline;
procedure Set_Injected_Channel_Sequence_Position
(This : in out Analog_To_Digital_Converter;
Channel : Analog_Input_Channel;
Rank : Injected_Channel_Rank)
with Inline;
procedure Set_Injected_Channel_Offset
(This : in out Analog_To_Digital_Converter;
Rank : Injected_Channel_Rank;
Offset : Injected_Data_Offset)
with Inline;
------------
-- Enable --
------------
procedure Enable (This : in out Analog_To_Digital_Converter) is
begin
if not This.CR2.ADON then
This.CR2.ADON := True;
delay until Clock + ADC_Stabilization;
end if;
end Enable;
-------------
-- Disable --
-------------
procedure Disable (This : in out Analog_To_Digital_Converter) is
begin
This.CR2.ADON := False;
end Disable;
-------------
-- Enabled --
-------------
function Enabled (This : Analog_To_Digital_Converter) return Boolean is
(This.CR2.ADON);
----------------------
-- Conversion_Value --
----------------------
function Conversion_Value
(This : Analog_To_Digital_Converter)
return UInt16
is
begin
return This.DR.DATA;
end Conversion_Value;
---------------------------
-- Data_Register_Address --
---------------------------
function Data_Register_Address
(This : Analog_To_Digital_Converter)
return System.Address
is
(This.DR'Address);
-------------------------------
-- Injected_Conversion_Value --
-------------------------------
function Injected_Conversion_Value
(This : Analog_To_Digital_Converter;
Rank : Injected_Channel_Rank)
return UInt16
is
begin
case Rank is
when 1 =>
return This.JDR1.JDATA;
when 2 =>
return This.JDR2.JDATA;
when 3 =>
return This.JDR3.JDATA;
when 4 =>
return This.JDR4.JDATA;
end case;
end Injected_Conversion_Value;
--------------------------------
-- Multimode_Conversion_Value --
--------------------------------
function Multimode_Conversion_Value return UInt32 is
(C_ADC_Periph.CDR.Val);
--------------------
-- Configure_Unit --
--------------------
procedure Configure_Unit
(This : in out Analog_To_Digital_Converter;
Resolution : ADC_Resolution;
Alignment : Data_Alignment)
is
begin
This.CR1.RES := ADC_Resolution'Enum_Rep (Resolution);
This.CR2.ALIGN := Alignment = Left_Aligned;
end Configure_Unit;
------------------------
-- Current_Resolution --
------------------------
function Current_Resolution
(This : Analog_To_Digital_Converter)
return ADC_Resolution
is (ADC_Resolution'Val (This.CR1.RES));
-----------------------
-- Current_Alignment --
-----------------------
function Current_Alignment
(This : Analog_To_Digital_Converter)
return Data_Alignment
is ((if This.CR2.ALIGN then Left_Aligned else Right_Aligned));
---------------------------------
-- Configure_Common_Properties --
---------------------------------
procedure Configure_Common_Properties
(Mode : Multi_ADC_Mode_Selections;
Prescalar : ADC_Prescalars;
DMA_Mode : Multi_ADC_DMA_Modes;
Sampling_Delay : Sampling_Delay_Selections)
is
begin
C_ADC_Periph.CCR.MULT := Multi_ADC_Mode_Selections'Enum_Rep (Mode);
C_ADC_Periph.CCR.DELAY_k :=
Sampling_Delay_Selections'Enum_Rep (Sampling_Delay);
C_ADC_Periph.CCR.DMA := Multi_ADC_DMA_Modes'Enum_Rep (DMA_Mode);
C_ADC_Periph.CCR.ADCPRE := ADC_Prescalars'Enum_Rep (Prescalar);
end Configure_Common_Properties;
-----------------------------------
-- Configure_Regular_Conversions --
-----------------------------------
procedure Configure_Regular_Conversions
(This : in out Analog_To_Digital_Converter;
Continuous : Boolean;
Trigger : Regular_Channel_Conversion_Trigger;
Enable_EOC : Boolean;
Conversions : Regular_Channel_Conversions)
is
begin
This.CR2.EOCS := Enable_EOC;
This.CR2.CONT := Continuous;
This.CR1.SCAN := Conversions'Length > 1;
if Trigger.Enabler /= Trigger_Disabled then
This.CR2.EXTSEL := External_Events_Regular_Group'Enum_Rep (Trigger.Event);
This.CR2.EXTEN := External_Trigger'Enum_Rep (Trigger.Enabler);
else
This.CR2.EXTSEL := 0;
This.CR2.EXTEN := 0;
end if;
for Rank in Conversions'Range loop
declare
Conversion : Regular_Channel_Conversion renames Conversions (Rank);
begin
Configure_Regular_Channel
(This, Conversion.Channel, Rank, Conversion.Sample_Time);
-- We check the VBat first because that channel is also used for
-- the temperature sensor channel on some MCUs, in which case the
-- VBat conversion is the only one done. This order reflects that
-- hardware behavior.
if VBat_Conversion (This, Conversion.Channel) then
Enable_VBat_Connection;
elsif VRef_TemperatureSensor_Conversion (This, Conversion.Channel)
then
Enable_VRef_TemperatureSensor_Connection;
end if;
end;
end loop;
This.SQR1.L := UInt4 (Conversions'Length - 1); -- biased rep
end Configure_Regular_Conversions;
------------------------------------
-- Configure_Injected_Conversions --
------------------------------------
procedure Configure_Injected_Conversions
(This : in out Analog_To_Digital_Converter;
AutoInjection : Boolean;
Trigger : Injected_Channel_Conversion_Trigger;
Enable_EOC : Boolean;
Conversions : Injected_Channel_Conversions)
is
begin
This.CR2.EOCS := Enable_EOC;
-- Injected channels cannot be converted continuously. The only
-- exception is when an injected channel is configured to be converted
-- automatically after regular channels in continuous mode. See note in
-- RM 13.3.5, pg 390, and "Auto-injection" section on pg 392.
This.CR1.JAUTO := AutoInjection;
if Trigger.Enabler /= Trigger_Disabled then
This.CR2.JEXTEN := External_Trigger'Enum_Rep (Trigger.Enabler);
This.CR2.JEXTSEL := External_Events_Injected_Group'Enum_Rep (Trigger.Event);
else
This.CR2.JEXTEN := 0;
This.CR2.JEXTSEL := 0;
end if;
for Rank in Conversions'Range loop
declare
Conversion : Injected_Channel_Conversion renames
Conversions (Rank);
begin
Configure_Injected_Channel
(This,
Conversion.Channel,
Rank,
Conversion.Sample_Time,
Conversion.Offset);
-- We check the VBat first because that channel is also used for
-- the temperature sensor channel on some MCUs, in which case the
-- VBat conversion is the only one done. This order reflects that
-- hardware behavior.
if VBat_Conversion (This, Conversion.Channel) then
Enable_VBat_Connection;
elsif VRef_TemperatureSensor_Conversion (This, Conversion.Channel)
then
Enable_VRef_TemperatureSensor_Connection;
end if;
end;
end loop;
This.JSQR.JL := UInt2 (Conversions'Length - 1); -- biased rep
end Configure_Injected_Conversions;
----------------------------
-- Enable_VBat_Connection --
----------------------------
procedure Enable_VBat_Connection is
begin
C_ADC_Periph.CCR.VBATE := True;
end Enable_VBat_Connection;
------------------
-- VBat_Enabled --
------------------
function VBat_Enabled return Boolean is
(C_ADC_Periph.CCR.VBATE);
----------------------------------------------
-- Enable_VRef_TemperatureSensor_Connection --
----------------------------------------------
procedure Enable_VRef_TemperatureSensor_Connection is
begin
C_ADC_Periph.CCR.TSVREFE := True;
delay until Clock + Temperature_Sensor_Stabilization;
end Enable_VRef_TemperatureSensor_Connection;
--------------------------------------
-- VRef_TemperatureSensor_Connected --
--------------------------------------
function VRef_TemperatureSensor_Enabled return Boolean is
(C_ADC_Periph.CCR.TSVREFE);
----------------------------------
-- Regular_Conversions_Expected --
----------------------------------
function Regular_Conversions_Expected (This : Analog_To_Digital_Converter)
return Natural is
(Natural (This.SQR1.L) + 1);
-----------------------------------
-- Injected_Conversions_Expected --
-----------------------------------
function Injected_Conversions_Expected (This : Analog_To_Digital_Converter)
return Natural is
(Natural (This.JSQR.JL) + 1);
-----------------------
-- Scan_Mode_Enabled --
-----------------------
function Scan_Mode_Enabled (This : Analog_To_Digital_Converter)
return Boolean
is (This.CR1.SCAN);
---------------------------
-- EOC_Selection_Enabled --
---------------------------
function EOC_Selection_Enabled (This : Analog_To_Digital_Converter)
return Boolean
is (This.CR2.EOCS);
-------------------------------
-- Configure_Regular_Channel --
-------------------------------
procedure Configure_Regular_Channel
(This : in out Analog_To_Digital_Converter;
Channel : Analog_Input_Channel;
Rank : Regular_Channel_Rank;
Sample_Time : Channel_Sampling_Times)
is
begin
Set_Sampling_Time (This, Channel, Sample_Time);
Set_Sequence_Position (This, Channel, Rank);
end Configure_Regular_Channel;
--------------------------------
-- Configure_Injected_Channel --
--------------------------------
procedure Configure_Injected_Channel
(This : in out Analog_To_Digital_Converter;
Channel : Analog_Input_Channel;
Rank : Injected_Channel_Rank;
Sample_Time : Channel_Sampling_Times;
Offset : Injected_Data_Offset)
is
begin
Set_Sampling_Time (This, Channel, Sample_Time);
Set_Injected_Channel_Sequence_Position (This, Channel, Rank);
Set_Injected_Channel_Offset (This, Rank, Offset);
end Configure_Injected_Channel;
----------------------
-- Start_Conversion --
----------------------
procedure Start_Conversion (This : in out Analog_To_Digital_Converter) is
begin
if External_Trigger'Val (This.CR2.EXTEN) /= Trigger_Disabled then
return;
end if;
if Multi_ADC_Mode_Selections'Val (C_ADC_Periph.CCR.MULT) = Independent
or else This'Address = STM32_SVD.ADC1_Base
then
This.CR2.SWSTART := True;
end if;
end Start_Conversion;
------------------------
-- Conversion_Started --
------------------------
function Conversion_Started (This : Analog_To_Digital_Converter)
return Boolean
is
(This.CR2.SWSTART);
-------------------------------
-- Start_Injected_Conversion --
-------------------------------
procedure Start_Injected_Conversion
(This : in out Analog_To_Digital_Converter)
is
begin
This.CR2.JSWSTART := True;
end Start_Injected_Conversion;
---------------------------------
-- Injected_Conversion_Started --
---------------------------------
function Injected_Conversion_Started (This : Analog_To_Digital_Converter)
return Boolean
is
(This.CR2.JSWSTART);
------------------------------
-- Watchdog_Enable_Channels --
------------------------------
procedure Watchdog_Enable_Channels
(This : in out Analog_To_Digital_Converter;
Mode : Multiple_Channels_Watchdog;
Low : Watchdog_Threshold;
High : Watchdog_Threshold)
is
begin
This.HTR.HT := High;
This.LTR.LT := Low;
-- see RM 13.3.7, pg 391, table 66
case Mode is
when Watchdog_All_Regular_Channels =>
This.CR1.AWDEN := True;
when Watchdog_All_Injected_Channels =>
This.CR1.JAWDEN := True;
when Watchdog_All_Both_Kinds =>
This.CR1.AWDEN := True;
This.CR1.JAWDEN := True;
end case;
end Watchdog_Enable_Channels;
-----------------------------
-- Watchdog_Enable_Channel --
-----------------------------
procedure Watchdog_Enable_Channel
(This : in out Analog_To_Digital_Converter;
Mode : Single_Channel_Watchdog;
Channel : Analog_Input_Channel;
Low : Watchdog_Threshold;
High : Watchdog_Threshold)
is
begin
This.HTR.HT := High;
This.LTR.LT := Low;
-- Set then channel
This.CR1.AWDCH := Channel;
-- Enable single channel mode
This.CR1.AWDSGL := True;
case Mode is
when Watchdog_Single_Regular_Channel =>
This.CR1.AWDEN := True;
when Watchdog_Single_Injected_Channel =>
This.CR1.JAWDEN := True;
when Watchdog_Single_Both_Kinds =>
This.CR1.AWDEN := True;
This.CR1.JAWDEN := True;
end case;
end Watchdog_Enable_Channel;
----------------------
-- Watchdog_Disable --
----------------------
procedure Watchdog_Disable (This : in out Analog_To_Digital_Converter) is
begin
This.CR1.AWDEN := False;
This.CR1.JAWDEN := False;
-- clearing the single-channel bit (AWGSDL) is not required to disable,
-- per the RM table 66, section 13.3.7, pg 391, but seems cleanest
This.CR1.AWDSGL := False;
end Watchdog_Disable;
----------------------
-- Watchdog_Enabled --
----------------------
function Watchdog_Enabled (This : Analog_To_Digital_Converter)
return Boolean
is
(This.CR1.AWDEN or This.CR1.JAWDEN);
-- per the RM table 66, section 13.3.7, pg 391
-------------------------------
-- Enable_Discontinuous_Mode --
-------------------------------
procedure Enable_Discontinuous_Mode
(This : in out Analog_To_Digital_Converter;
Regular : Boolean; -- if False, enabling for Injected channels
Count : Discontinuous_Mode_Channel_Count)
is
begin
if Regular then
This.CR1.JDISCEN := False;
This.CR1.DISCEN := True;
else -- Injected
This.CR1.DISCEN := False;
This.CR1.JDISCEN := True;
end if;
This.CR1.DISCNUM := UInt3 (Count - 1); -- biased
end Enable_Discontinuous_Mode;
----------------------------------------
-- Disable_Discontinuous_Mode_Regular --
---------------------------------------
procedure Disable_Discontinuous_Mode_Regular
(This : in out Analog_To_Digital_Converter)
is
begin
This.CR1.DISCEN := False;
end Disable_Discontinuous_Mode_Regular;
-----------------------------------------
-- Disable_Discontinuous_Mode_Injected --
-----------------------------------------
procedure Disable_Discontinuous_Mode_Injected
(This : in out Analog_To_Digital_Converter)
is
begin
This.CR1.JDISCEN := False;
end Disable_Discontinuous_Mode_Injected;
----------------------------------------
-- Discontinuous_Mode_Regular_Enabled --
----------------------------------------
function Discontinuous_Mode_Regular_Enabled
(This : Analog_To_Digital_Converter)
return Boolean
is (This.CR1.DISCEN);
-----------------------------------------
-- Discontinuous_Mode_Injected_Enabled --
-----------------------------------------
function Discontinuous_Mode_Injected_Enabled
(This : Analog_To_Digital_Converter)
return Boolean
is (This.CR1.JDISCEN);
---------------------------
-- AutoInjection_Enabled --
---------------------------
function AutoInjection_Enabled
(This : Analog_To_Digital_Converter)
return Boolean
is (This.CR1.JAUTO);
----------------
-- Enable_DMA --
----------------
procedure Enable_DMA (This : in out Analog_To_Digital_Converter) is
begin
This.CR2.DMA := True;
end Enable_DMA;
-----------------
-- Disable_DMA --
-----------------
procedure Disable_DMA (This : in out Analog_To_Digital_Converter) is
begin
This.CR2.DMA := False;
end Disable_DMA;
-----------------
-- DMA_Enabled --
-----------------
function DMA_Enabled (This : Analog_To_Digital_Converter) return Boolean is
(This.CR2.DMA);
------------------------------------
-- Enable_DMA_After_Last_Transfer --
------------------------------------
procedure Enable_DMA_After_Last_Transfer
(This : in out Analog_To_Digital_Converter)
is
begin
This.CR2.DDS := True;
end Enable_DMA_After_Last_Transfer;
-------------------------------------
-- Disable_DMA_After_Last_Transfer --
-------------------------------------
procedure Disable_DMA_After_Last_Transfer
(This : in out Analog_To_Digital_Converter)
is
begin
This.CR2.DDS := False;
end Disable_DMA_After_Last_Transfer;
-------------------------------------
-- DMA_Enabled_After_Last_Transfer --
-------------------------------------
function DMA_Enabled_After_Last_Transfer
(This : Analog_To_Digital_Converter)
return Boolean
is (This.CR2.DDS);
------------------------------------------
-- Multi_Enable_DMA_After_Last_Transfer --
------------------------------------------
procedure Multi_Enable_DMA_After_Last_Transfer is
begin
C_ADC_Periph.CCR.DMA := 1;
end Multi_Enable_DMA_After_Last_Transfer;
-------------------------------------------
-- Multi_Disable_DMA_After_Last_Transfer --
-------------------------------------------
procedure Multi_Disable_DMA_After_Last_Transfer is
begin
C_ADC_Periph.CCR.DMA := 0;
end Multi_Disable_DMA_After_Last_Transfer;
-------------------------------------------
-- Multi_DMA_Enabled_After_Last_Transfer --
-------------------------------------------
function Multi_DMA_Enabled_After_Last_Transfer return Boolean is
(C_ADC_Periph.CCR.DMA = 1);
---------------------
-- Poll_For_Status --
---------------------
procedure Poll_For_Status
(This : in out Analog_To_Digital_Converter;
Flag : ADC_Status_Flag;
Success : out Boolean;
Timeout : Time_Span := Time_Span_Last)
is
Deadline : constant Time := Clock + Timeout;
begin
Success := False;
while Clock < Deadline loop
if Status (This, Flag) then
Success := True;
exit;
end if;
end loop;
end Poll_For_Status;
------------
-- Status --
------------
function Status
(This : Analog_To_Digital_Converter;
Flag : ADC_Status_Flag)
return Boolean
is
begin
case Flag is
when Overrun =>
return This.SR.OVR;
when Regular_Channel_Conversion_Started =>
return This.SR.STRT;
when Injected_Channel_Conversion_Started =>
return This.SR.JSTRT;
when Injected_Channel_Conversion_Complete =>
return This.SR.JEOC;
when Regular_Channel_Conversion_Complete =>
return This.SR.EOC;
when Analog_Watchdog_Event_Occurred =>
return This.SR.AWD;
end case;
end Status;
------------------
-- Clear_Status --
------------------
procedure Clear_Status
(This : in out Analog_To_Digital_Converter;
Flag : ADC_Status_Flag)
is
begin
case Flag is
when Overrun =>
This.SR.OVR := False;
when Regular_Channel_Conversion_Started =>
This.SR.STRT := False;
when Injected_Channel_Conversion_Started =>
This.SR.JSTRT := False;
when Injected_Channel_Conversion_Complete =>
This.SR.JEOC := False;
when Regular_Channel_Conversion_Complete =>
This.SR.EOC := False;
when Analog_Watchdog_Event_Occurred =>
This.SR.AWD := False;
end case;
end Clear_Status;
-----------------------
-- Enable_Interrupts --
-----------------------
procedure Enable_Interrupts
(This : in out Analog_To_Digital_Converter;
Source : ADC_Interrupts)
is
begin
case Source is
when Overrun =>
This.CR1.OVRIE := True;
when Injected_Channel_Conversion_Complete =>
This.CR1.JEOCIE := True;
when Regular_Channel_Conversion_Complete =>
This.CR1.EOCIE := True;
when Analog_Watchdog_Event =>
This.CR1.AWDIE := True;
end case;
end Enable_Interrupts;
-----------------------
-- Interrupt_Enabled --
-----------------------
function Interrupt_Enabled
(This : Analog_To_Digital_Converter;
Source : ADC_Interrupts)
return Boolean
is
begin
case Source is
when Overrun =>
return This.CR1.OVRIE;
when Injected_Channel_Conversion_Complete =>
return This.CR1.JEOCIE;
when Regular_Channel_Conversion_Complete =>
return This.CR1.EOCIE;
when Analog_Watchdog_Event =>
return This.CR1.AWDIE;
end case;
end Interrupt_Enabled;
------------------------
-- Disable_Interrupts --
------------------------
procedure Disable_Interrupts
(This : in out Analog_To_Digital_Converter;
Source : ADC_Interrupts)
is
begin
case Source is
when Overrun =>
This.CR1.OVRIE := False;
when Injected_Channel_Conversion_Complete =>
This.CR1.JEOCIE := False;
when Regular_Channel_Conversion_Complete =>
This.CR1.EOCIE := False;
when Analog_Watchdog_Event =>
This.CR1.AWDIE := False;
end case;
end Disable_Interrupts;
-----------------------------
-- Clear_Interrupt_Pending --
-----------------------------
procedure Clear_Interrupt_Pending
(This : in out Analog_To_Digital_Converter;
Source : ADC_Interrupts)
is
begin
case Source is
when Overrun =>
This.SR.OVR := False;
when Injected_Channel_Conversion_Complete =>
This.SR.JEOC := False;
when Regular_Channel_Conversion_Complete =>
This.SR.EOC := False;
when Analog_Watchdog_Event =>
This.SR.AWD := False;
end case;
end Clear_Interrupt_Pending;
---------------------------
-- Set_Sequence_Position --
---------------------------
procedure Set_Sequence_Position
(This : in out Analog_To_Digital_Converter;
Channel : Analog_Input_Channel;
Rank : Regular_Channel_Rank)
is
begin
case Rank is
when 1 .. 6 =>
This.SQR3.SQ.Arr (Integer (Rank)) := Channel;
when 7 .. 12 =>
This.SQR2.SQ.Arr (Integer (Rank)) := Channel;
when 13 .. 16 =>
This.SQR1.SQ.Arr (Integer (Rank)) := Channel;
end case;
end Set_Sequence_Position;
--------------------------------------------
-- Set_Injected_Channel_Sequence_Position --
--------------------------------------------
procedure Set_Injected_Channel_Sequence_Position
(This : in out Analog_To_Digital_Converter;
Channel : Analog_Input_Channel;
Rank : Injected_Channel_Rank)
is
begin
This.JSQR.JSQ.Arr (Integer (Rank)) := Channel;
end Set_Injected_Channel_Sequence_Position;
-----------------------
-- Set_Sampling_Time --
-----------------------
procedure Set_Sampling_Time
(This : in out Analog_To_Digital_Converter;
Channel : Analog_Input_Channel;
Sample_Time : Channel_Sampling_Times)
is
begin
if Channel > 9 then
This.SMPR1.SMP.Arr (Natural (Channel)) :=
Channel_Sampling_Times'Enum_Rep (Sample_Time);
else
This.SMPR2.SMP.Arr (Natural (Channel)) :=
Channel_Sampling_Times'Enum_Rep (Sample_Time);
end if;
end Set_Sampling_Time;
---------------------------------
-- Set_Injected_Channel_Offset --
---------------------------------
procedure Set_Injected_Channel_Offset
(This : in out Analog_To_Digital_Converter;
Rank : Injected_Channel_Rank;
Offset : Injected_Data_Offset)
is
begin
case Rank is
when 1 => This.JOFR1.JOFFSET1 := Offset;
when 2 => This.JOFR2.JOFFSET2 := Offset;
when 3 => This.JOFR3.JOFFSET3 := Offset;
when 4 => This.JOFR4.JOFFSET4 := Offset;
end case;
end Set_Injected_Channel_Offset;
end STM32.ADC;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
local url = require("url")
local json = require("json")
name = "Arquivo"
type = "archive"
function start()
set_rate_limit(5)
end
function vertical(ctx, domain)
local resp, err = request(ctx, {['url']=build_url(domain)})
if (err ~= nil and err ~= "") then
log(ctx, "vertical request to service failed: " .. err)
return
end
local d = json.decode(resp)
if (d == nil or #(d.response_items) == 0) then
return
end
for _, r in pairs(d.response_items) do
send_names(ctx, r.originalURL)
end
end
function build_url(domain)
local params = {
['q']=domain,
['offset']="0",
['maxItems']="500",
['siteSearch']="",
['type']="",
['collection']="",
}
return "https://arquivo.pt/textsearch?" .. url.build_query_string(params)
end
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
------------------------------------------------------------------------------
with System; use System;
with AGATE.Traces;
with AGATE.Scheduler.Context_Switch;
with AGATE.Arch; use AGATE.Arch;
with AGATE.Timer;
with AGATE.Stack_Canaries_Enable;
package body AGATE.Scheduler is
Alarm_List : Task_Object_Access := null;
Idle_Stack : aliased Task_Stack := (1 .. 512 => 0);
Idle_Sec_Stack : aliased Task_Sec_Stack := (1 .. 0 => 0);
Idle_Heap : aliased Task_Heap := (1 .. 0 => 0);
Idle_Task : aliased Task_Object
(Proc => AGATE.Arch.Idle_Procedure'Access,
Base_Prio => -1,
Stack => Idle_Stack'Access,
Sec_Stack => Idle_Sec_Stack'Access,
Heap => Idle_Heap'Access);
function In_Ready_Tasks (ID : Task_ID) return Boolean;
procedure Extract (ID : Task_ID);
procedure Insert (ID : Task_ID)
with Pre => not In_Ready_Tasks (ID);
procedure Insert_Alarm
(T : Task_Object_Access);
procedure Update_Alarm_Time;
--------------
-- Register --
--------------
procedure Register
(ID : Task_ID;
Name : String)
is
T : constant Task_Object_Access := Task_Object_Access (ID);
begin
T.Status := Ready;
T.Name (Task_Name'First .. Task_Name'First + Name'Length - 1) := Name;
T.Current_Prio := T.Base_Prio;
Initialize_Task_Context (ID);
if AGATE.Stack_Canaries_Enable.Enabled then
Set_Stack_Canary (ID);
end if;
Insert (Task_ID (T));
ID.All_Task_Next := All_Tasks_List;
All_Tasks_List := Task_Object_Access (ID);
Traces.Register (Task_ID (T), T.Name);
end Register;
-----------
-- Start --
-----------
procedure Start is
begin
if Ready_Tasks = null then
raise Program_Error with "No task to run";
end if;
Register (Idle_Task'Access, "idle");
Running_Task := Ready_Tasks;
Jump_In_Task (Task_ID (Running_Task));
end Start;
------------------
-- Current_Task --
------------------
function Current_Task
return Task_ID
is (Task_ID (Running_Task));
--------------------------
-- Current_Task_Context --
--------------------------
function Current_Task_Context
return System.Address
is
begin
return Running_Task.Context (Running_Task.Context'First)'Address;
end Current_Task_Context;
-----------------
-- Task_To_Run --
-----------------
function Task_To_Run
return Task_ID
is (Task_ID (Ready_Tasks));
--------------------
-- In_Ready_Tasks --
--------------------
function In_Ready_Tasks
(ID : Task_ID)
return Boolean
is
T : Task_Object_Access := Ready_Tasks;
begin
while T /= null and then Task_ID (T) /= ID loop
T := T.Next;
end loop;
return Task_ID (T) = ID;
end In_Ready_Tasks;
----------------------
-- Print_Read_Tasks --
----------------------
procedure Print_Ready_Tasks
is
T : Task_Object_Access := Ready_Tasks;
begin
-- Ada.Text_IO.Put_Line ("Ready tasks:");
while T /= null loop
-- Ada.Text_IO.Put_Line (" - " & Image (Task_ID (T)));
T := T.Next;
end loop;
end Print_Ready_Tasks;
-------------
-- Extract --
-------------
procedure Extract
(ID : Task_ID)
is
Prev, Curr : Task_Object_Access;
begin
if Task_ID (Ready_Tasks) = ID then
-- Extract head
Ready_Tasks := Ready_Tasks.Next;
ID.Next := null;
else
-- Extract from inside the list
Prev := null;
Curr := Ready_Tasks;
while Curr /= null and then Task_ID (Curr) /= ID loop
Prev := Curr;
Curr := Curr.Next;
end loop;
if Task_ID (Curr) = ID then
Prev.Next := Curr.Next;
ID.Next := null;
end if;
end if;
end Extract;
------------
-- Insert --
------------
procedure Insert
(ID : Task_ID)
is
Acc : constant Task_Object_Access := Task_Object_Access (ID);
Cur : Task_Object_Access := Ready_Tasks;
Prev : Task_Object_Access := null;
begin
Acc.Next := null;
while Cur /= null and then Cur.Current_Prio >= Acc.Current_Prio loop
Prev := Cur;
Cur := Cur.Next;
end loop;
Acc.Next := Cur;
if Prev = null then
-- Head insertion
Ready_Tasks := Acc;
else
Prev.Next := Acc;
end if;
end Insert;
-----------
-- Yield --
-----------
procedure Yield
is
begin
Extract (Current_Task);
Insert (Current_Task);
Current_Task.Status := Ready;
if Context_Switch_Needed then
Context_Switch.Switch;
end if;
end Yield;
------------
-- Resume --
------------
procedure Resume
(ID : Task_ID)
is
begin
Task_Object_Access (ID).Status := Ready;
Insert (ID);
Traces.Resume (ID);
if Context_Switch_Needed then
Context_Switch.Switch;
end if;
end Resume;
-------------
-- Suspend --
-------------
procedure Suspend
(Reason : Suspend_Reason)
is
begin
Extract (Current_Task);
Current_Task.Status := (case Reason is
when Alarm => Suspended_Alarm,
when Semaphore => Suspended_Semaphore,
when Mutex => Suspended_Mutex);
Traces.Suspend (Current_Task);
end Suspend;
-----------
-- Fault --
-----------
procedure Fault (ID : Task_ID) is
begin
Extract (ID);
ID.Status := Fault;
Traces.Fault (ID);
end Fault;
-----------
-- Fault --
-----------
procedure Fault is
begin
Fault (Current_Task);
end Fault;
---------------------
-- Change_Priority --
---------------------
procedure Change_Priority
(New_Prio : Task_Priority)
is
T : constant Task_ID := Current_Task;
begin
if New_Prio < T.Base_Prio then
raise Program_Error with
"Cannot set priority below the task base priority";
end if;
Traces.Change_Priority (T, New_Prio);
if New_Prio >= T.Current_Prio then
-- The current task already have the highest priority of the ready
-- task, by the properties of the FIFO within priorities scheduling.
-- So the current task position in the ready tasks list won't change,
-- We don't have to re-insert it.
T.Current_Prio := New_Prio;
else
Extract (T);
T.Current_Prio := New_Prio;
Insert (T);
end if;
end Change_Priority;
-----------------
-- Delay_Until --
-----------------
procedure Delay_Until
(Wake_Up_Time : Time)
is
T : constant Task_Object_Access := Task_Object_Access (Current_Task);
Now : constant Time := AGATE.Timer.Clock;
begin
if Wake_Up_Time <= Now then
Scheduler.Yield;
else
Scheduler.Suspend (Alarm);
T.Alarm_Time := Wake_Up_Time;
Insert_Alarm (T);
if Context_Switch_Needed then
Context_Switch.Switch;
end if;
end if;
end Delay_Until;
------------------
-- Insert_Alarm --
------------------
procedure Insert_Alarm
(T : Task_Object_Access)
is
Cur : Task_Object_Access := Alarm_List;
Prev : Task_Object_Access := null;
begin
while Cur /= null and then Cur.Alarm_Time < T.Alarm_Time loop
Prev := Cur;
Cur := Cur.Next;
end loop;
if Prev = null then
-- Head insertion
T.Next := Alarm_List;
Alarm_List := T;
else
Prev.Next := T;
T.Next := Cur;
end if;
Update_Alarm_Time;
end Insert_Alarm;
---------------------------
-- Wakeup_Expired_Alarms --
---------------------------
procedure Wakeup_Expired_Alarms
is
Now : constant Time := AGATE.Timer.Clock;
T : Task_Object_Access := Alarm_List;
begin
while Alarm_List /= null and then Alarm_List.Alarm_Time <= Now loop
T := Alarm_List;
Alarm_List := T.Next;
Scheduler.Resume (Task_ID (T));
end loop;
Update_Alarm_Time;
end Wakeup_Expired_Alarms;
-----------------------
-- Update_Alarm_Time --
-----------------------
procedure Update_Alarm_Time
is
begin
if Alarm_List = null then
AGATE.Timer.Set_Alarm (Time'Last);
else
AGATE.Timer.Set_Alarm (Alarm_List.Alarm_Time);
end if;
end Update_Alarm_Time;
---------------------------
-- Context_Switch_Needed --
---------------------------
function Context_Switch_Needed
return Boolean
is (Task_To_Run /= Current_Task);
-----------------------
-- Do_Context_Switch --
-----------------------
procedure Do_Context_Switch renames AGATE.Scheduler.Context_Switch.Switch;
end AGATE.Scheduler;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
package Interfaces.C is
pragma Pure(C);
-- Declarations based on C's <limits.h>
CHAR_BIT : constant := implementation-defined; -- typically 8
SCHAR_MIN : constant := implementation-defined; -- typically -128
SCHAR_MAX : constant := implementation-defined; -- typically 127
UCHAR_MAX : constant := implementation-defined; -- typically 255
-- Signed and Unsigned Integers
type int is range implementation-defined .. implementation-defined;
type short is range implementation-defined .. implementation-defined;
type long is range implementation-defined .. implementation-defined;
type signed_char is range SCHAR_MIN .. SCHAR_MAX;
for signed_char'Size use CHAR_BIT;
type unsigned is mod implementation-defined;
type unsigned_short is mod implementation-defined;
type unsigned_long is mod implementation-defined;
type unsigned_char is mod (UCHAR_MAX+1);
for unsigned_char'Size use CHAR_BIT;
subtype plain_char is unsigned_char; -- implementation-defined;
type ptrdiff_t is range implementation-defined .. implementation-defined;
type size_t is mod implementation-defined;
-- Floating Point
type C_float is digits implementation-defined;
type double is digits implementation-defined;
type long_double is digits implementation-defined;
-- Characters and Strings
type char is ('x'); -- implementation-defined character type;
nul : constant char := implementation-defined;
function To_C (Item : in Character) return char;
function To_Ada (Item : in char) return Character;
type char_array is array (size_t range <>) of aliased char;
pragma Pack (char_array);
for char_array'Component_Size use CHAR_BIT;
function Is_Nul_Terminated (Item : in char_array) return Boolean;
function To_C (Item : in String;
Append_Nul : in Boolean := True)
return char_array;
function To_Ada (Item : in char_array;
Trim_Nul : in Boolean := True)
return String;
procedure To_C (Item : in String;
Target : out char_array;
Count : out size_t;
Append_Nul : in Boolean := True);
procedure To_Ada (Item : in char_array;
Target : out String;
Count : out Natural;
Trim_Nul : in Boolean := True);
-- Wide Character and Wide String
type wchar_t is (' '); -- implementation-defined char type;
wide_nul : constant wchar_t := implementation-defined;
function To_C (Item : in Wide_Character) return wchar_t;
function To_Ada (Item : in wchar_t ) return Wide_Character;
type wchar_array is array (size_t range <>) of aliased wchar_t;
pragma Pack (wchar_array);
function Is_Nul_Terminated (Item : in wchar_array) return Boolean;
function To_C (Item : in Wide_String;
Append_Nul : in Boolean := True)
return wchar_array;
function To_Ada (Item : in wchar_array;
Trim_Nul : in Boolean := True)
return Wide_String;
procedure To_C (Item : in Wide_String;
Target : out wchar_array;
Count : out size_t;
Append_Nul : in Boolean := True);
procedure To_Ada (Item : in wchar_array;
Target : out Wide_String;
Count : out Natural;
Trim_Nul : in Boolean := True);
-- ISO/IEC 10646:2003 compatible types defined by ISO/IEC TR 19769:2004.
type char16_t is ('x'); -- implementation-defined character type
char16_nul : constant char16_t := implementation-defined;
function To_C (Item : in Wide_Character) return char16_t;
function To_Ada (Item : in char16_t) return Wide_Character;
type char16_array is array (size_t range <>) of aliased char16_t;
pragma Pack (char16_array);
function Is_Nul_Terminated (Item : in char16_array) return Boolean;
function To_C (Item : in Wide_String;
Append_Nul : in Boolean := True)
return char16_array;
function To_Ada (Item : in char16_array;
Trim_Nul : in Boolean := True)
return Wide_String;
procedure To_C (Item : in Wide_String;
Target : out char16_array;
Count : out size_t;
Append_Nul : in Boolean := True);
procedure To_Ada (Item : in char16_array;
Target : out Wide_String;
Count : out Natural;
Trim_Nul : in Boolean := True);
type char32_t is ('x'); -- implementation-defined character type
char32_nul : constant char32_t := implementation-defined;
function To_C (Item : in Wide_Wide_Character) return char32_t;
function To_Ada (Item : in char32_t) return Wide_Wide_Character;
type char32_array is array (size_t range <>) of aliased char32_t;
pragma Pack (char32_array);
function Is_Nul_Terminated (Item : in char32_array) return Boolean;
function To_C (Item : in Wide_Wide_String;
Append_Nul : in Boolean := True)
return char32_array;
function To_Ada (Item : in char32_array;
Trim_Nul : in Boolean := True)
return Wide_Wide_String;
procedure To_C (Item : in Wide_Wide_String;
Target : out char32_array;
Count : out size_t;
Append_Nul : in Boolean := True);
procedure To_Ada (Item : in char32_array;
Target : out Wide_Wide_String;
Count : out Natural;
Trim_Nul : in Boolean := True);
Terminator_Error : exception;
end Interfaces.C;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- The following package implements the facilities to compile, bind and/or
-- link a set of Ada and non Ada sources, specified in Project Files.
package Makegpr is
procedure Gprmake;
-- The driver of gprmake
end Makegpr;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- SOFTWARE.
with Ada.Containers; use Ada.Containers;
with Ada.Containers.Hashed_Maps;
with Interfaces; use Interfaces;
with DG_Types; use DG_Types;
package Memory is
Words_Per_Page : constant Natural := 1024;
Ring_7_Page_0 : constant Natural := 16#001c_0000#;
-- Physical stuff that has to exist...
Mem_Size_Words : constant Integer := 8_388_608;
-- MemSizeLCPID is the code returned by the LCPID to indicate the size of RAM in half megabytes
Mem_Size_LCPID : constant Dword_T := 63;
-- MemSizeNCLID is the code returned by NCLID to indicate size of RAM in 32Kb increments
Mem_Size_NCLID : constant Word_T := Word_T(((Mem_Size_Words * 2) / (32 * 1024)) - 1);
type Memory_Region is array (Natural range <>) of Word_T;
type Page_T is array (0 .. Words_Per_Page - 1) of Word_T;
type Page_Arr_T is array (Natural range <>) of Page_T;
-- Page 0 special locations for stacks
WSFH_Loc : constant Phys_Addr_T := 8#14#;
WFP_Loc : constant Phys_Addr_T := 8#20#;
WSP_Loc : constant Phys_Addr_T := 8#22#;
WSL_Loc : constant Phys_Addr_T := 8#24#;
WSB_Loc : constant Phys_Addr_T := 8#26#;
NSP_Loc : constant Phys_Addr_T := 8#40#;
NFP_Loc : constant Phys_Addr_T := 8#41#;
NSL_Loc : constant Phys_Addr_T := 8#42#;
NSF_Loc : constant Phys_Addr_T := 8#43#;
-- Wide Stack Fault codes
WSF_Overflow : constant Dword_T := 0;
WSF_Pending : constant Dword_T := 1;
WSF_Too_Many_Args : constant Dword_T := 2;
WSF_Underflow : constant Dword_T := 3;
WSF_Return_Overflow : constant Dword_T := 4;
function NaturalHash (K : Natural) return Hash_Type is (Hash_Type (K));
package VRAM_Map is new Ada.Containers.Hashed_Maps (
Key_Type => Natural,
Hash => NaturalHash,
Equivalent_Keys => "=",
Element_Type => Page_T );
protected RAM is
procedure Init (Debug_Logging : in Boolean);
procedure Map_Page (Page : in Natural; Is_Shared : in Boolean);
function Page_Mapped (Page : in Natural) return Boolean;
function Get_Last_Unshared_Page return Dword_T;
function Get_First_Shared_Page return Dword_T;
function Get_Num_Shared_Pages return Dword_T;
function Get_Num_Unshared_Pages return Dword_T;
procedure Map_Range (Start_Addr : in Phys_Addr_T;
Region : in Memory_Region;
Is_Shared : in Boolean);
procedure Map_Shared_Pages (Start_Addr : in Phys_Addr_T; Pages : in Page_Arr_T);
-- function Address_Mapped (Addr : in Phys_Addr_T) return Boolean;
function Read_Word (Word_Addr : in Phys_Addr_T) return Word_T with Inline;
function Read_Dword (Word_Addr : in Phys_Addr_T) return Dword_T;
function Read_Qword (Word_Addr : in Phys_Addr_T) return Qword_T;
procedure Write_Word (Word_Addr : in Phys_Addr_T; Datum : Word_T);
procedure Write_Dword (Word_Addr : in Phys_Addr_T; Datum : Dword_T);
procedure Write_Qword (Word_Addr : in Phys_Addr_T; Datum : Qword_T);
function Read_Byte (Word_Addr : in Phys_Addr_T; Low_Byte : in Boolean) return Byte_T;
function Read_Byte_BA (BA : in Dword_T) return Byte_T;
procedure Write_Byte (Word_Addr : in Phys_Addr_T; Low_Byte : in Boolean; Byt : in Byte_T);
procedure Write_Byte_BA (BA : in Dword_T; Datum : in Byte_T);
procedure Copy_Byte_BA (Src, Dest : in Dword_T);
function Read_Byte_Eclipse_BA (Segment : in Phys_Addr_T; BA_16 : in Word_T) return Byte_T;
procedure Write_Byte_Eclipse_BA (Segment : in Phys_Addr_T; BA_16 : in Word_T; Datum : in Byte_T);
function Read_Bytes_BA (BA : in Dword_T; Num : in Natural) return Byte_Arr_T;
-- specific support for VS/Emua...
function Read_String_BA (BA : in Dword_T; Keep_NUL : in Boolean) return String;
procedure Write_String_BA (BA : in Dword_T; Str : in String);
private
VRAM : VRAM_Map.Map;
Logging : Boolean;
First_Shared_Page,
Last_Unshared_Page,
Num_Unshared_Pages,
Num_Shared_Pages : Natural;
end RAM;
protected Narrow_Stack is
procedure Push (Segment : in Phys_Addr_T; Datum : in Word_T);
function Pop (Segment : in Phys_Addr_T) return Word_T;
end Narrow_Stack;
Page_Already_Mapped,
Read_From_Unmapped_Page,
Write_To_Unmapped_Page : exception;
end Memory;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Libadalang.Analysis; use Libadalang.Analysis;
with Utils.Char_Vectors; use Utils.Char_Vectors;
with Utils.Command_Lines; use Utils.Command_Lines;
with Utils.Tools; use Utils.Tools;
with Pp.Scanner; use Pp;
package JSON_Gen.Actions is
type Json_Gen_Tool is new Tool_State with private;
procedure Format_Vector
(Cmd : Command_Line;
Input : Char_Vector;
Node : Ada_Node;
In_Range : Char_Subrange;
Output : out Char_Vector;
Out_Range : out Char_Subrange;
Messages : out Pp.Scanner.Source_Message_Vector);
private
overriding procedure Init (Tool : in out Json_Gen_Tool;
Cmd : in out Command_Line);
overriding procedure Per_File_Action
(Tool : in out Json_Gen_Tool;
Cmd : Command_Line;
File_Name : String;
Input : String;
BOM_Seen : Boolean;
Unit : Analysis_Unit);
overriding procedure Final (Tool : in out Json_Gen_Tool;
Cmd : Command_Line);
overriding procedure Tool_Help (Tool : Json_Gen_Tool);
type Json_Gen_Tool is new Tool_State with record
Ignored_Out_Range : Char_Subrange;
Ignored_Messages : Scanner.Source_Message_Vector;
end record;
-- For Debugging:
procedure Dump
(Tool : in out Json_Gen_Tool;
Message : String := "");
end JSON_Gen.Actions;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Util.Log.Loggers;
with ADO.Objects;
with ASF.Streams;
with AWA.Storages.Services;
with AWA.Storages.Modules;
package body AWA.Storages.Servlets is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Storages.Servlets");
-- ------------------------------
-- Called by the servlet container to indicate to a servlet that the servlet
-- is being placed into service.
-- ------------------------------
overriding
procedure Initialize (Server : in out Storage_Servlet;
Context : in ASF.Servlets.Servlet_Registry'Class) is
begin
null;
end Initialize;
-- ------------------------------
-- Called by the server (via the service method) to allow a servlet to handle
-- a GET request.
--
-- Overriding this method to support a GET request also automatically supports
-- an HTTP HEAD request. A HEAD request is a GET request that returns no body
-- in the response, only the request header fields.
--
-- When overriding this method, read the request data, write the response headers,
-- get the response's writer or output stream object, and finally, write the
-- response data. It's best to include content type and encoding.
-- When using a PrintWriter object to return the response, set the content type
-- before accessing the PrintWriter object.
--
-- The servlet container must write the headers before committing the response,
-- because in HTTP the headers must be sent before the response body.
--
-- Where possible, set the Content-Length header (with the
-- Response.Set_Content_Length method), to allow the servlet container
-- to use a persistent connection to return its response to the client,
-- improving performance. The content length is automatically set if the entire
-- response fits inside the response buffer.
--
-- When using HTTP 1.1 chunked encoding (which means that the response has a
-- Transfer-Encoding header), do not set the Content-Length header.
--
-- The GET method should be safe, that is, without any side effects for which
-- users are held responsible. For example, most form queries have no side effects.
-- If a client request is intended to change stored data, the request should use
-- some other HTTP method.
--
-- The GET method should also be idempotent, meaning that it can be safely repeated.
-- Sometimes making a method safe also makes it idempotent. For example, repeating
-- queries is both safe and idempotent, but buying a product online or modifying
-- data is neither safe nor idempotent.
--
-- If the request is incorrectly formatted, Do_Get returns an HTTP "Bad Request"
-- ------------------------------
overriding
procedure Do_Get (Server : in Storage_Servlet;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class) is
Data : ADO.Blob_Ref;
Mime : Ada.Strings.Unbounded.Unbounded_String;
Name : Ada.Strings.Unbounded.Unbounded_String;
Date : Ada.Calendar.Time;
begin
Storage_Servlet'Class (Server).Load (Request, Name, Mime, Date, Data);
if Data.Is_Null then
Log.Info ("Storage file {0} not found", Request.Get_Request_URI);
Response.Send_Error (ASF.Responses.SC_NOT_FOUND);
return;
end if;
-- Send the file.
Response.Set_Content_Type (Ada.Strings.Unbounded.To_String (Mime));
if Ada.Strings.Unbounded.Length (Name) > 0 then
Response.Add_Header ("Content-Disposition",
"attachment; filename=" & Ada.Strings.Unbounded.To_String (Name));
end if;
declare
Output : ASF.Streams.Print_Stream := Response.Get_Output_Stream;
begin
Output.Write (Data.Value.Data);
end;
exception
when ADO.Objects.NOT_FOUND | Constraint_Error =>
Log.Info ("Storage file {0} not found", Request.Get_Request_URI);
Response.Send_Error (ASF.Responses.SC_NOT_FOUND);
return;
end Do_Get;
-- ------------------------------
-- Load the data content that correspond to the GET request and get the name as well
-- as mime-type and date.
-- ------------------------------
procedure Load (Server : in Storage_Servlet;
Request : in out ASF.Requests.Request'Class;
Name : out Ada.Strings.Unbounded.Unbounded_String;
Mime : out Ada.Strings.Unbounded.Unbounded_String;
Date : out Ada.Calendar.Time;
Data : out ADO.Blob_Ref) is
pragma Unreferenced (Server);
Store : constant String := Request.Get_Path_Parameter (1);
Manager : constant Services.Storage_Service_Access := Storages.Modules.Get_Storage_Manager;
Id : ADO.Identifier;
begin
if Store'Length = 0 then
Log.Info ("Invalid storage URI: {0}", Store);
return;
end if;
-- Extract the storage identifier from the URI.
Id := ADO.Identifier'Value (Store);
Log.Info ("GET storage file {0}", Store);
Manager.Load (From => Id, Name => Name, Mime => Mime, Date => Date, Into => Data);
end Load;
end AWA.Storages.Servlets;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with impact.d3.Shape;
with impact.d3.triangle_Callback;
package impact.d3.Shape.concave
--
-- The impact.d3.Shape.concave class provides an interface for non-moving (static) concave shapes.
-- It has been implemented by the impact.d3.Shape.concave.static_plane, impact.d3.Shape.concave.triangle_mesh.bvh and impact.d3.Shape.concave.height_field_terrain.
--
is
type Item is abstract new impact.d3.Shape.item with private;
type View is access all Item'Class;
-- /// PHY_ScalarType enumerates possible scalar types.
-- /// See the impact.d3.striding_Mesh or impact.d3.Shape.concave.height_field_terrain for its use
-- typedef enum PHY_ScalarType {
-- PHY_FLOAT,
-- PHY_DOUBLE,
-- PHY_INTEGER,
-- PHY_SHORT,
-- PHY_FIXEDPOINT88,
-- PHY_UCHAR
-- } PHY_ScalarType;
--- Forge
--
procedure define (Self : in out Item);
overriding procedure destruct (Self : in out Item);
--- Attributes
--
overriding procedure setMargin (Self : in out Item; margin : in Real);
overriding function getMargin (Self : in Item) return Real;
procedure processAllTriangles (Self : in Item; callback : access impact.d3.triangle_Callback.Item'Class;
aabbMin, aabbMax : in math.Vector_3)
is abstract;
private
type Item is abstract new impact.d3.Shape.item with
record
m_collisionMargin : math.Real;
end record;
end impact.d3.Shape.concave;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Text_IO, Miller_Rabin;
procedure Nemesis is
type Number is range 0 .. 2**40-1; -- sufficiently large for the task
function Is_Prime(N: Number) return Boolean is
package MR is new Miller_Rabin(Number); use MR;
begin
return MR.Is_Prime(N) = Probably_Prime;
end Is_Prime;
begin
for P1 in Number(2) .. 61 loop
if Is_Prime(P1) then
for H3 in Number(1) .. P1 loop
declare
G: Number := H3 + P1;
P2, P3: Number;
begin
Inner:
for D in 1 .. G-1 loop
if ((H3+P1) * (P1-1)) mod D = 0 and then
(-(P1 * P1)) mod H3 = D mod H3
then
P2 := 1 + ((P1-1) * G / D);
P3 := 1 +(P1*P2/H3);
if Is_Prime(P2) and then Is_Prime(P3)
and then (P2*P3) mod (P1-1) = 1
then
Ada.Text_IO.Put_Line
( Number'Image(P1) & " *" & Number'Image(P2) & " *" &
Number'Image(P3) & " = " & Number'Image(P1*P2*P3) );
end if;
end if;
end loop Inner;
end;
end loop;
end if;
end loop;
end Nemesis;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with System; use System;
with GNAT.Altivec.Low_Level_Interface; use GNAT.Altivec.Low_Level_Interface;
with GNAT.Altivec.Low_Level_Vectors; use GNAT.Altivec.Low_Level_Vectors;
package body GNAT.Altivec.Conversions is
function To_Varray_unsigned_char is
new Ada.Unchecked_Conversion (Varray_signed_char,
Varray_unsigned_char);
function To_Varray_unsigned_char is
new Ada.Unchecked_Conversion (Varray_bool_char,
Varray_unsigned_char);
function To_Varray_unsigned_short is
new Ada.Unchecked_Conversion (Varray_signed_short,
Varray_unsigned_short);
function To_Varray_unsigned_short is
new Ada.Unchecked_Conversion (Varray_bool_short,
Varray_unsigned_short);
function To_Varray_unsigned_short is
new Ada.Unchecked_Conversion (Varray_pixel,
Varray_unsigned_short);
function To_Varray_unsigned_int is
new Ada.Unchecked_Conversion (Varray_signed_int,
Varray_unsigned_int);
function To_Varray_unsigned_int is
new Ada.Unchecked_Conversion (Varray_bool_int,
Varray_unsigned_int);
function To_Varray_unsigned_int is
new Ada.Unchecked_Conversion (Varray_float,
Varray_unsigned_int);
function To_Varray_signed_char is
new Ada.Unchecked_Conversion (Varray_unsigned_char,
Varray_signed_char);
function To_Varray_bool_char is
new Ada.Unchecked_Conversion (Varray_unsigned_char,
Varray_bool_char);
function To_Varray_signed_short is
new Ada.Unchecked_Conversion (Varray_unsigned_short,
Varray_signed_short);
function To_Varray_bool_short is
new Ada.Unchecked_Conversion (Varray_unsigned_short,
Varray_bool_short);
function To_Varray_pixel is
new Ada.Unchecked_Conversion (Varray_unsigned_short,
Varray_pixel);
function To_Varray_signed_int is
new Ada.Unchecked_Conversion (Varray_unsigned_int,
Varray_signed_int);
function To_Varray_bool_int is
new Ada.Unchecked_Conversion (Varray_unsigned_int,
Varray_bool_int);
function To_Varray_float is
new Ada.Unchecked_Conversion (Varray_unsigned_int,
Varray_float);
function To_VUC is new Ada.Unchecked_Conversion (VUC_View, VUC);
function To_VSC is new Ada.Unchecked_Conversion (VSC_View, VSC);
function To_VBC is new Ada.Unchecked_Conversion (VBC_View, VBC);
function To_VUS is new Ada.Unchecked_Conversion (VUS_View, VUS);
function To_VSS is new Ada.Unchecked_Conversion (VSS_View, VSS);
function To_VBS is new Ada.Unchecked_Conversion (VBS_View, VBS);
function To_VUI is new Ada.Unchecked_Conversion (VUI_View, VUI);
function To_VSI is new Ada.Unchecked_Conversion (VSI_View, VSI);
function To_VBI is new Ada.Unchecked_Conversion (VBI_View, VBI);
function To_VF is new Ada.Unchecked_Conversion (VF_View, VF);
function To_VP is new Ada.Unchecked_Conversion (VP_View, VP);
function To_VUC_View is new Ada.Unchecked_Conversion (VUC, VUC_View);
function To_VSC_View is new Ada.Unchecked_Conversion (VSC, VSC_View);
function To_VBC_View is new Ada.Unchecked_Conversion (VBC, VBC_View);
function To_VUS_View is new Ada.Unchecked_Conversion (VUS, VUS_View);
function To_VSS_View is new Ada.Unchecked_Conversion (VSS, VSS_View);
function To_VBS_View is new Ada.Unchecked_Conversion (VBS, VBS_View);
function To_VUI_View is new Ada.Unchecked_Conversion (VUI, VUI_View);
function To_VSI_View is new Ada.Unchecked_Conversion (VSI, VSI_View);
function To_VBI_View is new Ada.Unchecked_Conversion (VBI, VBI_View);
function To_VF_View is new Ada.Unchecked_Conversion (VF, VF_View);
function To_VP_View is new Ada.Unchecked_Conversion (VP, VP_View);
pragma Warnings (Off, Default_Bit_Order);
---------------
-- To_Vector --
---------------
function To_Vector (S : VSC_View) return VSC is
begin
if Default_Bit_Order = High_Order_First then
return To_VSC (S);
else
declare
Result : LL_VUC;
VS : constant VUC_View :=
(Values => To_Varray_unsigned_char (S.Values));
begin
Result := To_Vector (VS);
return To_LL_VSC (Result);
end;
end if;
end To_Vector;
function To_Vector (S : VBC_View) return VBC is
begin
if Default_Bit_Order = High_Order_First then
return To_VBC (S);
else
declare
Result : LL_VUC;
VS : constant VUC_View :=
(Values => To_Varray_unsigned_char (S.Values));
begin
Result := To_Vector (VS);
return To_LL_VBC (Result);
end;
end if;
end To_Vector;
function To_Vector (S : VSS_View) return VSS is
begin
if Default_Bit_Order = High_Order_First then
return To_VSS (S);
else
declare
Result : LL_VUS;
VS : constant VUS_View :=
(Values => To_Varray_unsigned_short (S.Values));
begin
Result := To_Vector (VS);
return VSS (To_LL_VSS (Result));
end;
end if;
end To_Vector;
function To_Vector (S : VBS_View) return VBS is
begin
if Default_Bit_Order = High_Order_First then
return To_VBS (S);
else
declare
Result : LL_VUS;
VS : constant VUS_View :=
(Values => To_Varray_unsigned_short (S.Values));
begin
Result := To_Vector (VS);
return To_LL_VBS (Result);
end;
end if;
end To_Vector;
function To_Vector (S : VP_View) return VP is
begin
if Default_Bit_Order = High_Order_First then
return To_VP (S);
else
declare
Result : LL_VUS;
VS : constant VUS_View :=
(Values => To_Varray_unsigned_short (S.Values));
begin
Result := To_Vector (VS);
return To_LL_VP (Result);
end;
end if;
end To_Vector;
function To_Vector (S : VSI_View) return VSI is
begin
if Default_Bit_Order = High_Order_First then
return To_VSI (S);
else
declare
Result : LL_VUI;
VS : constant VUI_View :=
(Values => To_Varray_unsigned_int (S.Values));
begin
Result := To_Vector (VS);
return To_LL_VSI (Result);
end;
end if;
end To_Vector;
function To_Vector (S : VBI_View) return VBI is
begin
if Default_Bit_Order = High_Order_First then
return To_VBI (S);
else
declare
Result : LL_VUI;
VS : constant VUI_View :=
(Values => To_Varray_unsigned_int (S.Values));
begin
Result := To_Vector (VS);
return To_LL_VBI (Result);
end;
end if;
end To_Vector;
function To_Vector (S : VF_View) return VF is
begin
if Default_Bit_Order = High_Order_First then
return To_VF (S);
else
declare
Result : LL_VUI;
VS : constant VUI_View :=
(Values => To_Varray_unsigned_int (S.Values));
begin
Result := To_Vector (VS);
return To_LL_VF (Result);
end;
end if;
end To_Vector;
function To_Vector (S : VUC_View) return VUC is
begin
if Default_Bit_Order = High_Order_First then
return To_VUC (S);
else
declare
Result : VUC_View;
begin
for J in Vchar_Range'Range loop
Result.Values (J) :=
S.Values (Vchar_Range'Last - J + Vchar_Range'First);
end loop;
return To_VUC (Result);
end;
end if;
end To_Vector;
function To_Vector (S : VUS_View) return VUS is
begin
if Default_Bit_Order = High_Order_First then
return To_VUS (S);
else
declare
Result : VUS_View;
begin
for J in Vshort_Range'Range loop
Result.Values (J) :=
S.Values (Vshort_Range'Last - J + Vshort_Range'First);
end loop;
return To_VUS (Result);
end;
end if;
end To_Vector;
function To_Vector (S : VUI_View) return VUI is
begin
if Default_Bit_Order = High_Order_First then
return To_VUI (S);
else
declare
Result : VUI_View;
begin
for J in Vint_Range'Range loop
Result.Values (J) :=
S.Values (Vint_Range'Last - J + Vint_Range'First);
end loop;
return To_VUI (Result);
end;
end if;
end To_Vector;
--------------
-- To_View --
--------------
function To_View (S : VSC) return VSC_View is
begin
if Default_Bit_Order = High_Order_First then
return To_VSC_View (S);
else
declare
Result : VUC_View;
begin
Result := To_View (To_LL_VUC (S));
return (Values => To_Varray_signed_char (Result.Values));
end;
end if;
end To_View;
function To_View (S : VBC) return VBC_View is
begin
if Default_Bit_Order = High_Order_First then
return To_VBC_View (S);
else
declare
Result : VUC_View;
begin
Result := To_View (To_LL_VUC (S));
return (Values => To_Varray_bool_char (Result.Values));
end;
end if;
end To_View;
function To_View (S : VSS) return VSS_View is
begin
if Default_Bit_Order = High_Order_First then
return To_VSS_View (S);
else
declare
Result : VUS_View;
begin
Result := To_View (To_LL_VUS (S));
return (Values => To_Varray_signed_short (Result.Values));
end;
end if;
end To_View;
function To_View (S : VBS) return VBS_View is
begin
if Default_Bit_Order = High_Order_First then
return To_VBS_View (S);
else
declare
Result : VUS_View;
begin
Result := To_View (To_LL_VUS (S));
return (Values => To_Varray_bool_short (Result.Values));
end;
end if;
end To_View;
function To_View (S : VP) return VP_View is
begin
if Default_Bit_Order = High_Order_First then
return To_VP_View (S);
else
declare
Result : VUS_View;
begin
Result := To_View (To_LL_VUS (S));
return (Values => To_Varray_pixel (Result.Values));
end;
end if;
end To_View;
function To_View (S : VSI) return VSI_View is
begin
if Default_Bit_Order = High_Order_First then
return To_VSI_View (S);
else
declare
Result : VUI_View;
begin
Result := To_View (To_LL_VUI (S));
return (Values => To_Varray_signed_int (Result.Values));
end;
end if;
end To_View;
function To_View (S : VBI) return VBI_View is
begin
if Default_Bit_Order = High_Order_First then
return To_VBI_View (S);
else
declare
Result : VUI_View;
begin
Result := To_View (To_LL_VUI (S));
return (Values => To_Varray_bool_int (Result.Values));
end;
end if;
end To_View;
function To_View (S : VF) return VF_View is
begin
if Default_Bit_Order = High_Order_First then
return To_VF_View (S);
else
declare
Result : VUI_View;
begin
Result := To_View (To_LL_VUI (S));
return (Values => To_Varray_float (Result.Values));
end;
end if;
end To_View;
function To_View (S : VUC) return VUC_View is
begin
if Default_Bit_Order = High_Order_First then
return To_VUC_View (S);
else
declare
VS : constant VUC_View := To_VUC_View (S);
Result : VUC_View;
begin
for J in Vchar_Range'Range loop
Result.Values (J) :=
VS.Values (Vchar_Range'Last - J + Vchar_Range'First);
end loop;
return Result;
end;
end if;
end To_View;
function To_View (S : VUS) return VUS_View is
begin
if Default_Bit_Order = High_Order_First then
return To_VUS_View (S);
else
declare
VS : constant VUS_View := To_VUS_View (S);
Result : VUS_View;
begin
for J in Vshort_Range'Range loop
Result.Values (J) :=
VS.Values (Vshort_Range'Last - J + Vshort_Range'First);
end loop;
return Result;
end;
end if;
end To_View;
function To_View (S : VUI) return VUI_View is
begin
if Default_Bit_Order = High_Order_First then
return To_VUI_View (S);
else
declare
VS : constant VUI_View := To_VUI_View (S);
Result : VUI_View;
begin
for J in Vint_Range'Range loop
Result.Values (J) :=
VS.Values (Vint_Range'Last - J + Vint_Range'First);
end loop;
return Result;
end;
end if;
end To_View;
end GNAT.Altivec.Conversions;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- -----------------------------------------------------------------------------
with Smk.Files; use Smk.Files;
with Ada.Containers.Doubly_Linked_Lists;
private package Smk.Assertions is
-- --------------------------------------------------------------------------
type Trigger_Type is (No_Trigger,
File_Update,
File_Presence,
File_Absence);
function Trigger_Image (Trigger : Trigger_Type) return String is
(case Trigger is
when No_Trigger => "No trigger ",
when File_Update => "If update ",
when File_Presence => "If presence",
when File_Absence => "If absence ");
Override : constant array (Trigger_Type, Trigger_Type) of Boolean :=
(No_Trigger => (others => False),
File_Update => (No_Trigger => True,
others => False),
File_Presence => (others => True),
File_Absence => (others => True));
type Condition is record
File : Files.File_Type;
Name : Files.File_Name;
Trigger : Trigger_Type;
end record;
-- --------------------------------------------------------------------------
function "=" (L, R : Condition) return Boolean is
(L.Name = R.Name and Role (L.File) = Role (R.File));
-- Equality is based on Name, but we also discriminate Sources from Targets
-- --------------------------------------------------------------------------
function Image (A : Condition;
Prefix : String := "") return String;
-- return an Image of that kind:
-- Prefix & [Pre :file exists]
-- --------------------------------------------------------------------------
package Condition_Lists is
new Ada.Containers.Doubly_Linked_Lists (Condition);
-- NB: "=" redefinition modify Contains (and other operations)
-- --------------------------------------------------------------------------
function Name_Order (Left, Right : Condition) return Boolean is
(Left.Name < Right.Name);
package Name_Sorting is new Condition_Lists.Generic_Sorting (Name_Order);
-- function Time_Order (Left, Right : Condition) return Boolean is
-- (Time_Tag (Left.File) < Time_Tag (Right.File));
-- package Time_Sorting is new Condition_Lists.Generic_Sorting (Time_Order);
-- --------------------------------------------------------------------------
type File_Count is new Natural;
function Count_Image (Count : File_Count) return String;
-- --------------------------------------------------------------------------
function Count (Cond_List : Condition_Lists.List;
Count_Sources : Boolean := False;
Count_Targets : Boolean := False;
With_System_Files : Boolean := False)
return File_Count;
-- --------------------------------------------------------------------------
type Rule_Kind is (Pattern_Rule, Simple_Rule);
-- type Rule (Kind : Rule_Kind) is record
-- when Pattern_Rule =>
-- From : Unbounded_String;
-- To : Unbounded_String;
-- when Simple_Rule =>
-- null;
-- end record;
end Smk.Assertions;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
with AWA.Modules.Beans;
with AWA.Modules.Get;
with AWA.Applications;
with AWA.Users.Beans;
with Util.Log.Loggers;
package body AWA.Users.Modules is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Users.Module");
package Register is new AWA.Modules.Beans (Module => User_Module,
Module_Access => User_Module_Access);
-- ------------------------------
-- Initialize the user module.
-- ------------------------------
overriding
procedure Initialize (Plugin : in out User_Module;
App : in AWA.Modules.Application_Access;
Props : in ASF.Applications.Config) is
begin
Log.Info ("Initializing the users module");
-- Setup the resource bundles.
App.Register ("userMsg", "users");
-- Register the OpenID servlets.
App.Add_Servlet (Name => "openid-auth",
Server => Plugin.Auth'Unchecked_Access);
App.Add_Servlet (Name => "openid-verify",
Server => Plugin.Verify_Auth'Unchecked_Access);
-- Setup the verify access key filter.
App.Add_Filter ("verify-access-key", Plugin.Key_Filter'Access);
App.Add_Filter ("auth-filter", Plugin.Auth_Filter'Access);
Plugin.Key_Filter.Initialize (App.all);
Register.Register (Plugin => Plugin,
Name => "AWA.Users.Beans.Authenticate_Bean",
Handler => AWA.Users.Beans.Create_Authenticate_Bean'Access);
Register.Register (Plugin => Plugin,
Name => "AWA.Users.Beans.Current_User_Bean",
Handler => AWA.Users.Beans.Create_Current_User_Bean'Access);
AWA.Modules.Module (Plugin).Initialize (App, Props);
-- Create the user manager when everything is initialized.
Plugin.Manager := Plugin.Create_User_Manager;
end Initialize;
-- ------------------------------
-- Get the user manager.
-- ------------------------------
function Get_User_Manager (Plugin : in User_Module) return Services.User_Service_Access is
begin
return Plugin.Manager;
end Get_User_Manager;
-- ------------------------------
-- Create a user manager. This operation can be overriden to provide another
-- user service implementation.
-- ------------------------------
function Create_User_Manager (Plugin : in User_Module) return Services.User_Service_Access is
Result : constant Services.User_Service_Access := new Services.User_Service;
begin
Result.Initialize (Plugin);
return Result;
end Create_User_Manager;
-- ------------------------------
-- Get the user module instance associated with the current application.
-- ------------------------------
function Get_User_Module return User_Module_Access is
function Get is new AWA.Modules.Get (User_Module, User_Module_Access, NAME);
begin
return Get;
end Get_User_Module;
-- ------------------------------
-- Get the user manager instance associated with the current application.
-- ------------------------------
function Get_User_Manager return Services.User_Service_Access is
Module : constant User_Module_Access := Get_User_Module;
begin
if Module = null then
Log.Error ("There is no active User_Module");
return null;
else
return Module.Get_User_Manager;
end if;
end Get_User_Manager;
end AWA.Users.Modules;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with GBA.Input;
use GBA.Input;
package GBA.Input.Buffered is
procedure Update_Key_State;
function Is_Key_Down (K : Key) return Boolean with Inline_Always;
function Are_Any_Down (F : Key_Flags) return Boolean with Inline_Always;
function Are_All_Down (F : Key_Flags) return Boolean with Inline_Always;
function Was_Key_Pressed (K : Key) return Boolean with Inline_Always;
function Were_Any_Pressed (F : Key_Flags) return Boolean with Inline_Always;
function Were_All_Pressed (F : Key_Flags) return Boolean with Inline_Always;
function Was_Key_Released (K : Key) return Boolean with Inline_Always;
function Were_Any_Released (F : Key_Flags) return Boolean with Inline_Always;
function Were_All_Released (F : Key_Flags) return Boolean with Inline_Always;
function Was_Key_Held (K : Key) return Boolean with Inline_Always;
function Were_Any_Held (F : Key_Flags) return Boolean with Inline_Always;
function Were_All_Held (F : Key_Flags) return Boolean with Inline_Always;
function Was_Key_Untouched (K : Key) return Boolean with Inline_Always;
function Were_Any_Untouched (F : Key_Flags) return Boolean with Inline_Always;
function Were_All_Untouched (F : Key_Flags) return Boolean with Inline_Always;
private
Last_Key_State : Key_Flags := 0;
Current_Key_State : Key_Flags := 0;
end GBA.Input.Buffered;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Unicode;
with Ada.Exceptions;
with Ada.Strings.Fixed;
with Util.Log.Loggers;
with Util.Serialize.IO.XML;
package body ASF.Views.Nodes.Reader is
use Sax.Readers;
use Sax.Exceptions;
use Sax.Locators;
use Sax.Attributes;
use Unicode;
use Unicode.CES;
use Ada.Strings.Fixed;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("ASF.Views.Nodes.Reader");
procedure Free is
new Ada.Unchecked_Deallocation (Element_Context_Array,
Element_Context_Array_Access);
procedure Push (Handler : in out Xhtml_Reader'Class);
procedure Pop (Handler : in out Xhtml_Reader'Class);
-- Freeze the current Text_Tag node, counting the number of elements it contains.
procedure Finish_Text_Node (Handler : in out Xhtml_Reader'Class);
-- ------------------------------
-- Push the current context when entering in an element.
-- ------------------------------
procedure Push (Handler : in out Xhtml_Reader'Class) is
begin
if Handler.Stack = null then
Handler.Stack := new Element_Context_Array (1 .. 100);
elsif Handler.Stack_Pos = Handler.Stack'Last then
declare
Old : Element_Context_Array_Access := Handler.Stack;
begin
Handler.Stack := new Element_Context_Array (1 .. Old'Last + 100);
Handler.Stack (1 .. Old'Last) := Old (1 .. Old'Last);
Free (Old);
end;
end if;
if Handler.Stack_Pos /= Handler.Stack'First then
Handler.Stack (Handler.Stack_Pos + 1) := Handler.Stack (Handler.Stack_Pos);
end if;
Handler.Stack_Pos := Handler.Stack_Pos + 1;
Handler.Current := Handler.Stack (Handler.Stack_Pos)'Access;
end Push;
-- ------------------------------
-- Pop the context and restore the previous context when leaving an element
-- ------------------------------
procedure Pop (Handler : in out Xhtml_Reader'Class) is
begin
Handler.Stack_Pos := Handler.Stack_Pos - 1;
Handler.Current := Handler.Stack (Handler.Stack_Pos)'Access;
end Pop;
-- ------------------------------
-- Find the function knowing its name.
-- ------------------------------
overriding
function Get_Function (Mapper : NS_Function_Mapper;
Namespace : String;
Name : String) return Function_Access is
use NS_Mapping;
Pos : constant NS_Mapping.Cursor := NS_Mapping.Find (Mapper.Mapping, Namespace);
begin
if Has_Element (Pos) then
return Mapper.Mapper.Get_Function (Element (Pos), Name);
end if;
raise No_Function with "Function '" & Namespace & ':' & Name & "' not found";
end Get_Function;
-- ------------------------------
-- Bind a name to a function in the given namespace.
-- ------------------------------
overriding
procedure Set_Function (Mapper : in out NS_Function_Mapper;
Namespace : in String;
Name : in String;
Func : in Function_Access) is
begin
null;
end Set_Function;
-- ------------------------------
-- Find the create function bound to the name in the given namespace.
-- Returns null if no such binding exist.
-- ------------------------------
function Find (Mapper : NS_Function_Mapper;
Namespace : String;
Name : String) return ASF.Views.Nodes.Binding_Access is
use NS_Mapping;
begin
return ASF.Factory.Find (Mapper.Factory.all, Namespace, Name);
end Find;
procedure Set_Namespace (Mapper : in out NS_Function_Mapper;
Prefix : in String;
URI : in String) is
use NS_Mapping;
begin
Log.Debug ("Add namespace {0}:{1}", Prefix, URI);
Mapper.Mapping.Include (Prefix, URI);
end Set_Namespace;
-- ------------------------------
-- Remove the namespace prefix binding.
-- ------------------------------
procedure Remove_Namespace (Mapper : in out NS_Function_Mapper;
Prefix : in String) is
use NS_Mapping;
Pos : NS_Mapping.Cursor := NS_Mapping.Find (Mapper.Mapping, Prefix);
begin
Log.Debug ("Remove namespace {0}", Prefix);
if Has_Element (Pos) then
NS_Mapping.Delete (Mapper.Mapping, Pos);
end if;
end Remove_Namespace;
-- ------------------------------
-- Warning
-- ------------------------------
overriding
procedure Warning (Handler : in out Xhtml_Reader;
Except : Sax.Exceptions.Sax_Parse_Exception'Class) is
pragma Warnings (Off, Handler);
begin
Log.Warn ("{0}: {1}", Util.Serialize.IO.XML.Get_Location (Except), Get_Message (Except));
end Warning;
-- ------------------------------
-- Error
-- ------------------------------
overriding
procedure Error (Handler : in out Xhtml_Reader;
Except : in Sax.Exceptions.Sax_Parse_Exception'Class) is
pragma Warnings (Off, Handler);
begin
Log.Error ("{0}: {1}", Util.Serialize.IO.XML.Get_Location (Except), Get_Message (Except));
end Error;
-- ------------------------------
-- Fatal_Error
-- ------------------------------
overriding
procedure Fatal_Error (Handler : in out Xhtml_Reader;
Except : in Sax.Exceptions.Sax_Parse_Exception'Class) is
pragma Unreferenced (Handler);
begin
Log.Error ("{0}: {1}", Util.Serialize.IO.XML.Get_Location (Except), Get_Message (Except));
end Fatal_Error;
-- ------------------------------
-- Set_Document_Locator
-- ------------------------------
overriding
procedure Set_Document_Locator (Handler : in out Xhtml_Reader;
Loc : in out Sax.Locators.Locator) is
begin
Handler.Locator := Loc;
end Set_Document_Locator;
-- ------------------------------
-- Start_Document
-- ------------------------------
overriding
procedure Start_Document (Handler : in out Xhtml_Reader) is
begin
null;
end Start_Document;
-- ------------------------------
-- End_Document
-- ------------------------------
overriding
procedure End_Document (Handler : in out Xhtml_Reader) is
begin
null;
end End_Document;
-- ------------------------------
-- Start_Prefix_Mapping
-- ------------------------------
overriding
procedure Start_Prefix_Mapping (Handler : in out Xhtml_Reader;
Prefix : in Unicode.CES.Byte_Sequence;
URI : in Unicode.CES.Byte_Sequence) is
begin
if Prefix = "" then
Handler.Add_NS := To_Unbounded_String (URI);
else
Handler.Functions.Set_Namespace (Prefix => Prefix, URI => URI);
end if;
end Start_Prefix_Mapping;
-- ------------------------------
-- End_Prefix_Mapping
-- ------------------------------
overriding
procedure End_Prefix_Mapping (Handler : in out Xhtml_Reader;
Prefix : in Unicode.CES.Byte_Sequence) is
begin
Handler.Functions.Remove_Namespace (Prefix => Prefix);
end End_Prefix_Mapping;
-- ------------------------------
-- Collect the text for an EL expression. The EL expression starts
-- with either '#{' or with '${' and ends with the matching '}'.
-- If the <b>Value</b> string does not contain the whole EL experssion
-- the <b>Expr_Buffer</b> stored in the reader is used to collect
-- that expression.
-- ------------------------------
procedure Collect_Expression (Handler : in out Xhtml_Reader) is
use Ada.Exceptions;
Expr : constant String := To_String (Handler.Expr_Buffer);
Content : constant Tag_Content_Access := Handler.Text.Last;
begin
Handler.Expr_Buffer := Null_Unbounded_String;
Content.Expr := EL.Expressions.Create_Expression (Expr, Handler.ELContext.all);
Content.Next := new Tag_Content;
Handler.Text.Last := Content.Next;
exception
when E : EL.Functions.No_Function | EL.Expressions.Invalid_Expression =>
Log.Error ("{0}: Invalid expression: {1}",
To_String (Handler.Locator),
Exception_Message (E));
Log.Error ("{0}: {1}",
To_String (Handler.Locator),
Expr);
when E : others =>
Log.Error ("{0}: Internal error: {1}:{2}",
To_String (Handler.Locator),
Exception_Name (E),
Exception_Message (E));
end Collect_Expression;
-- ------------------------------
-- Collect the raw-text in a buffer. The text must be flushed
-- when a new element is started or when an exiting element is closed.
-- ------------------------------
procedure Collect_Text (Handler : in out Xhtml_Reader;
Value : in Unicode.CES.Byte_Sequence) is
Pos : Natural := Value'First;
C : Character;
Content : Tag_Content_Access;
Start_Pos : Natural;
Last_Pos : Natural;
begin
while Pos <= Value'Last loop
case Handler.State is
-- Collect the white spaces and newlines in the 'Spaces'
-- buffer to ignore empty lines but still honor indentation.
when NO_CONTENT =>
loop
C := Value (Pos);
if C = ASCII.CR or C = ASCII.LF then
Handler.Spaces := Null_Unbounded_String;
elsif C = ' ' or C = ASCII.HT then
Append (Handler.Spaces, C);
else
Handler.State := HAS_CONTENT;
exit;
end if;
Pos := Pos + 1;
exit when Pos > Value'Last;
end loop;
-- Collect an EL expression until the end of that
-- expression. Evaluate the expression.
when PARSE_EXPR =>
Start_Pos := Pos;
loop
C := Value (Pos);
Last_Pos := Pos;
Pos := Pos + 1;
if C = '}' then
Handler.State := HAS_CONTENT;
exit;
end if;
exit when Pos > Value'Last;
end loop;
Append (Handler.Expr_Buffer, Value (Start_Pos .. Last_Pos));
if Handler.State /= PARSE_EXPR then
Handler.Collect_Expression;
end if;
-- Collect the raw text in the current content buffer
when HAS_CONTENT =>
if Handler.Text = null then
Handler.Text := new Text_Tag_Node;
Initialize (Handler.Text.all'Access, null,
Handler.Line, Handler.Current.Parent, null);
Handler.Text.Last := Handler.Text.Content'Access;
elsif Length (Handler.Expr_Buffer) > 0 then
Handler.Collect_Expression;
Pos := Pos + 1;
end if;
Content := Handler.Text.Last;
-- Scan until we find the start of an EL expression
-- or we have a new line.
Start_Pos := Pos;
loop
C := Value (Pos);
-- Check for the EL start #{ or ${
if (C = '#' or C = '$')
and then Pos + 1 <= Value'Last
and then Value (Pos + 1) = '{' then
Handler.State := PARSE_EXPR;
Append (Handler.Expr_Buffer, C);
Append (Handler.Expr_Buffer, '{');
Last_Pos := Pos - 1;
Pos := Pos + 2;
exit;
-- Handle \#{ and \${ as escape sequence
elsif C = '\' and then Pos + 2 <= Value'Last
and then Value (Pos + 2) = '{'
and then (Value (Pos + 1) = '#' or Value (Pos + 1) = '$') then
-- Since we have to strip the '\', flush the spaces and append the text
-- but ignore the '\'.
Append (Content.Text, Handler.Spaces);
Handler.Spaces := Null_Unbounded_String;
if Start_Pos < Pos then
Append (Content.Text, Value (Start_Pos .. Pos - 1));
end if;
Start_Pos := Pos + 1;
Pos := Pos + 2;
elsif (C = ASCII.CR or C = ASCII.LF) and Handler.Ignore_Empty_Lines then
Last_Pos := Pos;
Handler.State := NO_CONTENT;
exit;
end if;
Last_Pos := Pos;
Pos := Pos + 1;
exit when Pos > Value'Last;
end loop;
-- If we have some pending spaces, add them in the text stream.
if Length (Handler.Spaces) > 0 then
Append (Content.Text, Handler.Spaces);
Handler.Spaces := Null_Unbounded_String;
end if;
-- If we have some text, append to the current content buffer.
if Start_Pos <= Last_Pos then
Append (Content.Text, Value (Start_Pos .. Last_Pos));
end if;
end case;
end loop;
end Collect_Text;
-- ------------------------------
-- Freeze the current Text_Tag node, counting the number of elements it contains.
-- ------------------------------
procedure Finish_Text_Node (Handler : in out Xhtml_Reader'Class) is
begin
if Handler.Text /= null then
Handler.Text.Freeze;
Handler.Text := null;
end if;
end Finish_Text_Node;
-- ------------------------------
-- Start_Element
-- ------------------------------
overriding
procedure Start_Element (Handler : in out Xhtml_Reader;
Namespace_URI : in Unicode.CES.Byte_Sequence := "";
Local_Name : in Unicode.CES.Byte_Sequence := "";
Qname : in Unicode.CES.Byte_Sequence := "";
Atts : in Sax.Attributes.Attributes'Class) is
use ASF.Factory;
use Ada.Exceptions;
Attr_Count : Natural;
Attributes : Tag_Attribute_Array_Access;
Node : Tag_Node_Access;
Factory : ASF.Views.Nodes.Binding_Access;
begin
Handler.Line.Line := Sax.Locators.Get_Line_Number (Handler.Locator);
Handler.Line.Column := Sax.Locators.Get_Column_Number (Handler.Locator);
-- Push the current context to keep track where we are.
Push (Handler);
Attr_Count := Get_Length (Atts);
Factory := Handler.Functions.Find (Namespace => Namespace_URI,
Name => Local_Name);
if Factory /= null then
if Length (Handler.Add_NS) > 0 then
Attributes := new Tag_Attribute_Array (0 .. Attr_Count);
Attributes (0).Name := To_Unbounded_String ("xmlns");
Attributes (0).Value := Handler.Add_NS;
Handler.Add_NS := To_Unbounded_String ("");
else
Attributes := new Tag_Attribute_Array (1 .. Attr_Count);
end if;
for I in 0 .. Attr_Count - 1 loop
declare
Attr : constant Tag_Attribute_Access := Attributes (I + 1)'Access;
Value : constant String := Get_Value (Atts, I);
Name : constant String := Get_Qname (Atts, I);
Expr : EL.Expressions.Expression_Access;
begin
Attr.Name := To_Unbounded_String (Name);
if Index (Value, "#{") > 0 or Index (Value, "${") > 0 then
begin
Expr := new EL.Expressions.Expression;
Attr.Binding := Expr.all'Access;
EL.Expressions.Expression (Expr.all) := EL.Expressions.Create_Expression
(Value, Handler.ELContext.all);
exception
when E : EL.Functions.No_Function =>
Log.Error ("{0}: Invalid expression: {1}",
To_String (Handler.Locator),
Exception_Message (E));
Attr.Binding := null;
Attr.Value := To_Unbounded_String ("");
when E : EL.Expressions.Invalid_Expression =>
Log.Error ("{0}: Invalid expression: {1}",
To_String (Handler.Locator),
Exception_Message (E));
Attr.Binding := null;
Attr.Value := To_Unbounded_String ("");
end;
else
Attr.Value := To_Unbounded_String (Value);
end if;
end;
end loop;
Node := Factory.Tag (Binding => Factory,
Line => Handler.Line,
Parent => Handler.Current.Parent,
Attributes => Attributes);
Handler.Current.Parent := Node;
Handler.Current.Text := False;
Finish_Text_Node (Handler);
Handler.Spaces := Null_Unbounded_String;
Handler.State := Handler.Default_State;
else
declare
Is_Unknown : constant Boolean := Namespace_URI /= "" and Index (Qname, ":") > 0;
begin
-- Optimization: we know in which state we are.
Handler.State := HAS_CONTENT;
Handler.Current.Text := True;
if Is_Unknown then
Log.Error ("{0}: Element '{1}' not found",
To_String (Handler.Locator), Qname);
end if;
if Handler.Escape_Unknown_Tags and Is_Unknown then
Handler.Collect_Text ("<");
else
Handler.Collect_Text ("<");
end if;
Handler.Collect_Text (Qname);
if Length (Handler.Add_NS) > 0 then
Handler.Collect_Text (" xmlns=""");
Handler.Collect_Text (To_String (Handler.Add_NS));
Handler.Collect_Text ("""");
Handler.Add_NS := To_Unbounded_String ("");
end if;
if Attr_Count /= 0 then
for I in 0 .. Attr_Count - 1 loop
Handler.Collect_Text (" ");
Handler.Collect_Text (Get_Qname (Atts, I));
Handler.Collect_Text ("=""");
declare
Value : constant String := Get_Value (Atts, I);
begin
Handler.Collect_Text (Value);
end;
Handler.Collect_Text ("""");
end loop;
end if;
if Handler.Escape_Unknown_Tags and Is_Unknown then
Handler.Collect_Text (">");
else
Handler.Collect_Text (">");
end if;
end;
end if;
end Start_Element;
-- ------------------------------
-- End_Element
-- ------------------------------
overriding
procedure End_Element (Handler : in out Xhtml_Reader;
Namespace_URI : in Unicode.CES.Byte_Sequence := "";
Local_Name : in Unicode.CES.Byte_Sequence := "";
Qname : in Unicode.CES.Byte_Sequence := "") is
pragma Unreferenced (Local_Name);
begin
if Handler.Current.Parent = null then
Finish_Text_Node (Handler);
elsif not Handler.Current.Text then
Finish_Text_Node (Handler);
Handler.Current.Parent.Freeze;
end if;
if Handler.Current.Text or Handler.Text /= null then
declare
Is_Unknown : constant Boolean := Namespace_URI /= "" and Index (Qname, ":") > 0;
begin
-- Optimization: we know in which state we are.
Handler.State := HAS_CONTENT;
if Handler.Escape_Unknown_Tags and Is_Unknown then
Handler.Collect_Text ("</");
Handler.Collect_Text (Qname);
Handler.Collect_Text (">");
else
Handler.Collect_Text ("</");
Handler.Collect_Text (Qname);
Handler.Collect_Text (">");
end if;
end;
else
Handler.Spaces := Null_Unbounded_String;
end if;
-- Pop the current context to restore the last context.
Pop (Handler);
end End_Element;
-- ------------------------------
-- Characters
-- ------------------------------
overriding
procedure Characters (Handler : in out Xhtml_Reader;
Ch : in Unicode.CES.Byte_Sequence) is
begin
Collect_Text (Handler, Ch);
end Characters;
-- ------------------------------
-- Ignorable_Whitespace
-- ------------------------------
overriding
procedure Ignorable_Whitespace (Handler : in out Xhtml_Reader;
Ch : in Unicode.CES.Byte_Sequence) is
begin
if not Handler.Ignore_White_Spaces then
Collect_Text (Handler, Ch);
end if;
end Ignorable_Whitespace;
-- ------------------------------
-- Processing_Instruction
-- ------------------------------
overriding
procedure Processing_Instruction (Handler : in out Xhtml_Reader;
Target : in Unicode.CES.Byte_Sequence;
Data : in Unicode.CES.Byte_Sequence) is
pragma Unreferenced (Handler);
begin
Log.Error ("Processing instruction: {0}: {1}", Target, Data);
null;
end Processing_Instruction;
-- ------------------------------
-- Skipped_Entity
-- ------------------------------
overriding
procedure Skipped_Entity (Handler : in out Xhtml_Reader;
Name : in Unicode.CES.Byte_Sequence) is
pragma Unmodified (Handler);
begin
null;
end Skipped_Entity;
-- ------------------------------
-- Start_Cdata
-- ------------------------------
overriding
procedure Start_Cdata (Handler : in out Xhtml_Reader) is
pragma Unreferenced (Handler);
begin
Log.Info ("Start CDATA");
end Start_Cdata;
-- ------------------------------
-- End_Cdata
-- ------------------------------
overriding
procedure End_Cdata (Handler : in out Xhtml_Reader) is
pragma Unreferenced (Handler);
begin
Log.Info ("End CDATA");
end End_Cdata;
-- ------------------------------
-- Resolve_Entity
-- ------------------------------
overriding
function Resolve_Entity (Handler : Xhtml_Reader;
Public_Id : Unicode.CES.Byte_Sequence;
System_Id : Unicode.CES.Byte_Sequence)
return Input_Sources.Input_Source_Access is
pragma Unreferenced (Handler);
begin
Log.Error ("Cannot resolve entity {0} - {1}", Public_Id, System_Id);
return null;
end Resolve_Entity;
overriding
procedure Start_DTD (Handler : in out Xhtml_Reader;
Name : Unicode.CES.Byte_Sequence;
Public_Id : Unicode.CES.Byte_Sequence := "";
System_Id : Unicode.CES.Byte_Sequence := "") is
begin
if Handler.Text = null then
Handler.Text := new Text_Tag_Node;
Initialize (Handler.Text.all'Access, null,
Handler.Line, Handler.Current.Parent, null);
Handler.Text.Last := Handler.Text.Content'Access;
end if;
declare
Content : constant Tag_Content_Access := Handler.Text.Last;
begin
Append (Content.Text, "<!DOCTYPE ");
Append (Content.Text, Name);
Append (Content.Text, " ");
if Public_Id'Length > 0 then
Append (Content.Text, " PUBLIC """);
Append (Content.Text, Public_Id);
Append (Content.Text, """ ");
if System_Id'Length > 0 then
Append (Content.Text, '"');
Append (Content.Text, System_Id);
Append (Content.Text, '"');
end if;
elsif System_Id'Length > 0 then
Append (Content.Text, " SYSTEM """);
Append (Content.Text, System_Id);
Append (Content.Text, """ ");
end if;
Append (Content.Text, " >" & ASCII.LF);
end;
end Start_DTD;
-- ------------------------------
-- Get the root node that was created upon parsing of the XHTML file.
-- ------------------------------
function Get_Root (Reader : Xhtml_Reader) return Tag_Node_Access is
begin
return Reader.Root;
end Get_Root;
-- ------------------------------
-- Set the XHTML reader to ignore or not the white spaces.
-- When set to True, the ignorable white spaces will not be kept.
-- ------------------------------
procedure Set_Ignore_White_Spaces (Reader : in out Xhtml_Reader;
Value : in Boolean) is
begin
Reader.Ignore_White_Spaces := Value;
end Set_Ignore_White_Spaces;
-- ------------------------------
-- Set the XHTML reader to ignore empty lines.
-- ------------------------------
procedure Set_Ignore_Empty_Lines (Reader : in out Xhtml_Reader;
Value : in Boolean) is
begin
Reader.Ignore_Empty_Lines := Value;
end Set_Ignore_Empty_Lines;
-- ------------------------------
-- Set the XHTML reader to escape or not the unknown tags.
-- When set to True, the tags which are not recognized will be
-- emitted as a raw text component and they will be escaped using
-- the XML escape rules.
-- ------------------------------
procedure Set_Escape_Unknown_Tags (Reader : in out Xhtml_Reader;
Value : in Boolean) is
begin
Reader.Escape_Unknown_Tags := Value;
end Set_Escape_Unknown_Tags;
-- ------------------------------
-- Parse an XML stream, and calls the appropriate SAX callbacks for each
-- event.
-- This is not re-entrant: you can not call Parse with the same Parser
-- argument in one of the SAX callbacks. This has undefined behavior.
-- ------------------------------
procedure Parse (Parser : in out Xhtml_Reader;
Name : in ASF.Views.File_Info_Access;
Input : in out Input_Sources.Input_Source'Class;
Factory : access ASF.Factory.Component_Factory;
Context : in EL.Contexts.ELContext_Access) is
begin
Parser.Stack_Pos := 1;
Push (Parser);
Parser.Line.File := Name;
Parser.Root := new Tag_Node;
Parser.Functions.Factory := Factory;
Parser.Current.Parent := Parser.Root;
Parser.ELContext := Parser.Context'Unchecked_Access;
Parser.Context.Set_Function_Mapper (Parser.Functions'Unchecked_Access);
Parser.Functions.Mapper := Context.Get_Function_Mapper;
if Parser.Functions.Mapper = null then
Log.Warn ("There is no function mapper");
end if;
Sax.Readers.Reader (Parser).Parse (Input);
Finish_Text_Node (Parser);
Parser.Functions.Factory := null;
Parser.ELContext := null;
if Parser.Ignore_Empty_Lines then
Parser.Default_State := NO_CONTENT;
else
Parser.Default_State := HAS_CONTENT;
end if;
Parser.State := Parser.Default_State;
Free (Parser.Stack);
exception
when others =>
Free (Parser.Stack);
raise;
end Parse;
end ASF.Views.Nodes.Reader;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- LinkAction is an abstract class for all link actions that identify their
-- links by the objects at the ends of the links and by the qualifiers at
-- ends of the links.
------------------------------------------------------------------------------
with AMF.UML.Actions;
limited with AMF.UML.Associations;
limited with AMF.UML.Input_Pins.Collections;
limited with AMF.UML.Link_End_Datas.Collections;
package AMF.UML.Link_Actions is
pragma Preelaborate;
type UML_Link_Action is limited interface
and AMF.UML.Actions.UML_Action;
type UML_Link_Action_Access is
access all UML_Link_Action'Class;
for UML_Link_Action_Access'Storage_Size use 0;
not overriding function Get_End_Data
(Self : not null access constant UML_Link_Action)
return AMF.UML.Link_End_Datas.Collections.Set_Of_UML_Link_End_Data is abstract;
-- Getter of LinkAction::endData.
--
-- Data identifying one end of a link by the objects on its ends and
-- qualifiers.
not overriding function Get_Input_Value
(Self : not null access constant UML_Link_Action)
return AMF.UML.Input_Pins.Collections.Set_Of_UML_Input_Pin is abstract;
-- Getter of LinkAction::inputValue.
--
-- Pins taking end objects and qualifier values as input.
not overriding function Association
(Self : not null access constant UML_Link_Action)
return AMF.UML.Associations.UML_Association_Access is abstract;
-- Operation LinkAction::association.
--
-- The association operates on LinkAction. It returns the association of
-- the action.
end AMF.UML.Link_Actions;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Pre_Post is
package P is
type Int_Array is array (Integer range <>) of Integer;
-- Increment the input (obvious)
procedure Increment (A : in out Integer)
with
Post => A = A'Old + 1;
-- A "limited" negate (nonsense...)
procedure Limited_Negate (A : in out Integer;
B : in Integer)
with
Post => (if A < B then A = -A'Old else A = -B);
-- just to show the attribute Result
function Sum_Minus_One (A, B : Integer) return Integer
with
Post => Sum_Minus_One'Result = A + B - 1;
-- 5, 2 give 3; -2, -5 give 3, but -5, -2... fails pre
function Positive_Diff (A, B : Integer) return Integer
with
Pre => A > B,
Post => Positive_Diff'Result = A - B;
-- a sort... the precondition is rather odd: the caller must
-- call this subprogram only when she knows the array isn't
-- sorted; for a more "realistic" case, remove the Pre.
procedure Sort (A : in out Int_Array)
with
Pre => (for some I in A'First .. A'Last - 1 => A (I) > A (I+1)),
Post => (for all I in A'First .. A'Last - 1 => A (I) <= A (I+1));
end P;
package body P is
-- bubble sort
procedure Sort (A : in out Int_Array) is
App : Integer;
Swapped : Boolean := True;
begin
while Swapped loop
Swapped := False;
for I in A'First .. A'Last - 1 loop
if A (I) > A (I + 1) then
App := A (I);
A (I) := A (I + 1);
A (I + 1) := App;
Swapped := True;
end if;
end loop;
end loop;
end Sort;
procedure Increment (A : in out Integer) is
begin
A := A + 1;
end Increment;
procedure Limited_Negate (A : in out Integer;
B : in Integer) is
begin
-- correct implementation...
-- if A < B then
-- A := -A;
-- else
-- A := -B;
-- end if;
A := -A + B; -- wrong implementation...
end Limited_Negate;
function Sum_Minus_One (A, B : Integer) return Integer is
begin
-- for such a short function I prefer the other syntax...
return A + B - 1;
end Sum_Minus_One;
function Positive_Diff (A, B : Integer) return Integer is
begin
return A - B;
end Positive_Diff;
end P;
A : constant Integer := 1;
B : Integer := 2;
package IO is new Ada.Text_IO.Integer_IO (Integer);
procedure O (X : Integer)
with
Inline;
procedure O (X : Integer) is
begin
IO.Put (X); New_Line;
end O;
use P;
-- an unsorted array
Un_Arr : Int_Array := (10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
-- a sorted array
Ord_Arr : Int_Array := (1, 4, 8, 10, 11, 100, 200);
begin
O (A); O (B);
Increment (B); O (B);
O (Sum_Minus_One (A, B));
-- compiler warn: "actuals for this call may be in wrong order",
-- this is why I've used named parameters
O (Positive_Diff (A => B, B => A));
Put_Line ("everything's alright?");
-- Pre requires A > B, but B = 3 and A = 1... => runtime exception
-- telling us "failed precondition from pre_post.adb" (followed by
-- the line in the source code, which I removed because I'm
-- modifying this source adding lines)
--O (Positive_Diff (A, B));
-- and this at runtime gives "failed postcondition from
-- pre_post.adb", because the guy who implemented the code hasn't
-- understood the specifications...
--Limited_Negate (A, B);
O (A); O (B);
for I in Un_Arr'Range loop
IO.Put (Un_Arr (I));
end loop;
New_Line;
Sort (Un_Arr);
for I in Un_Arr'Range loop
IO.Put (Un_Arr (I));
end loop;
New_Line;
-- calling this violates the preconditions: our sort assumes that
-- the array isn't already sorted...
--Sort (Ord_Arr);
end Pre_Post;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- SOFTWARE.
with Ada.Text_IO; use Ada.Text_IO;
with Debug_Logs; use Debug_Logs;
with Resolver; use Resolver;
package body Processor.Eclipse_FPU_P is
procedure Debug_FPACs (CPU : in CPU_T) is
begin
Loggers.Debug_Print (Debug_Log, "FPAC0: " & CPU.FPAC(0)'Image &
" FPAC1: " & CPU.FPAC(1)'Image &
" FPAC2: " & CPU.FPAC(2)'Image &
" FPAC3: " & CPU.FPAC(3)'Image);
-- Ada.Text_IO.Put_Line("FPAC0: " & CPU.FPAC(0)'Image &
-- " FPAC1: " & CPU.FPAC(1)'Image &
-- " FPAC2: " & CPU.FPAC(2)'Image &
-- " FPAC3: " & CPU.FPAC(3)'Image);
end Debug_FPACs;
procedure Do_Eclipse_FPU (I : in Decoded_Instr_T; CPU : in out CPU_T) is
QW : Qword_T;
--LF : Long_Float;
DG_Dbl : Double_Overlay;
begin
Debug_FPACs (CPU);
case I.Instruction is
when I_FAD =>
CPU.FPAC(I.Acd) := CPU.FPAC(I.Acd) + CPU.FPAC(I.Acs);
Set_N (CPU, (CPU.FPAC(I.Acd) < 0.0));
Set_Z (CPU, (CPU.FPAC(I.Acd) = 0.0));
when I_FCLE =>
CPU.FPSR := 0; -- TODO verify - PoP contradicts itself
when I_FCMP =>
if CPU.FPAC(I.Acs) = CPU.FPAC(I.Acd) then
Set_N (CPU, false);
Set_Z (CPU, true);
elsif CPU.FPAC(I.Acs) > CPU.FPAC(I.Acd) then
Set_N (CPU, true);
Set_Z (CPU, false);
else
Set_N (CPU, false);
Set_Z (CPU, false);
end if;
when I_FDD =>
CPU.FPAC(I.Acd) := CPU.FPAC(I.Acd) / CPU.FPAC(I.Acs);
Set_N (CPU, (CPU.FPAC(I.Acd) < 0.0));
Set_Z (CPU, (CPU.FPAC(I.Acd) = 0.0));
when I_FMS =>
CPU.FPAC(I.Acd) := CPU.FPAC(I.Acd) * CPU.FPAC(I.Acs);
Set_N (CPU, (CPU.FPAC(I.Acd) < 0.0));
Set_Z (CPU, (CPU.FPAC(I.Acd) = 0.0));
when I_FSGT =>
if (not Get_Z(CPU)) and (not Get_N(CPU)) then
CPU.PC := CPU.PC + 1;
end if;
when I_FINT =>
CPU.FPAC(I.Ac) := Long_Float'Truncation(CPU.FPAC(I.Ac));
Set_N (CPU, (CPU.FPAC(I.Ac) < 0.0));
Set_Z (CPU, (CPU.FPAC(I.Ac) = 0.0));
when I_FMD =>
CPU.FPAC(I.Acd) := CPU.FPAC(I.Acd) * CPU.FPAC(I.Acs);
Set_N (CPU, (CPU.FPAC(I.Acd) < 0.0));
Set_Z (CPU, (CPU.FPAC(I.Acd) = 0.0));
when I_FSEQ =>
if Get_Z(CPU) then
CPU.PC := CPU.PC + 1;
end if;
when I_FSGE =>
if not Get_N(CPU) then
CPU.PC := CPU.PC + 1;
end if;
when I_FSLT =>
if Get_N(CPU) then
CPU.PC := CPU.PC + 1;
end if;
when I_FTD =>
Clear_QW_Bit (CPU.FPSR, FPSR_Te);
when I_FTE =>
Set_QW_Bit (CPU.FPSR, FPSR_Te);
when I_FRDS =>
QW := Long_Float_To_DG_Double(CPU.FPAC(I.Acs));
if Test_QW_Bit (CPU.FPSR, FPSR_Rnd) then
-- FIXME - should round not truncate
DG_Dbl.Double_QW := QW and 16#ffff_ffff_0000_0000#;
CPU.FPAC(I.Acd) := DG_Double_To_Long_Float(DG_Dbl);
else
DG_Dbl.Double_QW := QW and 16#ffff_ffff_0000_0000#;
CPU.FPAC(I.Acd) := DG_Double_To_Long_Float(DG_Dbl);
end if;
Set_N (CPU, (CPU.FPAC(I.Acd) < 0.0));
Set_Z (CPU, (CPU.FPAC(I.Acd) = 0.0));
when I_FSD =>
CPU.FPAC(I.Acd) := CPU.FPAC(I.Acd) - CPU.FPAC(I.Acs);
Set_N (CPU, (CPU.FPAC(I.Acd) < 0.0));
Set_Z (CPU, (CPU.FPAC(I.Acd) = 0.0));
when I_FSNE =>
if Get_Z(CPU) then
CPU.PC := CPU.PC + 1;
end if;
when others =>
Put_Line ("ERROR: ECLIPSE_FPU instruction " & To_String(I.Mnemonic) &
" not yet implemented");
raise Execution_Failure with "ERROR: ECLIPSE_FPU instruction " & To_String(I.Mnemonic) &
" not yet implemented";
end case;
Debug_FPACs (CPU);
CPU.PC := CPU.PC + Phys_Addr_T(I.Instr_Len);
end Do_Eclipse_FPU;
end Processor.Eclipse_FPU_P;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--*
-- OBJECTIVE:
-- CHECK THAT A VARIABLE CREATED BY AN ALLOCATOR CAN BE RENAMED AND
-- HAS THE CORRECT VALUE, AND THAT THE NEW NAME CAN BE USED IN AN
-- ASSIGNMENT STATEMENT AND PASSED ON AS AN ACTUAL SUBPROGRAM OR
-- ENTRY 'IN OUT' OR 'OUT' PARAMETER, AND AS AN ACTUAL GENERIC
-- 'IN OUT' PARAMETER, AND THAT WHEN THE VALUE OF THE RENAMED
-- VARIABLE IS CHANGED, THE NEW VALUE IS REFLECTED BY THE VALUE OF
-- THE NEW NAME.
-- HISTORY:
-- JET 03/15/88 CREATED ORIGINAL TEST.
WITH REPORT; USE REPORT;
PROCEDURE C85005E IS
TYPE ARRAY1 IS ARRAY (POSITIVE RANGE <>) OF INTEGER;
TYPE RECORD1 (D : INTEGER) IS
RECORD
FIELD1 : INTEGER := 1;
END RECORD;
TYPE POINTER1 IS ACCESS INTEGER;
PACKAGE PACK1 IS
TYPE PACKACC IS ACCESS INTEGER;
AK1 : PACKACC := NEW INTEGER'(0);
TYPE PRIVY IS PRIVATE;
ZERO : CONSTANT PRIVY;
ONE : CONSTANT PRIVY;
TWO : CONSTANT PRIVY;
THREE : CONSTANT PRIVY;
FOUR : CONSTANT PRIVY;
FIVE : CONSTANT PRIVY;
FUNCTION IDENT (I : PRIVY) RETURN PRIVY;
FUNCTION NEXT (I : PRIVY) RETURN PRIVY;
PRIVATE
TYPE PRIVY IS RANGE 0..127;
ZERO : CONSTANT PRIVY := 0;
ONE : CONSTANT PRIVY := 1;
TWO : CONSTANT PRIVY := 2;
THREE : CONSTANT PRIVY := 3;
FOUR : CONSTANT PRIVY := 4;
FIVE : CONSTANT PRIVY := 5;
END PACK1;
TASK TYPE TASK1 IS
ENTRY ASSIGN (J : IN INTEGER);
ENTRY VALU (J : OUT INTEGER);
ENTRY NEXT;
ENTRY STOP;
END TASK1;
GENERIC
GI1 : IN OUT INTEGER;
GA1 : IN OUT ARRAY1;
GR1 : IN OUT RECORD1;
GP1 : IN OUT POINTER1;
GV1 : IN OUT PACK1.PRIVY;
GT1 : IN OUT TASK1;
GK1 : IN OUT INTEGER;
PACKAGE GENERIC1 IS
END GENERIC1;
FUNCTION IDENT (P : POINTER1) RETURN POINTER1 IS
BEGIN
IF EQUAL (3,3) THEN
RETURN P;
ELSE
RETURN NULL;
END IF;
END IDENT;
PACKAGE BODY PACK1 IS
FUNCTION IDENT (I : PRIVY) RETURN PRIVY IS
BEGIN
IF EQUAL(3,3) THEN
RETURN I;
ELSE
RETURN PRIVY'(0);
END IF;
END IDENT;
FUNCTION NEXT (I : PRIVY) RETURN PRIVY IS
BEGIN
RETURN I+1;
END NEXT;
END PACK1;
PACKAGE BODY GENERIC1 IS
BEGIN
GI1 := GI1 + 1;
GA1 := (GA1(1)+1, GA1(2)+1, GA1(3)+1);
GR1 := (D => 1, FIELD1 => GR1.FIELD1 + 1);
GP1 := NEW INTEGER'(GP1.ALL + 1);
GV1 := PACK1.NEXT(GV1);
GT1.NEXT;
GK1 := GK1 + 1;
END GENERIC1;
TASK BODY TASK1 IS
TASK_VALUE : INTEGER := 0;
ACCEPTING_ENTRIES : BOOLEAN := TRUE;
BEGIN
WHILE ACCEPTING_ENTRIES LOOP
SELECT
ACCEPT ASSIGN (J : IN INTEGER) DO
TASK_VALUE := J;
END ASSIGN;
OR
ACCEPT VALU (J : OUT INTEGER) DO
J := TASK_VALUE;
END VALU;
OR
ACCEPT NEXT DO
TASK_VALUE := TASK_VALUE + 1;
END NEXT;
OR
ACCEPT STOP DO
ACCEPTING_ENTRIES := FALSE;
END STOP;
END SELECT;
END LOOP;
END TASK1;
BEGIN
TEST ("C85005E", "CHECK THAT A VARIABLE CREATED BY AN ALLOCATOR " &
"CAN BE RENAMED AND HAS THE CORRECT VALUE, AND " &
"THAT THE NEW NAME CAN BE USED IN AN ASSIGNMENT" &
" STATEMENT AND PASSED ON AS AN ACTUAL " &
"SUBPROGRAM OR ENTRY 'IN OUT' OR 'OUT' " &
"PARAMETER, AND AS AN ACTUAL GENERIC 'IN OUT' " &
"PARAMETER, AND THAT WHEN THE VALUE OF THE " &
"RENAMED VARIABLE IS CHANGED, THE NEW VALUE " &
"IS REFLECTED BY THE VALUE OF THE NEW NAME");
DECLARE
TYPE ACCINT IS ACCESS INTEGER;
TYPE ACCARR IS ACCESS ARRAY1;
TYPE ACCREC IS ACCESS RECORD1;
TYPE ACCPTR IS ACCESS POINTER1;
TYPE ACCPVT IS ACCESS PACK1.PRIVY;
TYPE ACCTSK IS ACCESS TASK1;
AI1 : ACCINT := NEW INTEGER'(0);
AA1 : ACCARR := NEW ARRAY1'(0, 0, 0);
AR1 : ACCREC := NEW RECORD1'(D => 1, FIELD1 => 0);
AP1 : ACCPTR := NEW POINTER1'(NEW INTEGER'(0));
AV1 : ACCPVT := NEW PACK1.PRIVY'(PACK1.ZERO);
AT1 : ACCTSK := NEW TASK1;
XAI1 : INTEGER RENAMES AI1.ALL;
XAA1 : ARRAY1 RENAMES AA1.ALL;
XAR1 : RECORD1 RENAMES AR1.ALL;
XAP1 : POINTER1 RENAMES AP1.ALL;
XAV1 : PACK1.PRIVY RENAMES AV1.ALL;
XAK1 : INTEGER RENAMES PACK1.AK1.ALL;
XAT1 : TASK1 RENAMES AT1.ALL;
TASK TYPE TASK2 IS
ENTRY ENTRY1 (TI1 : OUT INTEGER; TA1 : OUT ARRAY1;
TR1 : OUT RECORD1; TP1 : IN OUT POINTER1;
TV1 : IN OUT PACK1.PRIVY;
TT1 : IN OUT TASK1; TK1 : IN OUT INTEGER);
END TASK2;
I : INTEGER;
A_CHK_TASK : TASK2;
PROCEDURE PROC1 (PI1 : IN OUT INTEGER; PA1 : IN OUT ARRAY1;
PR1 : IN OUT RECORD1; PP1 : OUT POINTER1;
PV1 : OUT PACK1.PRIVY; PT1 : IN OUT TASK1;
PK1 : OUT INTEGER) IS
BEGIN
PI1 := PI1 + 1;
PA1 := (PA1(1)+1, PA1(2)+1, PA1(3)+1);
PR1 := (D => 1, FIELD1 => PR1.FIELD1 + 1);
PP1 := NEW INTEGER'(AP1.ALL.ALL + 1);
PV1 := PACK1.NEXT(AV1.ALL);
PT1.NEXT;
PK1 := PACK1.AK1.ALL + 1;
END PROC1;
TASK BODY TASK2 IS
BEGIN
ACCEPT ENTRY1 (TI1 : OUT INTEGER; TA1 : OUT ARRAY1;
TR1 : OUT RECORD1; TP1 : IN OUT POINTER1;
TV1 : IN OUT PACK1.PRIVY;
TT1 : IN OUT TASK1;
TK1 : IN OUT INTEGER) DO
TI1 := AI1.ALL + 1;
TA1 := (AA1.ALL(1)+1, AA1.ALL(2)+1, AA1.ALL(3)+1);
TR1 := (D => 1, FIELD1 => AR1.ALL.FIELD1 + 1);
TP1 := NEW INTEGER'(TP1.ALL + 1);
TV1 := PACK1.NEXT(TV1);
TT1.NEXT;
TK1 := TK1 + 1;
END ENTRY1;
END TASK2;
PACKAGE GENPACK2 IS NEW
GENERIC1 (XAI1, XAA1, XAR1, XAP1, XAV1, XAT1, XAK1);
BEGIN
IF XAI1 /= IDENT_INT(1) THEN
FAILED ("INCORRECT VALUE OF XAI1 (1)");
END IF;
IF XAA1 /= (IDENT_INT(1),IDENT_INT(1),IDENT_INT(1)) THEN
FAILED ("INCORRECT VALUE OF XAA1 (1)");
END IF;
IF XAR1 /= (D => 1, FIELD1 => IDENT_INT(1)) THEN
FAILED ("INCORRECT VALUE OF XAR1 (1)");
END IF;
IF XAP1 /= IDENT(AP1.ALL) OR XAP1.ALL /= IDENT_INT(1) THEN
FAILED ("INCORRECT VALUE OF XAP1 (1)");
END IF;
IF PACK1."/=" (XAV1, PACK1.IDENT(PACK1.ONE)) THEN
FAILED ("INCORRECT VALUE OF XAV1 (1)");
END IF;
XAT1.VALU(I);
IF I /= IDENT_INT(1) THEN
FAILED ("INCORRECT RETURN VALUE OF XAT1.VALU (1)");
END IF;
IF XAK1 /= IDENT_INT(1) THEN
FAILED ("INCORRECT VALUE OF XAK1 (1)");
END IF;
PROC1(XAI1, XAA1, XAR1, XAP1, XAV1, XAT1, XAK1);
IF XAI1 /= IDENT_INT(2) THEN
FAILED ("INCORRECT VALUE OF XAI1 (2)");
END IF;
IF XAA1 /= (IDENT_INT(2),IDENT_INT(2),IDENT_INT(2)) THEN
FAILED ("INCORRECT VALUE OF XAA1 (2)");
END IF;
IF XAR1 /= (D => 1, FIELD1 => IDENT_INT(2)) THEN
FAILED ("INCORRECT VALUE OF XAR1 (2)");
END IF;
IF XAP1 /= IDENT(AP1.ALL) OR XAP1.ALL /= IDENT_INT(2) THEN
FAILED ("INCORRECT VALUE OF XAP1 (2)");
END IF;
IF PACK1."/=" (XAV1, PACK1.IDENT(PACK1.TWO)) THEN
FAILED ("INCORRECT VALUE OF XAV1 (2)");
END IF;
XAT1.VALU(I);
IF I /= IDENT_INT(2) THEN
FAILED ("INCORRECT RETURN VALUE OF XAT1.VALU (2)");
END IF;
IF XAK1 /= IDENT_INT(2) THEN
FAILED ("INCORRECT VALUE OF XAK1 (2)");
END IF;
A_CHK_TASK.ENTRY1(XAI1, XAA1, XAR1, XAP1, XAV1, XAT1, XAK1);
IF XAI1 /= IDENT_INT(3) THEN
FAILED ("INCORRECT VALUE OF XAI1 (3)");
END IF;
IF XAA1 /= (IDENT_INT(3),IDENT_INT(3),IDENT_INT(3)) THEN
FAILED ("INCORRECT VALUE OF XAA1 (3)");
END IF;
IF XAR1 /= (D => 1, FIELD1 => IDENT_INT(3)) THEN
FAILED ("INCORRECT VALUE OF XAR1 (3)");
END IF;
IF XAP1 /= IDENT(AP1.ALL) OR XAP1.ALL /= IDENT_INT(3) THEN
FAILED ("INCORRECT VALUE OF XAP1 (3)");
END IF;
IF PACK1."/=" (XAV1, PACK1.IDENT(PACK1.THREE)) THEN
FAILED ("INCORRECT VALUE OF XAV1 (3)");
END IF;
XAT1.VALU(I);
IF I /= IDENT_INT(3) THEN
FAILED ("INCORRECT RETURN VALUE OF XAT1.VALU (3)");
END IF;
IF XAK1 /= IDENT_INT(3) THEN
FAILED ("INCORRECT VALUE OF XAK1 (3)");
END IF;
XAI1 := XAI1 + 1;
XAA1 := (XAA1(1)+1, XAA1(2)+1, XAA1(3)+1);
XAR1 := (D => 1, FIELD1 => XAR1.FIELD1 + 1);
XAP1 := NEW INTEGER'(XAP1.ALL + 1);
XAV1 := PACK1.NEXT(XAV1);
XAT1.NEXT;
XAK1 := XAK1 + 1;
IF XAI1 /= IDENT_INT(4) THEN
FAILED ("INCORRECT VALUE OF XAI1 (4)");
END IF;
IF XAA1 /= (IDENT_INT(4),IDENT_INT(4),IDENT_INT(4)) THEN
FAILED ("INCORRECT VALUE OF XAA1 (4)");
END IF;
IF XAR1 /= (D => 1, FIELD1 => IDENT_INT(4)) THEN
FAILED ("INCORRECT VALUE OF XAR1 (4)");
END IF;
IF XAP1 /= IDENT(AP1.ALL) OR XAP1.ALL /= IDENT_INT(4) THEN
FAILED ("INCORRECT VALUE OF XAP1 (4)");
END IF;
IF PACK1."/=" (XAV1, PACK1.IDENT(PACK1.FOUR)) THEN
FAILED ("INCORRECT VALUE OF XAV1 (4)");
END IF;
XAT1.VALU(I);
IF I /= IDENT_INT(4) THEN
FAILED ("INCORRECT RETURN VALUE OF XAT1.VALU (4)");
END IF;
IF XAK1 /= IDENT_INT(4) THEN
FAILED ("INCORRECT VALUE OF XAK1 (4)");
END IF;
AI1.ALL := AI1.ALL + 1;
AA1.ALL := (AA1.ALL(1)+1, AA1.ALL(2)+1, AA1.ALL(3)+1);
AR1.ALL := (D => 1, FIELD1 => AR1.ALL.FIELD1 + 1);
AP1.ALL := NEW INTEGER'(AP1.ALL.ALL + 1);
AV1.ALL := PACK1.NEXT(AV1.ALL);
AT1.NEXT;
PACK1.AK1.ALL := PACK1.AK1.ALL + 1;
IF XAI1 /= IDENT_INT(5) THEN
FAILED ("INCORRECT VALUE OF XAI1 (5)");
END IF;
IF XAA1 /= (IDENT_INT(5),IDENT_INT(5),IDENT_INT(5)) THEN
FAILED ("INCORRECT VALUE OF XAA1 (5)");
END IF;
IF XAR1 /= (D => 1, FIELD1 => IDENT_INT(5)) THEN
FAILED ("INCORRECT VALUE OF XAR1 (5)");
END IF;
IF XAP1 /= IDENT(AP1.ALL) OR XAP1.ALL /= IDENT_INT(5) THEN
FAILED ("INCORRECT VALUE OF XAP1 (5)");
END IF;
IF PACK1."/=" (XAV1, PACK1.IDENT(PACK1.FIVE)) THEN
FAILED ("INCORRECT VALUE OF XAV1 (5)");
END IF;
XAT1.VALU(I);
IF I /= IDENT_INT(5) THEN
FAILED ("INCORRECT RETURN VALUE OF XAT1.VALU (5)");
END IF;
IF XAK1 /= IDENT_INT(5) THEN
FAILED ("INCORRECT VALUE OF XAK1 (5)");
END IF;
AT1.STOP;
END;
RESULT;
END C85005E;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Arduino_Nano_33_Ble_Sense.IOs;
with Ada.Real_Time; use Ada.Real_Time;
procedure Main is
TimeNow : Ada.Real_Time.Time := Ada.Real_Time.Clock;
begin
loop
--6 13 41 16 24
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(13, True);
TimeNow := Ada.Real_Time.Clock;
delay until TimeNow + Ada.Real_Time.Milliseconds(50);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(41, True);
TimeNow := Ada.Real_Time.Clock;
delay until TimeNow + Ada.Real_Time.Milliseconds(50);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(6, False);
TimeNow := Ada.Real_Time.Clock;
delay until TimeNow + Ada.Real_Time.Milliseconds(50);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(13, False);
TimeNow := Ada.Real_Time.Clock;
delay until TimeNow + Ada.Real_Time.Milliseconds(50);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(41, False);
TimeNow := Ada.Real_Time.Clock;
delay until TimeNow + Ada.Real_Time.Milliseconds(50);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(6, True);
TimeNow := Ada.Real_Time.Clock;
delay until TimeNow + Ada.Real_Time.Milliseconds(50);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(13, True);
TimeNow := Ada.Real_Time.Clock;
delay until TimeNow + Ada.Real_Time.Milliseconds(50);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(41, True);
TimeNow := Ada.Real_Time.Clock;
delay until TimeNow + Ada.Real_Time.Milliseconds(50);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(16, False);
TimeNow := Ada.Real_Time.Clock;
delay until TimeNow + Ada.Real_Time.Milliseconds(50);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(13, False);
TimeNow := Ada.Real_Time.Clock;
delay until TimeNow + Ada.Real_Time.Milliseconds(50);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(41, False);
TimeNow := Ada.Real_Time.Clock;
delay until TimeNow + Ada.Real_Time.Milliseconds(50);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(16, True);
TimeNow := Ada.Real_Time.Clock;
delay until TimeNow + Ada.Real_Time.Milliseconds(50);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(13, True);
TimeNow := Ada.Real_Time.Clock;
delay until TimeNow + Ada.Real_Time.Milliseconds(50);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(41, True);
TimeNow := Ada.Real_Time.Clock;
delay until TimeNow + Ada.Real_Time.Milliseconds(50);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(24, False);
TimeNow := Ada.Real_Time.Clock;
delay until TimeNow + Ada.Real_Time.Milliseconds(50);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(13, False);
TimeNow := Ada.Real_Time.Clock;
delay until TimeNow + Ada.Real_Time.Milliseconds(50);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(41, False);
TimeNow := Ada.Real_Time.Clock;
delay until TimeNow + Ada.Real_Time.Milliseconds(50);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(24, True);
TimeNow := Ada.Real_Time.Clock;
delay until TimeNow + Ada.Real_Time.Milliseconds(50);
end loop;
end Main;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This unit exposes the low level vector support for the Hard binding,
-- intended for AltiVec capable targets. See Altivec.Design for a description
-- of what is expected to be exposed.
package GNAT.Altivec.Low_Level_Vectors is
pragma Elaborate_Body;
----------------------------------------
-- Low-level Vector Type Declarations --
----------------------------------------
type LL_VUC is private;
type LL_VSC is private;
type LL_VBC is private;
type LL_VUS is private;
type LL_VSS is private;
type LL_VBS is private;
type LL_VUI is private;
type LL_VSI is private;
type LL_VBI is private;
type LL_VF is private;
type LL_VP is private;
------------------------------------
-- Low-level Functional Interface --
------------------------------------
function abs_v16qi (A : LL_VSC) return LL_VSC;
function abs_v8hi (A : LL_VSS) return LL_VSS;
function abs_v4si (A : LL_VSI) return LL_VSI;
function abs_v4sf (A : LL_VF) return LL_VF;
function abss_v16qi (A : LL_VSC) return LL_VSC;
function abss_v8hi (A : LL_VSS) return LL_VSS;
function abss_v4si (A : LL_VSI) return LL_VSI;
function vaddubm (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vadduhm (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vadduwm (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vaddfp (A : LL_VF; B : LL_VF) return LL_VF;
function vaddcuw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vaddubs (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vaddsbs (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vadduhs (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vaddshs (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vadduws (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vaddsws (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vand (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vandc (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vavgub (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vavgsb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vavguh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vavgsh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vavguw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vavgsw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vcmpbfp (A : LL_VF; B : LL_VF) return LL_VSI;
function vcmpequb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vcmpequh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vcmpequw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vcmpeqfp (A : LL_VF; B : LL_VF) return LL_VF;
function vcmpgefp (A : LL_VF; B : LL_VF) return LL_VF;
function vcmpgtub (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vcmpgtsb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vcmpgtuh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vcmpgtsh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vcmpgtuw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vcmpgtsw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vcmpgtfp (A : LL_VF; B : LL_VF) return LL_VF;
function vcfux (A : LL_VUI; B : c_int) return LL_VF;
function vcfsx (A : LL_VSI; B : c_int) return LL_VF;
function vctsxs (A : LL_VF; B : c_int) return LL_VSI;
function vctuxs (A : LL_VF; B : c_int) return LL_VUI;
procedure dss (A : c_int);
procedure dssall;
procedure dst (A : c_ptr; B : c_int; C : c_int);
procedure dstst (A : c_ptr; B : c_int; C : c_int);
procedure dststt (A : c_ptr; B : c_int; C : c_int);
procedure dstt (A : c_ptr; B : c_int; C : c_int);
function vexptefp (A : LL_VF) return LL_VF;
function vrfim (A : LL_VF) return LL_VF;
function lvx (A : c_long; B : c_ptr) return LL_VSI;
function lvebx (A : c_long; B : c_ptr) return LL_VSC;
function lvehx (A : c_long; B : c_ptr) return LL_VSS;
function lvewx (A : c_long; B : c_ptr) return LL_VSI;
function lvxl (A : c_long; B : c_ptr) return LL_VSI;
function vlogefp (A : LL_VF) return LL_VF;
function lvsl (A : c_long; B : c_ptr) return LL_VSC;
function lvsr (A : c_long; B : c_ptr) return LL_VSC;
function vmaddfp (A : LL_VF; B : LL_VF; C : LL_VF) return LL_VF;
function vmhaddshs (A : LL_VSS; B : LL_VSS; C : LL_VSS) return LL_VSS;
function vmaxub (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vmaxsb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vmaxuh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vmaxsh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vmaxuw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vmaxsw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vmaxfp (A : LL_VF; B : LL_VF) return LL_VF;
function vmrghb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vmrghh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vmrghw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vmrglb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vmrglh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vmrglw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function mfvscr return LL_VSS;
function vminfp (A : LL_VF; B : LL_VF) return LL_VF;
function vminsb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vminsh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vminsw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vminub (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vminuh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vminuw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vmladduhm (A : LL_VSS; B : LL_VSS; C : LL_VSS) return LL_VSS;
function vmhraddshs (A : LL_VSS; B : LL_VSS; C : LL_VSS) return LL_VSS;
function vmsumubm (A : LL_VSC; B : LL_VSC; C : LL_VSI) return LL_VSI;
function vmsummbm (A : LL_VSC; B : LL_VSC; C : LL_VSI) return LL_VSI;
function vmsumuhm (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI;
function vmsumshm (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI;
function vmsumuhs (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI;
function vmsumshs (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI;
procedure mtvscr (A : LL_VSI);
function vmuleub (A : LL_VSC; B : LL_VSC) return LL_VSS;
function vmuleuh (A : LL_VSS; B : LL_VSS) return LL_VSI;
function vmulesb (A : LL_VSC; B : LL_VSC) return LL_VSS;
function vmulesh (A : LL_VSS; B : LL_VSS) return LL_VSI;
function vmulosb (A : LL_VSC; B : LL_VSC) return LL_VSS;
function vmulosh (A : LL_VSS; B : LL_VSS) return LL_VSI;
function vmuloub (A : LL_VSC; B : LL_VSC) return LL_VSS;
function vmulouh (A : LL_VSS; B : LL_VSS) return LL_VSI;
function vnmsubfp (A : LL_VF; B : LL_VF; C : LL_VF) return LL_VF;
function vxor (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vnor (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vor (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vpkuhum (A : LL_VSS; B : LL_VSS) return LL_VSC;
function vpkuwum (A : LL_VSI; B : LL_VSI) return LL_VSS;
function vpkpx (A : LL_VSI; B : LL_VSI) return LL_VSS;
function vpkuhus (A : LL_VSS; B : LL_VSS) return LL_VSC;
function vpkuwus (A : LL_VSI; B : LL_VSI) return LL_VSS;
function vpkshss (A : LL_VSS; B : LL_VSS) return LL_VSC;
function vpkswss (A : LL_VSI; B : LL_VSI) return LL_VSS;
function vpkshus (A : LL_VSS; B : LL_VSS) return LL_VSC;
function vpkswus (A : LL_VSI; B : LL_VSI) return LL_VSS;
function vperm_4si (A : LL_VSI; B : LL_VSI; C : LL_VSC) return LL_VSI;
function vrefp (A : LL_VF) return LL_VF;
function vrlb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vrlh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vrlw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vrfin (A : LL_VF) return LL_VF;
function vrfip (A : LL_VF) return LL_VF;
function vrfiz (A : LL_VF) return LL_VF;
function vrsqrtefp (A : LL_VF) return LL_VF;
function vsel_4si (A : LL_VSI; B : LL_VSI; C : LL_VSI) return LL_VSI;
function vslb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vslh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vslw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsldoi_4si (A : LL_VSI; B : LL_VSI; C : c_int) return LL_VSI;
function vsldoi_8hi (A : LL_VSS; B : LL_VSS; C : c_int) return LL_VSS;
function vsldoi_16qi (A : LL_VSC; B : LL_VSC; C : c_int) return LL_VSC;
function vsldoi_4sf (A : LL_VF; B : LL_VF; C : c_int) return LL_VF;
function vsl (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vslo (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vspltb (A : LL_VSC; B : c_int) return LL_VSC;
function vsplth (A : LL_VSS; B : c_int) return LL_VSS;
function vspltw (A : LL_VSI; B : c_int) return LL_VSI;
function vspltisb (A : c_int) return LL_VSC;
function vspltish (A : c_int) return LL_VSS;
function vspltisw (A : c_int) return LL_VSI;
function vsrb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vsrh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vsrw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsrab (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vsrah (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vsraw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsr (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsro (A : LL_VSI; B : LL_VSI) return LL_VSI;
procedure stvx (A : LL_VSI; B : c_int; C : c_ptr);
procedure stvebx (A : LL_VSC; B : c_int; C : c_ptr);
procedure stvehx (A : LL_VSS; B : c_int; C : c_ptr);
procedure stvewx (A : LL_VSI; B : c_int; C : c_ptr);
procedure stvxl (A : LL_VSI; B : c_int; C : c_ptr);
function vsububm (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vsubuhm (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vsubuwm (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsubfp (A : LL_VF; B : LL_VF) return LL_VF;
function vsubcuw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsububs (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vsubsbs (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vsubuhs (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vsubshs (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vsubuws (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsubsws (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsum4ubs (A : LL_VSC; B : LL_VSI) return LL_VSI;
function vsum4sbs (A : LL_VSC; B : LL_VSI) return LL_VSI;
function vsum4shs (A : LL_VSS; B : LL_VSI) return LL_VSI;
function vsum2sws (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsumsws (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vupkhsb (A : LL_VSC) return LL_VSS;
function vupkhsh (A : LL_VSS) return LL_VSI;
function vupkhpx (A : LL_VSS) return LL_VSI;
function vupklsb (A : LL_VSC) return LL_VSS;
function vupklsh (A : LL_VSS) return LL_VSI;
function vupklpx (A : LL_VSS) return LL_VSI;
function vcmpequb_p (A : c_int; B : LL_VSC; C : LL_VSC) return c_int;
function vcmpequh_p (A : c_int; B : LL_VSS; C : LL_VSS) return c_int;
function vcmpequw_p (A : c_int; B : LL_VSI; C : LL_VSI) return c_int;
function vcmpeqfp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int;
function vcmpgtub_p (A : c_int; B : LL_VSC; C : LL_VSC) return c_int;
function vcmpgtuh_p (A : c_int; B : LL_VSS; C : LL_VSS) return c_int;
function vcmpgtuw_p (A : c_int; B : LL_VSI; C : LL_VSI) return c_int;
function vcmpgtsb_p (A : c_int; B : LL_VSC; C : LL_VSC) return c_int;
function vcmpgtsh_p (A : c_int; B : LL_VSS; C : LL_VSS) return c_int;
function vcmpgtsw_p (A : c_int; B : LL_VSI; C : LL_VSI) return c_int;
function vcmpgtfp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int;
function vcmpgefp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int;
function vcmpbfp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int;
private
---------------------------------------
-- Low-level Vector Type Definitions --
---------------------------------------
-- [PIM-2.3.3 Alignment of aggregate and unions containing vector types]:
-- "Aggregates (structures and arrays) and unions containing vector
-- types must be aligned on 16-byte boundaries and their internal
-- organization padded, if necessary, so that each internal vector
-- type is aligned on a 16-byte boundary. This is an extension to
-- all ABIs (AIX, Apple, SVR4, and EABI).
--------------------------
-- char Core Components --
--------------------------
type LL_VUC is array (1 .. 16) of unsigned_char;
for LL_VUC'Alignment use VECTOR_ALIGNMENT;
pragma Machine_Attribute (LL_VUC, "vector_type");
pragma Suppress (All_Checks, LL_VUC);
type LL_VSC is array (1 .. 16) of signed_char;
for LL_VSC'Alignment use VECTOR_ALIGNMENT;
pragma Machine_Attribute (LL_VSC, "vector_type");
pragma Suppress (All_Checks, LL_VSC);
type LL_VBC is array (1 .. 16) of unsigned_char;
for LL_VBC'Alignment use VECTOR_ALIGNMENT;
pragma Machine_Attribute (LL_VBC, "vector_type");
pragma Suppress (All_Checks, LL_VBC);
---------------------------
-- short Core Components --
---------------------------
type LL_VUS is array (1 .. 8) of unsigned_short;
for LL_VUS'Alignment use VECTOR_ALIGNMENT;
pragma Machine_Attribute (LL_VUS, "vector_type");
pragma Suppress (All_Checks, LL_VUS);
type LL_VSS is array (1 .. 8) of signed_short;
for LL_VSS'Alignment use VECTOR_ALIGNMENT;
pragma Machine_Attribute (LL_VSS, "vector_type");
pragma Suppress (All_Checks, LL_VSS);
type LL_VBS is array (1 .. 8) of unsigned_short;
for LL_VBS'Alignment use VECTOR_ALIGNMENT;
pragma Machine_Attribute (LL_VBS, "vector_type");
pragma Suppress (All_Checks, LL_VBS);
-------------------------
-- int Core Components --
-------------------------
type LL_VUI is array (1 .. 4) of unsigned_int;
for LL_VUI'Alignment use VECTOR_ALIGNMENT;
pragma Machine_Attribute (LL_VUI, "vector_type");
pragma Suppress (All_Checks, LL_VUI);
type LL_VSI is array (1 .. 4) of signed_int;
for LL_VSI'Alignment use VECTOR_ALIGNMENT;
pragma Machine_Attribute (LL_VSI, "vector_type");
pragma Suppress (All_Checks, LL_VSI);
type LL_VBI is array (1 .. 4) of unsigned_int;
for LL_VBI'Alignment use VECTOR_ALIGNMENT;
pragma Machine_Attribute (LL_VBI, "vector_type");
pragma Suppress (All_Checks, LL_VBI);
---------------------------
-- Float Core Components --
---------------------------
type LL_VF is array (1 .. 4) of Float;
for LL_VF'Alignment use VECTOR_ALIGNMENT;
pragma Machine_Attribute (LL_VF, "vector_type");
pragma Suppress (All_Checks, LL_VF);
---------------------------
-- pixel Core Components --
---------------------------
type LL_VP is array (1 .. 8) of pixel;
for LL_VP'Alignment use VECTOR_ALIGNMENT;
pragma Machine_Attribute (LL_VP, "vector_type");
pragma Suppress (All_Checks, LL_VP);
------------------------------------
-- Low-level Functional Interface --
------------------------------------
-- The functions we have to expose here are exactly those for which
-- GCC builtins are available. Calls to these functions will be turned
-- into real AltiVec instructions by the GCC back-end.
pragma Convention_Identifier (LL_Altivec, Intrinsic);
pragma Import (LL_Altivec, dss, "__builtin_altivec_dss");
pragma Import (LL_Altivec, dssall, "__builtin_altivec_dssall");
pragma Import (LL_Altivec, dst, "__builtin_altivec_dst");
pragma Import (LL_Altivec, dstst, "__builtin_altivec_dstst");
pragma Import (LL_Altivec, dststt, "__builtin_altivec_dststt");
pragma Import (LL_Altivec, dstt, "__builtin_altivec_dstt");
pragma Import (LL_Altivec, mtvscr, "__builtin_altivec_mtvscr");
pragma Import (LL_Altivec, mfvscr, "__builtin_altivec_mfvscr");
pragma Import (LL_Altivec, stvebx, "__builtin_altivec_stvebx");
pragma Import (LL_Altivec, stvehx, "__builtin_altivec_stvehx");
pragma Import (LL_Altivec, stvewx, "__builtin_altivec_stvewx");
pragma Import (LL_Altivec, stvx, "__builtin_altivec_stvx");
pragma Import (LL_Altivec, stvxl, "__builtin_altivec_stvxl");
pragma Import (LL_Altivec, lvebx, "__builtin_altivec_lvebx");
pragma Import (LL_Altivec, lvehx, "__builtin_altivec_lvehx");
pragma Import (LL_Altivec, lvewx, "__builtin_altivec_lvewx");
pragma Import (LL_Altivec, lvx, "__builtin_altivec_lvx");
pragma Import (LL_Altivec, lvxl, "__builtin_altivec_lvxl");
pragma Import (LL_Altivec, lvsl, "__builtin_altivec_lvsl");
pragma Import (LL_Altivec, lvsr, "__builtin_altivec_lvsr");
pragma Import (LL_Altivec, abs_v16qi, "__builtin_altivec_abs_v16qi");
pragma Import (LL_Altivec, abs_v8hi, "__builtin_altivec_abs_v8hi");
pragma Import (LL_Altivec, abs_v4si, "__builtin_altivec_abs_v4si");
pragma Import (LL_Altivec, abs_v4sf, "__builtin_altivec_abs_v4sf");
pragma Import (LL_Altivec, abss_v16qi, "__builtin_altivec_abss_v16qi");
pragma Import (LL_Altivec, abss_v8hi, "__builtin_altivec_abss_v8hi");
pragma Import (LL_Altivec, abss_v4si, "__builtin_altivec_abss_v4si");
pragma Import (LL_Altivec, vaddcuw, "__builtin_altivec_vaddcuw");
pragma Import (LL_Altivec, vaddfp, "__builtin_altivec_vaddfp");
pragma Import (LL_Altivec, vaddsbs, "__builtin_altivec_vaddsbs");
pragma Import (LL_Altivec, vaddshs, "__builtin_altivec_vaddshs");
pragma Import (LL_Altivec, vaddsws, "__builtin_altivec_vaddsws");
pragma Import (LL_Altivec, vaddubm, "__builtin_altivec_vaddubm");
pragma Import (LL_Altivec, vaddubs, "__builtin_altivec_vaddubs");
pragma Import (LL_Altivec, vadduhm, "__builtin_altivec_vadduhm");
pragma Import (LL_Altivec, vadduhs, "__builtin_altivec_vadduhs");
pragma Import (LL_Altivec, vadduwm, "__builtin_altivec_vadduwm");
pragma Import (LL_Altivec, vadduws, "__builtin_altivec_vadduws");
pragma Import (LL_Altivec, vand, "__builtin_altivec_vand");
pragma Import (LL_Altivec, vandc, "__builtin_altivec_vandc");
pragma Import (LL_Altivec, vavgsb, "__builtin_altivec_vavgsb");
pragma Import (LL_Altivec, vavgsh, "__builtin_altivec_vavgsh");
pragma Import (LL_Altivec, vavgsw, "__builtin_altivec_vavgsw");
pragma Import (LL_Altivec, vavgub, "__builtin_altivec_vavgub");
pragma Import (LL_Altivec, vavguh, "__builtin_altivec_vavguh");
pragma Import (LL_Altivec, vavguw, "__builtin_altivec_vavguw");
pragma Import (LL_Altivec, vcfsx, "__builtin_altivec_vcfsx");
pragma Import (LL_Altivec, vcfux, "__builtin_altivec_vcfux");
pragma Import (LL_Altivec, vcmpbfp, "__builtin_altivec_vcmpbfp");
pragma Import (LL_Altivec, vcmpeqfp, "__builtin_altivec_vcmpeqfp");
pragma Import (LL_Altivec, vcmpequb, "__builtin_altivec_vcmpequb");
pragma Import (LL_Altivec, vcmpequh, "__builtin_altivec_vcmpequh");
pragma Import (LL_Altivec, vcmpequw, "__builtin_altivec_vcmpequw");
pragma Import (LL_Altivec, vcmpgefp, "__builtin_altivec_vcmpgefp");
pragma Import (LL_Altivec, vcmpgtfp, "__builtin_altivec_vcmpgtfp");
pragma Import (LL_Altivec, vcmpgtsb, "__builtin_altivec_vcmpgtsb");
pragma Import (LL_Altivec, vcmpgtsh, "__builtin_altivec_vcmpgtsh");
pragma Import (LL_Altivec, vcmpgtsw, "__builtin_altivec_vcmpgtsw");
pragma Import (LL_Altivec, vcmpgtub, "__builtin_altivec_vcmpgtub");
pragma Import (LL_Altivec, vcmpgtuh, "__builtin_altivec_vcmpgtuh");
pragma Import (LL_Altivec, vcmpgtuw, "__builtin_altivec_vcmpgtuw");
pragma Import (LL_Altivec, vctsxs, "__builtin_altivec_vctsxs");
pragma Import (LL_Altivec, vctuxs, "__builtin_altivec_vctuxs");
pragma Import (LL_Altivec, vexptefp, "__builtin_altivec_vexptefp");
pragma Import (LL_Altivec, vlogefp, "__builtin_altivec_vlogefp");
pragma Import (LL_Altivec, vmaddfp, "__builtin_altivec_vmaddfp");
pragma Import (LL_Altivec, vmaxfp, "__builtin_altivec_vmaxfp");
pragma Import (LL_Altivec, vmaxsb, "__builtin_altivec_vmaxsb");
pragma Import (LL_Altivec, vmaxsh, "__builtin_altivec_vmaxsh");
pragma Import (LL_Altivec, vmaxsw, "__builtin_altivec_vmaxsw");
pragma Import (LL_Altivec, vmaxub, "__builtin_altivec_vmaxub");
pragma Import (LL_Altivec, vmaxuh, "__builtin_altivec_vmaxuh");
pragma Import (LL_Altivec, vmaxuw, "__builtin_altivec_vmaxuw");
pragma Import (LL_Altivec, vmhaddshs, "__builtin_altivec_vmhaddshs");
pragma Import (LL_Altivec, vmhraddshs, "__builtin_altivec_vmhraddshs");
pragma Import (LL_Altivec, vminfp, "__builtin_altivec_vminfp");
pragma Import (LL_Altivec, vminsb, "__builtin_altivec_vminsb");
pragma Import (LL_Altivec, vminsh, "__builtin_altivec_vminsh");
pragma Import (LL_Altivec, vminsw, "__builtin_altivec_vminsw");
pragma Import (LL_Altivec, vminub, "__builtin_altivec_vminub");
pragma Import (LL_Altivec, vminuh, "__builtin_altivec_vminuh");
pragma Import (LL_Altivec, vminuw, "__builtin_altivec_vminuw");
pragma Import (LL_Altivec, vmladduhm, "__builtin_altivec_vmladduhm");
pragma Import (LL_Altivec, vmrghb, "__builtin_altivec_vmrghb");
pragma Import (LL_Altivec, vmrghh, "__builtin_altivec_vmrghh");
pragma Import (LL_Altivec, vmrghw, "__builtin_altivec_vmrghw");
pragma Import (LL_Altivec, vmrglb, "__builtin_altivec_vmrglb");
pragma Import (LL_Altivec, vmrglh, "__builtin_altivec_vmrglh");
pragma Import (LL_Altivec, vmrglw, "__builtin_altivec_vmrglw");
pragma Import (LL_Altivec, vmsummbm, "__builtin_altivec_vmsummbm");
pragma Import (LL_Altivec, vmsumshm, "__builtin_altivec_vmsumshm");
pragma Import (LL_Altivec, vmsumshs, "__builtin_altivec_vmsumshs");
pragma Import (LL_Altivec, vmsumubm, "__builtin_altivec_vmsumubm");
pragma Import (LL_Altivec, vmsumuhm, "__builtin_altivec_vmsumuhm");
pragma Import (LL_Altivec, vmsumuhs, "__builtin_altivec_vmsumuhs");
pragma Import (LL_Altivec, vmulesb, "__builtin_altivec_vmulesb");
pragma Import (LL_Altivec, vmulesh, "__builtin_altivec_vmulesh");
pragma Import (LL_Altivec, vmuleub, "__builtin_altivec_vmuleub");
pragma Import (LL_Altivec, vmuleuh, "__builtin_altivec_vmuleuh");
pragma Import (LL_Altivec, vmulosb, "__builtin_altivec_vmulosb");
pragma Import (LL_Altivec, vmulosh, "__builtin_altivec_vmulosh");
pragma Import (LL_Altivec, vmuloub, "__builtin_altivec_vmuloub");
pragma Import (LL_Altivec, vmulouh, "__builtin_altivec_vmulouh");
pragma Import (LL_Altivec, vnmsubfp, "__builtin_altivec_vnmsubfp");
pragma Import (LL_Altivec, vnor, "__builtin_altivec_vnor");
pragma Import (LL_Altivec, vxor, "__builtin_altivec_vxor");
pragma Import (LL_Altivec, vor, "__builtin_altivec_vor");
pragma Import (LL_Altivec, vperm_4si, "__builtin_altivec_vperm_4si");
pragma Import (LL_Altivec, vpkpx, "__builtin_altivec_vpkpx");
pragma Import (LL_Altivec, vpkshss, "__builtin_altivec_vpkshss");
pragma Import (LL_Altivec, vpkshus, "__builtin_altivec_vpkshus");
pragma Import (LL_Altivec, vpkswss, "__builtin_altivec_vpkswss");
pragma Import (LL_Altivec, vpkswus, "__builtin_altivec_vpkswus");
pragma Import (LL_Altivec, vpkuhum, "__builtin_altivec_vpkuhum");
pragma Import (LL_Altivec, vpkuhus, "__builtin_altivec_vpkuhus");
pragma Import (LL_Altivec, vpkuwum, "__builtin_altivec_vpkuwum");
pragma Import (LL_Altivec, vpkuwus, "__builtin_altivec_vpkuwus");
pragma Import (LL_Altivec, vrefp, "__builtin_altivec_vrefp");
pragma Import (LL_Altivec, vrfim, "__builtin_altivec_vrfim");
pragma Import (LL_Altivec, vrfin, "__builtin_altivec_vrfin");
pragma Import (LL_Altivec, vrfip, "__builtin_altivec_vrfip");
pragma Import (LL_Altivec, vrfiz, "__builtin_altivec_vrfiz");
pragma Import (LL_Altivec, vrlb, "__builtin_altivec_vrlb");
pragma Import (LL_Altivec, vrlh, "__builtin_altivec_vrlh");
pragma Import (LL_Altivec, vrlw, "__builtin_altivec_vrlw");
pragma Import (LL_Altivec, vrsqrtefp, "__builtin_altivec_vrsqrtefp");
pragma Import (LL_Altivec, vsel_4si, "__builtin_altivec_vsel_4si");
pragma Import (LL_Altivec, vsldoi_4si, "__builtin_altivec_vsldoi_4si");
pragma Import (LL_Altivec, vsldoi_8hi, "__builtin_altivec_vsldoi_8hi");
pragma Import (LL_Altivec, vsldoi_16qi, "__builtin_altivec_vsldoi_16qi");
pragma Import (LL_Altivec, vsldoi_4sf, "__builtin_altivec_vsldoi_4sf");
pragma Import (LL_Altivec, vsl, "__builtin_altivec_vsl");
pragma Import (LL_Altivec, vslb, "__builtin_altivec_vslb");
pragma Import (LL_Altivec, vslh, "__builtin_altivec_vslh");
pragma Import (LL_Altivec, vslo, "__builtin_altivec_vslo");
pragma Import (LL_Altivec, vslw, "__builtin_altivec_vslw");
pragma Import (LL_Altivec, vspltb, "__builtin_altivec_vspltb");
pragma Import (LL_Altivec, vsplth, "__builtin_altivec_vsplth");
pragma Import (LL_Altivec, vspltisb, "__builtin_altivec_vspltisb");
pragma Import (LL_Altivec, vspltish, "__builtin_altivec_vspltish");
pragma Import (LL_Altivec, vspltisw, "__builtin_altivec_vspltisw");
pragma Import (LL_Altivec, vspltw, "__builtin_altivec_vspltw");
pragma Import (LL_Altivec, vsr, "__builtin_altivec_vsr");
pragma Import (LL_Altivec, vsrab, "__builtin_altivec_vsrab");
pragma Import (LL_Altivec, vsrah, "__builtin_altivec_vsrah");
pragma Import (LL_Altivec, vsraw, "__builtin_altivec_vsraw");
pragma Import (LL_Altivec, vsrb, "__builtin_altivec_vsrb");
pragma Import (LL_Altivec, vsrh, "__builtin_altivec_vsrh");
pragma Import (LL_Altivec, vsro, "__builtin_altivec_vsro");
pragma Import (LL_Altivec, vsrw, "__builtin_altivec_vsrw");
pragma Import (LL_Altivec, vsubcuw, "__builtin_altivec_vsubcuw");
pragma Import (LL_Altivec, vsubfp, "__builtin_altivec_vsubfp");
pragma Import (LL_Altivec, vsubsbs, "__builtin_altivec_vsubsbs");
pragma Import (LL_Altivec, vsubshs, "__builtin_altivec_vsubshs");
pragma Import (LL_Altivec, vsubsws, "__builtin_altivec_vsubsws");
pragma Import (LL_Altivec, vsububm, "__builtin_altivec_vsububm");
pragma Import (LL_Altivec, vsububs, "__builtin_altivec_vsububs");
pragma Import (LL_Altivec, vsubuhm, "__builtin_altivec_vsubuhm");
pragma Import (LL_Altivec, vsubuhs, "__builtin_altivec_vsubuhs");
pragma Import (LL_Altivec, vsubuwm, "__builtin_altivec_vsubuwm");
pragma Import (LL_Altivec, vsubuws, "__builtin_altivec_vsubuws");
pragma Import (LL_Altivec, vsum2sws, "__builtin_altivec_vsum2sws");
pragma Import (LL_Altivec, vsum4sbs, "__builtin_altivec_vsum4sbs");
pragma Import (LL_Altivec, vsum4shs, "__builtin_altivec_vsum4shs");
pragma Import (LL_Altivec, vsum4ubs, "__builtin_altivec_vsum4ubs");
pragma Import (LL_Altivec, vsumsws, "__builtin_altivec_vsumsws");
pragma Import (LL_Altivec, vupkhpx, "__builtin_altivec_vupkhpx");
pragma Import (LL_Altivec, vupkhsb, "__builtin_altivec_vupkhsb");
pragma Import (LL_Altivec, vupkhsh, "__builtin_altivec_vupkhsh");
pragma Import (LL_Altivec, vupklpx, "__builtin_altivec_vupklpx");
pragma Import (LL_Altivec, vupklsb, "__builtin_altivec_vupklsb");
pragma Import (LL_Altivec, vupklsh, "__builtin_altivec_vupklsh");
pragma Import (LL_Altivec, vcmpbfp_p, "__builtin_altivec_vcmpbfp_p");
pragma Import (LL_Altivec, vcmpeqfp_p, "__builtin_altivec_vcmpeqfp_p");
pragma Import (LL_Altivec, vcmpgefp_p, "__builtin_altivec_vcmpgefp_p");
pragma Import (LL_Altivec, vcmpgtfp_p, "__builtin_altivec_vcmpgtfp_p");
pragma Import (LL_Altivec, vcmpequw_p, "__builtin_altivec_vcmpequw_p");
pragma Import (LL_Altivec, vcmpgtsw_p, "__builtin_altivec_vcmpgtsw_p");
pragma Import (LL_Altivec, vcmpgtuw_p, "__builtin_altivec_vcmpgtuw_p");
pragma Import (LL_Altivec, vcmpgtuh_p, "__builtin_altivec_vcmpgtuh_p");
pragma Import (LL_Altivec, vcmpgtsh_p, "__builtin_altivec_vcmpgtsh_p");
pragma Import (LL_Altivec, vcmpequh_p, "__builtin_altivec_vcmpequh_p");
pragma Import (LL_Altivec, vcmpequb_p, "__builtin_altivec_vcmpequb_p");
pragma Import (LL_Altivec, vcmpgtsb_p, "__builtin_altivec_vcmpgtsb_p");
pragma Import (LL_Altivec, vcmpgtub_p, "__builtin_altivec_vcmpgtub_p");
end GNAT.Altivec.Low_Level_Vectors;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with System;
with Interfaces.C.Strings;
package AdaBase.Bindings.SQLite is
pragma Preelaborate;
package SYS renames System;
package IC renames Interfaces.C;
package ICS renames Interfaces.C.Strings;
------------------------
-- Type Definitions --
------------------------
type sql64 is new Interfaces.Integer_64;
type sqlite3 is limited private;
type sqlite3_Access is access all sqlite3;
pragma Convention (C, sqlite3_Access);
type sqlite3_stmt is limited private;
type sqlite3_stmt_Access is access all sqlite3_stmt;
pragma Convention (C, sqlite3_stmt_Access);
type sqlite3_destructor is access procedure (text : ICS.char_array_access);
pragma Convention (C, sqlite3_destructor);
---------------
-- Constants --
---------------
type enum_field_types is
(SQLITE_INTEGER,
SQLITE_FLOAT,
SQLITE_TEXT,
SQLITE_BLOB,
SQLITE_NULL);
pragma Convention (C, enum_field_types);
for enum_field_types use
(SQLITE_INTEGER => 1,
SQLITE_FLOAT => 2,
SQLITE_TEXT => 3,
SQLITE_BLOB => 4,
SQLITE_NULL => 5);
SQLITE_OK : constant := 0; -- Successful result
SQLITE_ROW : constant := 100; -- sqlite3_step() has another row ready
SQLITE_DONE : constant := 101; -- sqlite3_step() has finished executing
SQLITE_CONFIG_SINGLETHREAD : constant := 1; -- nil
SQLITE_CONFIG_MULTITHREAD : constant := 2; -- nil
SQLITE_CONFIG_SERIALIZED : constant := 3; -- nil
SQLITE_STATIC : constant IC.int := IC.int (0);
SQLITE_TRANSIENT : constant IC.int := IC.int (-1);
---------------------
-- Library Calls --
----------------------
-- For now, only support SQLITE_STATIC and SQLITE_TRANSIENT at the
-- cost of sqlite3_destructor. Shame on them mixing pointers and integers
-- Applies to bind_text and bind_blob
function sqlite3_bind_text (Handle : sqlite3_stmt_Access;
Index : IC.int;
Text : ICS.chars_ptr;
nBytes : IC.int;
destructor : IC.int) return IC.int;
pragma Import (C, sqlite3_bind_text);
function sqlite3_bind_blob (Handle : sqlite3_stmt_Access;
Index : IC.int;
binary : ICS.char_array_access;
nBytes : IC.int;
destructor : IC.int) return IC.int;
pragma Import (C, sqlite3_bind_blob);
function sqlite3_bind_double (Handle : not null sqlite3_stmt_Access;
Index : IC.int;
Value : IC.double) return IC.int;
pragma Import (C, sqlite3_bind_double);
function sqlite3_bind_int64 (Handle : not null sqlite3_stmt_Access;
Index : IC.int;
Value : sql64) return IC.int;
pragma Import (C, sqlite3_bind_int64);
function sqlite3_bind_null (Handle : not null sqlite3_stmt_Access;
Index : IC.int) return IC.int;
pragma Import (C, sqlite3_bind_null);
function sqlite3_bind_parameter_count
(Handle : not null sqlite3_stmt_Access) return IC.int;
pragma Import (C, sqlite3_bind_parameter_count);
function sqlite3_column_count (Handle : not null sqlite3_stmt_Access)
return IC.int;
pragma Import (C, sqlite3_column_count);
function sqlite3_column_table_name (Handle : not null sqlite3_stmt_Access;
index : IC.int) return ICS.chars_ptr;
pragma Import (C, sqlite3_column_table_name);
function sqlite3_column_name (Handle : not null sqlite3_stmt_Access;
index : IC.int) return ICS.chars_ptr;
pragma Import (C, sqlite3_column_name);
function sqlite3_column_origin_name (Handle : not null sqlite3_stmt_Access;
index : IC.int) return ICS.chars_ptr;
pragma Import (C, sqlite3_column_origin_name);
function sqlite3_column_database_name
(Handle : not null sqlite3_stmt_Access;
index : IC.int) return ICS.chars_ptr;
pragma Import (C, sqlite3_column_database_name);
function sqlite3_table_column_metadata
(Handle : not null sqlite3_Access;
dbname : ICS.chars_ptr;
table : ICS.chars_ptr;
column : ICS.chars_ptr;
datatype : access ICS.chars_ptr;
collseq : access ICS.chars_ptr;
notnull : access IC.int;
primekey : access IC.int;
autoinc : access IC.int) return IC.int;
pragma Import (C, sqlite3_table_column_metadata);
function sqlite3_close (db : not null sqlite3_Access) return IC.int;
pragma Import (C, sqlite3_close);
function sqlite3_column_type (Handle : not null sqlite3_stmt_Access;
iCol : IC.int) return IC.int;
pragma Import (C, sqlite3_column_type);
function sqlite3_column_bytes (Handle : not null sqlite3_stmt_Access;
iCol : IC.int) return IC.int;
pragma Import (C, sqlite3_column_bytes);
function sqlite3_column_double (Handle : not null sqlite3_stmt_Access;
iCol : IC.int) return IC.double;
pragma Import (C, sqlite3_column_double);
function sqlite3_column_int64 (Handle : not null sqlite3_stmt_Access;
iCol : IC.int) return sql64;
pragma Import (C, sqlite3_column_int64);
function sqlite3_column_text (Handle : not null sqlite3_stmt_Access;
iCol : IC.int) return ICS.chars_ptr;
pragma Import (C, sqlite3_column_text);
function sqlite3_column_blob (Handle : not null sqlite3_stmt_Access;
iCol : IC.int) return ICS.chars_ptr;
pragma Import (C, sqlite3_column_blob);
function sqlite3_config (Option : IC.int) return IC.int;
pragma Import (C, sqlite3_config);
function sqlite3_errmsg (db : not null sqlite3_Access) return ICS.chars_ptr;
pragma Import (C, sqlite3_errmsg);
function sqlite3_errcode (db : not null sqlite3_Access) return IC.int;
pragma Import (C, sqlite3_errcode);
function sqlite3_changes (db : not null sqlite3_Access) return IC.int;
pragma Import (C, sqlite3_changes);
function sqlite3_last_insert_rowid (db : not null sqlite3_Access)
return sql64;
pragma Import (C, sqlite3_last_insert_rowid);
function sqlite3_exec (db : not null sqlite3_Access;
sql : ICS.chars_ptr;
callback : System.Address;
firstarg : System.Address;
errmsg : System.Address) return IC.int;
pragma Import (C, sqlite3_exec);
function sqlite3_open (File_Name : ICS.chars_ptr;
Handle : not null access sqlite3_Access)
return IC.int;
pragma Import (C, sqlite3_open);
function sqlite3_prepare_v2 (db : not null sqlite3_Access;
zSql : ICS.chars_ptr;
nByte : IC.int;
ppStmt : not null access sqlite3_stmt_Access;
pzTail : not null access ICS.chars_ptr)
return IC.int;
pragma Import (C, sqlite3_prepare_v2);
function sqlite3_reset (pStmt : not null sqlite3_stmt_Access) return IC.int;
pragma Import (C, sqlite3_reset);
function sqlite3_step (Handle : not null sqlite3_stmt_Access) return IC.int;
pragma Import (C, sqlite3_step);
function sqlite3_finalize (Handle : not null sqlite3_stmt_Access)
return IC.int;
pragma Import (C, sqlite3_finalize);
function sqlite3_libversion return ICS.chars_ptr;
pragma Import (C, sqlite3_libversion);
function sqlite3_sourceid return ICS.chars_ptr;
pragma Import (C, sqlite3_sourceid);
function sqlite3_get_autocommit (db : not null sqlite3_Access)
return IC.int;
pragma Import (C, sqlite3_get_autocommit);
private
type sqlite3 is limited null record;
type sqlite3_stmt is limited null record;
end AdaBase.Bindings.SQLite;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
with Interfaces.STM32.PWR; use Interfaces.STM32, Interfaces.STM32.PWR;
package body System.BB.MCU_Parameters is
--------------------
-- PWR_Initialize --
--------------------
procedure PWR_Initialize
is
begin
-- Range 1 boost mode (R1MODE = 0) when SYSCLK ≤ 170 MHz.
-- Range 1 normal mode (R1MODE = 1) when SYSCLK ≤ 150 MHz.
-- See RM0440 ver. 6 pg. 235 chapter 6.1.5 for other modes.
PWR_Periph.CR5.R1MODE := 0;
-- Main regulator in range 1 boost mode.
-- Set the PWR to Range 1 mode.
PWR_Periph.CR1.VOS := 1;
-- Wait for stabilization
loop
exit when PWR_Periph.SR2.VOSF = 0;
end loop;
-- Set the PWR voltage falling threshold and detector
PWR_Periph.CR2.PLS := 4;
PWR_Periph.CR2.PVDE := 1;
-- Disable RTC domain write protection
PWR_Periph.CR1.DBP := 1;
-- Wait until voltage supply scaling has completed
loop
exit when Interfaces.STM32.PWR.PWR_Periph.SR2.PVDO = 0;
end loop;
end PWR_Initialize;
--------------------------
-- PWR_Overdrive_Enable --
--------------------------
procedure PWR_Overdrive_Enable
is
begin
-- Range 1 boost mode (R1MODE = 0) when SYSCLK ≤ 170 MHz.
-- Range 1 normal mode (R1MODE = 1) when SYSCLK ≤ 150 MHz.
-- See RM0440 ver. 4 pg. 235 chapter 6.1.5 for other modes.
if PWR_Periph.CR1.VOS = 2 then -- Range 2
PWR_Periph.CR1.VOS := 1; -- put in Range 1
-- Wait for stabilization
loop
exit when PWR_Periph.SR2.VOSF = 0;
end loop;
end if;
PWR_Periph.CR5.R1MODE := 0;
-- Main regulator in range 1 boost mode.
-- Wait for stabilization
loop
exit when PWR_Periph.SR2.VOSF = 0;
end loop;
end PWR_Overdrive_Enable;
end System.BB.MCU_Parameters;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
with Util.Http.Clients;
with Ada.Strings.Unbounded;
package Util.Http.Clients.Mockups is
-- Register the Http manager.
procedure Register;
-- Set the path of the file that contains the response for the next
-- <b>Do_Get</b> and <b>Do_Post</b> calls.
procedure Set_File (Path : in String);
private
type File_Http_Manager is new Http_Manager with record
File : Ada.Strings.Unbounded.Unbounded_String;
end record;
type File_Http_Manager_Access is access all File_Http_Manager'Class;
procedure Create (Manager : in File_Http_Manager;
Http : in out Client'Class);
overriding
procedure Do_Get (Manager : in File_Http_Manager;
Http : in Client'Class;
URI : in String;
Reply : out Response'Class);
overriding
procedure Do_Head (Manager : in File_Http_Manager;
Http : in Client'Class;
URI : in String;
Reply : out Response'Class);
overriding
procedure Do_Post (Manager : in File_Http_Manager;
Http : in Client'Class;
URI : in String;
Data : in String;
Reply : out Response'Class);
overriding
procedure Do_Put (Manager : in File_Http_Manager;
Http : in Client'Class;
URI : in String;
Data : in String;
Reply : out Response'Class);
overriding
procedure Do_Patch (Manager : in File_Http_Manager;
Http : in Client'Class;
URI : in String;
Data : in String;
Reply : out Response'Class);
overriding
procedure Do_Delete (Manager : in File_Http_Manager;
Http : in Client'Class;
URI : in String;
Reply : out Response'Class);
overriding
procedure Do_Options (Manager : in File_Http_Manager;
Http : in Client'Class;
URI : in String;
Reply : out Response'Class);
-- Set the timeout for the connection.
overriding
procedure Set_Timeout (Manager : in File_Http_Manager;
Http : in Client'Class;
Timeout : in Duration);
end Util.Http.Clients.Mockups;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Find source dirs and source files for a project
with Prj.Tree;
private package Prj.Nmsc is
procedure Process_Naming_Scheme
(Tree : Project_Tree_Ref;
Root_Project : Project_Id;
Node_Tree : Prj.Tree.Project_Node_Tree_Ref;
Flags : Processing_Flags);
-- Perform consistency and semantic checks on all the projects in the tree.
-- This procedure interprets the various case statements in the project
-- based on the current external references. After checking the validity of
-- the naming scheme, it searches for all the source files of the project.
-- The result of this procedure is a filled-in data structure for
-- Project_Id which contains all the information about the project. This
-- information is only valid while the external references are preserved.
procedure Process_Aggregated_Projects
(Tree : Project_Tree_Ref;
Project : Project_Id;
Node_Tree : Prj.Tree.Project_Node_Tree_Ref;
Flags : Processing_Flags);
-- Assuming Project is an aggregate project, find out (based on the
-- current external references) what are the projects it aggregates.
-- This has to be done in phase 1 of the processing, so that we know the
-- full list of languages required for root_project and its aggregated
-- projects. As a result, it cannot be done as part of
-- Process_Naming_Scheme.
end Prj.Nmsc;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
package System.Generic_Array_Operations with SPARK_Mode is
pragma Pure (Generic_Array_Operations);
---------------------
-- Back_Substitute --
---------------------
generic
type Scalar is private;
type Matrix is array (Integer range <>, Integer range <>) of Scalar;
with function "-" (Left, Right : Scalar) return Scalar is <>;
with function "*" (Left, Right : Scalar) return Scalar is <>;
with function "/" (Left, Right : Scalar) return Scalar is <>;
with function Is_Non_Zero (X : Scalar) return Boolean is <>;
procedure Back_Substitute (M, N : in out Matrix);
--------------
-- Diagonal --
--------------
generic
type Scalar is private;
type Vector is array (Integer range <>) of Scalar;
type Matrix is array (Integer range <>, Integer range <>) of Scalar;
function Diagonal (A : Matrix) return Vector;
-----------------------
-- Forward_Eliminate --
-----------------------
-- Use elementary row operations to put square matrix M in row echolon
-- form. Identical row operations are performed on matrix N, must have the
-- same number of rows as M.
generic
type Scalar is private;
type Real is digits <>;
type Matrix is array (Integer range <>, Integer range <>) of Scalar;
with function "abs" (Right : Scalar) return Real'Base is <>;
with function "-" (Left, Right : Scalar) return Scalar is <>;
with function "*" (Left, Right : Scalar) return Scalar is <>;
with function "/" (Left, Right : Scalar) return Scalar is <>;
Zero : Scalar;
One : Scalar;
procedure Forward_Eliminate
(M : in out Matrix;
N : in out Matrix;
Det : out Scalar);
--------------------------
-- Square_Matrix_Length --
--------------------------
generic
type Scalar is private;
type Matrix is array (Integer range <>, Integer range <>) of Scalar;
function Square_Matrix_Length (A : Matrix) return Natural;
-- If A is non-square, raise Constraint_Error, else return its dimension
----------------------------------
-- Vector_Elementwise_Operation --
----------------------------------
generic
type X_Scalar is private;
type Result_Scalar is private;
type X_Vector is array (Integer range <>) of X_Scalar;
type Result_Vector is array (Integer range <>) of Result_Scalar;
with function Operation (X : X_Scalar) return Result_Scalar;
function Vector_Elementwise_Operation (X : X_Vector) return Result_Vector;
----------------------------------
-- Matrix_Elementwise_Operation --
----------------------------------
generic
type X_Scalar is private;
type Result_Scalar is private;
type X_Matrix is array (Integer range <>, Integer range <>) of X_Scalar;
type Result_Matrix is array (Integer range <>, Integer range <>)
of Result_Scalar;
with function Operation (X : X_Scalar) return Result_Scalar;
function Matrix_Elementwise_Operation (X : X_Matrix) return Result_Matrix;
-----------------------------------------
-- Vector_Vector_Elementwise_Operation --
-----------------------------------------
generic
type Left_Scalar is private;
type Right_Scalar is private;
type Result_Scalar is private;
type Left_Vector is array (Integer range <>) of Left_Scalar;
type Right_Vector is array (Integer range <>) of Right_Scalar;
type Result_Vector is array (Integer range <>) of Result_Scalar;
with function Operation
(Left : Left_Scalar;
Right : Right_Scalar) return Result_Scalar;
function Vector_Vector_Elementwise_Operation
(Left : Left_Vector;
Right : Right_Vector) return Result_Vector;
------------------------------------------------
-- Vector_Vector_Scalar_Elementwise_Operation --
------------------------------------------------
generic
type X_Scalar is private;
type Y_Scalar is private;
type Z_Scalar is private;
type Result_Scalar is private;
type X_Vector is array (Integer range <>) of X_Scalar;
type Y_Vector is array (Integer range <>) of Y_Scalar;
type Result_Vector is array (Integer range <>) of Result_Scalar;
with function Operation
(X : X_Scalar;
Y : Y_Scalar;
Z : Z_Scalar) return Result_Scalar;
function Vector_Vector_Scalar_Elementwise_Operation
(X : X_Vector;
Y : Y_Vector;
Z : Z_Scalar) return Result_Vector;
-----------------------------------------
-- Matrix_Matrix_Elementwise_Operation --
-----------------------------------------
generic
type Left_Scalar is private;
type Right_Scalar is private;
type Result_Scalar is private;
type Left_Matrix is array (Integer range <>, Integer range <>)
of Left_Scalar;
type Right_Matrix is array (Integer range <>, Integer range <>)
of Right_Scalar;
type Result_Matrix is array (Integer range <>, Integer range <>)
of Result_Scalar;
with function Operation
(Left : Left_Scalar;
Right : Right_Scalar) return Result_Scalar;
function Matrix_Matrix_Elementwise_Operation
(Left : Left_Matrix;
Right : Right_Matrix) return Result_Matrix;
------------------------------------------------
-- Matrix_Matrix_Scalar_Elementwise_Operation --
------------------------------------------------
generic
type X_Scalar is private;
type Y_Scalar is private;
type Z_Scalar is private;
type Result_Scalar is private;
type X_Matrix is array (Integer range <>, Integer range <>) of X_Scalar;
type Y_Matrix is array (Integer range <>, Integer range <>) of Y_Scalar;
type Result_Matrix is array (Integer range <>, Integer range <>)
of Result_Scalar;
with function Operation
(X : X_Scalar;
Y : Y_Scalar;
Z : Z_Scalar) return Result_Scalar;
function Matrix_Matrix_Scalar_Elementwise_Operation
(X : X_Matrix;
Y : Y_Matrix;
Z : Z_Scalar) return Result_Matrix;
-----------------------------------------
-- Vector_Scalar_Elementwise_Operation --
-----------------------------------------
generic
type Left_Scalar is private;
type Right_Scalar is private;
type Result_Scalar is private;
type Left_Vector is array (Integer range <>) of Left_Scalar;
type Result_Vector is array (Integer range <>) of Result_Scalar;
with function Operation
(Left : Left_Scalar;
Right : Right_Scalar) return Result_Scalar;
function Vector_Scalar_Elementwise_Operation
(Left : Left_Vector;
Right : Right_Scalar) return Result_Vector;
-----------------------------------------
-- Matrix_Scalar_Elementwise_Operation --
-----------------------------------------
generic
type Left_Scalar is private;
type Right_Scalar is private;
type Result_Scalar is private;
type Left_Matrix is array (Integer range <>, Integer range <>)
of Left_Scalar;
type Result_Matrix is array (Integer range <>, Integer range <>)
of Result_Scalar;
with function Operation
(Left : Left_Scalar;
Right : Right_Scalar) return Result_Scalar;
function Matrix_Scalar_Elementwise_Operation
(Left : Left_Matrix;
Right : Right_Scalar) return Result_Matrix;
-----------------------------------------
-- Scalar_Vector_Elementwise_Operation --
-----------------------------------------
generic
type Left_Scalar is private;
type Right_Scalar is private;
type Result_Scalar is private;
type Right_Vector is array (Integer range <>) of Right_Scalar;
type Result_Vector is array (Integer range <>) of Result_Scalar;
with function Operation
(Left : Left_Scalar;
Right : Right_Scalar) return Result_Scalar;
function Scalar_Vector_Elementwise_Operation
(Left : Left_Scalar;
Right : Right_Vector) return Result_Vector;
-----------------------------------------
-- Scalar_Matrix_Elementwise_Operation --
-----------------------------------------
generic
type Left_Scalar is private;
type Right_Scalar is private;
type Result_Scalar is private;
type Right_Matrix is array (Integer range <>, Integer range <>)
of Right_Scalar;
type Result_Matrix is array (Integer range <>, Integer range <>)
of Result_Scalar;
with function Operation
(Left : Left_Scalar;
Right : Right_Scalar) return Result_Scalar;
function Scalar_Matrix_Elementwise_Operation
(Left : Left_Scalar;
Right : Right_Matrix) return Result_Matrix;
-------------------
-- Inner_Product --
-------------------
generic
type Left_Scalar is private;
type Right_Scalar is private;
type Result_Scalar is private;
type Left_Vector is array (Integer range <>) of Left_Scalar;
type Right_Vector is array (Integer range <>) of Right_Scalar;
Zero : Result_Scalar;
with function "*"
(Left : Left_Scalar;
Right : Right_Scalar) return Result_Scalar is <>;
with function "+"
(Left : Result_Scalar;
Right : Result_Scalar) return Result_Scalar is <>;
function Inner_Product
(Left : Left_Vector;
Right : Right_Vector) return Result_Scalar;
-------------
-- L2_Norm --
-------------
generic
type X_Scalar is private;
type Result_Real is digits <>;
type X_Vector is array (Integer range <>) of X_Scalar;
with function "abs" (Right : X_Scalar) return Result_Real is <>;
with function Sqrt (X : Result_Real'Base) return Result_Real'Base is <>;
function L2_Norm (X : X_Vector) return Result_Real'Base;
-------------------
-- Outer_Product --
-------------------
generic
type Left_Scalar is private;
type Right_Scalar is private;
type Result_Scalar is private;
type Left_Vector is array (Integer range <>) of Left_Scalar;
type Right_Vector is array (Integer range <>) of Right_Scalar;
type Matrix is array (Integer range <>, Integer range <>)
of Result_Scalar;
with function "*"
(Left : Left_Scalar;
Right : Right_Scalar) return Result_Scalar is <>;
function Outer_Product
(Left : Left_Vector;
Right : Right_Vector) return Matrix;
---------------------------
-- Matrix_Vector_Product --
---------------------------
generic
type Left_Scalar is private;
type Right_Scalar is private;
type Result_Scalar is private;
type Matrix is array (Integer range <>, Integer range <>)
of Left_Scalar;
type Right_Vector is array (Integer range <>) of Right_Scalar;
type Result_Vector is array (Integer range <>) of Result_Scalar;
Zero : Result_Scalar;
with function "*"
(Left : Left_Scalar;
Right : Right_Scalar) return Result_Scalar is <>;
with function "+"
(Left : Result_Scalar;
Right : Result_Scalar) return Result_Scalar is <>;
function Matrix_Vector_Product
(Left : Matrix;
Right : Right_Vector) return Result_Vector;
---------------------------
-- Vector_Matrix_Product --
---------------------------
generic
type Left_Scalar is private;
type Right_Scalar is private;
type Result_Scalar is private;
type Left_Vector is array (Integer range <>) of Left_Scalar;
type Matrix is array (Integer range <>, Integer range <>)
of Right_Scalar;
type Result_Vector is array (Integer range <>) of Result_Scalar;
Zero : Result_Scalar;
with function "*"
(Left : Left_Scalar;
Right : Right_Scalar) return Result_Scalar is <>;
with function "+"
(Left : Result_Scalar;
Right : Result_Scalar) return Result_Scalar is <>;
function Vector_Matrix_Product
(Left : Left_Vector;
Right : Matrix) return Result_Vector;
---------------------------
-- Matrix_Matrix_Product --
---------------------------
generic
type Left_Scalar is private;
type Right_Scalar is private;
type Result_Scalar is private;
type Left_Matrix is array (Integer range <>, Integer range <>)
of Left_Scalar;
type Right_Matrix is array (Integer range <>, Integer range <>)
of Right_Scalar;
type Result_Matrix is array (Integer range <>, Integer range <>)
of Result_Scalar;
Zero : Result_Scalar;
with function "*"
(Left : Left_Scalar;
Right : Right_Scalar) return Result_Scalar is <>;
with function "+"
(Left : Result_Scalar;
Right : Result_Scalar) return Result_Scalar is <>;
function Matrix_Matrix_Product
(Left : Left_Matrix;
Right : Right_Matrix) return Result_Matrix;
----------------------------
-- Matrix_Vector_Solution --
----------------------------
generic
type Scalar is private;
Zero : Scalar;
type Vector is array (Integer range <>) of Scalar;
type Matrix is array (Integer range <>, Integer range <>) of Scalar;
with procedure Back_Substitute (M, N : in out Matrix) is <>;
with procedure Forward_Eliminate
(M : in out Matrix;
N : in out Matrix;
Det : out Scalar) is <>;
function Matrix_Vector_Solution (A : Matrix; X : Vector) return Vector;
----------------------------
-- Matrix_Matrix_Solution --
----------------------------
generic
type Scalar is private;
Zero : Scalar;
type Matrix is array (Integer range <>, Integer range <>) of Scalar;
with procedure Back_Substitute (M, N : in out Matrix) is <>;
with procedure Forward_Eliminate
(M : in out Matrix;
N : in out Matrix;
Det : out Scalar) is <>;
function Matrix_Matrix_Solution (A : Matrix; X : Matrix) return Matrix;
----------
-- Sqrt --
----------
generic
type Real is digits <>;
function Sqrt (X : Real'Base) return Real'Base;
-----------------
-- Swap_Column --
-----------------
generic
type Scalar is private;
type Matrix is array (Integer range <>, Integer range <>) of Scalar;
procedure Swap_Column (A : in out Matrix; Left, Right : Integer);
---------------
-- Transpose --
---------------
generic
type Scalar is private;
type Matrix is array (Integer range <>, Integer range <>) of Scalar;
procedure Transpose (A : Matrix; R : out Matrix);
-------------------------------
-- Update_Vector_With_Vector --
-------------------------------
generic
type X_Scalar is private;
type Y_Scalar is private;
type X_Vector is array (Integer range <>) of X_Scalar;
type Y_Vector is array (Integer range <>) of Y_Scalar;
with procedure Update (X : in out X_Scalar; Y : Y_Scalar);
procedure Update_Vector_With_Vector (X : in out X_Vector; Y : Y_Vector);
-------------------------------
-- Update_Matrix_With_Matrix --
-------------------------------
generic
type X_Scalar is private;
type Y_Scalar is private;
type X_Matrix is array (Integer range <>, Integer range <>) of X_Scalar;
type Y_Matrix is array (Integer range <>, Integer range <>) of Y_Scalar;
with procedure Update (X : in out X_Scalar; Y : Y_Scalar);
procedure Update_Matrix_With_Matrix (X : in out X_Matrix; Y : Y_Matrix);
-----------------
-- Unit_Matrix --
-----------------
generic
type Scalar is private;
type Matrix is array (Integer range <>, Integer range <>) of Scalar;
Zero : Scalar;
One : Scalar;
function Unit_Matrix
(Order : Positive;
First_1 : Integer := 1;
First_2 : Integer := 1) return Matrix;
-----------------
-- Unit_Vector --
-----------------
generic
type Scalar is private;
type Vector is array (Integer range <>) of Scalar;
Zero : Scalar;
One : Scalar;
function Unit_Vector
(Index : Integer;
Order : Positive;
First : Integer := 1) return Vector;
end System.Generic_Array_Operations;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
type Verbosity_Level_Type is (None, Low, Medium, High);
Verbosity_Level : Verbosity_Level_Type := High;
-- GNATMAKE, GPRMAKE
-- Modified by gnatmake or gprmake switches -v, -vl, -vm, -vh. Indicates
-- the level of verbosity of informational messages:
--
-- In Low Verbosity, the reasons why a source is recompiled, the name
-- of the executable and the reason it must be rebuilt is output.
--
-- In Medium Verbosity, additional lines are output for each ALI file
-- that is checked.
--
-- In High Verbosity, additional lines are output when the ALI file
-- is part of an Ada library, is read-only or is part of the runtime.
Warn_On_Ada_2005_Compatibility : Boolean := True;
-- GNAT
-- Set to True to active all warnings on Ada 2005 compatibility issues,
-- including warnings on Ada 2005 obsolescent features used in Ada 2005
-- mode. Set False by -gnatwY.
Warn_On_Bad_Fixed_Value : Boolean := False;
-- GNAT
-- Set to True to generate warnings for static fixed-point expression
-- values that are not an exact multiple of the small value of the type.
Warn_On_Constant : Boolean := False;
-- GNAT
-- Set to True to generate warnings for variables that could be declared
-- as constants. Modified by use of -gnatwk/K.
Warn_On_Dereference : Boolean := False;
-- GNAT
-- Set to True to generate warnings for implicit dereferences for array
-- indexing and record component access. Modified by use of -gnatwd/D.
Warn_On_Export_Import : Boolean := True;
-- GNAT
-- Set to True to generate warnings for suspicious use of export or
-- import pragmas. Modified by use of -gnatwx/X.
Warn_On_Hiding : Boolean := False;
-- GNAT
-- Set to True to generate warnings if a declared entity hides another
-- entity. The default is that this warning is suppressed.
Warn_On_Modified_Unread : Boolean := False;
-- GNAT
-- Set to True to generate warnings if a variable is assigned but is never
-- read. The default is that this warning is suppressed.
Warn_On_No_Value_Assigned : Boolean := True;
-- GNAT
-- Set to True to generate warnings if no value is ever assigned to a
-- variable that is at least partially uninitialized. Set to false to
-- suppress such warnings. The default is that such warnings are enabled.
Warn_On_Obsolescent_Feature : Boolean := False;
-- GNAT
-- Set to True to generate warnings on use of any feature in Annex or if a
-- subprogram is called for which a pragma Obsolescent applies.
Warn_On_Redundant_Constructs : Boolean := False;
-- GNAT
-- Set to True to generate warnings for redundant constructs (e.g. useless
-- assignments/conversions). The default is that this warning is disabled.
Warn_On_Unchecked_Conversion : Boolean := True;
-- GNAT
-- Set to True to generate warnings for unchecked conversions that may have
-- non-portable semantics (e.g. because sizes of types differ). The default
-- is that this warning is enabled.
Warn_On_Unrecognized_Pragma : Boolean := True;
-- GNAT
-- Set to True to generate warnings for unrecognized pragmas. The default
-- is that this warning is enabled.
type Warning_Mode_Type is (Suppress, Normal, Treat_As_Error);
Warning_Mode : Warning_Mode_Type := Normal;
-- GNAT, GNATBIND
-- Controls treatment of warning messages. If set to Suppress, warning
-- messages are not generated at all. In Normal mode, they are generated
-- but do not count as errors. In Treat_As_Error mode, warning messages
-- are generated and are treated as errors.
Wide_Character_Encoding_Method : WC_Encoding_Method := WCEM_Brackets;
-- GNAT
-- Method used for encoding wide characters in the source program. See
-- description of type in unit System.WCh_Con for a list of the methods
-- that are currently supported. Note that brackets notation is always
-- recognized in source programs regardless of the setting of this
-- variable. The default setting causes only the brackets notation to be
-- recognized. If this is the main unit, this setting also controls the
-- output of the W=? parameter in the ALI file, which is used to provide
-- the default for Wide_Text_IO files.
Xref_Active : Boolean := True;
-- GNAT
-- Set if cross-referencing is enabled (i.e. xref info in ALI files)
----------------------------
-- Configuration Settings --
----------------------------
-- These are settings that are used to establish the mode at the start of
-- each unit. The values defined below can be affected either by command
-- line switches, or by the use of appropriate configuration pragmas in the
-- gnat.adc file.
Ada_Version_Config : Ada_Version_Type;
-- GNAT
-- This is the value of the configuration switch for the Ada 83 mode, as
-- set by the command line switches -gnat83/95/05, and possibly modified by
-- the use of configuration pragmas Ada_83/Ada95/Ada05. This switch is used
-- to set the initial value for Ada_Version mode at the start of analysis
-- of a unit. Note however, that the setting of this flag is ignored for
-- internal and predefined units (which are always compiled in the most up
-- to date version of Ada).
Ada_Version_Explicit_Config : Ada_Version_Type;
-- GNAT
-- This is set in the same manner as Ada_Version_Config. The difference is
-- that the setting of this flag is not ignored for internal and predefined
-- units, which for some purposes do indeed access this value, regardless
-- of the fact that they are compiled the the most up to date ada version).
Assertions_Enabled_Config : Boolean;
-- GNAT
-- This is the value of the configuration switch for assertions enabled
-- mode, as possibly set by the command line switch -gnata, and possibly
-- modified by the use of the configuration pragma Assertion_Policy.
Debug_Pragmas_Enabled_Config : Boolean;
-- GNAT
-- This is the value of the configuration switch for debug pragmas enabled
-- mode, as possibly set by the command line switch -gnata and possibly
-- modified by the use of the configuration pragma Debug_Policy.
Dynamic_Elaboration_Checks_Config : Boolean := False;
-- GNAT
-- Set True for dynamic elaboration checking mode, as set by the -gnatE
-- switch or by the use of pragma Elaboration_Checking (Dynamic).
Exception_Locations_Suppressed_Config : Boolean := False;
-- GNAT
-- Set True by use of the configuration pragma Suppress_Exception_Messages
Extensions_Allowed_Config : Boolean;
-- GNAT
-- This is the flag that indicates whether extensions are allowed. It can
-- be set True either by use of the -gnatX switch, or by use of the
-- configuration pragma Extensions_Allowed (On). It is always set to True
-- for internal GNAT units, since extensions are always permitted in such
-- units.
External_Name_Exp_Casing_Config : External_Casing_Type;
-- GNAT
-- This is the value of the configuration switch that controls casing of
-- external symbols for which an explicit external name is given. It can be
-- set to Uppercase by the command line switch -gnatF, and further modified
-- by the use of the configuration pragma External_Name_Casing in the
-- gnat.adc file. This flag is used to set the initial value for
-- External_Name_Exp_Casing at the start of analyzing each unit. Note
-- however that the setting of this flag is ignored for internal and
-- predefined units (which are always compiled with As_Is mode).
External_Name_Imp_Casing_Config : External_Casing_Type;
-- GNAT
-- This is the value of the configuration switch that controls casing of
-- external symbols where the external name is implicitly given. It can be
-- set to Uppercase by the command line switch -gnatF, and further modified
-- by the use of the configuration pragma External_Name_Casing in the
-- gnat.adc file. This flag is used to set the initial value for
-- External_Name_Imp_Casing at the start of analyzing each unit. Note
-- however that the setting of this flag is ignored for internal and
-- predefined units (which are always compiled with Lowercase mode).
Persistent_BSS_Mode_Config : Boolean;
-- GNAT
-- This is the value of the configuration switch that controls whether
-- potentially persistent data is to be placed in the persistent_bss
-- section. It can be set True by use of the pragma Persistent_BSS.
-- This flag is used to set the initial value of Persistent_BSS_Mode
-- at the start of each compilation unit, except that it is always
-- set False for predefined units.
Polling_Required_Config : Boolean;
-- GNAT
-- This is the value of the configuration switch that controls polling
-- mode. It can be set True by the command line switch -gnatP, and then
-- further modified by the use of pragma Polling in the gnat.adc file. This
-- flag is used to set the initial value for Polling_Required at the start
-- of analyzing each unit.
Use_VADS_Size_Config : Boolean;
-- GNAT
-- This is the value of the configuration switch that controls the use of
-- VADS_Size instead of Size whereever the attribute Size is used. It can
-- be set True by the use of the pragma Use_VADS_Size in the gnat.adc file.
-- This flag is used to set the initial value for Use_VADS_Size at the
-- start of analyzing each unit. Note however that the setting of this flag
-- is ignored for internal and predefined units (which are always compiled
-- with the standard Size semantics).
type Config_Switches_Type is private;
-- Type used to save values of the switches set from Config values
procedure Save_Opt_Config_Switches (Save : out Config_Switches_Type);
-- This procedure saves the current values of the switches which are
-- initialized from the above Config values, and then resets these switches
-- according to the Config value settings.
procedure Set_Opt_Config_Switches
(Internal_Unit : Boolean;
Main_Unit : Boolean);
-- This procedure sets the switches to the appropriate initial values. The
-- parameter Internal_Unit is True for an internal or predefined unit, and
-- affects the way the switches are set (see above). Main_Unit is true if
-- switches are being set for the main unit (this affects setting of the
-- assert/debug pragm switches, which are normally set false by default for
-- an internal unit, except when the internal unit is the main unit, in
-- which case we use the command line settings).
procedure Restore_Opt_Config_Switches (Save : Config_Switches_Type);
-- This procedure restores a set of switch values previously saved by a
-- call to Save_Opt_Switches.
procedure Register_Opt_Config_Switches;
-- This procedure is called after processing the gnat.adc file to record
-- the values of the Config switches, as possibly modified by the use of
-- command line switches and configuration pragmas.
------------------------
-- Other Global Flags --
------------------------
Expander_Active : Boolean := False;
-- A flag that indicates if expansion is active (True) or deactivated
-- (False). When expansion is deactivated all calls to expander routines
-- have no effect. Note that the initial setting of False is merely to
-- prevent saving of an undefined value for an initial call to the
-- Expander_Mode_Save_And_Set procedure. For more information on the use of
-- this flag, see package Expander. Indeed this flag might more logically
-- be in the spec of Expander, but it is referenced by Errout, and it
-- really seems wrong for Errout to depend on Expander.
-----------------------
-- Tree I/O Routines --
-----------------------
procedure Tree_Read;
-- Reads switch settings from current tree file using Tree_Read
procedure Tree_Write;
-- Writes out switch settings to current tree file using Tree_Write
--------------------------
-- ASIS Version Control --
--------------------------
-- These two variables (Tree_Version_String and Tree_ASIS_Version_Number)
-- are supposed to be used in the GNAT/ASIS version check performed in
-- the ASIS code (this package is also a part of the ASIS implementation).
-- They are set by Tree_Read procedure, so they represent the version
-- number (and the version string) of the compiler which has created the
-- tree, and they are supposed to be compared with the corresponding values
-- from the Gnatvsn package which is a part of ASIS implementation.
Tree_Version_String : String_Access;
-- Used to store the compiler version string read from a tree file to check
-- if it is from the same date as stored in the version string in Gnatvsn.
-- We require that ASIS Pro can be used only with GNAT Pro, but we allow
-- non-Pro ASIS and ASIS-based tools to be used with any version of the
-- GNAT compiler. Therefore, we need the possibility to compare the dates
-- of the corresponding source sets, using version strings that may be
-- of different lengths.
Tree_ASIS_Version_Number : Int;
-- Used to store the ASIS version number read from a tree file to check if
-- it is the same as stored in the ASIS version number in Gnatvsn.
private
-- The following type is used to save and restore settings of switches in
-- Opt that represent the configuration (i.e. result of config pragmas).
-- Note that Ada_Version_Explicit is not included, since this is a sticky
-- flag that once set does not get reset, since the whole idea of this flag
-- is to record the setting for the main unit.
type Config_Switches_Type is record
Ada_Version : Ada_Version_Type;
Ada_Version_Explicit : Ada_Version_Type;
Assertions_Enabled : Boolean;
Debug_Pragmas_Enabled : Boolean;
Dynamic_Elaboration_Checks : Boolean;
Exception_Locations_Suppressed : Boolean;
Extensions_Allowed : Boolean;
External_Name_Exp_Casing : External_Casing_Type;
External_Name_Imp_Casing : External_Casing_Type;
Persistent_BSS_Mode : Boolean;
Polling_Required : Boolean;
Use_VADS_Size : Boolean;
end record;
end Opt;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
PDE at 0 range 2 .. 2;
PUE at 0 range 3 .. 3;
DRIVE at 0 range 4 .. 5;
IE at 0 range 6 .. 6;
OD at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
type PADS_BANK0_Peripheral is record
-- Voltage select. Per bank control
VOLTAGE_SELECT : aliased VOLTAGE_SELECT_Register;
-- Pad control register
GPIO0 : aliased GPIO_Register;
-- Pad control register
GPIO1 : aliased GPIO_Register;
-- Pad control register
GPIO2 : aliased GPIO_Register;
-- Pad control register
GPIO3 : aliased GPIO_Register;
-- Pad control register
GPIO4 : aliased GPIO_Register;
-- Pad control register
GPIO5 : aliased GPIO_Register;
-- Pad control register
GPIO6 : aliased GPIO_Register;
-- Pad control register
GPIO7 : aliased GPIO_Register;
-- Pad control register
GPIO8 : aliased GPIO_Register;
-- Pad control register
GPIO9 : aliased GPIO_Register;
-- Pad control register
GPIO10 : aliased GPIO_Register;
-- Pad control register
GPIO11 : aliased GPIO_Register;
-- Pad control register
GPIO12 : aliased GPIO_Register;
-- Pad control register
GPIO13 : aliased GPIO_Register;
-- Pad control register
GPIO14 : aliased GPIO_Register;
-- Pad control register
GPIO15 : aliased GPIO_Register;
-- Pad control register
GPIO16 : aliased GPIO_Register;
-- Pad control register
GPIO17 : aliased GPIO_Register;
-- Pad control register
GPIO18 : aliased GPIO_Register;
-- Pad control register
GPIO19 : aliased GPIO_Register;
-- Pad control register
GPIO20 : aliased GPIO_Register;
-- Pad control register
GPIO21 : aliased GPIO_Register;
-- Pad control register
GPIO22 : aliased GPIO_Register;
-- Pad control register
GPIO23 : aliased GPIO_Register;
-- Pad control register
GPIO24 : aliased GPIO_Register;
-- Pad control register
GPIO25 : aliased GPIO_Register;
-- Pad control register
GPIO26 : aliased GPIO_Register;
-- Pad control register
GPIO27 : aliased GPIO_Register;
-- Pad control register
GPIO28 : aliased GPIO_Register;
-- Pad control register
GPIO29 : aliased GPIO_Register;
-- Pad control register
SWCLK : aliased SWCLK_Register;
-- Pad control register
SWD : aliased SWD_Register;
end record
with Volatile;
for PADS_BANK0_Peripheral use record
VOLTAGE_SELECT at 16#0# range 0 .. 31;
GPIO0 at 16#4# range 0 .. 31;
GPIO1 at 16#8# range 0 .. 31;
GPIO2 at 16#C# range 0 .. 31;
GPIO3 at 16#10# range 0 .. 31;
GPIO4 at 16#14# range 0 .. 31;
GPIO5 at 16#18# range 0 .. 31;
GPIO6 at 16#1C# range 0 .. 31;
GPIO7 at 16#20# range 0 .. 31;
GPIO8 at 16#24# range 0 .. 31;
GPIO9 at 16#28# range 0 .. 31;
GPIO10 at 16#2C# range 0 .. 31;
GPIO11 at 16#30# range 0 .. 31;
GPIO12 at 16#34# range 0 .. 31;
GPIO13 at 16#38# range 0 .. 31;
GPIO14 at 16#3C# range 0 .. 31;
GPIO15 at 16#40# range 0 .. 31;
GPIO16 at 16#44# range 0 .. 31;
GPIO17 at 16#48# range 0 .. 31;
GPIO18 at 16#4C# range 0 .. 31;
GPIO19 at 16#50# range 0 .. 31;
GPIO20 at 16#54# range 0 .. 31;
GPIO21 at 16#58# range 0 .. 31;
GPIO22 at 16#5C# range 0 .. 31;
GPIO23 at 16#60# range 0 .. 31;
GPIO24 at 16#64# range 0 .. 31;
GPIO25 at 16#68# range 0 .. 31;
GPIO26 at 16#6C# range 0 .. 31;
GPIO27 at 16#70# range 0 .. 31;
GPIO28 at 16#74# range 0 .. 31;
GPIO29 at 16#78# range 0 .. 31;
SWCLK at 16#7C# range 0 .. 31;
SWD at 16#80# range 0 .. 31;
end record;
PADS_BANK0_Periph : aliased PADS_BANK0_Peripheral
with Import, Address => PADS_BANK0_Base;
end RP_SVD.PADS_BANK0;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Ada.Exceptions;
with Ada.Unchecked_Deallocation;
with Util.Strings;
with Util.Log.Loggers;
with ASF.Utils;
with ASF.Converters;
with ASF.Views.Nodes;
with ASF.Components;
with ASF.Components.Utils;
with ASF.Components.Base;
with ASF.Requests;
with ASF.Events.Faces.Actions;
with ASF.Applications.Main;
with AWA.Tags.Beans;
package body AWA.Tags.Components is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Tags.Components");
READONLY_ATTRIBUTE_NAMES : Util.Strings.String_Set.Set;
function Create_Tag return ASF.Components.Base.UIComponent_Access;
function Create_Cloud return ASF.Components.Base.UIComponent_Access;
procedure Swap (Item1 : in out AWA.Tags.Models.Tag_Info;
Item2 : in out AWA.Tags.Models.Tag_Info);
procedure Dispatch (List : in out Tag_Info_Array);
-- ------------------------------
-- Create an Tag_UIInput component
-- ------------------------------
function Create_Tag return ASF.Components.Base.UIComponent_Access is
begin
return new Tag_UIInput;
end Create_Tag;
-- ------------------------------
-- Create an Tag_UICloud component
-- ------------------------------
function Create_Cloud return ASF.Components.Base.UIComponent_Access is
begin
return new Tag_UICloud;
end Create_Cloud;
URI : aliased constant String := "http://code.google.com/p/ada-awa/jsf";
TAG_LIST_TAG : aliased constant String := "tagList";
TAG_CLOUD_TAG : aliased constant String := "tagCloud";
AWA_Bindings : aliased constant ASF.Factory.Binding_Array
:= (1 => (Name => TAG_CLOUD_TAG'Access,
Component => Create_Cloud'Access,
Tag => ASF.Views.Nodes.Create_Component_Node'Access),
2 => (Name => TAG_LIST_TAG'Access,
Component => Create_Tag'Access,
Tag => ASF.Views.Nodes.Create_Component_Node'Access)
);
AWA_Factory : aliased constant ASF.Factory.Factory_Bindings
:= (URI => URI'Access, Bindings => AWA_Bindings'Access);
-- ------------------------------
-- Get the Tags component factory.
-- ------------------------------
function Definition return ASF.Factory.Factory_Bindings_Access is
begin
return AWA_Factory'Access;
end Definition;
-- ------------------------------
-- Returns True if the tag component must be rendered as readonly.
-- ------------------------------
function Is_Readonly (UI : in Tag_UIInput;
Context : in ASF.Contexts.Faces.Faces_Context'Class) return Boolean is
pragma Unreferenced (Context);
use type ASF.Components.Html.Forms.UIForm_Access;
begin
return UI.Get_Form = null;
end Is_Readonly;
-- ------------------------------
-- Render the javascript to enable the tag edition.
-- ------------------------------
procedure Render_Script (UI : in Tag_UIInput;
Id : in String;
Writer : in Response_Writer_Access;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
Auto_Complete : constant String := UI.Get_Attribute ("autoCompleteUrl", Context);
Allow_Edit : constant Boolean := UI.Get_Attribute ("allowEdit", Context);
begin
Writer.Queue_Script ("$('#");
Writer.Queue_Script (Id);
Writer.Queue_Script (" input').tagedit({");
Writer.Queue_Script ("allowEdit: ");
if Allow_Edit then
Writer.Queue_Script ("true");
else
Writer.Queue_Script ("false");
end if;
if Auto_Complete'Length > 0 then
Writer.Queue_Script (", autocompleteURL: '");
Writer.Queue_Script (Auto_Complete);
Writer.Queue_Script ("'");
end if;
Writer.Queue_Script ("});");
end Render_Script;
-- ------------------------------
-- Get the tag after convertion with the optional converter.
-- ------------------------------
function Get_Tag (UI : in Tag_UIInput;
Tag : in Util.Beans.Objects.Object;
Context : in ASF.Contexts.Faces.Faces_Context'Class) return String is
begin
if not Util.Beans.Objects.Is_Null (Tag) then
declare
Convert : constant access ASF.Converters.Converter'Class
:= Tag_UIInput'Class (UI).Get_Converter;
begin
if Convert /= null then
return Convert.To_String (Value => Tag,
Component => UI,
Context => Context);
else
return Util.Beans.Objects.To_String (Value => Tag);
end if;
end;
else
return "";
end if;
end Get_Tag;
-- ------------------------------
-- Render the tag as a readonly item.
-- ------------------------------
procedure Render_Readonly_Tag (UI : in Tag_UIInput;
Tag : in Util.Beans.Objects.Object;
Class : in Util.Beans.Objects.Object;
Writer : in Response_Writer_Access;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
Value : constant String := UI.Get_Tag (Tag, Context);
begin
Writer.Start_Element ("li");
if not Util.Beans.Objects.Is_Null (Class) then
Writer.Write_Attribute ("class", Class);
end if;
Writer.Start_Element ("span");
Writer.Write_Text (Value);
Writer.End_Element ("span");
Writer.End_Element ("li");
end Render_Readonly_Tag;
-- ------------------------------
-- Render the tag as a link.
-- ------------------------------
procedure Render_Link_Tag (UI : in Tag_UIInput;
Name : in String;
Tag : in Util.Beans.Objects.Object;
Link : in EL.Expressions.Expression;
Class : in Util.Beans.Objects.Object;
Writer : in Response_Writer_Access;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
Value : constant String := UI.Get_Tag (Tag, Context);
begin
Context.Set_Attribute (Name, Util.Beans.Objects.To_Object (Value));
Writer.Start_Element ("li");
if not Util.Beans.Objects.Is_Null (Class) then
Writer.Write_Attribute ("class", Class);
end if;
Writer.Start_Element ("a");
Writer.Write_Attribute ("href", Link.Get_Value (Context.Get_ELContext.all));
Writer.Write_Text (Value);
Writer.End_Element ("a");
Writer.End_Element ("li");
end Render_Link_Tag;
-- ------------------------------
-- Render the tag for an input form.
-- ------------------------------
procedure Render_Form_Tag (UI : in Tag_UIInput;
Id : in String;
Tag : in Util.Beans.Objects.Object;
Writer : in Response_Writer_Access;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
begin
Writer.Start_Element ("input");
Writer.Write_Attribute (Name => "type", Value => "text");
Writer.Write_Attribute (Name => "name", Value => Id);
if not Util.Beans.Objects.Is_Null (Tag) then
declare
Convert : constant access ASF.Converters.Converter'Class
:= Tag_UIInput'Class (UI).Get_Converter;
begin
if Convert /= null then
Writer.Write_Attribute (Name => "value",
Value => Convert.To_String (Value => Tag,
Component => UI,
Context => Context));
else
Writer.Write_Attribute (Name => "value", Value => Tag);
end if;
end;
end if;
Writer.End_Element ("input");
end Render_Form_Tag;
-- ------------------------------
-- Render the list of tags as readonly list. If a <tt>tagLink</tt> attribute is defined,
-- a link is rendered for each tag. Otherwise, each tag is rendered as a <tt>span</tt>.
-- ------------------------------
procedure Render_Readonly (UI : in Tag_UIInput;
List : in Util.Beans.Basic.List_Bean_Access;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
Class : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, "tagClass");
Count : constant Natural := List.Get_Count;
Writer : constant Response_Writer_Access := Context.Get_Response_Writer;
Link : constant access ASF.Views.Nodes.Tag_Attribute := UI.Get_Attribute ("tagLink");
begin
if Count > 0 then
Writer.Start_Element ("ul");
UI.Render_Attributes (Context, Writer);
if Link /= null then
declare
Link : constant EL.Expressions.Expression := UI.Get_Expression ("tagLink");
Name : constant String := UI.Get_Attribute (Name => "var",
Context => Context,
Default => "tag");
begin
for I in 1 .. Count loop
List.Set_Row_Index (I);
Tag_UIInput'Class (UI).Render_Link_Tag (Name => Name,
Tag => List.Get_Row,
Link => Link,
Class => Class,
Writer => Writer,
Context => Context);
end loop;
end;
else
for I in 1 .. Count loop
List.Set_Row_Index (I);
Tag_UIInput'Class (UI).Render_Readonly_Tag (Tag => List.Get_Row,
Class => Class,
Writer => Writer,
Context => Context);
end loop;
end if;
Writer.End_Element ("ul");
end if;
end Render_Readonly;
-- ------------------------------
-- Render the list of tags for a form.
-- ------------------------------
procedure Render_Form (UI : in Tag_UIInput;
List : in Util.Beans.Basic.List_Bean_Access;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
Id : constant String := Ada.Strings.Unbounded.To_String (UI.Get_Client_Id);
Count : constant Natural := List.Get_Count;
Writer : constant Response_Writer_Access := Context.Get_Response_Writer;
begin
Writer.Start_Element ("div");
if Count > 0 then
UI.Render_Attributes (Context, Writer);
for I in 1 .. Count loop
List.Set_Row_Index (I);
Tag_UIInput'Class (UI).Render_Form_Tag (Id & "[" & Util.Strings.Image (I) & "]",
List.Get_Row, Writer, Context);
end loop;
else
Writer.Write_Attribute ("id", Id);
end if;
Tag_UIInput'Class (UI).Render_Form_Tag (Id & "[]", Util.Beans.Objects.Null_Object,
Writer, Context);
Writer.End_Element ("div");
Tag_UIInput'Class (UI).Render_Script (Id, Writer, Context);
end Render_Form;
-- ------------------------------
-- Render the input component. Starts the DL/DD list and write the input
-- component with the possible associated error message.
-- ------------------------------
overriding
procedure Encode_Begin (UI : in Tag_UIInput;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
begin
if not UI.Is_Rendered (Context) then
return;
end if;
declare
use AWA.Tags.Beans;
Value : constant Util.Beans.Objects.Object := Tag_UIInput'Class (UI).Get_Value;
Bean : constant access Util.Beans.Basic.Readonly_Bean'Class
:= Util.Beans.Objects.To_Bean (Value);
Readonly : constant Boolean := UI.Is_Readonly (Context);
List : Util.Beans.Basic.List_Bean_Access;
begin
if Bean = null then
if not Readonly then
ASF.Components.Base.Log_Error (UI, "There is no tagList bean value");
end if;
return;
elsif not (Bean.all in Util.Beans.Basic.List_Bean'Class) then
ASF.Components.Base.Log_Error (UI, "There bean value is not a List_Bean");
return;
end if;
List := Util.Beans.Basic.List_Bean'Class (Bean.all)'Unchecked_Access;
if Readonly then
UI.Render_Readonly (List, Context);
else
UI.Render_Form (List, Context);
end if;
end;
end Encode_Begin;
-- ------------------------------
-- Render the end of the input component. Closes the DL/DD list.
-- ------------------------------
overriding
procedure Encode_End (UI : in Tag_UIInput;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
begin
null;
end Encode_End;
-- ------------------------------
-- Get the action method expression to invoke if the command is pressed.
-- ------------------------------
function Get_Action_Expression (UI : in Tag_UIInput;
Context : in ASF.Contexts.Faces.Faces_Context'Class)
return EL.Expressions.Method_Expression is
pragma Unreferenced (Context);
begin
return UI.Get_Method_Expression (Name => ASF.Components.ACTION_NAME);
end Get_Action_Expression;
-- ------------------------------
-- Decode any new state of the specified component from the request contained
-- in the specified context and store that state on the component.
--
-- During decoding, events may be enqueued for later processing
-- (by event listeners that have registered an interest), by calling
-- the <b>Queue_Event</b> on the associated component.
-- ------------------------------
overriding
procedure Process_Decodes (UI : in out Tag_UIInput;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
begin
if not UI.Is_Rendered (Context) then
return;
end if;
declare
Req : constant ASF.Requests.Request_Access := Context.Get_Request;
Id : constant String := Ada.Strings.Unbounded.To_String (UI.Get_Client_Id);
procedure Process_Parameter (Name, Value : in String);
procedure Process_Parameter (Name, Value : in String) is
begin
if Name'Length <= Id'Length or Name (Name'Last) /= ']' then
return;
end if;
if Name (Name'First .. Name'First + Id'Length - 1) /= Id then
return;
end if;
if Name (Name'First + Id'Length) /= '[' then
return;
end if;
if Name (Name'Last - 1) = 'd' then
UI.Deleted.Append (Value);
elsif Name (Name'Last - 1) = 'a' or else Name (Name'Last - 1) = '[' then
UI.Added.Append (Value);
end if;
end Process_Parameter;
Val : constant String := Context.Get_Parameter (Id);
begin
Req.Iterate_Parameters (Process_Parameter'Access);
UI.Is_Valid := True;
if not UI.Added.Is_Empty or else not UI.Deleted.Is_Empty then
ASF.Events.Faces.Actions.Post_Event (UI => UI,
Method => UI.Get_Action_Expression (Context));
end if;
exception
when E : others =>
UI.Is_Valid := False;
Log.Info (ASF.Components.Utils.Get_Line_Info (UI)
& ": Exception raised when converting value {0} for component {1}: {2}",
Val, Id, Ada.Exceptions.Exception_Name (E));
end;
end Process_Decodes;
-- ------------------------------
-- Perform the component tree processing required by the <b>Update Model Values</b>
-- phase of the request processing lifecycle for all facets of this component,
-- all children of this component, and this component itself, as follows.
-- <ul>
-- <li>If this component <b>rendered</b> property is false, skip further processing.
-- <li>Call the <b>Process_Updates/b> of all facets and children.
-- <ul>
-- ------------------------------
overriding
procedure Process_Updates (UI : in out Tag_UIInput;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
begin
if UI.Is_Valid and then not UI.Is_Rendered (Context) then
return;
end if;
declare
use AWA.Tags.Beans;
Value : constant Util.Beans.Objects.Object := Tag_UIInput'Class (UI).Get_Value;
Bean : constant access Util.Beans.Basic.Readonly_Bean'Class
:= Util.Beans.Objects.To_Bean (Value);
List : access Tag_List_Bean'Class;
begin
if Bean = null then
ASF.Components.Base.Log_Error (UI, "There is no tagList bean value");
return;
elsif not (Bean.all in Tag_List_Bean'Class) then
ASF.Components.Base.Log_Error (UI, "There is not taglist bean");
return;
end if;
List := Tag_List_Bean'Class (Bean.all)'Access;
List.Set_Added (UI.Added);
List.Set_Deleted (UI.Deleted);
end;
end Process_Updates;
-- ------------------------------
-- Broadcast the event to the event listeners installed on this component.
-- Listeners are called in the order in which they were added.
-- ------------------------------
overriding
procedure Broadcast (UI : in out Tag_UIInput;
Event : not null access ASF.Events.Faces.Faces_Event'Class;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
pragma Unreferenced (UI);
use ASF.Events.Faces.Actions;
App : constant access ASF.Applications.Main.Application'Class := Context.Get_Application;
Disp : constant Action_Listener_Access := App.Get_Action_Listener;
begin
if Disp /= null and Event.all in Action_Event'Class then
Disp.Process_Action (Event => Action_Event (Event.all),
Context => Context);
end if;
end Broadcast;
-- ------------------------------
-- Render the list of tags. If the <tt>tagLink</tt> attribute is defined, a link
-- is rendered for each tag.
-- ------------------------------
procedure Render_Cloud (UI : in Tag_UICloud;
List : in Tag_Info_Array;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
Writer : constant Response_Writer_Access := Context.Get_Response_Writer;
Link : constant access ASF.Views.Nodes.Tag_Attribute := UI.Get_Attribute ("tagLink");
Style : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, "tagClass");
Font_Size : constant Boolean := True;
begin
Writer.Start_Element ("ul");
UI.Render_Attributes (Context, Writer);
if Link /= null then
declare
Link : constant EL.Expressions.Expression := UI.Get_Expression ("tagLink");
Name : constant String := UI.Get_Attribute ("var", Context, "");
begin
for I in List'Range loop
Writer.Start_Element ("li");
if not Util.Beans.Objects.Is_Null (Style) then
Writer.Write_Attribute ("class", Style);
end if;
Writer.Start_Element ("a");
Context.Set_Attribute (Name, Util.Beans.Objects.To_Object (List (I).Tag));
Writer.Write_Attribute ("href", Link.Get_Value (Context.Get_ELContext.all));
if Font_Size then
Writer.Write_Attribute ("style",
"font-size:" & Util.Strings.Image (List (I).Count / 100)
& "." & Util.Strings.Image (List (I).Count mod 100)
& "px;");
else
Writer.Write_Attribute ("class", "tag"
& Util.Strings.Image (List (I).Count / 100));
end if;
Writer.Write_Text (List (I).Tag);
Writer.End_Element ("a");
Writer.End_Element ("li");
end loop;
end;
else
for I in List'Range loop
Writer.Start_Element ("li");
if not Util.Beans.Objects.Is_Null (Style) then
Writer.Write_Attribute ("class", Style);
end if;
Writer.Write_Text (List (I).Tag);
Writer.End_Element ("li");
end loop;
end if;
Writer.End_Element ("ul");
end Render_Cloud;
-- ------------------------------
-- Compute the weight for each tag in the list according to the <tt>minWeight</tt> and
-- <tt>maxWeight</tt> attributes. The computed weight is an integer multiplied by 100
-- and will range from 100x<i>minWeight</i> and 100x<i>maxWeight</i>.
-- ------------------------------
procedure Compute_Cloud_Weight (UI : in Tag_UICloud;
List : in out Tag_Info_Array;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
Min : constant Integer := UI.Get_Attribute ("minWeight", Context, 0);
Max : constant Integer := UI.Get_Attribute ("maxWeight", Context, 100) - Min;
Min_Count : constant Natural := List (List'Last).Count;
Max_Count : Natural := List (List'First).Count;
begin
if Max_Count = Min_Count then
Max_Count := Min_Count + 1;
end if;
for I in List'Range loop
if List (I).Count = Min_Count then
List (I).Count := 100 * Min;
else
List (I).Count := (100 * Max * (List (I).Count - Min_Count)) / (Max_Count - Min_Count)
+ 100 * Min;
end if;
end loop;
end Compute_Cloud_Weight;
procedure Swap (Item1 : in out AWA.Tags.Models.Tag_Info;
Item2 : in out AWA.Tags.Models.Tag_Info) is
Tmp : constant AWA.Tags.Models.Tag_Info := Item2;
begin
Item2 := Item1;
Item1 := Tmp;
end Swap;
-- ------------------------------
-- A basic algorithm to dispatch the tags in the list.
-- The original list is sorted on the tag count (due to the Tag_Ordered_Sets).
-- We try to dispatch the first tags somewhere in the first or second halves of the list.
-- ------------------------------
procedure Dispatch (List : in out Tag_Info_Array) is
Middle : constant Natural := List'First + List'Length / 2;
Quarter : Natural := List'Length / 4;
Target : Natural := Middle;
Pos : Natural := 0;
begin
while Target <= List'Last and List'First + Pos < Middle and Quarter /= 0 loop
Swap (List (List'First + Pos), List (Target));
Pos := Pos + 1;
if Target <= Middle then
Target := List'Last - Quarter;
else
Target := List'First + Quarter;
Quarter := Quarter / 2;
end if;
end loop;
end Dispatch;
-- ------------------------------
-- Render the tag cloud component.
-- ------------------------------
overriding
procedure Encode_Children (UI : in Tag_UICloud;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
procedure Free is
new Ada.Unchecked_Deallocation (Object => Tag_Info_Array,
Name => Tag_Info_Array_Access);
Table : Tag_Info_Array_Access := null;
begin
if not UI.Is_Rendered (Context) then
return;
end if;
declare
use type Util.Beans.Basic.List_Bean_Access;
Max : constant Integer := UI.Get_Attribute ("rows", Context, 1000);
Layout : constant String := UI.Get_Attribute ("layout", Context);
Bean : constant Util.Beans.Basic.List_Bean_Access
:= ASF.Components.Utils.Get_List_Bean (UI, "value", Context);
Count : Natural;
Tags : AWA.Tags.Beans.Tag_Ordered_Sets.Set;
List : AWA.Tags.Beans.Tag_Info_List_Bean_Access;
begin
-- Check that we have a List_Bean but do not complain if we have a null value.
if Bean = null or Max <= 0 then
return;
end if;
if not (Bean.all in AWA.Tags.Beans.Tag_Info_List_Bean'Class) then
ASF.Components.Base.Log_Error (UI, "Invalid tag list bean: it does not "
& "implement 'Tag_Info_List_Bean' interface");
return;
end if;
List := AWA.Tags.Beans.Tag_Info_List_Bean'Class (Bean.all)'Unchecked_Access;
Count := List.Get_Count;
if Count = 0 then
return;
end if;
-- Pass 1: Collect the tags and keep the most used.
for I in 1 .. Count loop
Tags.Insert (List.List.Element (I - 1));
if Integer (Tags.Length) > Max then
Tags.Delete_Last;
end if;
end loop;
Count := Natural (Tags.Length);
Table := new Tag_Info_Array (1 .. Count);
for I in 1 .. Count loop
Table (I) := Tags.First_Element;
Tags.Delete_First;
end loop;
-- Pass 2: Assign weight to each tag.
UI.Compute_Cloud_Weight (Table.all, Context);
-- Pass 3: Dispatch the tags using some layout algorithm.
if Layout = "dispatch" then
Dispatch (Table.all);
end if;
-- Pass 4: Render each tag.
UI.Render_Cloud (Table.all, Context);
Free (Table);
exception
when others =>
Free (Table);
raise;
end;
end Encode_Children;
begin
ASF.Utils.Set_Text_Attributes (READONLY_ATTRIBUTE_NAMES);
end AWA.Tags.Components;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with
gel.World,
gel.Camera,
gel.Window;
package gel.Applet.gui_and_sim_world
--
-- Provides an applet configured with a single window and
-- two worlds (generally a simulation world and a gui world).
--
is
type Item is limited new gel.Applet.item with private;
type View is access all Item'Class;
package Forge
is
function to_Applet (Name : in String;
use_Window : in gel.Window.view) return Item;
function new_Applet (Name : in String;
use_Window : in gel.Window.view) return View;
end Forge;
gui_world_Id : constant gel. world_Id := 1;
gui_camera_Id : constant gel.camera_Id := 1;
sim_world_Id : constant gel. world_Id := 2;
sim_camera_Id : constant gel.camera_Id := 1;
function gui_World (Self : in Item) return gel.World .view;
function gui_Camera (Self : in Item) return gel.Camera.view;
function sim_World (Self : in Item) return gel.World .view;
function sim_Camera (Self : in Item) return gel.Camera.view;
private
type Item is limited new gel.Applet.item with
record
null;
end record;
end gel.Applet.gui_and_sim_world;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- { dg-do run }
-- { dg-options "-gnatp" }
procedure Discr24 is
type Family_Type is (Family_Inet, Family_Inet6);
type Port_Type is new Natural;
subtype Inet_Addr_Comp_Type is Natural range 0 .. 255;
type Inet_Addr_VN_Type is array (Natural range <>) of Inet_Addr_Comp_Type;
subtype Inet_Addr_V4_Type is Inet_Addr_VN_Type (1 .. 4);
subtype Inet_Addr_V6_Type is Inet_Addr_VN_Type (1 .. 16);
type Inet_Addr_Type (Family : Family_Type := Family_Inet) is record
case Family is
when Family_Inet =>
Sin_V4 : Inet_Addr_V4_Type := (others => 0);
when Family_Inet6 =>
Sin_V6 : Inet_Addr_V6_Type := (others => 0);
end case;
end record;
type Sock_Addr_Type (Family : Family_Type := Family_Inet) is record
Addr : Inet_Addr_Type (Family);
Port : Port_Type;
end record;
function F return Inet_Addr_Type is
begin
return Inet_Addr_Type'
(Family => Family_Inet, Sin_V4 => (192, 168, 169, 170));
end F;
SA : Sock_Addr_Type;
begin
SA.Addr.Sin_V4 := (172, 16, 17, 18);
SA.Port := 1111;
SA.Addr := F;
if SA.Port /= 1111 then
raise Program_Error;
end if;
end;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This is a POSIX version of this package where foreign threads are
-- recognized.
-- Currently, DEC Unix, SCO UnixWare, Solaris pthread, HPUX pthread and
-- GNU/Linux threads use this version.
separate (System.Task_Primitives.Operations)
package body Specific is
----------------
-- Initialize --
----------------
procedure Initialize (Environment_Task : Task_Id) is
pragma Warnings (Off, Environment_Task);
Result : Interfaces.C.int;
begin
Result := pthread_key_create (ATCB_Key'Access, null);
pragma Assert (Result = 0);
end Initialize;
-------------------
-- Is_Valid_Task --
-------------------
function Is_Valid_Task return Boolean is
begin
return pthread_getspecific (ATCB_Key) /= System.Null_Address;
end Is_Valid_Task;
---------
-- Set --
---------
procedure Set (Self_Id : Task_Id) is
Result : Interfaces.C.int;
begin
Result := pthread_setspecific (ATCB_Key, To_Address (Self_Id));
pragma Assert (Result = 0);
end Set;
----------
-- Self --
----------
-- To make Ada tasks and C threads interoperate better, we have added some
-- functionality to Self. Suppose a C main program (with threads) calls an
-- Ada procedure and the Ada procedure calls the tasking runtime system.
-- Eventually, a call will be made to self. Since the call is not coming
-- from an Ada task, there will be no corresponding ATCB.
-- What we do in Self is to catch references that do not come from
-- recognized Ada tasks, and create an ATCB for the calling thread.
-- The new ATCB will be "detached" from the normal Ada task master
-- hierarchy, much like the existing implicitly created signal-server
-- tasks.
function Self return Task_Id is
Result : System.Address;
begin
Result := pthread_getspecific (ATCB_Key);
-- If the key value is Null, then it is a non-Ada task.
if Result /= System.Null_Address then
return To_Task_Id (Result);
else
return Register_Foreign_Thread;
end if;
end Self;
end Specific;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Numerics.Float_Random;
with Ada.Numerics.Discrete_Random;
with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Containers.Vectors;
with Ada.Containers.Synchronized_Queue_Interfaces;
with Ada.Containers.Unbounded_Priority_Queues;
use type Ada.Containers.Count_Type;
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Strings.Fixed;
use Ada.Strings.Fixed;
separate (WFC)
package body Extended_Interfaces is
function Generic_Collapse_Within (Parameters : in Instance) return Boolean is
X_Dim_Length : constant X_Dim := X_Dim'Last - X_Dim'First + 1;
Y_Dim_Length : constant Y_Dim := Y_Dim'Last - Y_Dim'First + 1;
Num_Tiles : Natural renames Parameters.Num_Tiles;
Tile_Elements : Tile_Element_Array renames Parameters.Tile_Elements;
Frequency_Total : Natural renames Parameters.Frequency_Total;
Frequencies : Frequency_Array renames Parameters.Frequencies;
Adjacencies : Adjacency_Matrix renames Parameters.Adjacencies;
Init_Enablers : Enabler_Counts renames Parameters.Enablers;
Unsatisfiable_Tile_Constraint : exception;
subtype Tile_ID_Range is
Tile_ID range 1 .. Num_Tiles;
type Wave_Function is
array (Tile_ID_Range) of Boolean
with Pack;
package Float_Functions is
new Ada.Numerics.Generic_Elementary_Functions(Float);
function Frequency_Log_Frequency (Frequency : Natural) return Float is
Freq_Float : constant Float := Float(Frequency);
begin
return Freq_Float * Float_Functions.Log(Freq_Float);
end;
function Init_Log_Frequency_Total return Float is
Total : Float := 0.0;
begin
for Frequency of Frequencies loop
Total := Total + Frequency_Log_Frequency(Frequency);
end loop;
return Total;
end;
function Log_Frequency_Noise return Float is
use Ada.Numerics.Float_Random;
G : Generator;
begin
Reset(G);
return Random(G) * 1.0E-4;
end;
Log_Frequency_Total : constant Float := Init_Log_Frequency_Total;
type Entropy_Cell is record
Frequency_Sum : Natural := Frequency_Total;
Log_Frequency_Sum : Float := Log_Frequency_Total;
Noise : Float := Log_Frequency_Noise;
end record;
type Wave_Function_Cell is record
Collapsed : Boolean := False;
Possible : Wave_Function := (others => True);
Enablers : Enabler_Counts(Tile_ID_Range) := Init_Enablers;
Entropy : Entropy_Cell;
end record;
function Num_Remaining_Possibilities (Cell : in Wave_Function_Cell) return Natural is
Result : Natural := 0;
begin
for The_Tile_ID in Tile_ID_Range loop
if Cell.Possible(The_Tile_ID) then
Result := Result + 1;
end if;
end loop;
return Result;
end;
function Random_Remaining_Tile (Cell : in Wave_Function_Cell) return Tile_ID_Range is
subtype Choice_Range is Natural range 1 .. Cell.Entropy.Frequency_Sum;
package Random_Choice is new Ada.Numerics.Discrete_Random(Choice_Range);
use Random_Choice;
G : Generator;
Choice : Choice_Range;
begin
Reset(G);
Choice := Random(G);
for The_Tile_ID in Tile_ID_Range loop
if Cell.Possible(The_Tile_ID) then
if Choice <= Frequencies(The_Tile_ID) then
return The_Tile_ID;
else
Choice := Choice - Frequencies(The_Tile_ID);
end if;
end if;
end loop;
raise Constraint_Error;
end;
function Entropy_Value (Cell : in Wave_Function_Cell) return Float is
Float_Freq_Sum : constant Float := Float(Cell.Entropy.Frequency_Sum);
Log_Freq_Sum : constant Float := Float_Functions.Log(Float_Freq_Sum);
begin
return Cell.Entropy.Noise + Log_Freq_Sum -
(Cell.Entropy.Log_Frequency_Sum / Float_Freq_Sum);
end;
Remaining_Uncollapsed : Natural :=
Natural(X_Dim_Length) * Natural(Y_Dim_Length);
type Wave_Function_Matrix_Type is
array (X_Dim, Y_Dim) of Wave_Function_Cell;
type Wave_Function_Matrix_Access is
access Wave_Function_Matrix_Type;
Wave_Function_Matrix : constant Wave_Function_Matrix_Access
:= new Wave_Function_Matrix_Type;
type Info is new Collapse_Info with null record;
overriding
function Is_Possible
(This : in Info; X : X_Dim; Y : Y_Dim; T : Tile_ID) return Boolean;
overriding
function Is_Possible
(This : in Info; X : X_Dim; Y : Y_Dim; E : Element_Type) return Boolean;
overriding
function Is_Possible
(This : in Info; X : X_Dim; Y : Y_Dim; T : Tile_ID) return Boolean
is
pragma Unreferenced (This);
Cell : Wave_Function_Cell renames Wave_Function_Matrix(X, Y);
begin
return (T in Tile_ID_Range) and then Cell.Possible(T);
end;
overriding
function Is_Possible
(This : in Info; X : X_Dim; Y : Y_Dim; E : Element_Type) return Boolean
is
pragma Unreferenced (This);
Cell : Wave_Function_Cell renames Wave_Function_Matrix(X, Y);
begin
return (for some Tile_ID in Tile_ID_Range =>
Cell.Possible(Tile_ID) and then Tile_Elements(Tile_ID) = E);
end;
Collapsed_Tile_Choices : array (X_Dim, Y_Dim) of Tile_ID_Range;
type Cell_Coord is record
X : X_Dim;
Y : Y_Dim;
end record;
function Neighbor (Coord : in Cell_Coord; Direction : in Adjacency_Direction) return Cell_Coord is
X : X_Dim renames Coord.X;
Y : Y_Dim renames Coord.Y;
begin
return (case Direction is
when Upwards =>
(X => X, Y => ((Y - 1 - Y_Dim'First) mod Y_Dim_Length) + Y_Dim'First),
when Downwards =>
(X => X, Y => ((Y + 1 - Y_Dim'First) mod Y_Dim_Length) + Y_Dim'First),
when Leftwards =>
(Y => Y, X => ((X - 1 - X_Dim'First) mod X_Dim_Length) + X_Dim'First),
when Rightwards =>
(Y => Y, X => ((X + 1 - X_Dim'First) mod X_Dim_Length) + X_Dim'First)
);
end;
type Entropy_Cell_ID is record
Coord : Cell_Coord;
Entropy : Float;
end record;
function Entropy_Cell_At (X : X_Dim; Y : Y_Dim) return Entropy_Cell_ID
is
Cell : Wave_Function_Cell renames Wave_Function_Matrix(X, Y);
Entropy : constant Float := Entropy_Value(Cell);
begin
return Entropy_Cell_ID'((X, Y), Entropy);
end;
function Entropy_Cell_Priority (Cell_ID : in Entropy_Cell_ID) return Float is
( Cell_ID.Entropy );
package Entropy_Queue_Interfaces is
new Ada.Containers.Synchronized_Queue_Interfaces(Entropy_Cell_ID);
package Entropy_Priority_Queues is
new Ada.Containers.Unbounded_Priority_Queues
( Entropy_Queue_Interfaces
, Queue_Priority => Float
, Get_Priority => Entropy_Cell_Priority
, Before => "<");
Entropy_Heap : Entropy_Priority_Queues.Queue;
type Removal_Update is record
Coord : Cell_Coord;
Removed_Tile_ID : Tile_ID_Range;
end record;
package Removal_Vectors is
new Ada.Containers.Vectors(Natural, Removal_Update);
Propagation_Removals : Removal_Vectors.Vector;
procedure Collapse (X : X_Dim; Y : Y_Dim) is
Cell : Wave_Function_Cell renames Wave_Function_Matrix(X, Y);
Collapsed_Tile : Tile_ID_Range;
begin
if Cell.Collapsed then
return;
end if;
Collapsed_Tile := Random_Remaining_Tile(Cell);
Cell.Collapsed := True;
for Tile_Possibility in Tile_ID_Range loop
if Tile_Possibility /= Collapsed_Tile and Cell.Possible(Tile_Possibility) then
Cell.Possible(Tile_Possibility) := False;
Propagation_Removals.Append(
Removal_Update'((X, Y), Tile_Possibility));
end if;
end loop;
if Num_Remaining_Possibilities(Cell) = 0 then
raise Unsatisfiable_Tile_Constraint with
Cell.Entropy.Frequency_Sum'Image
& " " & Cell.Entropy.Log_Frequency_Sum'Image
& " " & X'Image
& " " & Y'Image;
end if;
Collapsed_Tile_Choices(X, Y) := Collapsed_Tile;
Remaining_Uncollapsed := Remaining_Uncollapsed - 1;
Upon_Collapse(X, Y, Info'(null record));
end;
procedure Remove_Tile_Possibility (X : X_Dim; Y : Y_Dim; T : Tile_ID_Range) is
Cell : Wave_Function_Cell renames Wave_Function_Matrix(X, Y);
T_Freq : constant Natural := Frequencies(T);
begin
if not Cell.Possible(T) then
return;
end if;
Cell.Possible(T) := False;
Cell.Entropy.Frequency_Sum :=
Cell.Entropy.Frequency_Sum - T_Freq;
Cell.Entropy.Log_Frequency_Sum :=
Cell.Entropy.Log_Frequency_Sum - Frequency_Log_Frequency(T_Freq);
if Num_Remaining_Possibilities(Cell) = 0 then
raise Unsatisfiable_Tile_Constraint with
Cell.Entropy.Frequency_Sum'Image
& " " & Cell.Entropy.Log_Frequency_Sum'Image
& " " & X'Image
& " " & Y'Image;
end if;
Entropy_Heap.Enqueue(Entropy_Cell_At(X, Y));
Propagation_Removals.Append(Removal_Update'((X, Y), T));
end;
procedure Handle_Propagation_Removal (Update : in Removal_Update) is
Coord : Cell_Coord renames Update.Coord;
Removed_Tile_ID : Tile_ID_Range renames Update.Removed_Tile_ID;
begin
for Direction in Adjacency_Direction loop
for Adjacent_Tile in Tile_ID_Range loop
if Adjacencies(Removed_Tile_ID, Adjacent_Tile)(Direction) then
declare
Nbor_Coord : constant Cell_Coord := Neighbor(Coord, Direction);
Nbor_Cell : Wave_Function_Cell renames
Wave_Function_Matrix(Nbor_Coord.X, Nbor_Coord.Y);
Opposite : constant Adjacency_Direction := Opposite_Direction(Direction);
Enablers : Enablers_By_Direction renames Nbor_Cell.Enablers(Adjacent_Tile);
begin
if (for all Count of Enablers => Count /= 0) then
Enablers(Opposite) := Enablers(Opposite) - 1;
if Enablers(Opposite) = 0 then
Remove_Tile_Possibility(Nbor_Coord.X, Nbor_Coord.Y, Adjacent_Tile);
end if;
Upon_Removal(Nbor_Coord.X, Nbor_Coord.Y, Info'(null record));
end if;
end;
end if;
end loop;
end loop;
end;
procedure Put_Debug_Info is
begin
Put_Line(Standard_Error, "Tile_ID_Bytes =>" & Integer'Image(Tile_ID_Range'Object_Size / 8));
Put_Line(Standard_Error, " Small_Bytes =>" & Integer'Image(Small_Integer'Object_Size / 8));
Put_Line(Standard_Error, " Cell_Bytes =>" & Integer'Image(Wave_Function_Cell'Object_Size / 8));
Put_Line(Standard_Error, " Wave_Bytes =>" & Integer'Image(Wave_Function'Object_Size / 8));
Put_Line(Standard_Error, "Enabler_Bytes =>" & Integer'Image(Init_Enablers'Size / 8));
Put_Line(Standard_Error, " Matrix_Bytes =>" & Integer'Image(Wave_Function_Matrix.all'Size / 8));
New_Line(Standard_Error, 1);
for Y in Y_Dim loop
for X in X_Dim loop
declare
Collapsed_Tile : constant Tile_ID_Range := Collapsed_Tile_Choices(X, Y);
begin
Put(Standard_Error, Tail(Tile_ID'Image(Collapsed_Tile), 4));
end;
end loop;
New_Line(Standard_Error);
end loop;
New_Line(Standard_Error);
end;
begin
declare
type Settings is new Info and Collapse_Settings with null record;
overriding
procedure Require (This : Settings; X : X_Dim; Y : Y_Dim; T : Tile_ID);
overriding
procedure Require (This : Settings; X : X_Dim; Y : Y_Dim; E : Element_Type);
overriding
procedure Require (This : Settings; X : X_Dim; Y : Y_Dim; T : Tile_ID) is
pragma Unreferenced (This);
begin
for Other_T in Tile_ID_Range loop
if Other_T /= T then
Remove_Tile_Possibility(X, Y, Other_T);
end if;
end loop;
end;
overriding
procedure Require (This : Settings; X : X_Dim; Y : Y_Dim; E : Element_Type) is
pragma Unreferenced (This);
begin
for T in Tile_ID_Range loop
if Tile_Elements(T) /= E then
Remove_Tile_Possibility(X, Y, T);
end if;
end loop;
end;
begin
Set_Initial_Requirements(Settings'(null record));
while Propagation_Removals.Length > 0 loop
declare
Next_Update : constant Removal_Update := Propagation_Removals.Last_Element;
begin
Propagation_Removals.Delete_Last;
Handle_Propagation_Removal(Next_Update);
end;
end loop;
end;
-- Initialize cell entropy heap
for X in X_Dim loop
for Y in Y_Dim loop
Entropy_Heap.Enqueue(Entropy_Cell_At(X, Y));
end loop;
end loop;
while Remaining_Uncollapsed > 0 loop
declare
Min_Entropy : Entropy_Cell_ID;
Min_X : X_Dim renames Min_Entropy.Coord.X;
Min_Y : Y_Dim renames Min_Entropy.Coord.Y;
Next_Update : Removal_Update;
begin
Entropy_Heap.Dequeue(Min_Entropy);
Collapse(Min_X, Min_Y);
while Propagation_Removals.Length > 0 loop
Next_Update := Propagation_Removals.Last_Element;
Propagation_Removals.Delete_Last;
Handle_Propagation_Removal(Next_Update);
end loop;
exception
when Unsatisfiable_Tile_Constraint => return False;
end;
end loop;
pragma Debug (Put_Debug_Info);
for X in X_Dim loop
for Y in Y_Dim loop
declare
Collapsed_Tile : constant Tile_ID_Range := Collapsed_Tile_Choices(X, Y);
begin
Set_Resulting_Element(X, Y, Tile_Elements(Collapsed_Tile));
end;
end loop;
end loop;
return True;
end;
end;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
------------------------------------------------------------------------------
-- This package implements an extension of TCP_Connection that is secured with
-- TLS.
with INET.TLS; use INET.TLS;
private with INET.Internal.TLS;
package INET.TCP.TLS is
Explicit_Handshake_Timeout: constant Duration := 30.0;
-- TODO: Migrate to AURA config. This might end up in TLS_Configuration, but
-- this seems problematic since libtls executes handshakes on it's own
-- volition, and we can't control the timeouts of those. It might be
-- misleading to put that property there
--------------------
-- TLS_Connection --
--------------------
type TLS_Connection is abstract limited new TCP_Connection with private;
-- TLS_Connection is an extension of TCP_Connection, and behaves in the
-- same way, with the underlying communications being secured by TLS.
--
-- If Configuration is null, the connection can only be established
-- via TLS_Listener.Dequeue (and thus is a server-side connection)
--
-- For security-concious applications where client authentication is
-- also requred (and thus the Configuration contains private keys),
-- Clear_Keys can be invoked on Configuration after the required
-- TCP_Connections have been established.
not overriding
function Secured (Connection: TLS_Connection) return Boolean;
-- True iff the Connection has successfull established a TLS session
-- over the underlying TCP connection.
--
-- Default initialized TLS_Connection'Class objects return False.
--
-- If a TLS_Connection is Dequeued from a TCP_Listener'Class object that
-- is not a member of TLS_Listener'Class, Established will return False.
--
-- Read or Write operations are illegal if Secured is false and
-- will cause Program_Error to be raised.
--
-- Unsecured connections can be secured by the Secure operation
--
-- See the description of Secure for example applications of
-- unsecured TLS_Connection objects.
overriding
procedure Read (Stream: in out TLS_Connection;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset)
with Pre => Stream.Secured;
-- Semantics are preserved as with TCP_Connection.
--
-- Program_Error is raised if the connection has not yet been Secured.
overriding
procedure Read_Immediate (Stream: in out TLS_Connection;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset)
with Pre => Stream.Secured;
-- Semantics are preserved as with TCP_Connection
--
-- Program_Error is raised if the connection has not yet been Secured.
overriding
procedure Write (Stream: in out TLS_Connection;
Item : in Stream_Element_Array)
with Pre => Stream.Secured;
-- Semantics are preserved as with TCP_Connection
--
-- Program_Error is raised if the connection has not yet been Secured.
overriding
procedure Write_Immediate (Stream: in out TLS_Connection;
Item : in Stream_Element_Array;
Last : out Stream_Element_Offset)
with Pre => Stream.Secured;
-- Semantics are preserved as with TCP_Connection
--
-- Program_Error is raised if the connection has not yet been Secured.
overriding procedure Shutdown (Connection: in out TLS_Connection);
overriding procedure Shutdown_Read (Connection: in out TLS_Connection);
overriding procedure Shutdown_Write (Connection: in out TLS_Connection);
-- Shutdown Read and Shutdown Write are not supported for TLS connections
-- at the socket (TCP) level. In order to preserve the behaviour as much as
-- possible, the _Read and _Write variations will cause raise End_Error if
-- a subsequent read/write is performed on the shutdown direction.
--
-- If both are invoked, Shutdown is invoked automatically.
---------------------------
-- TLS_Client_Connection --
---------------------------
type TLS_Client_Connection
(Configuration: not null access TLS_Client_Configuration'Class)
is limited new TLS_Connection with private;
-- A TLS_Client_Connection is only able to form outbound connections.
overriding
procedure Connect (Connection: in out TLS_Client_Connection;
Address : in IP.IP_Address;
Port : in TCP_Port)
with No_Return; -- Raises Program_Error
not overriding
procedure Connect (Connection : in out TLS_Client_Connection;
Address : in IP.IP_Address;
Port : in TCP_Port;
Server_Name: in String)
with Pre'Class => Server_Name'Length > 0;
overriding
procedure Connect (Connection: in out TLS_Client_Connection;
Host_Name : in String;
Port : in TCP_Port);
overriding
procedure Connect (Connection : in out TLS_Client_Connection;
Host_Name : in String;
Port : in TCP_Port;
Version : in IP.IP_Version);
-- Attempts to establish a TLS connection over an new TCP connection.
-- If Connection is already connected (or Secured), it is first shutdown.
--
-- TLS requires the verification of the server's hostname as part of the
-- handshake, therefore connecting with only an Address and a Port requires
-- a supplimental Server_Name. If the inherited Address-only Connect is
-- invoked, Program_Error is raised.
--
-- It is generally recommended to use the inhereted Host_Name lookup
-- operations for outbound TLS connections.
not overriding
procedure Secure (Connection : in out TLS_Client_Connection;
Server_Name: in String)
with Pre'Class => Server_Name'Length > 0,
Post'Class => Connection.Secured;
-- Secure completes a TLS handshake initiated by the remote peer
-- (the server). If it returns without error, TLS has been successfully
-- established for the connection, according to Connection.Configuration.
--
-- If the connection is already Secured, Secure forces another handshake.
-- This works even if Shutdown_Read or Shutdown_Write has been invoked
-- (but not both, nor Shutdown - which makes the connection inactive).
--
-- If a Server_Name is specified, this will be used to verify the server
-- name through the SNI extension (RFC4366). If Server_Name is a null string,
-- Constraint_Error is raised.
--
-- If the connection has been fully Shutdown, Program_Error is raised.
--
-- If Secure fails, the connection is shutdown, and an exception is
-- always propegated.
--
-- The remote peer must be a server, or else the TLS handshake will fail.
-- Therefore, if Connection was initialized by a Dequeue from a TCP_Listener,
-- TLS_Error is all but guaranteed.
--
-- For special application protocols that may start as plain-text,
-- such as SMTP with STARTTLS, the socket may be first view converted
-- upwards to a TCP_Connection, Connect invoked on that converion, and
-- the subsequent plain-text negotiation. When ready to establish a TLS
-- connection, Secure can be then be invoked on the underlying
-- TLS_Client_Connection object.
---------------------------
-- TLS_Server_Connection --
---------------------------
type TLS_Server_Connection is limited new TLS_Connection with private;
-- TLS_Server_Connection objects do not need a configuration if Dequeued
-- from a TLS_Listener. The context is implicitly configured from the
-- TLS_Listener, which is configured via a TLS_Server_Configuration
-- access discriminant
overriding
procedure Connect (Connection: in out TLS_Server_Connection;
Address : in IP.IP_Address;
Port : in TCP_Port)
with No_Return;
procedure Connect (Connection: in out TLS_Server_Connection;
Host_Name : in String;
Port : in TCP_Port)
with No_Return;
procedure Connect (Connection : in out TLS_Server_Connection;
Host_Name : in String;
Port : in TCP_Port;
Version : in IP.IP_Version)
with No_Return;
-- Connect is not legal on a server connection. Invoking Connect raises
-- Program_Error.
not overriding
procedure Secure (Connection : in out TLS_Server_Connection;
Configuration: in TLS_Server_Configuration'Class)
with Pre'Class => not Connection.Secured,
Post'Class => Connection.Secured;
-- Secure initiates a TLS handshake with the remote peer (the client).
-- If it returns without error, TLS has been successfully established for
-- the connection, according to the Configuration.
--
-- Due to the presence of the Configuration parameter, which is non-
-- sensical on an established connection, invoking Secure on a Secured
-- connection raises Program_Error.
--
-- To force a handshake, see Re_secure below.
--
-- If the connection has been fully Shutdown, Program_Error is raised.
--
-- If Secure fails, the connection is shutdown, and an exception is
-- always propegated.
--
-- The remote peer must be a client, or else the TLS handshake will fail.
-- Therefore, if Connection was initialized by a Connect via a upwards
-- view conversion. TLS_Error is all but guaranteed.
--
-- For special application protocols that may start as plain-text,
-- such as SMTP with STARTTLS, the socket may be dequeued from a
-- regular TCP_Listener (rather than a TLS_Listener), and then
-- view converted up to a regular TCP_Connection to perform the clear-text
-- negotiation. When ready to establish a TLS connection, Secure can be
-- then be invoked on the underlying TLS_Server_Connection object.
not overriding
procedure Re_Secure (Connection: in out TLS_Server_Connection) with
Pre'Class => Connection.Secured;
-- Connection must already be Secured, or else Program_Error is raised.
-- Otherwise, Re_secure forces a handshake immediately. If Re_secure
-- returns successfully, the handshake was successful.
--
-- If the connection has been fully Shutdown, Program_Error is raised.
--
-- If Re_secure fails, the connection is shutdown, and an exception is
-- always propegated.
------------------
-- TLS_Listener --
------------------
type TLS_Listener
(Queue_Size : Positive;
Configuration: not null access TLS_Server_Configuration'Class)
is limited new TCP_Listener with private;
-- Note that sessions can stil be managed separately via the Configuration
-- object, even while the listener is live (Bound)
overriding
procedure Bind (Listener: in out TLS_Listener;
Address : in IP.IP_Address;
Port : in TCP_Port);
-- Note that Clear_Keys may be invoked on Configuration after all
-- TLS_Listener objects that depend on it have been successfully
-- Bound. In other words, Bind is what establishes the listener context,
-- and is therefore that moment that the keys are copied to that
-- context.
overriding
procedure Dequeue (Listener : in out TLS_Listener;
Connection: in out TCP_Connection'Class)
with Pre => Connection in TLS_Server_Connection'Class;
overriding
function Dequeue (Listener: in out TLS_Listener) return TCP_Connection'Class
with Post'Class => Dequeue'Result in TLS_Server_Connection'Class
and then TLS_Connection'Class (Dequeue'Result).Secured;
-- Dequeues an established TLS_Server_Connection object from a TLS_Listener.
-- The dequeued TLS_Server_Connection will be secured, and ready for use.
--
-- To negotiate plain-text protocols before initiating TLS, a TCP_Listener
-- that is not a member of TLS_Listener'Class should be used to dequeue to
-- a TLS_Server_Connection object. See TLS_Server_Connection.Secure, above.
--
-- If using the procedure, if Connection is connected (secured or not), it
-- is first closed
private
type TLS_Connection is
limited new TCP.TCP_Connection with
record
Context: INET.Internal.TLS.TLS_Stream_Context;
TLS_Go: Boolean := False;
-- Set to True only if the connection and handshake attempt is
-- reported successful by libtls. This value must be True
-- for Reads or Writes to be allowed.
Read_Down, Write_Down: Boolean := False;
-- Used to track the use of Shutdown_Read/_Write. See the
-- comments for Shutdown above for more information.
end record;
-- All a TLS Connection really needs is a context. The context is sufficent
-- to send and receive, and to manage the state of the connection. Contexts
-- are created during Connect, Secure, or when Dequeing from a TLS_Listener
-- object Contexts are reset if possible, making it possible for the
-- underlying libtls to re-use memory, however this appears to be unlikely.
type TLS_Client_Connection
(Configuration: not null access TLS_Client_Configuration'Class)
is limited new TLS_Connection with null record;
type TLS_Server_Connection is limited new TLS_Connection with null record;
------------------
-- TLS_Listener --
------------------
type TLS_Listener
(Queue_Size : Positive;
Configuration: not null access TLS_Server_Configuration'Class)
is limited new TCP_Listener (Queue_Size) with
record
Context: INET.Internal.TLS.TLS_Listener_Context;
end record;
end INET.TCP.TLS;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Types; use Types;
package Sem_Ch5 is
procedure Analyze_Assignment (N : Node_Id);
procedure Analyze_Block_Statement (N : Node_Id);
procedure Analyze_Case_Statement (N : Node_Id);
procedure Analyze_Compound_Statement (N : Node_Id);
procedure Analyze_Exit_Statement (N : Node_Id);
procedure Analyze_Goto_Statement (N : Node_Id);
procedure Analyze_If_Statement (N : Node_Id);
procedure Analyze_Implicit_Label_Declaration (N : Node_Id);
procedure Analyze_Iterator_Specification (N : Node_Id);
procedure Analyze_Iteration_Scheme (N : Node_Id);
procedure Analyze_Label (N : Node_Id);
procedure Analyze_Loop_Parameter_Specification (N : Node_Id);
procedure Analyze_Loop_Statement (N : Node_Id);
procedure Analyze_Null_Statement (N : Node_Id);
procedure Analyze_Statements (L : List_Id);
procedure Analyze_Target_Name (N : Node_Id);
procedure Analyze_Label_Entity (E : Entity_Id);
-- This procedure performs direct analysis of the label entity E. It
-- is used when a label is created by the expander without bothering
-- to insert an N_Implicit_Label_Declaration in the tree. It also takes
-- care of setting Reachable, since labels defined by the expander can
-- be assumed to be reachable.
procedure Check_Unreachable_Code (N : Node_Id);
-- This procedure is called with N being the node for a statement that is
-- an unconditional transfer of control or an apparent infinite loop. It
-- checks to see if the statement is followed by some other statement, and
-- if so generates an appropriate warning for unreachable code.
end Sem_Ch5;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Finalization;
generic
type Data_Type is private;
type Data_Access is access Data_Type;
package kv.Ref_Counting_Mixin is
type Control_Type is
record
Count : Natural := 0;
Data : Data_Access;
end record;
type Control_Access is access Control_Type;
type Ref_Type is new Ada.Finalization.Controlled with
record
Control : Control_Access;
end record;
overriding procedure Initialize(Self : in out Ref_Type);
overriding procedure Adjust(Self : in out Ref_Type);
overriding procedure Finalize(Self : in out Ref_Type);
procedure Set(Self : in out Ref_Type; Data : in Data_Access);
function Get(Self : Ref_Type) return Data_Access;
end kv.Ref_Counting_Mixin;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
package body Selection with SPARK_Mode is
procedure Sort (A: in out Arr) is
Tmp: Integer;
Min: Integer;
begin
for I in Integer range A'First .. A'Last loop
Min := I;
for J in Integer range I + 1 .. A'Last loop
pragma Loop_Invariant (for all K in I .. J - 1 => A (Min) <= A (K));
pragma Loop_Invariant (Min in I .. A'Last);
if A (J) < A(Min) then
Min := J;
end if;
end loop;
Tmp := A (I);
A (I) := A (Min);
A (Min) := Tmp;
pragma Loop_Invariant (for all K in A'First .. I => (for all M in K + 1 .. A'Last => A (K) <= A (M)));
end loop;
end Sort;
end Selection;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Calendar;
package PortScan.Log is
package CAL renames Ada.Calendar;
overall_log : exception;
-- Open log, dump diagnostic data and stop timer.
function initialize_log
(log_handle : in out TIO.File_Type;
head_time : out CAL.Time;
seq_id : port_id;
slave_root : String;
UNAME : String;
BENV : String;
COPTS : String;
PTVAR : String;
block_dog : Boolean) return Boolean;
-- Stop time, write duration data, close log
procedure finalize_log
(log_handle : in out TIO.File_Type;
head_time : CAL.Time;
tail_time : out CAL.Time);
-- Helper to format phase/section heading
function log_section (title : String) return String;
-- Format start of build phase in log
procedure log_phase_begin (log_handle : TIO.File_Type; phase : String);
-- Format end of build phase in log
procedure log_phase_end (log_handle : TIO.File_Type);
-- Standard log name based on port origin and variant.
function log_name (sid : port_id) return String;
-- Returns formatted difference in seconds between two times
function elapsed_HH_MM_SS (start, stop : CAL.Time) return String;
-- Returns formatted difference in seconds between overall start time and now.
function elapsed_now return String;
-- Establish times before the start and upon completion of a scan.
procedure set_scan_start_time (mark : CAL.Time);
procedure set_scan_complete (mark : CAL.Time);
-- Establish times before the start and upon completion of a bulk run
procedure set_overall_start_time (mark : CAL.Time);
procedure set_overall_complete (mark : CAL.Time);
-- build log operations
procedure start_logging (flavor : count_type);
procedure stop_logging (flavor : count_type);
procedure scribe (flavor : count_type; line : String; flush_after : Boolean);
procedure flush_log (flavor : count_type);
-- Establish values of build counters
procedure set_build_counters (A, B, C, D, E : Natural);
-- Increments the indicated build counter by some quality.
procedure increment_build_counter (flavor : count_type; quantity : Natural := 1);
-- Open log to document packages that get deleted and the reason why
procedure start_obsolete_package_logging;
procedure stop_obsolete_package_logging;
-- Write to log if open and optionally output a copy to screen.
procedure obsolete_notice (message : String; write_to_screen : Boolean);
-- Return WWW report-formatted timestamp of start time.
function www_timestamp_start_time return String;
-- Return current build queue size
function ports_remaining_to_build return Integer;
-- Return value of individual port counter
function port_counter_value (flavor : count_type) return Integer;
-- Return number of packages built since build started
function hourly_build_rate return Natural;
-- Return number of packages built in the last 600 seconds
function impulse_rate return Natural;
-- Show duration between overall start and stop times.
function bulk_run_duration return String;
-- Return formatted duration of scan
function scan_duration return String;
-- Former private function exposed for web page generator
function timestamp (hack : CAL.Time; www_format : Boolean := False) return String;
private
type impulse_rec is
record
hack : CAL.Time;
packages : Natural := 0;
virgin : Boolean := True;
end record;
subtype logname_field is String (1 .. 19);
subtype impulse_range is Integer range 1 .. 600;
type dim_handlers is array (count_type) of TIO.File_Type;
type dim_counters is array (count_type) of Natural;
type dim_logname is array (count_type) of logname_field;
type dim_impulse is array (impulse_range) of impulse_rec;
function log_duration (start, stop : CAL.Time) return String;
function split_collection (line : String; title : String) return String;
procedure dump_port_variables (log_handle : TIO.File_Type; contents : String);
-- Simple time calculation (guts)
function get_packages_per_hour (packages_done : Natural; from_when : CAL.Time) return Natural;
-- bulk run variables
Flog : dim_handlers;
start_time : CAL.Time;
stop_time : CAL.Time;
scan_start : CAL.Time;
scan_stop : CAL.Time;
bld_counter : dim_counters := (0, 0, 0, 0, 0);
impulse_counter : impulse_range := impulse_range'Last;
impulse_data : dim_impulse;
obsolete_pkg_log : TIO.File_Type;
obsolete_log_open : Boolean := False;
bailing : constant String := " (ravenadm must exit)";
logname : constant dim_logname := ("00_last_results.log",
"01_success_list.log",
"02_failure_list.log",
"03_ignored_list.log",
"04_skipped_list.log");
end PortScan.Log;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Asis.Declarations;
with Asis.Elements;
with Properties.Tools;
package body Properties.Declarations.Procedure_Body_Declarations is
----------
-- Code --
----------
function Code
(Engine : access Engines.Contexts.Context;
Element : Asis.Declaration;
Name : Engines.Text_Property) return League.Strings.Universal_String
is
Spec : constant Asis.Declaration :=
Asis.Declarations.Corresponding_Declaration (Element);
Is_Generic : constant Boolean :=
Asis.Elements.Declaration_Kind (Spec) in Asis.A_Generic_Declaration;
Is_Library_Level : constant Boolean := Asis.Elements.Is_Nil
(Asis.Elements.Enclosing_Element (Element));
Inside_Package : constant Boolean := Engine.Boolean.Get_Property
(Element, Engines.Inside_Package);
Is_Dispatching : constant Boolean := Engine.Boolean.Get_Property
(Element, Engines.Is_Dispatching);
Subprogram_Name : constant League.Strings.Universal_String :=
Engine.Text.Get_Property
(Element => Asis.Declarations.Names (Element) (1),
Name => Name);
List : constant Asis.Parameter_Specification_List :=
Asis.Declarations.Parameter_Profile (Element);
Has_Output : constant Boolean :=
Has_Simple_Output (Engine, Element, Engines.Has_Simple_Output);
Names : array (List'Range) of League.Strings.Universal_String;
First : Boolean := True;
Text : League.Strings.Universal_String;
begin
if Is_Generic then
return Text;
elsif Is_Library_Level then
Text.Append
(Properties.Tools.Library_Level_Header
(Asis.Elements.Enclosing_Compilation_Unit (Element)));
Text.Append ("return _ec.");
Text.Append (Subprogram_Name);
Text.Append ("=");
elsif Is_Dispatching then
declare
Tipe : constant Asis.Declaration :=
Tools.Corresponding_Type (Spec);
Type_Name : constant Asis.Defining_Name :=
Asis.Declarations.Names (Tipe) (1);
Image : constant League.Strings.Universal_String :=
Engine.Text.Get_Property (Type_Name, Name);
Method_Name : constant League.Strings.Universal_String :=
Engine.Text.Get_Property
(Element => Asis.Declarations.Names (Element) (1),
Name => Engines.Method_Name);
begin
if Inside_Package then
Text.Append ("_ec.");
Text.Append (Subprogram_Name);
Text.Append ("=");
Text.Append ("_ec.");
end if;
Text.Append (Image);
Text.Append (".prototype.");
Text.Append (Method_Name);
Text.Append (" = ");
end;
elsif Inside_Package then
Text.Append ("_ec.");
Text.Append (Subprogram_Name);
Text.Append ("=");
end if;
Text.Append ("function ");
Text.Append (Subprogram_Name);
Text.Append (" (");
declare
Default : League.Strings.Universal_String;
begin
for J in List'Range loop
declare
Init_Code : League.Strings.Universal_String;
Init : constant Asis.Expression :=
Asis.Declarations.Initialization_Expression (List (J));
Arg_Code : constant League.Strings.Universal_String :=
Engine.Text.Get_Property
(Asis.Declarations.Names (List (J)) (1), Name);
begin
Names (J) := Arg_Code;
if not Is_Dispatching or J /= List'First then
Text.Append (Arg_Code);
if J /= List'Last then
Text.Append (",");
end if;
if not Asis.Elements.Is_Nil (Init) then
Init_Code := Engine.Text.Get_Property (Init, Name);
Default.Append (Arg_Code);
Default.Append (" = typeof ");
Default.Append (Arg_Code);
Default.Append (" === 'undefined' ? ");
Default.Append (Init_Code);
Default.Append (" : ");
Default.Append (Arg_Code);
Default.Append (";");
end if;
end if;
end;
end loop;
Text.Append ("){");
Text.Append (Default);
end;
if Has_Output then
Text.Append ("function _return(){ return {");
for J in List'Range loop
if Engine.Boolean.Get_Property
(Element => List (J),
Name => Engines.Has_Simple_Output)
then
if First then
First := False;
else
Text.Append (", ");
end if;
Text.Append (Names (J));
Text.Append (": ");
Text.Append (Names (J));
end if;
end loop;
Text.Append ("}; };");
end if;
declare
Down : League.Strings.Universal_String;
List : constant Asis.Element_List :=
Asis.Declarations.Body_Declarative_Items (Element);
begin
Down := Engine.Text.Get_Property
(List => List,
Name => Name,
Empty => League.Strings.Empty_Universal_String,
Sum => Properties.Tools.Join'Access);
Text.Append (Down);
end;
declare
Down : League.Strings.Universal_String;
List : constant Asis.Element_List :=
Asis.Declarations.Body_Statements (Element);
begin
Down := Engine.Text.Get_Property
(List => List,
Name => Name,
Empty => League.Strings.Empty_Universal_String,
Sum => Properties.Tools.Join'Access);
Text.Append (Down);
end;
if Has_Output then
Text.Append ("return _return();");
end if;
Text.Append ("};");
if Is_Library_Level then
Text.Append ("});");
end if;
return Text;
end Code;
------------
-- Export --
------------
function Export
(Engine : access Engines.Contexts.Context;
Element : Asis.Declaration;
Name : Engines.Boolean_Property) return Boolean
is
Spec : constant Asis.Declaration :=
Asis.Declarations.Corresponding_Declaration (Element);
Result : constant Wide_String :=
Properties.Tools.Get_Aspect (Element, "Export");
begin
if Result = "True" then
return True;
elsif Asis.Elements.Is_Nil (Spec) then
return False;
else
return Engine.Boolean.Get_Property (Spec, Name);
end if;
end Export;
-----------------------
-- Has_Simple_Output --
-----------------------
function Has_Simple_Output
(Engine : access Engines.Contexts.Context;
Element : Asis.Declaration;
Name : Engines.Boolean_Property) return Boolean
is
pragma Unreferenced (Name);
List : constant Asis.Parameter_Specification_List :=
Asis.Declarations.Parameter_Profile (Element);
Output : constant Boolean :=
Engine.Boolean.Get_Property
(List => List,
Name => Engines.Has_Simple_Output,
Empty => False,
Sum => Properties.Tools."or"'Access);
begin
return Output;
end Has_Simple_Output;
--------------------
-- Is_Dispatching --
--------------------
function Is_Dispatching
(Engine : access Engines.Contexts.Context;
Element : Asis.Declaration;
Name : Engines.Boolean_Property) return Boolean
is
Spec : constant Asis.Declaration :=
Asis.Declarations.Corresponding_Declaration (Element);
begin
if Asis.Elements.Is_Nil (Spec) then
return False;
else
return Engine.Boolean.Get_Property (Spec, Name);
end if;
end Is_Dispatching;
end Properties.Declarations.Procedure_Body_Declarations;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Interfaces; use Interfaces;
package body Natools.Static_Maps.Web.Fallback_Render.Commands is
P : constant array (0 .. 4) of Natural :=
(1, 4, 9, 13, 16);
T1 : constant array (0 .. 4) of Unsigned_8 :=
(34, 66, 52, 35, 47);
T2 : constant array (0 .. 4) of Unsigned_8 :=
(5, 26, 36, 26, 50);
G : constant array (0 .. 66) of Unsigned_8 :=
(0, 11, 0, 0, 2, 21, 0, 28, 16, 0, 0, 0, 0, 15, 0, 5, 0, 0, 12, 30, 0,
8, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 19, 0, 0, 27, 0, 17, 11, 0, 13,
0, 4, 18, 23, 20, 9, 0, 0, 27, 0, 14, 0, 0, 30, 6, 25, 25, 0, 4, 5, 0,
2, 14, 0);
function Hash (S : String) return Natural is
F : constant Natural := S'First - 1;
L : constant Natural := S'Length;
F1, F2 : Natural := 0;
J : Natural;
begin
for K in P'Range loop
exit when L < P (K);
J := Character'Pos (S (P (K) + F));
F1 := (F1 + Natural (T1 (K)) * J) mod 67;
F2 := (F2 + Natural (T2 (K)) * J) mod 67;
end loop;
return (Natural (G (F1)) + Natural (G (F2))) mod 33;
end Hash;
end Natools.Static_Maps.Web.Fallback_Render.Commands;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--*
-- OBJECTIVE:
-- CHECK THAT FLOAT_IO GET RAISES CONSTRAINT_ERROR WHEN THE VALUE
-- SUPPLIED BY WIDTH IS NEGATIVE, WIDTH IS GREATER THAN FIELD'LAST
-- WHEN FIELD'LAST IS LESS THAN INTEGER'LAST, OR THE VALUE READ IS
-- OUT OF RANGE OF THE ITEM PARAMETER, BUT WITHIN THE RANGE OF THE
-- SUBTYPE USED TO INSTANTIATE FLOAT_IO.
-- APPLICABILITY CRITERIA:
-- THIS TEST IS APPLICABLE ONLY TO IMPLEMENTATIONS WHICH
-- SUPPORT TEXT FILES.
-- HISTORY:
-- SPS 09/07/82
-- JBG 08/30/83
-- DWC 09/11/87 SPLIT CASE FOR FIXED_IO INTO CE3804P.ADA AND
-- CORRECTED EXCEPTION HANDLING.
-- JRL 06/07/96 Added call to Ident_Int in expressions involving
-- Field'Last, to make the expressions non-static and
-- prevent compile-time rejection.
WITH REPORT;
USE REPORT;
WITH TEXT_IO;
USE TEXT_IO;
PROCEDURE CE3804F IS
INCOMPLETE : EXCEPTION;
BEGIN
TEST ("CE3804F", "CHECK THAT FLOAT_IO GET RAISES " &
"CONSTRAINT_ERROR WHEN THE VALUE SUPPLIED " &
"BY WIDTH IS NEGATIVE, WIDTH IS GREATER THAN " &
"FIELD'LAST WHEN FIELD'LAST IS LESS THAN " &
"INTEGER'LAST, OR THE VALUE READ IS OUT OF " &
"RANGE OF THE ITEM PARAMETER, BUT WITHIN THE " &
"RANGE OF THE SUBTYPE USED TO INSTANTIATE " &
"FLOAT_IO.");
DECLARE
FT : FILE_TYPE;
TYPE FLT IS NEW FLOAT RANGE 1.0 .. 10.0;
PACKAGE FL_IO IS NEW FLOAT_IO (FLT);
USE FL_IO;
X : FLT RANGE 1.0 .. 5.0;
BEGIN
BEGIN
GET (FT, X, IDENT_INT(-3));
FAILED ("CONSTRAINT_ERROR NOT RAISED FOR NEGATIVE " &
"WIDTH");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN STATUS_ERROR =>
FAILED ("STATUS_ERROR RAISED INSTEAD OF " &
"CONSTRAINT_ERROR FOR NEGATIVE WIDTH");
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED FOR NEGATIVE " &
"WIDTH");
END;
IF FIELD'LAST < INTEGER'LAST THEN
BEGIN
GET (X, FIELD'LAST + Ident_Int(1));
FAILED ("CONSTRAINT_ERROR NOT RAISED - " &
"FIELD'LAST + 1 WIDTH - DEFAULT");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED - " &
"FIELD'LAST + 1 WIDTH - DEFAULT");
END;
END IF;
BEGIN
CREATE (FT, OUT_FILE, LEGAL_FILE_NAME);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("USE_ERROR RAISED; TEXT CREATE " &
"WITH OUT_FILE MODE");
RAISE INCOMPLETE;
WHEN NAME_ERROR =>
NOT_APPLICABLE ("NAME_ERROR RAISED; TEXT CREATE " &
"WITH OUT_FILE MODE");
RAISE INCOMPLETE;
END;
PUT (FT, "1.0");
NEW_LINE (FT);
PUT (FT, "8.0");
NEW_LINE (FT);
PUT (FT, "2.0");
NEW_LINE (FT);
PUT (FT, "3.0");
CLOSE (FT);
BEGIN
OPEN (FT, IN_FILE, LEGAL_FILE_NAME);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("USE_ERROR RAISED; TEXT OPEN " &
"FOR IN_FILE MODE");
RAISE INCOMPLETE;
END;
GET (FT, X);
IF X /= 1.0 THEN
FAILED ("WRONG VALUE READ WITH EXTERNAL FILE");
END IF;
BEGIN
GET (FT, X);
FAILED ("CONSTRAINT_ERROR NOT RAISED - " &
"VALUE OUT OF RANGE WITH EXTERNAL FILE");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED - " &
"VALUE OUT OF RANGE WITH EXTERNAL FILE");
END;
BEGIN
GET (FT, X, IDENT_INT(-1));
FAILED ("CONSTRAINT_ERROR NOT RAISED - " &
"NEGATIVE WIDTH WITH EXTERNAL FILE");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED - " &
"NEGATIVE WIDTH WITH EXTERNAL FILE");
END;
SKIP_LINE (FT);
IF FIELD'LAST < INTEGER'LAST THEN
BEGIN
GET (FT, X, FIELD'LAST + Ident_Int(1));
FAILED ("CONSTRAINT_ERROR NOT RAISED - " &
"FIELD'LAST + 1 WIDTH WITH " &
"EXTERNAL FILE");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED - " &
"FIELD'LAST + 1 WIDTH WITH " &
"EXTERNAL FILE");
END;
END IF;
SKIP_LINE (FT);
BEGIN
GET (FT, X, 3);
EXCEPTION
WHEN CONSTRAINT_ERROR =>
FAILED ("CONSTRAINT_ERROR RAISED - " &
"OUT OF RANGE WITH EXTERNAL FILE");
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED - " &
"OUT OF RANGE WITH EXTERNAL FILE");
END;
BEGIN
DELETE (FT);
EXCEPTION
WHEN USE_ERROR =>
NULL;
END;
EXCEPTION
WHEN INCOMPLETE =>
NULL;
END;
RESULT;
END CE3804F;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-------------------------------------------------------------
with Ada.Iterator_Interfaces;
with Program.Elements;
limited with Program.Element_Vectors;
package Program.Element_Iterators is
pragma Pure;
type Child_Iterator is tagged;
type Property_Name is
(Aborted_Tasks,
Actual_Parameter,
Ancestor,
Arguments,
Aspect_Definition,
Aspect_Mark,
Aspects,
Associated_Message,
Attribute_Designator,
Called_Name,
Choice_Parameter,
Choices,
Clause_Name,
Clause_Names,
Clause_Range,
Component_Clauses,
Component_Definition,
Component_Value,
Components,
Condition,
Constraint,
Declarations,
Default_Expression,
Definition,
Delta_Expression,
Digits_Expression,
Discriminant,
Discriminant_Part,
Discriminant_Value,
Discriminants,
Element_Iterator,
Else_Expression,
Else_Statements,
Elsif_Paths,
Enclosing_Element,
End_Name,
End_Statement_Identifier,
Entry_Barrier,
Entry_Family_Definition,
Entry_Index,
Entry_Index_Subtype,
Entry_Name,
Exception_Handlers,
Exception_Name,
Exit_Loop_Name,
Expression,
Expressions,
Formal_Parameter,
Formal_Parameters,
Generalized_Iterator,
Generic_Function_Name,
Generic_Package_Name,
Generic_Procedure_Name,
Goto_Label,
Guard,
Index_Subtypes,
Initialization_Expression,
Iterable_Name,
Iterator_Name,
Left,
Literals,
Loop_Parameter,
Lower_Bound,
Mod_Clause_Expression,
Modulus,
Name,
Names,
Object_Subtype,
Operand,
Operator,
Parameter,
Parameters,
Parameter_Subtype,
Parent,
Paths,
Position,
Predicate,
Prefix,
Private_Declarations,
Progenitors,
Protected_Operations,
Qualified_Expression,
Raised_Exception,
Range_Attribute,
Ranges,
Real_Range,
Real_Range_Constraint,
Record_Definition,
Renamed_Exception,
Renamed_Function,
Renamed_Object,
Renamed_Package,
Renamed_Procedure,
Result_Expression,
Result_Subtype,
Return_Object,
Right,
Selecting_Expression,
Selector,
Selector_Names,
Slice_Range,
Statement_Identifier,
Statements,
Subpool_Name,
Subprogram_Default,
Subtype_Indication,
Subtype_Mark,
Then_Abort_Statements,
Then_Expression,
Then_Statements,
Upper_Bound,
Variable_Name,
Variants,
Visible_Declarations);
package Cursors is
type Enclosing_Element_Cursor is record
Element : Program.Elements.Element_Access;
Level : Positive;
end record;
function Has_Enclosing_Element
(Self : Enclosing_Element_Cursor) return Boolean;
type Child_Cursor is tagged private;
function Has_Element (Self : Child_Cursor) return Boolean;
function Element
(Self : Child_Cursor) return Program.Elements.Element_Access;
function Property (Self : Child_Cursor) return Property_Name;
-- Property name for element pointed by the cursor
function Index (Self : Child_Cursor) return Positive;
-- Index if the cursor in the middle of Element_Vector or 1 for single
-- element.
function Total (Self : Child_Cursor) return Positive;
-- Vector length if the cursor in the middle of Element_Vector or 1 for
-- single element.
package Internal is
procedure Step
(Self : Child_Iterator'Class;
Cursor : in out Child_Cursor;
Reset : Boolean);
end Internal;
private
type Child_Cursor is tagged record
Element : Program.Elements.Element_Access;
Property : Property_Name;
Getter_Index : Positive;
Item_Index : Positive;
Total_Items : Positive;
end record;
end Cursors;
package Enclosing_Element_Iterators is new Ada.Iterator_Interfaces
(Cursors.Enclosing_Element_Cursor, Cursors.Has_Enclosing_Element);
type Enclosing_Element_Iterator is
new Enclosing_Element_Iterators.Forward_Iterator with private;
function To_Enclosing_Element_Iterator
(Parent : not null Program.Elements.Element_Access)
return Enclosing_Element_Iterator;
overriding function First
(Self : Enclosing_Element_Iterator)
return Cursors.Enclosing_Element_Cursor;
overriding function Next
(Self : Enclosing_Element_Iterator;
Position : Cursors.Enclosing_Element_Cursor)
return Cursors.Enclosing_Element_Cursor;
package Child_Iterators is
new Ada.Iterator_Interfaces (Cursors.Child_Cursor, Cursors.Has_Element);
type Child_Iterator is new Child_Iterators.Forward_Iterator with private;
overriding function First
(Self : Child_Iterator) return Cursors.Child_Cursor;
overriding function Next
(Self : Child_Iterator;
Position : Cursors.Child_Cursor) return Cursors.Child_Cursor;
type Cursor_Checker is access
function (Cursor : Cursors.Child_Cursor) return Boolean;
function Only_If
(Parent : Child_Iterator;
Filter : not null Cursor_Checker)
return Child_Iterator;
type Element_Checker is access function
(Element : not null Program.Elements.Element_Access) return Boolean;
function Only_If
(Parent : Child_Iterator;
Filter : not null Element_Checker)
return Child_Iterator;
function To_Child_Iterator
(Parent : not null Program.Elements.Element_Access;
Filter : Element_Checker := null)
return Child_Iterator;
private
type Getter (Is_Vector : Boolean := False) is record
Property : Property_Name;
case Is_Vector is
when False =>
Get_Child : access function
(Self : not null Program.Elements.Element_Access)
return Program.Elements.Element_Access;
when True =>
Get_Vector : access function
(Self : not null Program.Elements.Element_Access)
return Program.Element_Vectors.Element_Vector_Access;
end case;
end record;
type Getter_Array is array (Positive range <>) of Getter;
Empty : aliased constant Getter_Array := (1 .. 0 => <>);
type Enclosing_Element_Iterator is
new Enclosing_Element_Iterators.Forward_Iterator with
record
First : Program.Elements.Element_Access;
end record;
type Checker_Chain (Is_Cursor : Boolean := False) is record
case Is_Cursor is
when True =>
Cursor_Filter : Cursor_Checker;
when False =>
Element_Filter : Element_Checker;
end case;
end record;
type Checker_Chain_Array is array (Positive range <>) of Checker_Chain;
function Check
(Cursor : Cursors.Child_Cursor;
List : Checker_Chain_Array) return Boolean;
type Child_Iterator is new Child_Iterators.Forward_Iterator with record
Parent : Program.Elements.Element_Access;
Getters : access constant Getter_Array;
Filter : Checker_Chain_Array (1 .. 3);
Last : Natural := 0;
end record;
end Program.Element_Iterators;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- Lambda Calculus interpreter
-- ---------------------------
-- Parses and reduces Lamdba Calculus statements.
--
-- Use a simple recursive parser for the simplest computer language.
-- It would be nice to build an ADT for Instructions and hide the Multiway tree implementation.
--
-- Source:
-- lambda - [This file] definitions and helper functions
-- lambda_REPL - REPL and command line parsers
-- lambda_parser - parse tree generator
-- lambda_reducer - optimises and reduces lambda expressions
--
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Containers; use Ada.Containers;
with Ada.Containers.Multiway_Trees;
with Ada.Strings.Unbounded;
Package Lambda is
subtype Statement is String; -- A Lambda Calculus Statement, eg fn x.x
Max_Statement_Length : constant Integer := 80;
Empty_Statement : constant String :=
Ada.Strings.Fixed.Head("", Max_Statement_Length,' ');
subtype Name_Type is Character range 'a' .. 'z';
subtype Synonym_Type is Character range 'A' .. 'Z';
-- L_Variable : Variable name
-- L_Synonym : Synonym name
-- L_Function : Function definition
-- L_Expression : Expression
-- L_Definition : Synonym definition
type Element_Type is (L_Variable, L_Synonym, L_Function, L_Expression, L_Definition, L_Comments);
type Element_Record ( Element : Element_Type := L_Expression ) is record
Name : Character;
is_Explicit : Boolean := true;
case Element is
when L_Comments => Comments : Statement(1..Max_Statement_Length);
when others => null;
end case;
end record;
-- Exceptions
Syntax_Error : exception;
Recursion_Overflow : exception;
Internal_Error : exception;
Package SU renames Ada.Strings.Unbounded;
package Instructions is new Ada.Containers.Multiway_Trees
(Element_Type => Element_Record);
use Instructions;
function format ( I: Instructions.Tree ) return String;
function format ( I: Instructions.Tree; Curs : Instructions.Cursor ) return String;
function Indent( I : Natural ) return String;
type Log_Type is ( Log_Parse, Log_Reduce, Log_Format );
procedure Log ( S: String );
procedure Log ( S: String; I: Instructions.Tree );
procedure Log ( S: String; I: Instructions.Tree; C: Instructions.Cursor );
procedure Log ( T: Log_Type; S: String );
procedure Log ( T: Log_Type; S: String; I: Instructions.Tree );
procedure Log ( T: Log_Type; S: String; I: Instructions.Tree; C: Instructions.Cursor );
procedure Log_Format ( I: Instructions.Tree );
procedure Add_Synonym ( Source : Instructions.Cursor );
procedure Remove_Synonym ( S : Statement );
procedure List_Synonyms;
Trace : Boolean := FALSE; -- Trace the REPL
Trace_Parse : Boolean := FALSE; -- Trace Parser detail
Trace_Reduce : Boolean := FALSE; -- Trace Reducer detail
Trace_Format : Boolean := FALSE; -- Trace Formatter detail
private
Synonyms : Instructions.Tree := Instructions.Empty_Tree;
function format_Element ( I : Instructions.tree; Curs : Instructions.Cursor ) return SU.Unbounded_String;
end Lambda;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Butil; use Butil;
with Namet; use Namet;
with Opt; use Opt;
with Output; use Output;
package body Binderr is
---------------
-- Error_Msg --
---------------
procedure Error_Msg (Msg : String) is
begin
if Msg (Msg'First) = '?' then
if Warning_Mode = Suppress then
return;
end if;
if Warning_Mode = Treat_As_Error then
Errors_Detected := Errors_Detected + 1;
else
Warnings_Detected := Warnings_Detected + 1;
end if;
else
Errors_Detected := Errors_Detected + 1;
end if;
if Brief_Output or else (not Verbose_Mode) then
Set_Standard_Error;
Error_Msg_Output (Msg, Info => False);
Set_Standard_Output;
end if;
if Verbose_Mode then
if Errors_Detected + Warnings_Detected = 0 then
Write_Eol;
end if;
Error_Msg_Output (Msg, Info => False);
end if;
if Warnings_Detected + Errors_Detected > Maximum_Errors then
raise Unrecoverable_Error;
end if;
end Error_Msg;
--------------------
-- Error_Msg_Info --
--------------------
procedure Error_Msg_Info (Msg : String) is
begin
if Brief_Output or else (not Verbose_Mode) then
Set_Standard_Error;
Error_Msg_Output (Msg, Info => True);
Set_Standard_Output;
end if;
if Verbose_Mode then
Error_Msg_Output (Msg, Info => True);
end if;
end Error_Msg_Info;
----------------------
-- Error_Msg_Output --
----------------------
procedure Error_Msg_Output (Msg : String; Info : Boolean) is
Use_Second_Name : Boolean := False;
begin
if Warnings_Detected + Errors_Detected > Maximum_Errors then
Write_Str ("error: maximum errors exceeded");
Write_Eol;
return;
end if;
if Msg (Msg'First) = '?' then
Write_Str ("warning: ");
elsif Info then
if not Info_Prefix_Suppress then
Write_Str ("info: ");
end if;
else
Write_Str ("error: ");
end if;
for I in Msg'Range loop
if Msg (I) = '%' then
if Use_Second_Name then
Get_Name_String (Error_Msg_Name_2);
else
Use_Second_Name := True;
Get_Name_String (Error_Msg_Name_1);
end if;
Write_Char ('"');
Write_Str (Name_Buffer (1 .. Name_Len));
Write_Char ('"');
elsif Msg (I) = '&' then
Write_Char ('"');
if Use_Second_Name then
Write_Unit_Name (Error_Msg_Name_2);
else
Use_Second_Name := True;
Write_Unit_Name (Error_Msg_Name_1);
end if;
Write_Char ('"');
elsif Msg (I) /= '?' then
Write_Char (Msg (I));
end if;
end loop;
Write_Eol;
end Error_Msg_Output;
----------------------
-- Finalize_Binderr --
----------------------
procedure Finalize_Binderr is
begin
-- Message giving number of errors detected (verbose mode only)
if Verbose_Mode then
Write_Eol;
if Errors_Detected = 0 then
Write_Str ("No errors");
elsif Errors_Detected = 1 then
Write_Str ("1 error");
else
Write_Int (Errors_Detected);
Write_Str (" errors");
end if;
if Warnings_Detected = 1 then
Write_Str (", 1 warning");
elsif Warnings_Detected > 1 then
Write_Str (", ");
Write_Int (Warnings_Detected);
Write_Str (" warnings");
end if;
Write_Eol;
end if;
end Finalize_Binderr;
------------------------
-- Initialize_Binderr --
------------------------
procedure Initialize_Binderr is
begin
Errors_Detected := 0;
Warnings_Detected := 0;
end Initialize_Binderr;
end Binderr;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
package body Atlas.Applications.Models is
use type ADO.Objects.Object_Record_Access;
use type ADO.Objects.Object_Ref;
use type ADO.Objects.Object_Record;
-- --------------------
-- Get the bean attribute identified by the given name.
-- --------------------
overriding
function Get_Value (From : in User_Stat_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "post_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Post_Count));
end if;
if Name = "document_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Document_Count));
end if;
if Name = "question_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Question_Count));
end if;
if Name = "answer_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Answer_Count));
end if;
if Name = "review_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Review_Count));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- --------------------
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
-- --------------------
procedure List (Object : in out User_Stat_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
begin
List (Object.List, Session, Context);
end List;
-- --------------------
-- Stats about what the user did.
-- --------------------
procedure List (Object : in out User_Stat_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
procedure Read (Into : in out User_Stat_Info);
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Context);
Pos : Natural := 0;
procedure Read (Into : in out User_Stat_Info) is
begin
Into.Post_Count := Stmt.Get_Integer (0);
Into.Document_Count := Stmt.Get_Integer (1);
Into.Question_Count := Stmt.Get_Integer (2);
Into.Answer_Count := Stmt.Get_Integer (3);
Into.Review_Count := Stmt.Get_Integer (4);
end Read;
begin
Stmt.Execute;
User_Stat_Info_Vectors.Clear (Object);
while Stmt.Has_Elements loop
Object.Insert_Space (Before => Pos);
Object.Update_Element (Index => Pos, Process => Read'Access);
Pos := Pos + 1;
Stmt.Next;
end loop;
end List;
end Atlas.Applications.Models;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Types; use Types;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
generic
type T_Element is digits <>;
package Module_IO is
-- Lire l'intégralité du fichier.
procedure Lire(Fichier: in Unbounded_String; PagesNum: out Integer; Liens: out LC_Integer_Integer.T_LC);
-- Ecrire les PageRank et les Poids.
procedure Ecrire(Fichier: in Unbounded_String; PagesNum: in Integer; MaxIterations: in Integer; Alpha: in T_Digits; Rangs: in Vecteur_Poids.T_Vecteur);
end Module_IO;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
package freetype_c.FT_Size_Metrics
is
type Item is
record
X_ppem : aliased FT_UShort;
Y_ppem : aliased FT_UShort;
X_Scale : aliased FT_Fixed;
Y_Scale : aliased FT_Fixed;
Ascender : aliased FT_Pos;
Descender : aliased FT_Pos;
Height : aliased FT_Pos;
max_Advance : aliased FT_Pos;
end record;
type Item_array is array (C.Size_t range <>) of aliased FT_Size_Metrics.Item;
type Pointer is access all freetype_c.FT_Size_Metrics.Item;
type Pointer_array is array (C.Size_t range <>) of aliased freetype_c.FT_Size_Metrics.Pointer;
type pointer_Pointer is access all freetype_c.FT_Size_Metrics.Pointer;
end freetype_c.FT_Size_Metrics;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Interfaces; use Interfaces;
package body Lithium.Comment_Cookie_Smaz_Hash is
P : constant array (0 .. 2) of Natural :=
(1, 2, 4);
T1 : constant array (0 .. 2) of Unsigned_8 :=
(44, 115, 66);
T2 : constant array (0 .. 2) of Unsigned_8 :=
(27, 43, 74);
G : constant array (0 .. 122) of Unsigned_8 :=
(0, 0, 25, 0, 0, 0, 55, 0, 0, 19, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 28, 2,
0, 0, 0, 0, 29, 45, 0, 0, 14, 59, 0, 60, 15, 2, 0, 38, 0, 0, 0, 25,
52, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 41, 0, 0, 35, 27, 5, 43,
32, 0, 0, 22, 0, 7, 21, 50, 0, 18, 0, 0, 0, 17, 0, 8, 37, 57, 0, 0, 0,
1, 8, 4, 3, 58, 27, 7, 0, 49, 0, 37, 54, 10, 0, 0, 0, 21, 41, 13, 30,
12, 19, 0, 0, 44, 3, 35, 26, 46, 54, 0, 0, 0, 37, 0, 0, 24, 41, 6);
function Hash (S : String) return Natural is
F : constant Natural := S'First - 1;
L : constant Natural := S'Length;
F1, F2 : Natural := 0;
J : Natural;
begin
for K in P'Range loop
exit when L < P (K);
J := Character'Pos (S (P (K) + F));
F1 := (F1 + Natural (T1 (K)) * J) mod 123;
F2 := (F2 + Natural (T2 (K)) * J) mod 123;
end loop;
return (Natural (G (F1)) + Natural (G (F2))) mod 61;
end Hash;
end Lithium.Comment_Cookie_Smaz_Hash;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package encapsulates all direct interfaces to task debugging services
-- that are needed by gdb with gnat mode (1.13 and higher)
-- Note : This file *must* be compiled with debugging information
-- Do not add any dependency to GNARL packages since this package is used
-- in both normal and resticted (ravenscar) environments.
with System.Task_Info,
System.Task_Primitives.Operations,
Unchecked_Conversion;
package body System.Tasking.Debug is
use Interfaces.C;
package STPO renames System.Task_Primitives.Operations;
type Integer_Address is mod 2 ** Standard'Address_Size;
type Integer_Address_Ptr is access all Integer_Address;
function "+" is new
Unchecked_Conversion (System.Address, Integer_Address_Ptr);
function "+" is new
Unchecked_Conversion (Task_ID, Integer_Address);
Hex_Address_Width : constant := (Standard'Address_Size / 4);
Zero_Pos : constant := Character'Pos ('0');
Hex_Digits : constant array (0 .. Integer_Address'(15)) of Character :=
"0123456789abcdef";
subtype Buf_Range is Integer range 1 .. 80;
type Buf_Array is array (Buf_Range) of aliased Character;
type Buffer is record
Next : Buf_Range := Buf_Range'First;
Chars : Buf_Array := (Buf_Range => ' ');
end record;
type Buffer_Ptr is access all Buffer;
type Trace_Flag_Set is array (Character) of Boolean;
Trace_On : Trace_Flag_Set := ('A' .. 'Z' => False, others => True);
-----------------------
-- Local Subprograms --
-----------------------
procedure Put
(T : ST.Task_ID;
Width : Integer;
Buffer : Buffer_Ptr);
-- Put TCB pointer T, (coded in hexadecimal) into Buffer
-- right-justified in Width characters.
procedure Put
(N : Integer_Address;
Width : Integer;
Buffer : Buffer_Ptr);
-- Put N (coded in decimal) into Buf right-justified in Width
-- characters starting at Buf (Next).
procedure Put
(S : String;
Width : Integer;
Buffer : Buffer_Ptr);
-- Put string S into Buf left-justified in Width characters
-- starting with space in Buf (Next), truncated as necessary.
procedure Put
(C : Character;
Buffer : Buffer_Ptr);
-- Put character C into Buf, left-justified, starting at Buf (Next)
procedure Space (Buffer : Buffer_Ptr);
-- Increment Next, resulting in a space
procedure Space
(N : Integer;
Buffer : Buffer_Ptr);
-- Increment Next by N, resulting in N spaces
procedure Clear (Buffer : Buffer_Ptr);
-- Clear Buf and reset Next to 1
procedure Write_Buf (Buffer : Buffer_Ptr);
-- Write contents of Buf (1 .. Next) to standard output
-----------
-- Clear --
-----------
procedure Clear (Buffer : Buffer_Ptr) is
Next : Buf_Range renames Buffer.Next;
Buf : Buf_Array renames Buffer.Chars;
begin
Buf := (Buf_Range => ' ');
Next := 1;
end Clear;
-----------
-- Image --
-----------
function Image (T : ST.Task_ID) return String is
Buf : aliased Buffer;
Result : String (1 .. Hex_Address_Width + 21);
use type System.Task_Info.Task_Image_Type;
begin
Clear (Buf'Unchecked_Access);
Put (T, Hex_Address_Width, Buf'Unchecked_Access);
Put (':', Buf'Unchecked_Access);
Put (Integer_Address (T.Serial_Number), 4, Buf'Unchecked_Access);
Space (Buf'Unchecked_Access);
if T.Common.Task_Image = null then
Put ("", 15, Buf'Unchecked_Access);
else
Put (T.Common.Task_Image.all, 15, Buf'Unchecked_Access);
end if;
for J in Result'Range loop
Result (J) := Buf.Chars (J);
end loop;
return Result;
end Image;
----------------
-- List_Tasks --
----------------
procedure List_Tasks is
C : ST.Task_ID;
begin
Print_Task_Info_Header;
C := All_Tasks_List;
while C /= null loop
Print_Task_Info (C);
C := C.Common.All_Tasks_Link;
end loop;
end List_Tasks;
-----------------------
-- Print_Accept_Info --
-----------------------
procedure Print_Accept_Info (T : ST.Task_ID) is
Buf : aliased Buffer;
begin
if T.Open_Accepts = null then
return;
end if;
Clear (Buf'Unchecked_Access);
Space (10, Buf'Unchecked_Access);
Put ("accepting:", 11, Buf'Unchecked_Access);
for J in T.Open_Accepts.all'Range loop
Put (Integer_Address (T.Open_Accepts (J).S), 3, Buf'Unchecked_Access);
end loop;
Write_Buf (Buf'Unchecked_Access);
end Print_Accept_Info;
------------------------
-- Print_Current_Task --
------------------------
procedure Print_Current_Task is
begin
Print_Task_Info (STPO.Self);
end Print_Current_Task;
---------------------
-- Print_Task_Info --
---------------------
procedure Print_Task_Info (T : ST.Task_ID) is
Entry_Call : Entry_Call_Link;
Buf : aliased Buffer;
use type System.Task_Info.Task_Image_Type;
begin
Clear (Buf'Unchecked_Access);
Put (T, Hex_Address_Width, Buf'Unchecked_Access);
Put (':', Buf'Unchecked_Access);
Put (' ', Buf'Unchecked_Access);
Put (':', Buf'Unchecked_Access);
if T = null then
Put (" null task", 10, Buf'Unchecked_Access);
Write_Buf (Buf'Unchecked_Access);
return;
end if;
Put (Integer_Address (T.Serial_Number), 4, Buf'Unchecked_Access);
Space (Buf'Unchecked_Access);
if T.Common.Task_Image = null then
Put ("", 15, Buf'Unchecked_Access);
else
Put (T.Common.Task_Image.all, 15, Buf'Unchecked_Access);
end if;
Space (Buf'Unchecked_Access);
Put (Task_States'Image (T.Common.State), 10, Buf'Unchecked_Access);
Space (Buf'Unchecked_Access);
if T.Callable then
Put ('C', Buf'Unchecked_Access);
else
Space (Buf'Unchecked_Access);
end if;
if T.Open_Accepts /= null then
Put ('A', Buf'Unchecked_Access);
else
Space (Buf'Unchecked_Access);
end if;
if T.Common.Call /= null then
Put ('C', Buf'Unchecked_Access);
else
Space (Buf'Unchecked_Access);
end if;
if T.Terminate_Alternative then
Put ('T', Buf'Unchecked_Access);
else
Space (Buf'Unchecked_Access);
end if;
if T.Aborting then
Put ('A', Buf'Unchecked_Access);
else
Space (Buf'Unchecked_Access);
end if;
if T.Deferral_Level = 0 then
Space (3, Buf'Unchecked_Access);
else
Put ('D', Buf'Unchecked_Access);
if T.Deferral_Level < 0 then
Put ("<0", 2, Buf'Unchecked_Access);
elsif T.Deferral_Level > 1 then
Put (Integer_Address (T.Deferral_Level), 2, Buf'Unchecked_Access);
else
Space (2, Buf'Unchecked_Access);
end if;
end if;
Space (Buf'Unchecked_Access);
Put (Integer_Address (T.Master_of_Task), 1, Buf'Unchecked_Access);
Space (Buf'Unchecked_Access);
Put (Integer_Address (T.Master_Within), 1, Buf'Unchecked_Access);
Put (',', Buf'Unchecked_Access);
Space (Buf'Unchecked_Access);
Put (Integer_Address (T.Awake_Count), 1, Buf'Unchecked_Access);
Space (Buf'Unchecked_Access);
Put (Integer_Address (T.Alive_Count), 1, Buf'Unchecked_Access);
Put (',', Buf'Unchecked_Access);
Space (Buf'Unchecked_Access);
Put (Integer_Address (T.ATC_Nesting_Level), 1, Buf'Unchecked_Access);
Space (Buf'Unchecked_Access);
Put (Integer_Address (T.Pending_ATC_Level), 1, Buf'Unchecked_Access);
Put (',', Buf'Unchecked_Access);
Space (Buf'Unchecked_Access);
Put (Integer_Address (T.Common.Wait_Count), 1, Buf'Unchecked_Access);
Put (',', Buf'Unchecked_Access);
Space (Buf'Unchecked_Access);
Put (Integer_Address (T.User_State), 1, Buf'Unchecked_Access);
Write_Buf (Buf'Unchecked_Access);
if T.Common.Call /= null then
Entry_Call := T.Common.Call;
Clear (Buf'Unchecked_Access);
Space (10, Buf'Unchecked_Access);
Put ("serving:", 8, Buf'Unchecked_Access);
while Entry_Call /= null loop
Put (Integer_Address
(Entry_Call.Self.Serial_Number), 5, Buf'Unchecked_Access);
Entry_Call := Entry_Call.Acceptor_Prev_Call;
end loop;
Write_Buf (Buf'Unchecked_Access);
end if;
Print_Accept_Info (T);
end Print_Task_Info;
----------------------------
-- Print_Task_Info_Header --
----------------------------
procedure Print_Task_Info_Header is
Buf : aliased Buffer;
begin
Clear (Buf'Unchecked_Access);
Put ("TASK_ID", Hex_Address_Width, Buf'Unchecked_Access);
Put (':', Buf'Unchecked_Access);
Put ('F', Buf'Unchecked_Access);
Put (':', Buf'Unchecked_Access);
Put ("SERIAL_NUMBER", 4, Buf'Unchecked_Access);
Space (Buf'Unchecked_Access);
Put (" NAME", 15, Buf'Unchecked_Access);
Put (" STATE", 10, Buf'Unchecked_Access);
Space (11, Buf'Unchecked_Access);
Put ("MAST", 5, Buf'Unchecked_Access);
Put ("AWAK", 5, Buf'Unchecked_Access);
Put ("ATC", 5, Buf'Unchecked_Access);
Put ("WT", 3, Buf'Unchecked_Access);
Put ("DBG", 3, Buf'Unchecked_Access);
Write_Buf (Buf'Unchecked_Access);
end Print_Task_Info_Header;
---------
-- Put --
---------
procedure Put
(T : ST.Task_ID;
Width : Integer;
Buffer : Buffer_Ptr)
is
J : Integer;
X : Integer_Address := +T;
Next : Buf_Range renames Buffer.Next;
Buf : Buf_Array renames Buffer.Chars;
First : constant Integer := Next;
Wdth : Integer := Width;
begin
if Wdth > Buf'Last - Next then
Wdth := Buf'Last - Next;
end if;
J := Next + (Wdth - 1);
if X = 0 then
Buf (J) := '0';
else
while X > 0 loop
Buf (J) := Hex_Digits (X rem 16);
J := J - 1;
X := X / 16;
-- Check for overflow
if J < First and then X > 0 then
Buf (J + 1) := '*';
exit;
end if;
end loop;
end if;
Next := Next + Wdth;
end Put;
procedure Put
(N : Integer_Address;
Width : Integer;
Buffer : Buffer_Ptr)
is
J : Integer;
X : Integer_Address := N;
Next : Buf_Range renames Buffer.Next;
Buf : Buf_Array renames Buffer.Chars;
First : constant Integer := Next;
Wdth : Integer := Width;
begin
if Wdth > Buf'Last - Next then
Wdth := Buf'Last - Next;
end if;
J := Next + (Wdth - 1);
if N = 0 then
Buf (J) := '0';
else
while X > 0 loop
Buf (J) := Hex_Digits (X rem 10);
J := J - 1;
X := X / 10;
-- Check for overflow
if J < First and then X > 0 then
Buf (J + 1) := '*';
exit;
end if;
end loop;
end if;
Next := Next + Wdth;
end Put;
procedure Put
(S : String;
Width : Integer;
Buffer : Buffer_Ptr)
is
Next : Buf_Range renames Buffer.Next;
Buf : Buf_Array renames Buffer.Chars;
Bound : constant Integer := Integer'Min (Next + Width, Buf'Last);
J : Integer := Next;
begin
for K in S'Range loop
-- Check overflow
if J >= Bound then
Buf (J - 1) := '*';
exit;
end if;
Buf (J) := S (K);
J := J + 1;
end loop;
Next := Bound;
end Put;
procedure Put
(C : Character;
Buffer : Buffer_Ptr)
is
Next : Buf_Range renames Buffer.Next;
Buf : Buf_Array renames Buffer.Chars;
begin
if Next >= Buf'Last then
Buf (Next) := '*';
else Buf (Next) := C;
Next := Next + 1;
end if;
end Put;
----------------------
-- Resume_All_Tasks --
----------------------
procedure Resume_All_Tasks (Thread_Self : OS_Interface.Thread_Id) is
C : ST.Task_ID;
R : Boolean;
begin
STPO.Lock_All_Tasks_List;
C := All_Tasks_List;
while C /= null loop
R := STPO.Resume_Task (C, Thread_Self);
C := C.Common.All_Tasks_Link;
end loop;
STPO.Unlock_All_Tasks_List;
end Resume_All_Tasks;
----------
-- Self --
----------
function Self return Task_ID is
begin
return STPO.Self;
end Self;
---------------
-- Set_Trace --
---------------
procedure Set_Trace
(Flag : Character;
Value : Boolean := True)
is
begin
Trace_On (Flag) := Value;
end Set_Trace;
--------------------
-- Set_User_State --
--------------------
procedure Set_User_State (Value : Integer) is
begin
STPO.Self.User_State := Value;
end Set_User_State;
-----------
-- Space --
-----------
procedure Space (Buffer : Buffer_Ptr) is
Next : Buf_Range renames Buffer.Next;
Buf : Buf_Array renames Buffer.Chars;
begin
if Next >= Buf'Last then
Buf (Next) := '*';
else
Next := Next + 1;
end if;
end Space;
procedure Space
(N : Integer;
Buffer : Buffer_Ptr)
is
Next : Buf_Range renames Buffer.Next;
Buf : Buf_Array renames Buffer.Chars;
begin
if Next + N > Buf'Last then
Buf (Next) := '*';
else
Next := Next + N;
end if;
end Space;
-----------------------
-- Suspend_All_Tasks --
-----------------------
procedure Suspend_All_Tasks (Thread_Self : OS_Interface.Thread_Id) is
C : ST.Task_ID;
R : Boolean;
begin
STPO.Lock_All_Tasks_List;
C := All_Tasks_List;
while C /= null loop
R := STPO.Suspend_Task (C, Thread_Self);
C := C.Common.All_Tasks_Link;
end loop;
STPO.Unlock_All_Tasks_List;
end Suspend_All_Tasks;
------------------------
-- Task_Creation_Hook --
------------------------
procedure Task_Creation_Hook (Thread : OS_Interface.Thread_Id) is
pragma Inspection_Point (Thread);
-- gdb needs to access the thread parameter in order to implement
-- the multitask mode under VxWorks.
begin
null;
end Task_Creation_Hook;
---------------------------
-- Task_Termination_Hook --
---------------------------
procedure Task_Termination_Hook is
begin
null;
end Task_Termination_Hook;
-----------
-- Trace --
-----------
procedure Trace
(Self_ID : ST.Task_ID;
Msg : String;
Other_ID : ST.Task_ID;
Flag : Character)
is
Buf : aliased Buffer;
use type System.Task_Info.Task_Image_Type;
begin
if Trace_On (Flag) then
Clear (Buf'Unchecked_Access);
Put (Self_ID, Hex_Address_Width, Buf'Unchecked_Access);
Put (':', Buf'Unchecked_Access);
Put (Flag, Buf'Unchecked_Access);
Put (':', Buf'Unchecked_Access);
Put
(Integer_Address (Self_ID.Serial_Number),
4, Buf'Unchecked_Access);
Space (Buf'Unchecked_Access);
if Self_ID.Common.Task_Image = null then
Put ("", 15, Buf'Unchecked_Access);
else
Put (Self_ID.Common.Task_Image.all, 15, Buf'Unchecked_Access);
end if;
Space (Buf'Unchecked_Access);
if Other_ID /= null then
Put
(Integer_Address (Other_ID.Serial_Number),
4, Buf'Unchecked_Access);
Space (Buf'Unchecked_Access);
end if;
Put (Msg, Buf.Chars'Last - Buf.Next + 1, Buf'Unchecked_Access);
Write_Buf (Buf'Unchecked_Access);
end if;
end Trace;
procedure Trace
(Self_ID : ST.Task_ID;
Msg : String;
Flag : Character)
is
begin
Trace (Self_ID, Msg, null, Flag);
end Trace;
procedure Trace
(Msg : String;
Flag : Character)
is
Self_ID : constant ST.Task_ID := STPO.Self;
begin
Trace (Self_ID, Msg, null, Flag);
end Trace;
procedure Trace
(Msg : String;
Other_ID : ST.Task_ID;
Flag : Character)
is
Self_ID : constant ST.Task_ID := STPO.Self;
begin
Trace (Self_ID, Msg, null, Flag);
end Trace;
---------------
-- Write_Buf --
---------------
procedure Write_Buf (Buffer : Buffer_Ptr) is
Next : Buf_Range renames Buffer.Next;
Buf : Buf_Array renames Buffer.Chars;
procedure put_char (C : Integer);
pragma Import (C, put_char, "put_char");
begin
for J in 1 .. Next - 1 loop
put_char (Character'Pos (Buf (J)));
end loop;
put_char (Character'Pos (ASCII.LF));
end Write_Buf;
end System.Tasking.Debug;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- Environment
with System;
package Lumen.Internal is
---------------------------------------------------------------------------
-- Xlib stuff needed for our window info record
type Atom is new Long_Integer;
type Display_Pointer is new System.Address;
Null_Display_Pointer : constant Display_Pointer :=
Display_Pointer (System.Null_Address);
type Screen_Depth is new Natural;
type Screen_Number is new Natural;
type Visual_ID is new Long_Integer;
type Window_ID is new Long_Integer;
type X_Visual_Info is record
Visual : System.Address;
Visual_Ident : Visual_ID;
Screen : Screen_Number;
Depth : Screen_Depth;
Class : Integer;
Red_Mask : Long_Integer;
Green_Mask : Long_Integer;
Blue_Mask : Long_Integer;
Colormap_Size : Natural;
Bits_Per_RGB : Natural;
end record;
type X_Visual_Info_Pointer is access all X_Visual_Info;
---------------------------------------------------------------------------
-- The GL rendering context type
type GLX_Context is new System.Address;
Null_Context : constant GLX_Context := GLX_Context (System.Null_Address);
---------------------------------------------------------------------------
-- The native window type
type Window_Internal is record
Display : Display_Pointer := Null_Display_Pointer;
Window : Window_ID := 0;
Visual : X_Visual_Info_Pointer := null;
Width : Natural := 0;
Height : Natural := 0;
Context : GLX_Context := Null_Context;
end record;
---------------------------------------------------------------------------
-- Values used to compute record rep clause values that are portable
-- between 32- and 64-bit systems
Is_32 : constant := Boolean'Pos (System.Word_Size = 32);
Is_64 : constant := 1 - Is_32;
Word_Bytes : constant := Integer'Size / System.Storage_Unit;
Word_Bits : constant := Integer'Size - 1;
Long_Bytes : constant := Long_Integer'Size / System.Storage_Unit;
Long_Bits : constant := Long_Integer'Size - 1;
---------------------------------------------------------------------------
-- The maximum length of an event data record
type Padding is array (1 .. 23) of Long_Integer;
---------------------------------------------------------------------------
end Lumen.Internal;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
end if;
end loop;
end if;
end uptate_state;
-------------------------
-- update_cov
-------------------------
procedure update_cov( P : in out State_Covariance_Matrix; K :Kalman_Gain_Matrix ) is
begin
-- update cov
P := P - (K * G.H) * P;
end update_cov;
-------------------------
-- calculate_A
-------------------------
procedure calculate_A( A : out State_Transition_Matrix; dt : Time_Type ) is
begin
A := (others => (others => 0.0));
A( map(X_LAT), map(X_LAT) ) := 1.0; A( map(X_LAT), map(X_GROUND_SPEED_X) ) := Base_Unit_Type(dt);
A( map(X_LON), map(X_LON) ) := 1.0; A( map(X_LON), map(X_GROUND_SPEED_Y) ) := Base_Unit_Type(dt);
A( map(X_ALT), map(X_ALT) ) := 1.0; A( map(X_ALT), map(X_GROUND_SPEED_Z) ) := -Base_Unit_Type(dt);
A( map(X_ROLL), map(X_ROLL) ) := 1.0; A( map(X_ROLL), map(X_ROLL_RATE) ) := Base_Unit_Type(dt); A( map(X_ROLL), map(X_ROLL_BIAS) ) := -Base_Unit_Type(dt);
A( map(X_PITCH), map(X_PITCH) ) := 1.0; A( map(X_PITCH), map(X_PITCH_RATE) ) := Base_Unit_Type(dt); A( map(X_PITCH), map(X_PITCH_BIAS) ) := -Base_Unit_Type(dt);
A( map(X_YAW), map(X_YAW) ) := 1.0; A( map(X_YAW), map(X_YAW_RATE) ) := Base_Unit_Type(dt); A( map(X_YAW), map(X_YAW_BIAS) ) := -Base_Unit_Type(dt);
A( map(X_ROLL_RATE), map(X_ROLL_RATE) ) := 1.0;
A( map(X_PITCH_RATE), map(X_PITCH_RATE) ) := 1.0;
A( map(X_YAW_RATE), map(X_YAW_RATE) ) := 1.0;
A( map(X_ROLL_BIAS), map(X_ROLL_BIAS) ) := 1.0;
A( map(X_PITCH_BIAS), map(X_PITCH_BIAS) ) := 1.0;
A( map(X_YAW_BIAS), map(X_YAW_BIAS) ) := 1.0;
end calculate_A;
end Kalman;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with System;
package Init11 is
type My_Integer is new Integer;
for My_Integer'Alignment use 1;
type Arr1 is array (1 .. 3) of My_Integer;
for Arr1'Scalar_Storage_Order use System.Low_Order_First;
type R1 is record
I : My_Integer;
A : Arr1;
end record;
for R1'Bit_Order use System.Low_Order_First;
for R1'Scalar_Storage_Order use System.Low_Order_First;
type Arr2 is array (1 .. 3) of My_Integer;
for Arr2'Scalar_Storage_Order use System.High_Order_First;
type R2 is record
I : My_Integer;
A : Arr2;
end record;
for R2'Bit_Order use System.High_Order_First;
for R2'Scalar_Storage_Order use System.High_Order_First;
My_R1 : constant R1 := (I => 16#12345678#,
A => (16#AB0012#, 16#CD0034#, 16#EF0056#));
My_R2 : constant R2 := (I => 16#12345678#,
A => (16#AB0012#, 16#CD0034#, 16#EF0056#));
end Init11;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- with Ada.Containers.Vectors;
-- with Ada.Text_IO;
with Ada.Long_Long_Integer_Text_IO;
with Ada.Strings;
with Ada.Strings.Bounded;
with Ada.Containers; use Ada.Containers;
-- Note that this package currently only handles positive numbers.
package body BigInteger is
use BigInteger.Int_Vector;
-- Sadly we can't use this in our type because the compiler doesn't support
-- modular types greater than 2**32. We have chosen a power of ten for now
-- because it allows us to give a base 10 printed representation without
-- needing to implement division.
Base : constant Long_Long_Integer := 1_000_000_000_000_000_000;
-- Used in multiplication to split the number into two halves
Half_Base : constant Long_Long_Integer := 1_000_000_000;
function Create(l : in Long_Long_Integer) return BigInt is
bi : BigInt;
num : Long_Long_Integer := l;
begin
-- The given Long_Long_Integer can be larger than our base, so we need
-- to normalize it.
if num >= Base then
bi.bits.append(num mod Base);
num := num / Base;
end if;
bi.bits.append(num);
return bi;
end Create;
function Create(s : in String) return BigInt is
bi : BigInt := Create(0);
multiplier : BigInt := Create(1);
begin
for index in reverse s'Range loop
declare
c : constant Character := s(index);
begin
case c is
when '0' .. '9' =>
declare
value : constant Long_Long_Integer := Character'Pos(c) - Character'Pos('0');
begin
bi := bi + multiplier * Create(value);
if index > 0 then
multiplier := multiplier * Create(10);
end if;
end;
when others =>
null;
end case;
end;
end loop;
return bi;
end Create;
function "+" (Left, Right: in BigInt) return BigInt is
result : BigInt;
carry : Long_Long_Integer := 0;
begin
-- Normalize the input such that |left.bits| >= |right.bits|
if Right.bits.Length > Left.bits.Length then
return Right + Left;
end if;
result.bits := Int_Vector.Empty_Vector;
result.negative := False;
-- Sum all the bits that the numbers have in common.
for index in 1 .. Integer(Right.bits.Length) loop
carry := carry + Left.bits.Element(index) + Right.bits.Element(index);
if carry >= Base then
result.bits.Append(carry - Base);
carry := 1;
else
result.bits.Append(carry);
carry := 0;
end if;
end loop;
-- Append all the bits that the left number has that the right number
-- does not (remembering to continue the carry)
for index in Integer(Right.bits.Length + 1) .. Integer(Left.bits.Length) loop
carry := carry + Left.bits.Element(index);
if carry >= Base then
result.bits.append(carry - Base);
carry := 1;
else
result.bits.append(carry);
carry := 0;
end if;
end loop;
-- Finally remember to add an extra '1' to the result if we ended up with
-- a carry bit.
if carry /= 0 then
result.bits.append(carry);
end if;
return result;
end "+";
function "-" (Left, Right: in BigInt) return BigInt is
result : BigInt;
carry_in : Long_Long_Integer := 0;
begin
-- Currently always assuming |left| >= |right|
result.bits := Int_Vector.Empty_Vector;
result.negative := False;
-- Subtract all the bits they have in common
for index in 1 .. Integer(Right.bits.Length) loop
carry_in := Left.bits.Element(index) - Right.bits.Element(index) - carry_in;
if carry_in < 0 then
result.bits.Append(Base + carry_in);
carry_in := 1;
else
result.bits.Append(carry_in);
carry_in := 0;
end if;
end loop;
-- Subtract the carry from any remaining bits in Left as neccessary
for index in Integer(Right.bits.Length + 1) .. Integer(Left.bits.Length) loop
carry_in := Left.bits.Element(index) - carry_in;
if carry_in < 0 then
result.bits.Append(Base + carry_in);
carry_in := 1;
else
result.bits.Append(carry_in);
carry_in := 0;
end if;
end loop;
-- Handle left over carry bit
-- Todo: We don't handle this right now
return result;
end "-";
function "*" (Left, Right: in BigInt) return BigInt is
result : BigInt;
Intermediate : Long_Long_Integer;
Temporary : Long_Long_Integer;
carry : Long_Long_Integer := 0;
double_carry : Boolean;
begin
-- Normalize the input such that |left.bits| >= |right.bits|
if Right.bits.Length > Left.bits.Length then
return Right * Left;
end if;
result.bits := Int_Vector.Empty_Vector;
result.negative := False;
-- Multiplication is done by splitting the Left and Right base units into
-- two half-base units representing the upper and lower bits of the
-- number. These portions are then multiplied pairwise
for left_index in 1 .. Integer(Left.bits.Length) loop
if Left.bits.Element(left_index) = 0 then
goto Next_Left;
end if;
declare
Left_Lower : constant Long_Long_Integer := Left.bits.Element(left_index) mod Half_Base;
Left_Upper : constant Long_Long_Integer := Left.bits.Element(left_index) / Half_Base;
begin
for right_index in 1 .. Integer(Right.bits.Length) loop
if Right.bits.Element(right_index) = 0 then
goto Next_Right;
end if;
declare
Right_Lower : constant Long_Long_Integer := Right.bits.Element(right_index) mod Half_Base;
Right_Upper : constant Long_Long_Integer := Right.bits.Element(right_index) / Half_Base;
result_index : constant Integer := left_index + right_index - 1;
begin
double_carry := False;
if Integer(result.bits.Length) > result_index then
carry := result.bits.Element(result_index + 1);
intermediate := result.bits.Element(result_index);
elsif Integer(result.bits.Length) >= result_index then
carry := 0;
intermediate := result.bits.Element(result_index);
else
carry := 0;
intermediate := 0;
while Integer(result.bits.Length) < result_index loop
result.bits.Append(0);
end loop;
end if;
-- Left_Lower * Right_Lower
Intermediate := Intermediate + Left_Lower * Right_Lower;
if Intermediate >= Base then
Intermediate := Intermediate - Base;
carry := carry + 1;
if carry = Base then
carry := 0;
double_carry := True;
end if;
end if;
-- Left_Lower * Right_Upper
Temporary := Left_Lower * Right_Upper;
if Temporary >= Half_Base then
Intermediate := Intermediate + (Temporary mod Half_Base) * Half_Base;
carry := carry + (Temporary / Half_Base);
if carry >= Base then
carry := carry - Base;
double_carry := True;
end if;
else
Intermediate := Intermediate + Temporary * Half_Base;
end if;
if Intermediate >= Base then
Intermediate := Intermediate - Base;
carry := carry + 1;
if carry = Base then
carry := 0;
double_carry := True;
end if;
end if;
-- Left_Upper * Right_Lower
Temporary := Left_Upper * Right_Lower;
if Temporary >= Half_Base then
Intermediate := Intermediate + (Temporary mod Half_Base) * Half_Base;
carry := carry + (Temporary / Half_Base);
if carry >= Base then
carry := carry - Base;
double_carry := True;
end if;
else
Intermediate := Intermediate + Temporary * Half_Base;
end if;
if Intermediate >= Base then
Intermediate := Intermediate - Base;
carry := carry + 1;
if carry = Base then
carry := 0;
double_carry := True;
end if;
end if;
result.bits.Replace_Element(result_index, Intermediate);
-- Left_Upper * Right_Upper
carry := carry + Left_Upper * Right_Upper;
if double_carry then
if Integer(result.bits.Length) >= result_index + 2 then
result.bits.Replace_Element(result_index + 2,
result.bits.Element(result_index + 2) + 1);
else
result.bits.Append(1);
end if;
-- If we have a double carry, we know we had at least
-- result_index + 1 elements in our vector because
-- otherwise we wouldn't have overflown the carry capacity.
result.bits.Replace_Element(result_index + 1, carry);
elsif carry > 0 then
if Integer(result.bits.Length ) > result_index then
result.bits.Replace_Element(result_index + 1, carry);
else
result.bits.Append(carry);
end if;
end if;
end;
<<Next_Right>>
null;
end loop;
end;
<<Next_Left>>
null;
end loop;
return result;
end "*";
function "**"(Left : in BigInt; Right: in Natural) return BigInt is
result : BigInt := Create(1);
current_base : BigInt := Left;
current_exponent : Long_Long_Integer := Long_Long_Integer(Right);
begin
while current_exponent > 0 loop
if current_exponent mod 2 = 0 then
current_base := current_base * current_base;
current_exponent := current_exponent / 2;
else
result := result * current_base;
current_exponent := current_exponent - 1;
end if;
end loop;
return result;
end;
function Magnitude(bi : in BigInt) return Positive is
function Log10(n : Long_Long_Integer) return Positive is
begin
if n >= 100_000_000_000_000_000 then
return 18;
elsif n >= 10_000_000_000_000_000 then
return 17;
elsif n >= 1_000_000_000_000_000 then
return 16;
elsif n >= 100_000_000_000_000 then
return 15;
elsif n >= 10_000_000_000_000 then
return 14;
elsif n >= 1_000_000_000_000 then
return 13;
elsif n >= 100_000_000_000 then
return 12;
elsif n >= 10_000_000_000 then
return 11;
elsif n >= 1_000_000_000 then
return 10;
elsif n >= 100_000_000 then
return 9;
elsif n >= 10_000_000 then
return 8;
elsif n >= 1_000_000 then
return 7;
elsif n >= 100_000 then
return 6;
elsif n >= 10_000 then
return 5;
elsif n >= 1_000 then
return 4;
elsif n >= 100 then
return 3;
elsif n >= 10 then
return 2;
else
return 1;
end if;
end Log10;
mag : constant Positive := Log10(bi.bits.Last_Element) + Natural(bi.bits.Length - 1) * 18;
begin
return mag;
end Magnitude;
function ToString(bi : in BigInt) return String is
begin
if bi.bits.Length > 0 then
declare
package Bounded is new Ada.Strings.Bounded.Generic_Bounded_Length(Integer(bi.bits.Length) * 18);
bs : Bounded.Bounded_String := Bounded.Null_Bounded_String;
temporary : String (1 .. 18);
begin
Ada.Long_Long_Integer_Text_IO.Put(temporary, bi.bits.Element(Integer(bi.bits.Length)));
Bounded.Append(bs, temporary);
Bounded.Trim(bs, Ada.Strings.Left);
for index in reverse 1 .. Integer(bi.bits.Length - 1) loop
Ada.Long_Long_Integer_Text_IO.Put(temporary, bi.bits.Element(index));
for ch_in in temporary'Range loop
if temporary(ch_in) = ' ' then
temporary(ch_in) := '0';
else
exit;
end if;
end loop;
Bounded.Append(bs, temporary);
end loop;
return Bounded.To_String(bs);
end;
else
return "0";
end if;
end;
end BigInteger;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with gnatcoll.SQL.Postgres; use gnatcoll.SQL.Postgres;
with gnatcoll.SQL.Exec; use gnatcoll.SQL.Exec;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO.Unbounded_IO;
with Formatter;
with Ada.Containers.Doubly_Linked_Lists;
with Ada.Containers; use Ada.Containers;
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with GNAT.Regpat; use GNAT.Regpat;
-- with Templates;
-- with Dbase.DrackSpace;
with Ada.Numerics.Generic_Elementary_Functions;
package Dbase.Scroller is
package SU renames Ada.Strings.Unbounded;
package SUIO renames Ada.Text_IO.Unbounded_IO;
type Scrl_Record is record
ID : Integer;
Prompt : Unbounded_String;
-- Func : Function_Access;
end record;
package Scrl_List is new Ada.Containers.Doubly_Linked_Lists(Scrl_Record);
use Scrl_List;
-- package Drack is new Dbase.DrackSpace;
Radar_Mode : Boolean := False;
subtype Value_Type is Long_Long_Float;
package Value_Functions is new Ada.Numerics.Generic_Elementary_Functions (
Value_Type);
use Value_Functions;
Definition_Ptr : Integer := 1;
function Fld (CI : Direct_Cursor; FldNme : Unbounded_String) return String;
function OpenDb return Boolean;
procedure CloseDb;
procedure Scroll (L_AckStatement : String; Down : Integer := 0; Left : Integer := 0; AltFunctions : Boolean := False); --; CI : in out Direct_Cursor);
procedure Run;
end Dbase.Scroller;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- Versions of the `struct stat' data structure.
-- i386 versions of the `xmknod' interface.
-- x86-64 versions of the `xmknod' interface.
-- Device.
type stat_uu_glibc_reserved_array is array (0 .. 2) of aliased CUPS.bits_types_h.uu_syscall_slong_t;
type stat is record
st_dev : aliased CUPS.bits_types_h.uu_dev_t; -- bits/stat.h:48
st_ino : aliased CUPS.bits_types_h.uu_ino_t; -- bits/stat.h:53
st_nlink : aliased CUPS.bits_types_h.uu_nlink_t; -- bits/stat.h:61
st_mode : aliased CUPS.bits_types_h.uu_mode_t; -- bits/stat.h:62
st_uid : aliased CUPS.bits_types_h.uu_uid_t; -- bits/stat.h:64
st_gid : aliased CUPS.bits_types_h.uu_gid_t; -- bits/stat.h:65
uu_pad0 : aliased int; -- bits/stat.h:67
st_rdev : aliased CUPS.bits_types_h.uu_dev_t; -- bits/stat.h:69
st_size : aliased CUPS.bits_types_h.uu_off_t; -- bits/stat.h:74
st_blksize : aliased CUPS.bits_types_h.uu_blksize_t; -- bits/stat.h:78
st_blocks : aliased CUPS.bits_types_h.uu_blkcnt_t; -- bits/stat.h:80
st_atim : aliased CUPS.time_h.timespec; -- bits/stat.h:91
st_mtim : aliased CUPS.time_h.timespec; -- bits/stat.h:92
st_ctim : aliased CUPS.time_h.timespec; -- bits/stat.h:93
uu_glibc_reserved : aliased stat_uu_glibc_reserved_array; -- bits/stat.h:106
end record;
pragma Convention (C_Pass_By_Copy, stat); -- bits/stat.h:46
-- File serial number.
-- 32bit file serial number.
-- File mode.
-- Link count.
-- Link count.
-- File mode.
-- User ID of the file's owner.
-- Group ID of the file's group.
-- Device number, if device.
-- Size of file, in bytes.
-- Size of file, in bytes.
-- Optimal block size for I/O.
-- Number 512-byte blocks allocated.
-- Number 512-byte blocks allocated.
-- Nanosecond resolution timestamps are stored in a format
-- equivalent to 'struct timespec'. This is the type used
-- whenever possible but the Unix namespace rules do not allow the
-- identifier 'timespec' to appear in the <sys/stat.h> header.
-- Therefore we have to handle the use of this header in strictly
-- standard-compliant sources special.
-- Time of last access.
-- Time of last modification.
-- Time of last status change.
-- Time of last access.
-- Nscecs of last access.
-- Time of last modification.
-- Nsecs of last modification.
-- Time of last status change.
-- Nsecs of last status change.
-- File serial number.
-- Note stat64 has the same shape as stat for x86-64.
-- Device.
type stat64_uu_glibc_reserved_array is array (0 .. 2) of aliased CUPS.bits_types_h.uu_syscall_slong_t;
type stat64 is record
st_dev : aliased CUPS.bits_types_h.uu_dev_t; -- bits/stat.h:121
st_ino : aliased CUPS.bits_types_h.uu_ino64_t; -- bits/stat.h:123
st_nlink : aliased CUPS.bits_types_h.uu_nlink_t; -- bits/stat.h:124
st_mode : aliased CUPS.bits_types_h.uu_mode_t; -- bits/stat.h:125
st_uid : aliased CUPS.bits_types_h.uu_uid_t; -- bits/stat.h:132
st_gid : aliased CUPS.bits_types_h.uu_gid_t; -- bits/stat.h:133
uu_pad0 : aliased int; -- bits/stat.h:135
st_rdev : aliased CUPS.bits_types_h.uu_dev_t; -- bits/stat.h:136
st_size : aliased CUPS.bits_types_h.uu_off_t; -- bits/stat.h:137
st_blksize : aliased CUPS.bits_types_h.uu_blksize_t; -- bits/stat.h:143
st_blocks : aliased CUPS.bits_types_h.uu_blkcnt64_t; -- bits/stat.h:144
st_atim : aliased CUPS.time_h.timespec; -- bits/stat.h:152
st_mtim : aliased CUPS.time_h.timespec; -- bits/stat.h:153
st_ctim : aliased CUPS.time_h.timespec; -- bits/stat.h:154
uu_glibc_reserved : aliased stat64_uu_glibc_reserved_array; -- bits/stat.h:164
end record;
pragma Convention (C_Pass_By_Copy, stat64); -- bits/stat.h:119
-- File serial number.
-- Link count.
-- File mode.
-- 32bit file serial number.
-- File mode.
-- Link count.
-- User ID of the file's owner.
-- Group ID of the file's group.
-- Device number, if device.
-- Size of file, in bytes.
-- Device number, if device.
-- Size of file, in bytes.
-- Optimal block size for I/O.
-- Nr. 512-byte blocks allocated.
-- Nanosecond resolution timestamps are stored in a format
-- equivalent to 'struct timespec'. This is the type used
-- whenever possible but the Unix namespace rules do not allow the
-- identifier 'timespec' to appear in the <sys/stat.h> header.
-- Therefore we have to handle the use of this header in strictly
-- standard-compliant sources special.
-- Time of last access.
-- Time of last modification.
-- Time of last status change.
-- Time of last access.
-- Nscecs of last access.
-- Time of last modification.
-- Nsecs of last modification.
-- Time of last status change.
-- Nsecs of last status change.
-- File serial number.
-- Tell code we have these members.
-- Nanosecond resolution time values are supported.
-- Encoding of the file mode.
-- File types.
-- POSIX.1b objects. Note that these macros always evaluate to zero. But
-- they do it by enforcing the correct use of the macros.
-- Protection bits.
end CUPS.bits_stat_h;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Ada.Containers.Ordered_Sets;
with DOM.Core;
with Util.Strings.Vectors;
package Are.Utils is
-- Generic procedure to iterate over the DOM nodes children of <b>node</b>
-- and having the entity name <b>name</b>.
generic
type T (<>) is limited private;
with procedure Process (Closure : in out T;
Node : DOM.Core.Node);
procedure Iterate_Nodes (Closure : in out T;
Node : in DOM.Core.Node;
Name : in String;
Recurse : in Boolean := True);
-- Get the first DOM child from the given entity tag
function Get_Child (Node : in DOM.Core.Node;
Name : in String) return DOM.Core.Node;
-- Get the content of the node
function Get_Data_Content (Node : in DOM.Core.Node) return String;
-- Get the content of the node identified by <b>Name</b> under the given DOM node.
function Get_Data_Content (Node : in DOM.Core.Node;
Name : in String) return String;
-- Get a boolean attribute
function Get_Attribute (Node : in DOM.Core.Node;
Name : in String;
Default : in Boolean := False) return Boolean;
-- Get a string attribute
function Get_Attribute (Node : in DOM.Core.Node;
Name : in String;
Default : in String := "") return String;
use Ada.Strings.Unbounded;
package String_Set is
new Ada.Containers.Ordered_Sets (Element_Type => Ada.Strings.Unbounded.Unbounded_String,
"<" => Ada.Strings.Unbounded."<",
"=" => Ada.Strings.Unbounded."=");
package String_List renames Util.Strings.Vectors;
-- Returns True if the file name must be ignored (.svn, CVS, .git, are ignored).
function Is_File_Ignored (Name : in String) return Boolean;
-- Get a string attribute
function Get_Attribute (Node : in DOM.Core.Node;
Name : in String;
Default : in String := "")
return Ada.Strings.Unbounded.Unbounded_String;
end Are.Utils;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
-- GNAT: enforce generation of preinitialized data section instead of
-- generation of elaboration code.
package Matreshka.Internals.Unicode.Ucd.Core_001C is
pragma Preelaborate;
Group_001C : aliased constant Core_Second_Stage
:= (16#00# .. 16#23# => -- 1C00 .. 1C23
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#24# .. 16#2B# => -- 1C24 .. 1C2B
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#2C# .. 16#33# => -- 1C2C .. 1C33
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#34# .. 16#35# => -- 1C34 .. 1C35
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#36# => -- 1C36
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Extender
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#37# => -- 1C37
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#3B# .. 16#3C# => -- 1C3B .. 1C3C
(Other_Punctuation, Neutral,
Other, Other, S_Term, Break_After,
(STerm
| Terminal_Punctuation
| Grapheme_Base => True,
others => False)),
16#3D# .. 16#3F# => -- 1C3D .. 1C3F
(Other_Punctuation, Neutral,
Other, Other, Other, Break_After,
(Terminal_Punctuation
| Grapheme_Base => True,
others => False)),
16#40# .. 16#49# => -- 1C40 .. 1C49
(Decimal_Number, Neutral,
Other, Numeric, Numeric, Numeric,
(Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#4D# .. 16#4F# => -- 1C4D .. 1C4F
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#50# .. 16#59# => -- 1C50 .. 1C59
(Decimal_Number, Neutral,
Other, Numeric, Numeric, Numeric,
(Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#5A# .. 16#77# => -- 1C5A .. 1C77
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#78# .. 16#7A# => -- 1C78 .. 1C7A
(Modifier_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Diacritic
| Alphabetic
| Case_Ignorable
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#7B# => -- 1C7B
(Modifier_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Diacritic
| Extender
| Alphabetic
| Case_Ignorable
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#7C# .. 16#7D# => -- 1C7C .. 1C7D
(Modifier_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Diacritic
| Alphabetic
| Case_Ignorable
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#7E# .. 16#7F# => -- 1C7E .. 1C7F
(Other_Punctuation, Neutral,
Other, Other, S_Term, Break_After,
(STerm
| Terminal_Punctuation
| Grapheme_Base => True,
others => False)),
16#C0# .. 16#C7# => -- 1CC0 .. 1CC7
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#D0# .. 16#D2# => -- 1CD0 .. 1CD2
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#D3# => -- 1CD3
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Diacritic
| Grapheme_Base => True,
others => False)),
16#D4# .. 16#E0# => -- 1CD4 .. 1CE0
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#E1# => -- 1CE1
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Diacritic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#E2# .. 16#E8# => -- 1CE2 .. 1CE8
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#E9# .. 16#EC# => -- 1CE9 .. 1CEC
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#ED# => -- 1CED
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#EE# .. 16#F1# => -- 1CEE .. 1CF1
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#F2# .. 16#F3# => -- 1CF2 .. 1CF3
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#F4# => -- 1CF4
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#F5# .. 16#F6# => -- 1CF5 .. 1CF6
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#F8# .. 16#F9# => -- 1CF8 .. 1CF9
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
others =>
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_001C;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Text_IO;
procedure Hamming is
generic
type Int_Type is private;
Zero : Int_Type;
One : Int_Type;
Two : Int_Type;
Three : Int_Type;
Five : Int_Type;
with function "mod" (Left, Right : Int_Type) return Int_Type is <>;
with function "/" (Left, Right : Int_Type) return Int_Type is <>;
with function "+" (Left, Right : Int_Type) return Int_Type is <>;
function Get_Hamming (Position : Positive) return Int_Type;
function Get_Hamming (Position : Positive) return Int_Type is
function Is_Hamming (Number : Int_Type) return Boolean is
Temporary : Int_Type := Number;
begin
while Temporary mod Two = Zero loop
Temporary := Temporary / Two;
end loop;
while Temporary mod Three = Zero loop
Temporary := Temporary / Three;
end loop;
while Temporary mod Five = Zero loop
Temporary := Temporary / Five;
end loop;
return Temporary = One;
end Is_Hamming;
Result : Int_Type := One;
Previous : Positive := 1;
begin
while Previous /= Position loop
Result := Result + One;
if Is_Hamming (Result) then
Previous := Previous + 1;
end if;
end loop;
return Result;
end Get_Hamming;
-- up to 2**32 - 1
function Integer_Get_Hamming is new Get_Hamming
(Int_Type => Integer,
Zero => 0,
One => 1,
Two => 2,
Three => 3,
Five => 5);
-- up to 2**64 - 1
function Long_Long_Integer_Get_Hamming is new Get_Hamming
(Int_Type => Long_Long_Integer,
Zero => 0,
One => 1,
Two => 2,
Three => 3,
Five => 5);
begin
Ada.Text_IO.Put ("1) First 20 Hamming numbers: ");
for I in 1 .. 20 loop
Ada.Text_IO.Put (Integer'Image (Integer_Get_Hamming (I)));
end loop;
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line ("2) 1_691st Hamming number: " &
Integer'Image (Integer_Get_Hamming (1_691)));
-- even Long_Long_Integer overflows here
Ada.Text_IO.Put_Line ("3) 1_000_000st Hamming number: " &
Long_Long_Integer'Image (Long_Long_Integer_Get_Hamming (1_000_000)));
end Hamming;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
package body AWS.Resources.Streams.Pipes is
------------
-- Append --
------------
procedure Append
(Resource : in out Stream_Type;
Buffer : Stream_Element_Array;
Trim : Boolean := False)
is
Lock : Lock_Type (Resource.Guard'Access) with Warnings => Off;
begin
if Resource.Has_Read then
Streams.Memory.Stream_Type (Resource).Append (Buffer, Trim);
Resource.Has_Write := True;
end if;
end Append;
------------
-- Append --
------------
procedure Append
(Resource : in out Stream_Type;
Buffer : Stream_Element_Access)
is
Lock : Lock_Type (Resource.Guard'Access) with Warnings => Off;
begin
if Resource.Has_Read then
Streams.Memory.Stream_Type (Resource).Append (Buffer);
Resource.Has_Write := True;
end if;
end Append;
------------
-- Append --
------------
procedure Append
(Resource : in out Stream_Type;
Buffer : Buffer_Access)
is
Lock : Lock_Type (Resource.Guard'Access) with Warnings => Off;
begin
if Resource.Has_Read then
Streams.Memory.Stream_Type (Resource).Append (Buffer);
Resource.Has_Write := True;
end if;
end Append;
----------
-- Read --
----------
overriding procedure Read
(Resource : in out Stream_Type;
Buffer : out Stream_Element_Array;
Last : out Stream_Element_Offset)
is
Lock : Lock_Type (Resource.Guard'Access) with Warnings => Off;
begin
Resource.Has_Read := True;
while not Resource.Has_Write loop
delay 0.01;
end loop;
Streams.Memory.Stream_Type (Resource).Read (Buffer, Last);
end Read;
-----------------
-- End_Of_File --
-----------------
overriding function End_Of_File (Resource : Stream_Type) return Boolean is
begin
return Streams.Memory.Stream_Type (Resource).End_Of_File;
end End_Of_File;
-----------
-- Clear --
-----------
procedure Clear (Resource : in out Stream_Type) is
Lock : Lock_Type (Resource.Guard'Access) with Warnings => Off;
begin
Streams.Memory.Stream_Type (Resource).Clear;
end Clear;
-----------
-- Close --
-----------
overriding procedure Close (Resource : in out Stream_Type) is
Lock : Lock_Type (Resource.Guard'Access) with Warnings => Off;
begin
Streams.Memory.Stream_Type (Resource).Close;
end Close;
----------------
-- Initialize --
----------------
procedure Initialize (Object : in out Lock_Type) is
begin
OBJECT.Guard.Seize;
end Initialize;
--------------
-- Finalize --
--------------
procedure Finalize (Object : in out Lock_Type) is
begin
OBJECT.Guard.Release;
end Finalize;
end AWS.Resources.Streams.Pipes;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with League.Holders;
package AMF.DG.Holders is
pragma Preelaborate;
-- ClosePath [0..1]
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Close_Path;
function To_Holder
(Element : AMF.DG.Optional_DG_Close_Path)
return League.Holders.Holder;
-- CubicCurveTo [0..1]
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Cubic_Curve_To;
function To_Holder
(Element : AMF.DG.Optional_DG_Cubic_Curve_To)
return League.Holders.Holder;
-- EllipticalArcTo [0..1]
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Elliptical_Arc_To;
function To_Holder
(Element : AMF.DG.Optional_DG_Elliptical_Arc_To)
return League.Holders.Holder;
-- GradientStop [0..1]
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Gradient_Stop;
function To_Holder
(Element : AMF.DG.Optional_DG_Gradient_Stop)
return League.Holders.Holder;
-- LineTo [0..1]
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Line_To;
function To_Holder
(Element : AMF.DG.Optional_DG_Line_To)
return League.Holders.Holder;
-- Matrix [0..1]
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Matrix;
function To_Holder
(Element : AMF.DG.Optional_DG_Matrix)
return League.Holders.Holder;
-- MoveTo [0..1]
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Move_To;
function To_Holder
(Element : AMF.DG.Optional_DG_Move_To)
return League.Holders.Holder;
-- PathCommand [0..1]
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Path_Command;
function To_Holder
(Element : AMF.DG.Optional_DG_Path_Command)
return League.Holders.Holder;
-- QuadraticCurveTo [0..1]
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Quadratic_Curve_To;
function To_Holder
(Element : AMF.DG.Optional_DG_Quadratic_Curve_To)
return League.Holders.Holder;
-- Rotate [0..1]
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Rotate;
function To_Holder
(Element : AMF.DG.Optional_DG_Rotate)
return League.Holders.Holder;
-- Scale [0..1]
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Scale;
function To_Holder
(Element : AMF.DG.Optional_DG_Scale)
return League.Holders.Holder;
-- Skew [0..1]
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Skew;
function To_Holder
(Element : AMF.DG.Optional_DG_Skew)
return League.Holders.Holder;
-- Transform [0..1]
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Transform;
function To_Holder
(Element : AMF.DG.Optional_DG_Transform)
return League.Holders.Holder;
-- Translate [0..1]
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Translate;
function To_Holder
(Element : AMF.DG.Optional_DG_Translate)
return League.Holders.Holder;
end AMF.DG.Holders;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
pragma Ada_2012;
-- with Ada.Text_Io; use Ada.Text_Io;
package body Protypo.Api.Engine_Values.Constant_Wrappers is
----------------
-- To_Handler --
----------------
function To_Handler_Value (Value : Engine_Value) return Handler_Value is
begin
if Value in Handler_Value then
return value;
else
declare
Result : constant Engine_Value :=
Handlers.Create (Handlers.Constant_Interface_Access (Make_Wrapper (Value)));
begin
-- Put_Line (Result.Class'Image);
-- Put_Line (Boolean'image(Result.Class in Handler_Classes));
-- Put_Line (Boolean'Image (Result in Handler_Value));
return Result;
end;
end if;
end To_Handler_Value;
end Protypo.Api.Engine_Values.Constant_Wrappers;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--
generic
type Element is private;
type Buffer_Index is mod <>;
package Generic_Realtime_Buffer is
pragma Elaborate_Body;
type Realtime_Buffer is private;
procedure Put (B : in out Realtime_Buffer; Item : Element);
procedure Get (B : in out Realtime_Buffer; Item : out Element);
function Element_Available (B : Realtime_Buffer) return Boolean;
Calling_Get_On_Empty_Buffer : exception;
private
type No_Of_Elements is new Natural range 0 .. Natural (Buffer_Index'Last) + 1;
type Buffer_Array is array (Buffer_Index) of Element;
type Realtime_Buffer is record
Write_To,
Read_From : Buffer_Index := Buffer_Index'First;
Elements_In_Buffer : No_Of_Elements := 0;
Buffer : Buffer_Array;
end record;
end Generic_Realtime_Buffer;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Text_IO;
with Ada.Command_Line;
with AWS.Client;
with AWS.Headers;
with AWS.Response;
with AWS.Messages;
use AWS.Messages;
procedure main is
hdrs : AWS.Headers.List := AWS.Headers.Empty_List;
server_url : constant String := Ada.Command_Line.Argument(1);
player_key : constant String := Ada.Command_Line.Argument(2);
result : AWS.Response.Data;
status : AWS.Messages.Status_Code;
begin
Text_IO.Put_Line("ServerURL: " & server_url & ", PlayerKey: " & player_key);
AWS.Headers.Add(hdrs, "Content-Type", "text/plain");
result := AWS.Client.Post(URL => server_url, Data => player_key, Headers => hdrs);
status := AWS.Response.Status_Code(result);
if status = AWS.Messages.S200 then
Text_IO.Put_Line("Server response: " & AWS.Response.Message_Body(result));
else
Text_IO.Put_Line("Unexpected server response:");
Text_IO.Put_Line("HTTP code: " & AWS.Messages.Image(status) & " (" & AWS.Messages.Reason_Phrase(status) & ")");
Text_IO.Put_Line("Response body: " & AWS.Response.Message_Body(result));
Ada.Command_Line.Set_Exit_Status(2);
end if;
end main;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--*
-- OBJECTIVE:
-- CHECK THAT AN IMPLICIT DECLARATION OF A PREDEFINED OPERATOR OR
-- AN ENUMERATION LITERAL IS HIDDEN BY A DERIVED SUBPROGRAM
-- HOMOGRAPH.
-- HISTORY:
-- VCL 08/10/88 CREATED ORIGINAL TEST.
WITH REPORT; USE REPORT;
PROCEDURE C83032A IS
BEGIN
TEST ("C83032A", "AN IMPLICIT DECLARATION OF A PREDEFINED " &
"OPERATOR OR AN ENUMERATION LITERAL IS HIDDEN " &
"BY A DERIVED SUBPROGRAM HOMOGRAPH");
DECLARE -- CHECK PREDEFINED OPERATOR.
PACKAGE P IS
TYPE INT IS RANGE -20 .. 20;
FUNCTION "ABS" (X : INT) RETURN INT;
END P;
USE P;
TYPE NINT IS NEW INT;
I2 : NINT := -5;
PACKAGE BODY P IS
I1 : NINT := 5;
FUNCTION "ABS" (X : INT) RETURN INT IS
BEGIN
RETURN INT (- (ABS (INTEGER (X))));
END "ABS";
BEGIN
IF "ABS"(I1) /= -5 THEN
FAILED ("INCORRECT VALUE FOR 'I1' AFTER CALL " &
"TO DERIVED ""ABS"" - 1");
END IF;
I1 := ABS (-10);
IF ABS I1 /= NINT(IDENT_INT (-10)) THEN
FAILED ("INCORRECT VALUE FOR 'I1' AFTER CALL " &
"TO DERIVED ""ABS"" - 2");
END IF;
END P;
BEGIN
IF "ABS"(I2) /= -5 THEN
FAILED ("INCORRECT VALUE FOR 'I2' AFTER CALL " &
"TO DERIVED ""ABS"" - 1");
END IF;
I2 := ABS (10);
IF ABS I2 /= NINT (IDENT_INT (-10)) THEN
FAILED ("INCORRECT VALUE FOR 'I1' AFTER CALL " &
"TO DERIVED ""ABS"" - 2");
END IF;
END;
DECLARE -- CHECK ENUMERATION LITERALS.
PACKAGE P1 IS
TYPE ENUM1 IS (E11, E12, E13);
TYPE PRIV1 IS PRIVATE;
FUNCTION E11 RETURN PRIV1;
PRIVATE
TYPE PRIV1 IS NEW ENUM1;
TYPE NPRIV1 IS NEW PRIV1;
END P1;
USE P1;
PACKAGE BODY P1 IS
FUNCTION E11 RETURN PRIV1 IS
BEGIN
RETURN E13;
END E11;
BEGIN
IF NPRIV1'(E11) /= E13 THEN
FAILED ("INCORRECT VALUE FOR E11");
END IF;
END P1;
BEGIN
NULL;
END;
RESULT;
END C83032A;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
------------------------------------------------------------------------------
package body SAM.SERCOM.SPI is
---------------
-- Configure --
---------------
procedure Configure
(This : in out SPI_Device;
Baud : UInt8;
Data_Order : Data_Bit_Order;
Phase : Clock_Phase;
Polarity : Clock_Polarity;
DIPO : Pad_Id;
DOPO : Pad_Id;
Slave_Select_Enable : Boolean)
is
CTRLB : SERCOM_CTRLB_SERCOM_SPI_Register;
begin
This.Reset;
This.Periph.SERCOM_SPI.CTRLA :=
(MODE => 3, -- SPI Master
DOPO => UInt2 (DOPO),
DIPO => UInt2 (DIPO),
FORM => 0,
CPHA => (case Phase is
when Sample_Leading_Edge => False,
when Sample_Trailing_Edge => True),
CPOL => (case Polarity is
when Active_High => False,
when Active_Low => True),
DORD => (case Data_Order is
when Most_Significant_First => False,
when Least_Significant_First => True),
others => <>
);
This.Periph.SERCOM_SPI.BAUD := Baud;
CTRLB := This.Periph.SERCOM_SPI.CTRLB;
CTRLB.CHSIZE := 0;
CTRLB.MSSEN := Slave_Select_Enable;
This.Periph.SERCOM_SPI.CTRLB := CTRLB;
-- Wait for CTRLB synchronization signal
while This.Periph.SERCOM_SPI.SYNCBUSY.CTRLB loop
null;
end loop;
This.Config_Done := True;
end Configure;
---------------------
-- Enable_Receiver --
---------------------
procedure Enable_Receiver (This : in out SPI_Device) is
begin
This.Periph.SERCOM_SPI.CTRLB.RXEN := True;
-- Wait for CTRLB synchronization signal
while This.Periph.SERCOM_SPI.SYNCBUSY.CTRLB loop
null;
end loop;
end Enable_Receiver;
----------------------
-- Disable_Receiver --
----------------------
procedure Disable_Receiver (This : in out SPI_Device) is
begin
This.Periph.SERCOM_SPI.CTRLB.RXEN := False;
-- Wait for CTRLB synchronization signal
while This.Periph.SERCOM_SPI.SYNCBUSY.CTRLB loop
null;
end loop;
end Disable_Receiver;
------------------
-- Data_Address --
------------------
function Data_Address (This : SPI_Device) return System.Address
is (This.Periph.SERCOM_SPI.DATA'Address);
--------------
-- Transmit --
--------------
overriding
procedure Transmit
(This : in out SPI_Device;
Data : SPI_Data_8b;
Status : out SPI_Status;
Timeout : Natural := 1_000)
is
pragma Unreferenced (Timeout);
begin
for Elt of Data loop
This.Periph.SERCOM_SPI.DATA := UInt32 (Elt);
while not This.Periph.SERCOM_SPI.INTFLAG.TXC loop
null;
end loop;
end loop;
Status := Ok;
end Transmit;
--------------
-- Transmit --
--------------
overriding
procedure Transmit
(This : in out SPI_Device;
Data : SPI_Data_16b;
Status : out SPI_Status;
Timeout : Natural := 1_000)
is
begin
raise Program_Error with "Unimplemented procedure Transmit 16b";
end Transmit;
-------------
-- Receive --
-------------
overriding
procedure Receive
(This : in out SPI_Device;
Data : out SPI_Data_8b;
Status : out SPI_Status;
Timeout : Natural := 1_000)
is
pragma Unreferenced (Timeout);
begin
for Elt of Data loop
-- Write anything to trigger the transaction
This.Periph.SERCOM_SPI.DATA := 0;
while not This.Periph.SERCOM_SPI.INTFLAG.RXC loop
null;
end loop;
Elt := UInt8 (This.Periph.SERCOM_SPI.DATA and 16#FF#);
end loop;
Status := Ok;
end Receive;
-------------
-- Receive --
-------------
overriding
procedure Receive
(This : in out SPI_Device;
Data : out SPI_Data_16b;
Status : out SPI_Status;
Timeout : Natural := 1_000)
is
begin
raise Program_Error with "Unimplemented procedure Receive 16bit";
end Receive;
end SAM.SERCOM.SPI;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
package Progress_Indicators.Work_Trackers is
-- Tracker used in the tracking of homogenous groups of work farmed out to
-- many tasks. The goal is to track the amount of outstanding elements to
-- process, without caring too much about any individual element of work.
type Status_Report is record
Completed : Natural := 0;
Total : Natural := 0;
end record;
protected type Work_Tracker is
procedure Start_Work (Amount : Natural);
procedure Finish_Work (Amount : Natural);
function Report return Status_Report;
private
Current : Status_Report;
end Work_Tracker;
end Progress_Indicators.Work_Trackers;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Numerics.Long_Elementary_Functions;
with Ada.Text_IO; use Ada.Text_IO;
procedure Sequence_Of_Non_Squares_Test is
use Ada.Numerics.Long_Elementary_Functions;
function Non_Square (N : Positive) return Positive is
begin
return N + Positive (Long_Float'Rounding (Sqrt (Long_Float (N))));
end Non_Square;
I : Positive;
begin
for N in 1..22 loop -- First 22 non-squares
Put (Natural'Image (Non_Square (N)));
end loop;
New_Line;
for N in 1..1_000_000 loop -- Check first million of
I := Non_Square (N);
if I = Positive (Sqrt (Long_Float (I)))**2 then
Put_Line ("Found a square:" & Positive'Image (N));
end if;
end loop;
end Sequence_Of_Non_Squares_Test;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
pragma Ada_2012;
with Protypo.Api.Engine_Values.Parameter_Lists; use Protypo.Api.Engine_Values.Parameter_Lists;
package body User_Records is
---------------
-- Split_Bit --
---------------
function Split_Bit
(Params : Protypo.Api.Engine_Values.Engine_Value_Vectors.Vector)
return Protypo.Api.Engine_Values.Engine_Value_Vectors.Vector
is
use Protypo.Api.Engine_Values;
Parameters : Parameter_List := Create (Params);
X : constant Integer := Get_Integer (Shift (Parameters));
Y : constant Integer := Get_Integer (Shift (Parameters), 2);
Result : Engine_Value_Vectors.Vector;
begin
Result (1) := Create (X / Y);
Result (2) := Create (X mod Y);
return Result;
end Split_Bit;
end User_Records;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
With
EPL.Types,
EPL.Bracket,
Ada.Strings.Fixed;
Separate (Risi_Script.Types.Patterns)
Package Body Conversions is
Function Trimmed_Image( Input : Integer ) return String is
Use Ada.Strings.Fixed, Ada.Strings;
Begin
return Trim(Side => Left, Source => Integer'Image(Input));
End Trimmed_Image;
-------------------------
-- PATTERN TO STRING --
-------------------------
Function Convert( Pattern : Half_Pattern ) return String is
Begin
Return Result : String(Pattern'Range) do
for Index in Result'Range loop
Result(Index):= +Pattern(Index);
end loop;
End Return;
End Convert;
Function Convert( Pattern : Three_Quarter_Pattern ) return String is
Function Internal_Convert( Pattern : Three_Quarter_Pattern ) return String is
Subtype Tail is Positive Range Positive'Succ(Pattern'First)..Pattern'Last;
Begin
if Pattern'Length not in Positive then
return "";
else
Declare
Head : Enumeration_Length renames Pattern(Pattern'First).All;
Sigil : constant Character := +Head.Enum;
Length : constant String :=
(if Head.Enum not in RT_String | RT_Array | RT_Hash then ""
else '(' & Trimmed_Image(Head.Length) & ')');
Begin
return Sigil & Length & String'(+Pattern(Tail));
End;
end if;
End Internal_Convert;
Result : constant String := Internal_Convert( Pattern );
Parens : constant Boolean := Ada.Strings.Fixed.Index(Result, "(") in Positive;
Begin
Return "";
-- Return (if Parens then Result else )
End Convert;
Function Convert( Pattern : Full_Pattern ) return String is ("");
Function Convert( Pattern : Extended_Pattern ) return String is ("");
Function Convert( Pattern : Square_Pattern ) return String is ("");
Function Convert( Pattern : Cubic_Pattern ) return String is ("");
Function Convert( Pattern : Power_Pattern ) return String is ("");
-------------------------
-- STRING TO PATTERN --
-------------------------
-- Function Convert( Text : String ) return Half_Pattern is ("");
-- Function Convert( Text : String ) return Three_Quarter_Pattern is ("");
-- Function Convert( Text : String ) return Full_Pattern is ("");
-- Function Convert( Text : String ) return Extended_Pattern is ("");
-- Function Convert( Text : String ) return Square_Pattern is ("");
-- Function Convert( Text : String ) return Cubic_Pattern is ("");
-- Function Convert( Text : String ) return Power_Pattern is ("");
--
-- Function "+"( Pattern : Half_Pattern ) return String is
-- Subtype Tail is Positive Range Positive'Succ(Pattern'First)..Pattern'Last;
-- begin
-- if Pattern'Length not in Positive then
-- return "";
-- else
-- Declare
-- Head : Enumeration renames Pattern(Pattern'First);
-- Sigil : constant Character := +(+Head);
-- Begin
-- return Sigil & String'(+Pattern(Tail));
-- End;
-- end if;
-- end "+";
--
--
-- Function "+"( Text : String ) return Half_Pattern is
-- Subtype Tail is Positive Range Positive'Succ(Text'First)..Text'Last;
-- begin
-- if Text'Length not in Positive then
-- return (2..1 => <>);
-- else
-- Declare
-- Element : constant Enumeration:= +(+Text(Text'First));
-- Begin
-- return Element & (+Text(Tail));
-- End;
-- end if;
-- end "+";
End Conversions;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
------------------------------------------------------------------------
-- AMD Élan(tm) SC 520 embedded microprocessor --
-- MMCR -> SDRAM Controller Registers --
-- --
-- reference: Register Set Manual Chapter 7 --
------------------------------------------------------------------------
with Elan520.Basic_Types;
package Elan520.SDRAM_Controller_Registers is
---------------------------------------------------------------------
-- SDRAM Control (DRCCTL) --
-- Memory Mapped, Read/Write --
-- MMCR Offset 10h --
---------------------------------------------------------------------
---------------------------------------------------------------------
-- sub types for SDRAM_Control
type Operation_Mode_Select is (Normal,
NOP_Command,
All_Banks_Precharge,
Load_Mode_Register,
Auto_Refresh);
for Operation_Mode_Select use (Normal => 2#000#,
NOP_Command => 2#001#,
All_Banks_Precharge => 2#010#,
Load_Mode_Register => 2#100#,
Auto_Refresh => 2#101#);
for Operation_Mode_Select'Size use 3;
DEFAULT_OPERATION_MODE_SELECT :
constant Operation_Mode_Select := Normal;
-- unit is 7.8 microseconds
type Refresh_Request_Speed is range 1 .. 4;
for Refresh_Request_Speed'Size use 2;
DEFAULT_REFRESH_REQUEST_SPEED : constant Refresh_Request_Speed := 2;
---------------------------------------------------------------------
-- SDRAM Control at MMCR offset 16#10#
---------------------------------------------------------------------
MMCR_OFFSET_SDRAM_CONTROL : constant := 16#10#;
SDRAM_CONTROL_SIZE : constant := 8;
type SDRAM_Control is
record
Op_Mode_Sel : Operation_Mode_Select;
Rfsh : Basic_Types.Positive_Bit;
Rfsh_Spd : Refresh_Request_Speed;
Wb_Tst : Basic_Types.Positive_Bit;
end record;
for SDRAM_Control use
record
Op_Mode_Sel at 0 range 0 .. 2;
Rfsh at 0 range 3 .. 3;
Rfsh_Spd at 0 range 4 .. 5;
-- bit 6 is reserved
Wb_Tst at 0 range 7 .. 7;
end record;
for SDRAM_Control'Size use SDRAM_CONTROL_SIZE;
---------------------------------------------------------------------
-- SDRAM Timing Control (DRCTMCTL) --
-- Memory Mapped, Read/Write --
-- MMCR Offset 12h --
---------------------------------------------------------------------
---------------------------------------------------------------------
-- subtypes for SDRAM Timing Contol
type RAS_CAS_Delay is range 2 .. 4;
for RAS_CAS_Delay'Size use 2;
DEFAULT_RAS_CAS_DELAY : constant RAS_CAS_Delay := 4;
type RAS_Precharge_Delay is (Two_Cycles, Three_Cycles,
Four_Cycles, Six_Cycles);
for RAS_Precharge_Delay use (Two_Cycles => 2#00#,
Three_Cycles => 2#01#,
Four_Cycles => 2#10#,
Six_Cycles => 2#11#);
for RAS_Precharge_Delay'Size use 2;
DEFAULT_RAS_PRECHARGE_DELAY :
constant RAS_Precharge_Delay := Four_Cycles;
type CAS_Latency is range 2 .. 3;
for CAS_Latency'Size use 1;
DEFAULT_CAS_LATENCY : constant CAS_Latency := 3;
---------------------------------------------------------------------
-- SDRAM Timing Control at MMCR offset 16#12#
---------------------------------------------------------------------
MMCR_OFFSET_SDRAM_TIMING_CONTROL : constant := 16#12#;
SDRAM_TIMING_CONTROL_SIZE : constant := 8;
type SDRAM_Timing_Control is
record
Ras_Cas_Dly : RAS_CAS_Delay;
Ras_Pchg_Dly : RAS_Precharge_Delay;
Cas_Lat : CAS_Latency;
end record;
for SDRAM_Timing_Control use
record
Ras_Cas_Dly at 0 range 0 .. 1;
Ras_Pchg_Dly at 0 range 2 .. 3;
Cas_Lat at 0 range 4 .. 4;
-- bits 5-7 are reserved
end record;
for SDRAM_Timing_Control'Size use SDRAM_TIMING_CONTROL_SIZE;
---------------------------------------------------------------------
-- SDRAM Bank Configuration (DRCCFG) --
-- Memory Mapped, Read/Write --
-- MMCR Offset 14h --
---------------------------------------------------------------------
---------------------------------------------------------------------
-- subtypes for SDRAM Bank Configuration
type Bank_Count is (Two_Bank_Device, Four_Bank_Device);
for Bank_Count use (Two_Bank_Device => 0,
Four_Bank_Device => 1);
for Bank_Count'Size use 1;
type Column_Address_Width is range 8 .. 11;
for Column_Address_Width'Size use 2;
type Bank_Descriptor is
record
Col_Width : Column_Address_Width;
Bnk_Cnt : Bank_Count;
end record;
for Bank_Descriptor use
record
Col_Width at 0 range 0 .. 1;
-- bit 2 is reserved
Bnk_Cnt at 0 range 3 .. 3;
end record;
for Bank_Descriptor'Size use 4;
---------------------------------------------------------------------
-- SDRAM Bank Configuration at MMCR offset 16#14#
---------------------------------------------------------------------
MMCR_OFFSET_SDRAM_BANK_CONFIGURATION : constant := 16#14#;
SDRAM_BANK_CONFIGURATION_SIZE : constant := 16;
type SDRAM_Bank_Configuration is
record
Bnk0 : Bank_Descriptor;
Bnk1 : Bank_Descriptor;
Bnk2 : Bank_Descriptor;
Bnk3 : Bank_Descriptor;
end record;
for SDRAM_Bank_Configuration use
record
Bnk0 at 0 range 0 .. 3;
Bnk1 at 0 range 4 .. 7;
Bnk2 at 0 range 8 .. 11;
Bnk3 at 0 range 12 .. 15;
end record;
for SDRAM_Bank_Configuration'Size use SDRAM_BANK_CONFIGURATION_SIZE;
---------------------------------------------------------------------
-- SDRAM Bank 0 - 3 Ending Address (DRCBENDADR) --
-- Memory Mapped, Read/Write --
-- MMCR Offset 18h --
---------------------------------------------------------------------
---------------------------------------------------------------------
-- subtypes for SDRAM Bank Ending Address
type Ending_Address is range 0 .. 2**7 - 1;
type Ending_Address_Descriptor is
record
End_Address : Ending_Address;
Bnk : Basic_Types.Positive_Bit;
end record;
for Ending_Address_Descriptor use
record
End_Address at 0 range 0 .. 6;
Bnk at 0 range 7 .. 7;
end record;
for Ending_Address_Descriptor'Size use 8;
---------------------------------------------------------------------
-- SDRAM Bank Ending Address at MMCR offset 16#18#
---------------------------------------------------------------------
MMCR_OFFSET_SDRAM_BANK_ENDING_ADDRESS : constant := 16#18#;
SDRAM_BANK_ENDING_ADDRESS_SIZE : constant := 32;
type SDRAM_Bank_Ending_Address is
record
Bnk0 : Ending_Address_Descriptor;
Bnk1 : Ending_Address_Descriptor;
Bnk2 : Ending_Address_Descriptor;
Bnk3 : Ending_Address_Descriptor;
end record;
for SDRAM_Bank_Ending_Address use
record
Bnk0 at 0 range 0 .. 7;
Bnk1 at 0 range 8 .. 15;
Bnk2 at 0 range 16 .. 23;
Bnk3 at 0 range 24 .. 31;
end record;
for SDRAM_Bank_Ending_Address'Size use
SDRAM_BANK_ENDING_ADDRESS_SIZE;
---------------------------------------------------------------------
-- ECC Control (ECCCTL) --
-- Memory Mapped, Read/Write --
-- MMCR Offset 20h --
---------------------------------------------------------------------
---------------------------------------------------------------------
-- ECC Control at MMCR offset 16#20#
---------------------------------------------------------------------
MMCR_OFFSET_ECC_CONTROL : constant := 16#20#;
ECC_CONTROL_SIZE : constant := 8;
type ECC_Control is
record
ECC_All : Basic_Types.Positive_Bit;
Single_Bit_Interrupt : Basic_Types.Positive_Bit;
Multi_Bit_Interrupt : Basic_Types.Positive_Bit;
end record;
for ECC_Control use
record
ECC_All at 0 range 0 .. 0;
Single_Bit_Interrupt at 0 range 1 .. 1;
Multi_Bit_Interrupt at 0 range 2 .. 2;
-- bits 3 to 7 are reserved
end record;
for ECC_Control'Size use ECC_CONTROL_SIZE;
---------------------------------------------------------------------
-- ECC Status (ECCSTA) --
-- Memory Mapped, Read/Write --
-- MMCR Offset 21h --
---------------------------------------------------------------------
---------------------------------------------------------------------
-- ECC Status at MMCR offset 16#21#
---------------------------------------------------------------------
MMCR_OFFSET_ECC_STATUS : constant := 16#21#;
ECC_STATUS_SIZE : constant := 8;
type ECC_Status is
record
Single_Bit_Error : Basic_Types.Positive_Bit;
Multi_Bit_Error : Basic_Types.Positive_Bit;
end record;
for ECC_Status use
record
Single_Bit_Error at 0 range 0 .. 0;
Multi_Bit_Error at 0 range 1 .. 1;
-- bits 2 to 7 are reserved
end record;
for ECC_Status'Size use ECC_STATUS_SIZE;
---------------------------------------------------------------------
-- ECC Check Bit Position (ECCCKBPOS) --
-- Memory Mapped, Read Only --
-- MMCR Offset 22h --
---------------------------------------------------------------------
---------------------------------------------------------------------
-- ECC Status at MMCR offset 16#22#
---------------------------------------------------------------------
MMCR_OFFSET_ECC_CHECK_BIT_POSITION : constant := 16#22#;
ECC_CHECK_BIT_POSITION_SIZE : constant := 8;
type ECC_Check_Bit_Position is range 0 .. 38;
for ECC_Check_Bit_Position'Size use ECC_CHECK_BIT_POSITION_SIZE;
---------------------------------------------------------------------
-- ECC Check Code Test (ECCCKTEST) --
-- Memory Mapped, Read/Write --
-- MMCR Offset 23h --
---------------------------------------------------------------------
---------------------------------------------------------------------
-- subtypes for ECC Check Code Test
type Forced_ECC_Check_Bits is range 0 .. 2**7 - 1;
---------------------------------------------------------------------
-- ECC Check Code Test at MMCR offset 16#23#
---------------------------------------------------------------------
MMCR_OFFSET_ECC_CHECK_CODE_TEST : constant := 16#23#;
ECC_CHECK_CODE_TEST_SIZE : constant := 8;
type ECC_Check_Code_Test is
record
Force_Bad_ECC_Check_Bits : Forced_ECC_Check_Bits;
Bad_Check : Basic_Types.Positive_Bit;
end record;
for ECC_Check_Code_Test use
record
Force_Bad_ECC_Check_Bits at 0 range 0 .. 6;
Bad_Check at 0 range 7 .. 7;
end record;
for ECC_Check_Code_Test'Size use ECC_CHECK_CODE_TEST_SIZE;
---------------------------------------------------------------------
-- subtypes for error addresses (single & multi-bit)
type Error_Address is range 0 .. 2**26 - 1;
---------------------------------------------------------------------
-- ECC Single-Bit Error Address (ECCSBADD) --
-- Memory Mapped, Read Only --
-- MMCR Offset 24h --
---------------------------------------------------------------------
MMCR_OFFSET_ECC_SINGLE_BIT_ERROR_ADDRESS : constant := 16#24#;
ECC_SINGLE_BIT_ERROR_ADDRESS_SIZE : constant := 32;
type ECC_Single_Bit_Error_Address is
record
SB_Addr : Error_Address;
end record;
for ECC_Single_Bit_Error_Address use
record
SB_Addr at 0 range 2 .. 27;
end record;
---------------------------------------------------------------------
-- ECC Multi-Bit Error Address (ECCMBADD) --
-- Memory Mapped, Read Only --
-- MMCR Offset 28h --
---------------------------------------------------------------------
MMCR_OFFSET_ECC_MULTI_BIT_ERROR_ADDRESS : constant := 16#28#;
ECC_MULTI_BIT_ERROR_ADDRESS_SIZE : constant := 32;
type ECC_Multi_Bit_Error_Address is
record
MB_Addr : Error_Address;
end record;
for ECC_Multi_Bit_Error_Address use
record
MB_Addr at 0 range 2 .. 27;
end record;
end Elan520.SDRAM_Controller_Registers;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
------------------------------------------------------------------------------
-- This version is for ARM bareboard targets using the ARMv7-M targets,
-- which only use Thumb2 instructions.
with Ada.Unchecked_Conversion; use Ada;
with System.Storage_Elements;
with System.Multiprocessors;
with System.BB.Board_Support;
with System.BB.Threads;
with System.BB.Threads.Queues;
with System.BB.Time;
with System.Machine_Code; use System.Machine_Code;
package body System.BB.CPU_Primitives is
use Parameters;
use Threads;
use Queues;
use Board_Support;
use Time;
use System.Multiprocessors;
package SSE renames System.Storage_Elements;
use type SSE.Integer_Address;
use type SSE.Storage_Offset;
NL : constant String := ASCII.LF & ASCII.HT;
-- New line separator in Asm templates
No_Floating_Point : constant Boolean := False;
-- Set True iff the FPU should not be used
-----------
-- Traps --
-----------
Reset_Vector : constant Vector_Id := 1;
NMI_Vector : constant Vector_Id := 2;
Hard_Fault_Vector : constant Vector_Id := 3;
-- Mem_Manage_Vector : constant Vector_Id := 4; -- Never referenced
Bus_Fault_Vector : constant Vector_Id := 5;
Usage_Fault_Vector : constant Vector_Id := 6;
SV_Call_Vector : constant Vector_Id := 10;
-- Debug_Mon_Vector : constant Vector_Id := 11; -- Never referenced
Pend_SV_Vector : constant Vector_Id := 13;
Sys_Tick_Vector : constant Vector_Id := 14;
Interrupt_Request_Vector : constant Vector_Id := 15;
pragma Assert (Interrupt_Request_Vector = Vector_Id'Last);
type Trap_Handler_Ptr is access procedure (Id : Vector_Id);
function To_Pointer is new Unchecked_Conversion (Address, Trap_Handler_Ptr);
type Trap_Handler_Table is array (Vector_Id) of Trap_Handler_Ptr;
pragma Suppress_Initialization (Trap_Handler_Table);
Trap_Handlers : Trap_Handler_Table;
pragma Export (C, Trap_Handlers, "__gnat_bb_exception_handlers");
System_Vectors : constant System.Address;
pragma Import (Asm, System_Vectors, "__vectors");
-- As ARMv7M does not directly provide a single-shot alarm timer, and
-- we have to use Sys_Tick for that, we need to have this clock generate
-- interrupts at a relatively high rate. To avoid unnecessary overhead
-- when no alarms are requested, we'll only call the alarm handler if
-- the current time exceeds the Alarm_Time by at most half the modulus
-- of Timer_Interval.
Alarm_Time : Board_Support.Timer_Interval;
pragma Volatile (Alarm_Time);
pragma Import (C, Alarm_Time, "__gnat_alarm_time");
procedure SV_Call_Handler;
pragma Export (Asm, SV_Call_Handler, "__gnat_sv_call_trap");
procedure Pend_SV_Handler;
pragma Machine_Attribute (Pend_SV_Handler, "naked");
pragma Export (Asm, Pend_SV_Handler, "__gnat_pend_sv_trap");
-- This assembly routine needs to save and restore registers without
-- interference. The "naked" machine attribute communicates this to GCC.
procedure Sys_Tick_Handler;
pragma Export (Asm, Sys_Tick_Handler, "__gnat_sys_tick_trap");
procedure Interrupt_Request_Handler;
pragma Export (Asm, Interrupt_Request_Handler, "__gnat_irq_trap");
procedure GNAT_Error_Handler (Trap : Vector_Id);
pragma No_Return (GNAT_Error_Handler);
-----------------------
-- Context Switching --
-----------------------
-- This port uses the ARMv7-M hardware for saving volatile context for
-- interrupts, see the Hardware_Context type below for details. Any
-- non-volatile registers will be preserved by the interrupt handler in
-- the same way as it happens for ordinary procedure calls.
-- The non-volatile registers, as well as the value of the stack pointer
-- (SP_process) are saved in the Context buffer of the Thread_Descriptor.
-- Any non-volatile floating-point registers are saved on the stack.
-- R4 .. R11 are at offset 0 .. 7
SP_process : constant Context_Id := 8;
type Hardware_Context is record
R0, R1, R2, R3 : Word;
R12, LR, PC, PSR : Word;
end record;
ICSR : Word with Volatile, Address => 16#E000_ED04#; -- Int. Control/State
ICSR_Pend_SV_Set : constant Word := 2**28;
VTOR : Address with Volatile, Address => 16#E000_ED08#; -- Vec. Table Offset
AIRCR : Word with Volatile, Address => 16#E000_ED0C#; -- App Int/Reset Ctrl
CCR : Word with Volatile, Address => 16#E000_ED14#; -- Config. Control
SHPR1 : Word with Volatile, Address => 16#E000_ED18#; -- Sys Hand 4- 7 Prio
SHPR2 : Word with Volatile, Address => 16#E000_ED1C#; -- Sys Hand 8-11 Prio
SHPR3 : Word with Volatile, Address => 16#E000_ED20#; -- Sys Hand 12-15 Prio
SHCSR : Word with Volatile, Address => 16#E000_ED24#; -- Sys Hand Ctrl/State
function PRIMASK return Word with Inline, Export, Convention => C;
-- Function returning the contents of the PRIMASK register
procedure Initialize_CPU;
-- Set the CPU up to use the proper stack for interrupts, initialize and
-- enable system trap handlers.
-------------
-- PRIMASK --
-------------
function PRIMASK return Word is
R : Word;
begin
Asm ("mrs %0, PRIMASK", Outputs => Word'Asm_Output ("=r", R),
Volatile => True);
return R;
end PRIMASK;
--------------------
-- Initialize_CPU --
--------------------
procedure Initialize_CPU is
Interrupt_Stack_Table : array (System.Multiprocessors.CPU)
of System.Address;
pragma Import (Asm, Interrupt_Stack_Table, "interrupt_stack_table");
-- Table containing a pointer to the top of the stack for each processor
begin
-- Switch the stack pointer to SP_process (PSP)
Asm ("mrs r0, MSP" & NL &
"msr PSP, r0" & NL &
"mrs r0, CONTROL" & NL &
"orr r0,r0,2" & NL &
"msr CONTROL,r0",
Clobber => "r0",
Volatile => True);
-- Initialize SP_main (MSP)
Asm ("msr MSP, %0",
Inputs => Address'Asm_Input ("r", Interrupt_Stack_Table (1)),
Volatile => True);
-- Initialize vector table
VTOR := System_Vectors'Address;
-- Set configuration: stack is 8 byte aligned, trap on divide by 0,
-- no trap on unaligned access, can enter thread mode from any level.
CCR := CCR or 16#211#;
-- Set priorities of system handlers. The Pend_SV handler runs at the
-- lowest priority, so context switching does not block higher priority
-- interrupt handlers. All other system handlers run at the highest
-- priority (0), so they will not be interrupted. This is also true for
-- the SysTick interrupt, as this interrupt must be serviced promptly in
-- order to avoid losing track of time.
SHPR1 := 0;
SHPR2 := 0;
SHPR3 := 16#00_FF_00_00#;
-- Write the required key (16#05FA#) and desired PRIGROUP value. We
-- configure this to 3, to have 16 group priorities
AIRCR := 16#05FA_0300#;
pragma Assert (AIRCR = 16#FA05_0300#); -- Key value is swapped
-- Enable usage, bus and memory management fault
SHCSR := SHCSR or 16#7_000#;
-- Unmask Fault
Asm ("cpsie f", Volatile => True);
end Initialize_CPU;
--------------------
-- Context_Switch --
--------------------
procedure Context_Switch is
begin
-- Interrupts must be disabled at this point
pragma Assert (PRIMASK = 1);
-- Make deferred supervisor call pending
ICSR := ICSR_Pend_SV_Set;
-- The context switch better be pending, as otherwise it means
-- interrupts were not disabled.
pragma Assert ((ICSR and ICSR_Pend_SV_Set) /= 0);
-- Memory must be clobbered, as task switching causes a task to signal,
-- which means its memory changes must be visible to all other tasks.
Asm ("", Volatile => True, Clobber => "memory");
end Context_Switch;
-----------------
-- Get_Context --
-----------------
function Get_Context
(Context : Context_Buffer;
Index : Context_Id) return Word
is
(Word (Context (Index)));
------------------------
-- GNAT_Error_Handler --
------------------------
procedure GNAT_Error_Handler (Trap : Vector_Id) is
begin
case Trap is
when Reset_Vector =>
raise Program_Error with "unexpected reset";
when NMI_Vector =>
raise Program_Error with "non-maskable interrupt";
when Hard_Fault_Vector =>
raise Program_Error with "hard fault";
when Bus_Fault_Vector =>
raise Program_Error with "bus fault";
when Usage_Fault_Vector =>
raise Constraint_Error with "usage fault";
when others =>
raise Program_Error with "unhandled trap";
end case;
end GNAT_Error_Handler;
----------------------------------
-- Interrupt_Request_Handler -- --
----------------------------------
procedure Interrupt_Request_Handler is
begin
-- Call the handler (System.BB.Interrupts.Interrupt_Wrapper)
Trap_Handlers (Interrupt_Request_Vector)(Interrupt_Request_Vector);
-- The handler has changed the current priority (BASEPRI), although
-- being useless on ARMv7m. We need to revert it.
-- The interrupt handler may have scheduled a new task, so we need to
-- check whether a context switch is needed.
if Context_Switch_Needed then
-- Perform a context switch because the currently executing thread is
-- no longer the one with the highest priority.
-- No need to update execution time. Already done in the wrapper.
-- Note that the following context switch is not immediate, but
-- will only take effect after interrupts are enabled.
Context_Switch;
end if;
-- Restore interrupt masking of interrupted thread
Enable_Interrupts (Running_Thread.Active_Priority);
end Interrupt_Request_Handler;
---------------------
-- Pend_SV_Handler --
---------------------
procedure Pend_SV_Handler is
begin
-- At most one instance of this handler can run at a time, and
-- interrupts will preserve all state, so interrupts can be left
-- enabled. Note the invariant that at all times the active context is
-- in the ("__gnat_running_thread_table"). Only this handler may update
-- that variable.
Asm
(Template =>
"movw r2, #:lower16:__gnat_running_thread_table" & NL &
"movt r2, #:upper16:__gnat_running_thread_table" & NL &
"mrs r12, PSP " & NL & -- Retrieve current PSP
"ldr r3, [r2]" & NL & -- Load address of running context
-- If floating point is enabled, we may have to save the non-volatile
-- floating point registers, and save bit 4 of the LR register, as
-- this will indicate whether the floating point context was saved
-- or not.
(if No_Floating_Point then "" -- No FP context to save
else
"tst lr, #16" & NL & -- if FPCA flag was set,
"itte eq" & NL & -- then
"vstmdbeq r12!,{s16-s31}" & NL & -- save FP context below PSP
"addeq r12, #1" & NL & -- save flag in bit 0 of PSP
"subne lr, #16" & NL) & -- else set FPCA flag in LR
-- Swap R4-R11 and PSP (stored in R12)
"stm r3, {r4-r12}" & NL & -- Save context
"movw r3, #:lower16:first_thread_table" & NL &
"movt r3, #:upper16:first_thread_table" & NL &
"ldr r3, [r3]" & NL & -- Load address of new context
"str r3, [r2]" & NL & -- Update value of Pend_SV_Context
"ldm r3, {r4-r12}" & NL & -- Load context and new PSP
-- If floating point is enabled, check bit 0 of PSP to see if we
-- need to restore the floating point context.
(if No_Floating_Point then "" -- No FP context to restore
else
"tst r12, #1" & NL & -- if FPCA was set,
"itte ne" & NL & -- then
"subne r12, #1" & NL & -- remove flag from PSP
"vldmiane r12!,{s16-s31}" & NL & -- Restore FP context
"addeq lr, #16" & NL) & -- else clear FPCA flag in LR
-- Finally, update PSP and perform the exception return
"msr PSP, r12" & NL & -- Update PSP
"bx lr", -- return to caller
Volatile => True);
end Pend_SV_Handler;
---------------------
-- SV_Call_Handler --
---------------------
procedure SV_Call_Handler is
begin
GNAT_Error_Handler (SV_Call_Vector);
end SV_Call_Handler;
-----------------
-- Set_Context --
-----------------
procedure Set_Context
(Context : in out Context_Buffer;
Index : Context_Id;
Value : Word) is
begin
Context (Index) := Address (Value);
end Set_Context;
----------------------
-- Sys_Tick_Handler --
----------------------
procedure Sys_Tick_Handler is
Max_Alarm_Interval : constant Timer_Interval := Timer_Interval'Last / 2;
Now : constant Timer_Interval := Read_Clock;
begin
-- The following allows max. efficiency for "useless" tick interrupts
if Alarm_Time - Now <= Max_Alarm_Interval then
-- Alarm is still in the future, nothing to do, so return quickly
return;
end if;
Alarm_Time := Now + Max_Alarm_Interval;
-- Call the alarm handler
Trap_Handlers (Sys_Tick_Vector)(Sys_Tick_Vector);
-- The interrupt handler may have scheduled a new task
if Context_Switch_Needed then
Context_Switch;
end if;
Enable_Interrupts (Running_Thread.Active_Priority);
end Sys_Tick_Handler;
------------------------
-- Initialize_Context --
------------------------
procedure Initialize_Context
(Buffer : not null access Context_Buffer;
Program_Counter : System.Address;
Argument : System.Address;
Stack_Pointer : System.Address)
is
HW_Ctx_Bytes : constant System.Address := Hardware_Context'Size / 8;
New_SP : constant System.Address :=
(Stack_Pointer - HW_Ctx_Bytes) and not 4;
HW_Ctx : Hardware_Context with Address => New_SP;
begin
-- No need to initialize the context of the environment task
if Program_Counter = Null_Address then
return;
end if;
HW_Ctx := (R0 => Word (Argument),
PC => Word (Program_Counter),
PSR => 2**24, -- Set thumb bit
others => 0);
Buffer.all := (SP_process => New_SP, others => 0);
end Initialize_Context;
----------------------------
-- Install_Error_Handlers --
----------------------------
procedure Install_Error_Handlers is
EH : constant Address := GNAT_Error_Handler'Address;
begin
Install_Trap_Handler (EH, Reset_Vector);
Install_Trap_Handler (EH, NMI_Vector);
Install_Trap_Handler (EH, Hard_Fault_Vector);
Install_Trap_Handler (EH, Bus_Fault_Vector);
Install_Trap_Handler (EH, Usage_Fault_Vector);
Install_Trap_Handler (EH, Sys_Tick_Vector);
Install_Trap_Handler (EH, Pend_SV_Vector);
Install_Trap_Handler (EH, SV_Call_Vector);
end Install_Error_Handlers;
--------------------------
-- Install_Trap_Handler --
--------------------------
procedure Install_Trap_Handler
(Service_Routine : System.Address;
Vector : Vector_Id;
Synchronous : Boolean := False)
is
pragma Unreferenced (Synchronous);
begin
Trap_Handlers (Vector) := To_Pointer (Service_Routine);
end Install_Trap_Handler;
------------------------
-- Disable_Interrupts --
------------------------
procedure Disable_Interrupts is
begin
Asm ("cpsid i", Volatile => True);
end Disable_Interrupts;
-----------------------
-- Enable_Interrupts --
-----------------------
procedure Enable_Interrupts (Level : System.Any_Priority) is
begin
-- Set the BASEPRI according to the specified level. PRIMASK is still
-- set, so the change does not take effect until the next Asm.
Set_Current_Priority (Level);
-- The following enables interrupts and will cause any pending
-- interrupts to take effect. The barriers and their placing are
-- essential, otherwise a blocking operation might not cause an
-- immediate context switch, violating mutual exclusion.
Asm ("cpsie i" & NL
& "dsb" & NL
& "isb",
Clobber => "memory", Volatile => True);
end Enable_Interrupts;
-------------------------------
-- Initialize_Floating_Point --
-------------------------------
procedure Initialize_Floating_Point renames Initialize_CPU;
end System.BB.CPU_Primitives;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.HTable;
with System.Soft_Links; use System.Soft_Links;
package body System.Exception_Table is
use System.Standard_Library;
type HTable_Headers is range 1 .. 37;
procedure Set_HT_Link (T : Exception_Data_Ptr; Next : Exception_Data_Ptr);
function Get_HT_Link (T : Exception_Data_Ptr) return Exception_Data_Ptr;
function Hash (F : System.Address) return HTable_Headers;
function Equal (A, B : System.Address) return Boolean;
function Get_Key (T : Exception_Data_Ptr) return System.Address;
package Exception_HTable is new System.HTable.Static_HTable (
Header_Num => HTable_Headers,
Element => Exception_Data,
Elmt_Ptr => Exception_Data_Ptr,
Null_Ptr => null,
Set_Next => Set_HT_Link,
Next => Get_HT_Link,
Key => System.Address,
Get_Key => Get_Key,
Hash => Hash,
Equal => Equal);
-----------
-- Equal --
-----------
function Equal (A, B : System.Address) return Boolean is
S1 : constant Big_String_Ptr := To_Ptr (A);
S2 : constant Big_String_Ptr := To_Ptr (B);
J : Integer := 1;
begin
loop
if S1 (J) /= S2 (J) then
return False;
elsif S1 (J) = ASCII.NUL then
return True;
else
J := J + 1;
end if;
end loop;
end Equal;
-----------------
-- Get_HT_Link --
-----------------
function Get_HT_Link (T : Exception_Data_Ptr) return Exception_Data_Ptr is
begin
return T.HTable_Ptr;
end Get_HT_Link;
-------------
-- Get_Key --
-------------
function Get_Key (T : Exception_Data_Ptr) return System.Address is
begin
return T.Full_Name;
end Get_Key;
-------------------------------
-- Get_Registered_Exceptions --
-------------------------------
procedure Get_Registered_Exceptions
(List : out Exception_Data_Array;
Last : out Integer)
is
Data : Exception_Data_Ptr := Exception_HTable.Get_First;
begin
Lock_Task.all;
Last := List'First - 1;
while Last < List'Last and then Data /= null loop
Last := Last + 1;
List (Last) := Data;
Data := Exception_HTable.Get_Next;
end loop;
Unlock_Task.all;
end Get_Registered_Exceptions;
----------
-- Hash --
----------
function Hash (F : System.Address) return HTable_Headers is
type S is mod 2**8;
Str : constant Big_String_Ptr := To_Ptr (F);
Size : constant S := S (HTable_Headers'Last - HTable_Headers'First + 1);
Tmp : S := 0;
J : Positive;
begin
J := 1;
loop
if Str (J) = ASCII.NUL then
return HTable_Headers'First + HTable_Headers'Base (Tmp mod Size);
else
Tmp := Tmp xor S (Character'Pos (Str (J)));
end if;
J := J + 1;
end loop;
end Hash;
------------------------
-- Internal_Exception --
------------------------
function Internal_Exception
(X : String;
Create_If_Not_Exist : Boolean := True) return Exception_Data_Ptr
is
type String_Ptr is access all String;
Copy : aliased String (X'First .. X'Last + 1);
Res : Exception_Data_Ptr;
Dyn_Copy : String_Ptr;
begin
Copy (X'Range) := X;
Copy (Copy'Last) := ASCII.NUL;
Res := Exception_HTable.Get (Copy'Address);
-- If unknown exception, create it on the heap. This is a legitimate
-- situation in the distributed case when an exception is defined only
-- in a partition
if Res = null and then Create_If_Not_Exist then
Dyn_Copy := new String'(Copy);
Res :=
new Exception_Data'
(Not_Handled_By_Others => False,
Lang => 'A',
Name_Length => Copy'Length,
Full_Name => Dyn_Copy.all'Address,
HTable_Ptr => null,
Import_Code => 0,
Raise_Hook => null);
Register_Exception (Res);
end if;
return Res;
end Internal_Exception;
------------------------
-- Register_Exception --
------------------------
procedure Register_Exception (X : Exception_Data_Ptr) is
begin
Exception_HTable.Set (X);
end Register_Exception;
---------------------------------
-- Registered_Exceptions_Count --
---------------------------------
function Registered_Exceptions_Count return Natural is
Count : Natural := 0;
Data : Exception_Data_Ptr := Exception_HTable.Get_First;
begin
-- We need to lock the runtime in the meantime, to avoid concurrent
-- access since we have only one iterator.
Lock_Task.all;
while Data /= null loop
Count := Count + 1;
Data := Exception_HTable.Get_Next;
end loop;
Unlock_Task.all;
return Count;
end Registered_Exceptions_Count;
-----------------
-- Set_HT_Link --
-----------------
procedure Set_HT_Link
(T : Exception_Data_Ptr;
Next : Exception_Data_Ptr)
is
begin
T.HTable_Ptr := Next;
end Set_HT_Link;
-- Register the standard exceptions at elaboration time
begin
Register_Exception (Abort_Signal_Def'Access);
Register_Exception (Tasking_Error_Def'Access);
Register_Exception (Storage_Error_Def'Access);
Register_Exception (Program_Error_Def'Access);
Register_Exception (Numeric_Error_Def'Access);
Register_Exception (Constraint_Error_Def'Access);
end System.Exception_Table;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--
with Ada.Unchecked_Conversion;
with Interfaces;
with Interfaces.C.Strings;
with Interfaces.C_Streams;
with Interfaces.C;
with Notcurses_Thin;
package Notcurses is
type Notcurses_Context is private;
type Notcurses_Plane is private;
type Notcurses_Input is record
Id : Wide_Wide_Character;
Y : Interfaces.C.int;
X : Interfaces.C.int;
Alt : Boolean;
Shift : Boolean;
Ctrl : Boolean;
Seqnum : Interfaces.Unsigned_64;
end record;
type Coordinate is record
Y, X : Integer;
end record;
function "+" (Left, Right : Coordinate) return Coordinate;
function "-" (Left, Right : Coordinate) return Coordinate;
Notcurses_Error : exception;
function Version
return String;
private
package Thin renames Notcurses_Thin;
type Notcurses_Context is access all Thin.notcurses;
type Notcurses_Plane is access all Thin.ncplane;
Default_Options : aliased Thin.notcurses_options :=
(termtype => Interfaces.C.Strings.Null_Ptr,
renderfp => Interfaces.C_Streams.NULL_Stream,
loglevel => Thin.NCLOGLEVEL_ERROR,
flags => 0,
others => 0);
Default_Context : Notcurses_Context := null;
function To_Ada is new Ada.Unchecked_Conversion
(Source => Thin.ncinput,
Target => Notcurses_Input);
function To_C is new Ada.Unchecked_Conversion
(Source => Notcurses_Input,
Target => Thin.ncinput);
end Notcurses;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.