Dataset Viewer (First 5GB)
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 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"
}
|
--*
-- 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"
}
|
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"
}
|
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"
}
|
------------------------------------------------------------------------------
-- $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 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"
}
|
-- -----------------------------------------------------------------------------
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"
}
|
End of preview. Expand
in Data Studio
YAML Metadata
Warning:
empty or missing yaml metadata in repo card
(https://huggingface.co/docs/hub/datasets-cards)
This is part of the continued pretraining dataset used to train the Aurora-M model described in [Aurora-M: Open Source Continual Pre-training for Multilingual Language and Code, COLING 2025] (https://aclanthology.org/2025.coling-industry.56/).
- Downloads last month
- 706