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" }
----------------------------------------------------------------------- with Ada.Unchecked_Deallocation; with Unicode; with Ada.Exceptions; with Ada.Strings.Fixed; with Util.Log.Loggers; with Util.Serialize.IO.XML; package body ASF.Views.Nodes.Reader is use Sax.Readers; use Sax.Exceptions; use Sax.Locators; use Sax.Attributes; use Unicode; use Unicode.CES; use Ada.Strings.Fixed; -- The logger Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("ASF.Views.Nodes.Reader"); procedure Free is new Ada.Unchecked_Deallocation (Element_Context_Array, Element_Context_Array_Access); procedure Push (Handler : in out Xhtml_Reader'Class); procedure Pop (Handler : in out Xhtml_Reader'Class); -- Freeze the current Text_Tag node, counting the number of elements it contains. procedure Finish_Text_Node (Handler : in out Xhtml_Reader'Class); -- ------------------------------ -- Push the current context when entering in an element. -- ------------------------------ procedure Push (Handler : in out Xhtml_Reader'Class) is begin if Handler.Stack = null then Handler.Stack := new Element_Context_Array (1 .. 100); elsif Handler.Stack_Pos = Handler.Stack'Last then declare Old : Element_Context_Array_Access := Handler.Stack; begin Handler.Stack := new Element_Context_Array (1 .. Old'Last + 100); Handler.Stack (1 .. Old'Last) := Old (1 .. Old'Last); Free (Old); end; end if; if Handler.Stack_Pos /= Handler.Stack'First then Handler.Stack (Handler.Stack_Pos + 1) := Handler.Stack (Handler.Stack_Pos); end if; Handler.Stack_Pos := Handler.Stack_Pos + 1; Handler.Current := Handler.Stack (Handler.Stack_Pos)'Access; end Push; -- ------------------------------ -- Pop the context and restore the previous context when leaving an element -- ------------------------------ procedure Pop (Handler : in out Xhtml_Reader'Class) is begin Handler.Stack_Pos := Handler.Stack_Pos - 1; Handler.Current := Handler.Stack (Handler.Stack_Pos)'Access; end Pop; -- ------------------------------ -- Find the function knowing its name. -- ------------------------------ overriding function Get_Function (Mapper : NS_Function_Mapper; Namespace : String; Name : String) return Function_Access is use NS_Mapping; Pos : constant NS_Mapping.Cursor := NS_Mapping.Find (Mapper.Mapping, Namespace); begin if Has_Element (Pos) then return Mapper.Mapper.Get_Function (Element (Pos), Name); end if; raise No_Function with "Function '" & Namespace & ':' & Name & "' not found"; end Get_Function; -- ------------------------------ -- Bind a name to a function in the given namespace. -- ------------------------------ overriding procedure Set_Function (Mapper : in out NS_Function_Mapper; Namespace : in String; Name : in String; Func : in Function_Access) is begin null; end Set_Function; -- ------------------------------ -- Find the create function bound to the name in the given namespace. -- Returns null if no such binding exist. -- ------------------------------ function Find (Mapper : NS_Function_Mapper; Namespace : String; Name : String) return ASF.Views.Nodes.Binding_Access is use NS_Mapping; begin return ASF.Factory.Find (Mapper.Factory.all, Namespace, Name); end Find; procedure Set_Namespace (Mapper : in out NS_Function_Mapper; Prefix : in String; URI : in String) is use NS_Mapping; begin Log.Debug ("Add namespace {0}:{1}", Prefix, URI); Mapper.Mapping.Include (Prefix, URI); end Set_Namespace; -- ------------------------------ -- Remove the namespace prefix binding. -- ------------------------------ procedure Remove_Namespace (Mapper : in out NS_Function_Mapper; Prefix : in String) is use NS_Mapping; Pos : NS_Mapping.Cursor := NS_Mapping.Find (Mapper.Mapping, Prefix); begin Log.Debug ("Remove namespace {0}", Prefix); if Has_Element (Pos) then NS_Mapping.Delete (Mapper.Mapping, Pos); end if; end Remove_Namespace; -- ------------------------------ -- Warning -- ------------------------------ overriding procedure Warning (Handler : in out Xhtml_Reader; Except : Sax.Exceptions.Sax_Parse_Exception'Class) is pragma Warnings (Off, Handler); begin Log.Warn ("{0}: {1}", Util.Serialize.IO.XML.Get_Location (Except), Get_Message (Except)); end Warning; -- ------------------------------ -- Error -- ------------------------------ overriding procedure Error (Handler : in out Xhtml_Reader; Except : in Sax.Exceptions.Sax_Parse_Exception'Class) is pragma Warnings (Off, Handler); begin Log.Error ("{0}: {1}", Util.Serialize.IO.XML.Get_Location (Except), Get_Message (Except)); end Error; -- ------------------------------ -- Fatal_Error -- ------------------------------ overriding procedure Fatal_Error (Handler : in out Xhtml_Reader; Except : in Sax.Exceptions.Sax_Parse_Exception'Class) is pragma Unreferenced (Handler); begin Log.Error ("{0}: {1}", Util.Serialize.IO.XML.Get_Location (Except), Get_Message (Except)); end Fatal_Error; -- ------------------------------ -- Set_Document_Locator -- ------------------------------ overriding procedure Set_Document_Locator (Handler : in out Xhtml_Reader; Loc : in out Sax.Locators.Locator) is begin Handler.Locator := Loc; end Set_Document_Locator; -- ------------------------------ -- Start_Document -- ------------------------------ overriding procedure Start_Document (Handler : in out Xhtml_Reader) is begin null; end Start_Document; -- ------------------------------ -- End_Document -- ------------------------------ overriding procedure End_Document (Handler : in out Xhtml_Reader) is begin null; end End_Document; -- ------------------------------ -- Start_Prefix_Mapping -- ------------------------------ overriding procedure Start_Prefix_Mapping (Handler : in out Xhtml_Reader; Prefix : in Unicode.CES.Byte_Sequence; URI : in Unicode.CES.Byte_Sequence) is begin if Prefix = "" then Handler.Add_NS := To_Unbounded_String (URI); else Handler.Functions.Set_Namespace (Prefix => Prefix, URI => URI); end if; end Start_Prefix_Mapping; -- ------------------------------ -- End_Prefix_Mapping -- ------------------------------ overriding procedure End_Prefix_Mapping (Handler : in out Xhtml_Reader; Prefix : in Unicode.CES.Byte_Sequence) is begin Handler.Functions.Remove_Namespace (Prefix => Prefix); end End_Prefix_Mapping; -- ------------------------------ -- Collect the text for an EL expression. The EL expression starts -- with either '#{' or with '${' and ends with the matching '}'. -- If the <b>Value</b> string does not contain the whole EL experssion -- the <b>Expr_Buffer</b> stored in the reader is used to collect -- that expression. -- ------------------------------ procedure Collect_Expression (Handler : in out Xhtml_Reader) is use Ada.Exceptions; Expr : constant String := To_String (Handler.Expr_Buffer); Content : constant Tag_Content_Access := Handler.Text.Last; begin Handler.Expr_Buffer := Null_Unbounded_String; Content.Expr := EL.Expressions.Create_Expression (Expr, Handler.ELContext.all); Content.Next := new Tag_Content; Handler.Text.Last := Content.Next; exception when E : EL.Functions.No_Function | EL.Expressions.Invalid_Expression => Log.Error ("{0}: Invalid expression: {1}", To_String (Handler.Locator), Exception_Message (E)); Log.Error ("{0}: {1}", To_String (Handler.Locator), Expr); when E : others => Log.Error ("{0}: Internal error: {1}:{2}", To_String (Handler.Locator), Exception_Name (E), Exception_Message (E)); end Collect_Expression; -- ------------------------------ -- Collect the raw-text in a buffer. The text must be flushed -- when a new element is started or when an exiting element is closed. -- ------------------------------ procedure Collect_Text (Handler : in out Xhtml_Reader; Value : in Unicode.CES.Byte_Sequence) is Pos : Natural := Value'First; C : Character; Content : Tag_Content_Access; Start_Pos : Natural; Last_Pos : Natural; begin while Pos <= Value'Last loop case Handler.State is -- Collect the white spaces and newlines in the 'Spaces' -- buffer to ignore empty lines but still honor indentation. when NO_CONTENT => loop C := Value (Pos); if C = ASCII.CR or C = ASCII.LF then Handler.Spaces := Null_Unbounded_String; elsif C = ' ' or C = ASCII.HT then Append (Handler.Spaces, C); else Handler.State := HAS_CONTENT; exit; end if; Pos := Pos + 1; exit when Pos > Value'Last; end loop; -- Collect an EL expression until the end of that -- expression. Evaluate the expression. when PARSE_EXPR => Start_Pos := Pos; loop C := Value (Pos); Last_Pos := Pos; Pos := Pos + 1; if C = '}' then Handler.State := HAS_CONTENT; exit; end if; exit when Pos > Value'Last; end loop; Append (Handler.Expr_Buffer, Value (Start_Pos .. Last_Pos)); if Handler.State /= PARSE_EXPR then Handler.Collect_Expression; end if; -- Collect the raw text in the current content buffer when HAS_CONTENT => if Handler.Text = null then Handler.Text := new Text_Tag_Node; Initialize (Handler.Text.all'Access, null, Handler.Line, Handler.Current.Parent, null); Handler.Text.Last := Handler.Text.Content'Access; elsif Length (Handler.Expr_Buffer) > 0 then Handler.Collect_Expression; Pos := Pos + 1; end if; Content := Handler.Text.Last; -- Scan until we find the start of an EL expression -- or we have a new line. Start_Pos := Pos; loop C := Value (Pos); -- Check for the EL start #{ or ${ if (C = '#' or C = '$') and then Pos + 1 <= Value'Last and then Value (Pos + 1) = '{' then Handler.State := PARSE_EXPR; Append (Handler.Expr_Buffer, C); Append (Handler.Expr_Buffer, '{'); Last_Pos := Pos - 1; Pos := Pos + 2; exit; -- Handle \#{ and \${ as escape sequence elsif C = '\' and then Pos + 2 <= Value'Last and then Value (Pos + 2) = '{' and then (Value (Pos + 1) = '#' or Value (Pos + 1) = '$') then -- Since we have to strip the '\', flush the spaces and append the text -- but ignore the '\'. Append (Content.Text, Handler.Spaces); Handler.Spaces := Null_Unbounded_String; if Start_Pos < Pos then Append (Content.Text, Value (Start_Pos .. Pos - 1)); end if; Start_Pos := Pos + 1; Pos := Pos + 2; elsif (C = ASCII.CR or C = ASCII.LF) and Handler.Ignore_Empty_Lines then Last_Pos := Pos; Handler.State := NO_CONTENT; exit; end if; Last_Pos := Pos; Pos := Pos + 1; exit when Pos > Value'Last; end loop; -- If we have some pending spaces, add them in the text stream. if Length (Handler.Spaces) > 0 then Append (Content.Text, Handler.Spaces); Handler.Spaces := Null_Unbounded_String; end if; -- If we have some text, append to the current content buffer. if Start_Pos <= Last_Pos then Append (Content.Text, Value (Start_Pos .. Last_Pos)); end if; end case; end loop; end Collect_Text; -- ------------------------------ -- Freeze the current Text_Tag node, counting the number of elements it contains. -- ------------------------------ procedure Finish_Text_Node (Handler : in out Xhtml_Reader'Class) is begin if Handler.Text /= null then Handler.Text.Freeze; Handler.Text := null; end if; end Finish_Text_Node; -- ------------------------------ -- Start_Element -- ------------------------------ overriding procedure Start_Element (Handler : in out Xhtml_Reader; Namespace_URI : in Unicode.CES.Byte_Sequence := ""; Local_Name : in Unicode.CES.Byte_Sequence := ""; Qname : in Unicode.CES.Byte_Sequence := ""; Atts : in Sax.Attributes.Attributes'Class) is use ASF.Factory; use Ada.Exceptions; Attr_Count : Natural; Attributes : Tag_Attribute_Array_Access; Node : Tag_Node_Access; Factory : ASF.Views.Nodes.Binding_Access; begin Handler.Line.Line := Sax.Locators.Get_Line_Number (Handler.Locator); Handler.Line.Column := Sax.Locators.Get_Column_Number (Handler.Locator); -- Push the current context to keep track where we are. Push (Handler); Attr_Count := Get_Length (Atts); Factory := Handler.Functions.Find (Namespace => Namespace_URI, Name => Local_Name); if Factory /= null then if Length (Handler.Add_NS) > 0 then Attributes := new Tag_Attribute_Array (0 .. Attr_Count); Attributes (0).Name := To_Unbounded_String ("xmlns"); Attributes (0).Value := Handler.Add_NS; Handler.Add_NS := To_Unbounded_String (""); else Attributes := new Tag_Attribute_Array (1 .. Attr_Count); end if; for I in 0 .. Attr_Count - 1 loop declare Attr : constant Tag_Attribute_Access := Attributes (I + 1)'Access; Value : constant String := Get_Value (Atts, I); Name : constant String := Get_Qname (Atts, I); Expr : EL.Expressions.Expression_Access; begin Attr.Name := To_Unbounded_String (Name); if Index (Value, "#{") > 0 or Index (Value, "${") > 0 then begin Expr := new EL.Expressions.Expression; Attr.Binding := Expr.all'Access; EL.Expressions.Expression (Expr.all) := EL.Expressions.Create_Expression (Value, Handler.ELContext.all); exception when E : EL.Functions.No_Function => Log.Error ("{0}: Invalid expression: {1}", To_String (Handler.Locator), Exception_Message (E)); Attr.Binding := null; Attr.Value := To_Unbounded_String (""); when E : EL.Expressions.Invalid_Expression => Log.Error ("{0}: Invalid expression: {1}", To_String (Handler.Locator), Exception_Message (E)); Attr.Binding := null; Attr.Value := To_Unbounded_String (""); end; else Attr.Value := To_Unbounded_String (Value); end if; end; end loop; Node := Factory.Tag (Binding => Factory, Line => Handler.Line, Parent => Handler.Current.Parent, Attributes => Attributes); Handler.Current.Parent := Node; Handler.Current.Text := False; Finish_Text_Node (Handler); Handler.Spaces := Null_Unbounded_String; Handler.State := Handler.Default_State; else declare Is_Unknown : constant Boolean := Namespace_URI /= "" and Index (Qname, ":") > 0; begin -- Optimization: we know in which state we are. Handler.State := HAS_CONTENT; Handler.Current.Text := True; if Is_Unknown then Log.Error ("{0}: Element '{1}' not found", To_String (Handler.Locator), Qname); end if; if Handler.Escape_Unknown_Tags and Is_Unknown then Handler.Collect_Text ("&lt;"); else Handler.Collect_Text ("<"); end if; Handler.Collect_Text (Qname); if Length (Handler.Add_NS) > 0 then Handler.Collect_Text (" xmlns="""); Handler.Collect_Text (To_String (Handler.Add_NS)); Handler.Collect_Text (""""); Handler.Add_NS := To_Unbounded_String (""); end if; if Attr_Count /= 0 then for I in 0 .. Attr_Count - 1 loop Handler.Collect_Text (" "); Handler.Collect_Text (Get_Qname (Atts, I)); Handler.Collect_Text ("="""); declare Value : constant String := Get_Value (Atts, I); begin Handler.Collect_Text (Value); end; Handler.Collect_Text (""""); end loop; end if; if Handler.Escape_Unknown_Tags and Is_Unknown then Handler.Collect_Text ("&gt;"); else Handler.Collect_Text (">"); end if; end; end if; end Start_Element; -- ------------------------------ -- End_Element -- ------------------------------ overriding procedure End_Element (Handler : in out Xhtml_Reader; Namespace_URI : in Unicode.CES.Byte_Sequence := ""; Local_Name : in Unicode.CES.Byte_Sequence := ""; Qname : in Unicode.CES.Byte_Sequence := "") is pragma Unreferenced (Local_Name); begin if Handler.Current.Parent = null then Finish_Text_Node (Handler); elsif not Handler.Current.Text then Finish_Text_Node (Handler); Handler.Current.Parent.Freeze; end if; if Handler.Current.Text or Handler.Text /= null then declare Is_Unknown : constant Boolean := Namespace_URI /= "" and Index (Qname, ":") > 0; begin -- Optimization: we know in which state we are. Handler.State := HAS_CONTENT; if Handler.Escape_Unknown_Tags and Is_Unknown then Handler.Collect_Text ("&lt;/"); Handler.Collect_Text (Qname); Handler.Collect_Text ("&gt;"); else Handler.Collect_Text ("</"); Handler.Collect_Text (Qname); Handler.Collect_Text (">"); end if; end; else Handler.Spaces := Null_Unbounded_String; end if; -- Pop the current context to restore the last context. Pop (Handler); end End_Element; -- ------------------------------ -- Characters -- ------------------------------ overriding procedure Characters (Handler : in out Xhtml_Reader; Ch : in Unicode.CES.Byte_Sequence) is begin Collect_Text (Handler, Ch); end Characters; -- ------------------------------ -- Ignorable_Whitespace -- ------------------------------ overriding procedure Ignorable_Whitespace (Handler : in out Xhtml_Reader; Ch : in Unicode.CES.Byte_Sequence) is begin if not Handler.Ignore_White_Spaces then Collect_Text (Handler, Ch); end if; end Ignorable_Whitespace; -- ------------------------------ -- Processing_Instruction -- ------------------------------ overriding procedure Processing_Instruction (Handler : in out Xhtml_Reader; Target : in Unicode.CES.Byte_Sequence; Data : in Unicode.CES.Byte_Sequence) is pragma Unreferenced (Handler); begin Log.Error ("Processing instruction: {0}: {1}", Target, Data); null; end Processing_Instruction; -- ------------------------------ -- Skipped_Entity -- ------------------------------ overriding procedure Skipped_Entity (Handler : in out Xhtml_Reader; Name : in Unicode.CES.Byte_Sequence) is pragma Unmodified (Handler); begin null; end Skipped_Entity; -- ------------------------------ -- Start_Cdata -- ------------------------------ overriding procedure Start_Cdata (Handler : in out Xhtml_Reader) is pragma Unreferenced (Handler); begin Log.Info ("Start CDATA"); end Start_Cdata; -- ------------------------------ -- End_Cdata -- ------------------------------ overriding procedure End_Cdata (Handler : in out Xhtml_Reader) is pragma Unreferenced (Handler); begin Log.Info ("End CDATA"); end End_Cdata; -- ------------------------------ -- Resolve_Entity -- ------------------------------ overriding function Resolve_Entity (Handler : Xhtml_Reader; Public_Id : Unicode.CES.Byte_Sequence; System_Id : Unicode.CES.Byte_Sequence) return Input_Sources.Input_Source_Access is pragma Unreferenced (Handler); begin Log.Error ("Cannot resolve entity {0} - {1}", Public_Id, System_Id); return null; end Resolve_Entity; overriding procedure Start_DTD (Handler : in out Xhtml_Reader; Name : Unicode.CES.Byte_Sequence; Public_Id : Unicode.CES.Byte_Sequence := ""; System_Id : Unicode.CES.Byte_Sequence := "") is begin if Handler.Text = null then Handler.Text := new Text_Tag_Node; Initialize (Handler.Text.all'Access, null, Handler.Line, Handler.Current.Parent, null); Handler.Text.Last := Handler.Text.Content'Access; end if; declare Content : constant Tag_Content_Access := Handler.Text.Last; begin Append (Content.Text, "<!DOCTYPE "); Append (Content.Text, Name); Append (Content.Text, " "); if Public_Id'Length > 0 then Append (Content.Text, " PUBLIC """); Append (Content.Text, Public_Id); Append (Content.Text, """ "); if System_Id'Length > 0 then Append (Content.Text, '"'); Append (Content.Text, System_Id); Append (Content.Text, '"'); end if; elsif System_Id'Length > 0 then Append (Content.Text, " SYSTEM """); Append (Content.Text, System_Id); Append (Content.Text, """ "); end if; Append (Content.Text, " >" & ASCII.LF); end; end Start_DTD; -- ------------------------------ -- Get the root node that was created upon parsing of the XHTML file. -- ------------------------------ function Get_Root (Reader : Xhtml_Reader) return Tag_Node_Access is begin return Reader.Root; end Get_Root; -- ------------------------------ -- Set the XHTML reader to ignore or not the white spaces. -- When set to True, the ignorable white spaces will not be kept. -- ------------------------------ procedure Set_Ignore_White_Spaces (Reader : in out Xhtml_Reader; Value : in Boolean) is begin Reader.Ignore_White_Spaces := Value; end Set_Ignore_White_Spaces; -- ------------------------------ -- Set the XHTML reader to ignore empty lines. -- ------------------------------ procedure Set_Ignore_Empty_Lines (Reader : in out Xhtml_Reader; Value : in Boolean) is begin Reader.Ignore_Empty_Lines := Value; end Set_Ignore_Empty_Lines; -- ------------------------------ -- Set the XHTML reader to escape or not the unknown tags. -- When set to True, the tags which are not recognized will be -- emitted as a raw text component and they will be escaped using -- the XML escape rules. -- ------------------------------ procedure Set_Escape_Unknown_Tags (Reader : in out Xhtml_Reader; Value : in Boolean) is begin Reader.Escape_Unknown_Tags := Value; end Set_Escape_Unknown_Tags; -- ------------------------------ -- Parse an XML stream, and calls the appropriate SAX callbacks for each -- event. -- This is not re-entrant: you can not call Parse with the same Parser -- argument in one of the SAX callbacks. This has undefined behavior. -- ------------------------------ procedure Parse (Parser : in out Xhtml_Reader; Name : in ASF.Views.File_Info_Access; Input : in out Input_Sources.Input_Source'Class; Factory : access ASF.Factory.Component_Factory; Context : in EL.Contexts.ELContext_Access) is begin Parser.Stack_Pos := 1; Push (Parser); Parser.Line.File := Name; Parser.Root := new Tag_Node; Parser.Functions.Factory := Factory; Parser.Current.Parent := Parser.Root; Parser.ELContext := Parser.Context'Unchecked_Access; Parser.Context.Set_Function_Mapper (Parser.Functions'Unchecked_Access); Parser.Functions.Mapper := Context.Get_Function_Mapper; if Parser.Functions.Mapper = null then Log.Warn ("There is no function mapper"); end if; Sax.Readers.Reader (Parser).Parse (Input); Finish_Text_Node (Parser); Parser.Functions.Factory := null; Parser.ELContext := null; if Parser.Ignore_Empty_Lines then Parser.Default_State := NO_CONTENT; else Parser.Default_State := HAS_CONTENT; end if; Parser.State := Parser.Default_State; Free (Parser.Stack); exception when others => Free (Parser.Stack); raise; end Parse; end ASF.Views.Nodes.Reader;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Text_IO; use Ada.Text_IO; procedure Pre_Post is package P is type Int_Array is array (Integer range <>) of Integer; -- Increment the input (obvious) procedure Increment (A : in out Integer) with Post => A = A'Old + 1; -- A "limited" negate (nonsense...) procedure Limited_Negate (A : in out Integer; B : in Integer) with Post => (if A < B then A = -A'Old else A = -B); -- just to show the attribute Result function Sum_Minus_One (A, B : Integer) return Integer with Post => Sum_Minus_One'Result = A + B - 1; -- 5, 2 give 3; -2, -5 give 3, but -5, -2... fails pre function Positive_Diff (A, B : Integer) return Integer with Pre => A > B, Post => Positive_Diff'Result = A - B; -- a sort... the precondition is rather odd: the caller must -- call this subprogram only when she knows the array isn't -- sorted; for a more "realistic" case, remove the Pre. procedure Sort (A : in out Int_Array) with Pre => (for some I in A'First .. A'Last - 1 => A (I) > A (I+1)), Post => (for all I in A'First .. A'Last - 1 => A (I) <= A (I+1)); end P; package body P is -- bubble sort procedure Sort (A : in out Int_Array) is App : Integer; Swapped : Boolean := True; begin while Swapped loop Swapped := False; for I in A'First .. A'Last - 1 loop if A (I) > A (I + 1) then App := A (I); A (I) := A (I + 1); A (I + 1) := App; Swapped := True; end if; end loop; end loop; end Sort; procedure Increment (A : in out Integer) is begin A := A + 1; end Increment; procedure Limited_Negate (A : in out Integer; B : in Integer) is begin -- correct implementation... -- if A < B then -- A := -A; -- else -- A := -B; -- end if; A := -A + B; -- wrong implementation... end Limited_Negate; function Sum_Minus_One (A, B : Integer) return Integer is begin -- for such a short function I prefer the other syntax... return A + B - 1; end Sum_Minus_One; function Positive_Diff (A, B : Integer) return Integer is begin return A - B; end Positive_Diff; end P; A : constant Integer := 1; B : Integer := 2; package IO is new Ada.Text_IO.Integer_IO (Integer); procedure O (X : Integer) with Inline; procedure O (X : Integer) is begin IO.Put (X); New_Line; end O; use P; -- an unsorted array Un_Arr : Int_Array := (10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); -- a sorted array Ord_Arr : Int_Array := (1, 4, 8, 10, 11, 100, 200); begin O (A); O (B); Increment (B); O (B); O (Sum_Minus_One (A, B)); -- compiler warn: "actuals for this call may be in wrong order", -- this is why I've used named parameters O (Positive_Diff (A => B, B => A)); Put_Line ("everything's alright?"); -- Pre requires A > B, but B = 3 and A = 1... => runtime exception -- telling us "failed precondition from pre_post.adb" (followed by -- the line in the source code, which I removed because I'm -- modifying this source adding lines) --O (Positive_Diff (A, B)); -- and this at runtime gives "failed postcondition from -- pre_post.adb", because the guy who implemented the code hasn't -- understood the specifications... --Limited_Negate (A, B); O (A); O (B); for I in Un_Arr'Range loop IO.Put (Un_Arr (I)); end loop; New_Line; Sort (Un_Arr); for I in Un_Arr'Range loop IO.Put (Un_Arr (I)); end loop; New_Line; -- calling this violates the preconditions: our sort assumes that -- the array isn't already sorted... --Sort (Ord_Arr); end Pre_Post;
{ "source": "starcoderdata", "programming_language": "ada" }
-- SOFTWARE. with Ada.Text_IO; use Ada.Text_IO; with Debug_Logs; use Debug_Logs; with Resolver; use Resolver; package body Processor.Eclipse_FPU_P is procedure Debug_FPACs (CPU : in CPU_T) is begin Loggers.Debug_Print (Debug_Log, "FPAC0: " & CPU.FPAC(0)'Image & " FPAC1: " & CPU.FPAC(1)'Image & " FPAC2: " & CPU.FPAC(2)'Image & " FPAC3: " & CPU.FPAC(3)'Image); -- Ada.Text_IO.Put_Line("FPAC0: " & CPU.FPAC(0)'Image & -- " FPAC1: " & CPU.FPAC(1)'Image & -- " FPAC2: " & CPU.FPAC(2)'Image & -- " FPAC3: " & CPU.FPAC(3)'Image); end Debug_FPACs; procedure Do_Eclipse_FPU (I : in Decoded_Instr_T; CPU : in out CPU_T) is QW : Qword_T; --LF : Long_Float; DG_Dbl : Double_Overlay; begin Debug_FPACs (CPU); case I.Instruction is when I_FAD => CPU.FPAC(I.Acd) := CPU.FPAC(I.Acd) + CPU.FPAC(I.Acs); Set_N (CPU, (CPU.FPAC(I.Acd) < 0.0)); Set_Z (CPU, (CPU.FPAC(I.Acd) = 0.0)); when I_FCLE => CPU.FPSR := 0; -- TODO verify - PoP contradicts itself when I_FCMP => if CPU.FPAC(I.Acs) = CPU.FPAC(I.Acd) then Set_N (CPU, false); Set_Z (CPU, true); elsif CPU.FPAC(I.Acs) > CPU.FPAC(I.Acd) then Set_N (CPU, true); Set_Z (CPU, false); else Set_N (CPU, false); Set_Z (CPU, false); end if; when I_FDD => CPU.FPAC(I.Acd) := CPU.FPAC(I.Acd) / CPU.FPAC(I.Acs); Set_N (CPU, (CPU.FPAC(I.Acd) < 0.0)); Set_Z (CPU, (CPU.FPAC(I.Acd) = 0.0)); when I_FMS => CPU.FPAC(I.Acd) := CPU.FPAC(I.Acd) * CPU.FPAC(I.Acs); Set_N (CPU, (CPU.FPAC(I.Acd) < 0.0)); Set_Z (CPU, (CPU.FPAC(I.Acd) = 0.0)); when I_FSGT => if (not Get_Z(CPU)) and (not Get_N(CPU)) then CPU.PC := CPU.PC + 1; end if; when I_FINT => CPU.FPAC(I.Ac) := Long_Float'Truncation(CPU.FPAC(I.Ac)); Set_N (CPU, (CPU.FPAC(I.Ac) < 0.0)); Set_Z (CPU, (CPU.FPAC(I.Ac) = 0.0)); when I_FMD => CPU.FPAC(I.Acd) := CPU.FPAC(I.Acd) * CPU.FPAC(I.Acs); Set_N (CPU, (CPU.FPAC(I.Acd) < 0.0)); Set_Z (CPU, (CPU.FPAC(I.Acd) = 0.0)); when I_FSEQ => if Get_Z(CPU) then CPU.PC := CPU.PC + 1; end if; when I_FSGE => if not Get_N(CPU) then CPU.PC := CPU.PC + 1; end if; when I_FSLT => if Get_N(CPU) then CPU.PC := CPU.PC + 1; end if; when I_FTD => Clear_QW_Bit (CPU.FPSR, FPSR_Te); when I_FTE => Set_QW_Bit (CPU.FPSR, FPSR_Te); when I_FRDS => QW := Long_Float_To_DG_Double(CPU.FPAC(I.Acs)); if Test_QW_Bit (CPU.FPSR, FPSR_Rnd) then -- FIXME - should round not truncate DG_Dbl.Double_QW := QW and 16#ffff_ffff_0000_0000#; CPU.FPAC(I.Acd) := DG_Double_To_Long_Float(DG_Dbl); else DG_Dbl.Double_QW := QW and 16#ffff_ffff_0000_0000#; CPU.FPAC(I.Acd) := DG_Double_To_Long_Float(DG_Dbl); end if; Set_N (CPU, (CPU.FPAC(I.Acd) < 0.0)); Set_Z (CPU, (CPU.FPAC(I.Acd) = 0.0)); when I_FSD => CPU.FPAC(I.Acd) := CPU.FPAC(I.Acd) - CPU.FPAC(I.Acs); Set_N (CPU, (CPU.FPAC(I.Acd) < 0.0)); Set_Z (CPU, (CPU.FPAC(I.Acd) = 0.0)); when I_FSNE => if Get_Z(CPU) then CPU.PC := CPU.PC + 1; end if; when others => Put_Line ("ERROR: ECLIPSE_FPU instruction " & To_String(I.Mnemonic) & " not yet implemented"); raise Execution_Failure with "ERROR: ECLIPSE_FPU instruction " & To_String(I.Mnemonic) & " not yet implemented"; end case; Debug_FPACs (CPU); CPU.PC := CPU.PC + Phys_Addr_T(I.Instr_Len); end Do_Eclipse_FPU; end Processor.Eclipse_FPU_P;
{ "source": "starcoderdata", "programming_language": "ada" }
--* -- OBJECTIVE: -- CHECK THAT A VARIABLE CREATED BY AN ALLOCATOR CAN BE RENAMED AND -- HAS THE CORRECT VALUE, AND THAT THE NEW NAME CAN BE USED IN AN -- ASSIGNMENT STATEMENT AND PASSED ON AS AN ACTUAL SUBPROGRAM OR -- ENTRY 'IN OUT' OR 'OUT' PARAMETER, AND AS AN ACTUAL GENERIC -- 'IN OUT' PARAMETER, AND THAT WHEN THE VALUE OF THE RENAMED -- VARIABLE IS CHANGED, THE NEW VALUE IS REFLECTED BY THE VALUE OF -- THE NEW NAME. -- HISTORY: -- JET 03/15/88 CREATED ORIGINAL TEST. WITH REPORT; USE REPORT; PROCEDURE C85005E IS TYPE ARRAY1 IS ARRAY (POSITIVE RANGE <>) OF INTEGER; TYPE RECORD1 (D : INTEGER) IS RECORD FIELD1 : INTEGER := 1; END RECORD; TYPE POINTER1 IS ACCESS INTEGER; PACKAGE PACK1 IS TYPE PACKACC IS ACCESS INTEGER; AK1 : PACKACC := NEW INTEGER'(0); TYPE PRIVY IS PRIVATE; ZERO : CONSTANT PRIVY; ONE : CONSTANT PRIVY; TWO : CONSTANT PRIVY; THREE : CONSTANT PRIVY; FOUR : CONSTANT PRIVY; FIVE : CONSTANT PRIVY; FUNCTION IDENT (I : PRIVY) RETURN PRIVY; FUNCTION NEXT (I : PRIVY) RETURN PRIVY; PRIVATE TYPE PRIVY IS RANGE 0..127; ZERO : CONSTANT PRIVY := 0; ONE : CONSTANT PRIVY := 1; TWO : CONSTANT PRIVY := 2; THREE : CONSTANT PRIVY := 3; FOUR : CONSTANT PRIVY := 4; FIVE : CONSTANT PRIVY := 5; END PACK1; TASK TYPE TASK1 IS ENTRY ASSIGN (J : IN INTEGER); ENTRY VALU (J : OUT INTEGER); ENTRY NEXT; ENTRY STOP; END TASK1; GENERIC GI1 : IN OUT INTEGER; GA1 : IN OUT ARRAY1; GR1 : IN OUT RECORD1; GP1 : IN OUT POINTER1; GV1 : IN OUT PACK1.PRIVY; GT1 : IN OUT TASK1; GK1 : IN OUT INTEGER; PACKAGE GENERIC1 IS END GENERIC1; FUNCTION IDENT (P : POINTER1) RETURN POINTER1 IS BEGIN IF EQUAL (3,3) THEN RETURN P; ELSE RETURN NULL; END IF; END IDENT; PACKAGE BODY PACK1 IS FUNCTION IDENT (I : PRIVY) RETURN PRIVY IS BEGIN IF EQUAL(3,3) THEN RETURN I; ELSE RETURN PRIVY'(0); END IF; END IDENT; FUNCTION NEXT (I : PRIVY) RETURN PRIVY IS BEGIN RETURN I+1; END NEXT; END PACK1; PACKAGE BODY GENERIC1 IS BEGIN GI1 := GI1 + 1; GA1 := (GA1(1)+1, GA1(2)+1, GA1(3)+1); GR1 := (D => 1, FIELD1 => GR1.FIELD1 + 1); GP1 := NEW INTEGER'(GP1.ALL + 1); GV1 := PACK1.NEXT(GV1); GT1.NEXT; GK1 := GK1 + 1; END GENERIC1; TASK BODY TASK1 IS TASK_VALUE : INTEGER := 0; ACCEPTING_ENTRIES : BOOLEAN := TRUE; BEGIN WHILE ACCEPTING_ENTRIES LOOP SELECT ACCEPT ASSIGN (J : IN INTEGER) DO TASK_VALUE := J; END ASSIGN; OR ACCEPT VALU (J : OUT INTEGER) DO J := TASK_VALUE; END VALU; OR ACCEPT NEXT DO TASK_VALUE := TASK_VALUE + 1; END NEXT; OR ACCEPT STOP DO ACCEPTING_ENTRIES := FALSE; END STOP; END SELECT; END LOOP; END TASK1; BEGIN TEST ("C85005E", "CHECK THAT A VARIABLE CREATED BY AN ALLOCATOR " & "CAN BE RENAMED AND HAS THE CORRECT VALUE, AND " & "THAT THE NEW NAME CAN BE USED IN AN ASSIGNMENT" & " STATEMENT AND PASSED ON AS AN ACTUAL " & "SUBPROGRAM OR ENTRY 'IN OUT' OR 'OUT' " & "PARAMETER, AND AS AN ACTUAL GENERIC 'IN OUT' " & "PARAMETER, AND THAT WHEN THE VALUE OF THE " & "RENAMED VARIABLE IS CHANGED, THE NEW VALUE " & "IS REFLECTED BY THE VALUE OF THE NEW NAME"); DECLARE TYPE ACCINT IS ACCESS INTEGER; TYPE ACCARR IS ACCESS ARRAY1; TYPE ACCREC IS ACCESS RECORD1; TYPE ACCPTR IS ACCESS POINTER1; TYPE ACCPVT IS ACCESS PACK1.PRIVY; TYPE ACCTSK IS ACCESS TASK1; AI1 : ACCINT := NEW INTEGER'(0); AA1 : ACCARR := NEW ARRAY1'(0, 0, 0); AR1 : ACCREC := NEW RECORD1'(D => 1, FIELD1 => 0); AP1 : ACCPTR := NEW POINTER1'(NEW INTEGER'(0)); AV1 : ACCPVT := NEW PACK1.PRIVY'(PACK1.ZERO); AT1 : ACCTSK := NEW TASK1; XAI1 : INTEGER RENAMES AI1.ALL; XAA1 : ARRAY1 RENAMES AA1.ALL; XAR1 : RECORD1 RENAMES AR1.ALL; XAP1 : POINTER1 RENAMES AP1.ALL; XAV1 : PACK1.PRIVY RENAMES AV1.ALL; XAK1 : INTEGER RENAMES PACK1.AK1.ALL; XAT1 : TASK1 RENAMES AT1.ALL; TASK TYPE TASK2 IS ENTRY ENTRY1 (TI1 : OUT INTEGER; TA1 : OUT ARRAY1; TR1 : OUT RECORD1; TP1 : IN OUT POINTER1; TV1 : IN OUT PACK1.PRIVY; TT1 : IN OUT TASK1; TK1 : IN OUT INTEGER); END TASK2; I : INTEGER; A_CHK_TASK : TASK2; PROCEDURE PROC1 (PI1 : IN OUT INTEGER; PA1 : IN OUT ARRAY1; PR1 : IN OUT RECORD1; PP1 : OUT POINTER1; PV1 : OUT PACK1.PRIVY; PT1 : IN OUT TASK1; PK1 : OUT INTEGER) IS BEGIN PI1 := PI1 + 1; PA1 := (PA1(1)+1, PA1(2)+1, PA1(3)+1); PR1 := (D => 1, FIELD1 => PR1.FIELD1 + 1); PP1 := NEW INTEGER'(AP1.ALL.ALL + 1); PV1 := PACK1.NEXT(AV1.ALL); PT1.NEXT; PK1 := PACK1.AK1.ALL + 1; END PROC1; TASK BODY TASK2 IS BEGIN ACCEPT ENTRY1 (TI1 : OUT INTEGER; TA1 : OUT ARRAY1; TR1 : OUT RECORD1; TP1 : IN OUT POINTER1; TV1 : IN OUT PACK1.PRIVY; TT1 : IN OUT TASK1; TK1 : IN OUT INTEGER) DO TI1 := AI1.ALL + 1; TA1 := (AA1.ALL(1)+1, AA1.ALL(2)+1, AA1.ALL(3)+1); TR1 := (D => 1, FIELD1 => AR1.ALL.FIELD1 + 1); TP1 := NEW INTEGER'(TP1.ALL + 1); TV1 := PACK1.NEXT(TV1); TT1.NEXT; TK1 := TK1 + 1; END ENTRY1; END TASK2; PACKAGE GENPACK2 IS NEW GENERIC1 (XAI1, XAA1, XAR1, XAP1, XAV1, XAT1, XAK1); BEGIN IF XAI1 /= IDENT_INT(1) THEN FAILED ("INCORRECT VALUE OF XAI1 (1)"); END IF; IF XAA1 /= (IDENT_INT(1),IDENT_INT(1),IDENT_INT(1)) THEN FAILED ("INCORRECT VALUE OF XAA1 (1)"); END IF; IF XAR1 /= (D => 1, FIELD1 => IDENT_INT(1)) THEN FAILED ("INCORRECT VALUE OF XAR1 (1)"); END IF; IF XAP1 /= IDENT(AP1.ALL) OR XAP1.ALL /= IDENT_INT(1) THEN FAILED ("INCORRECT VALUE OF XAP1 (1)"); END IF; IF PACK1."/=" (XAV1, PACK1.IDENT(PACK1.ONE)) THEN FAILED ("INCORRECT VALUE OF XAV1 (1)"); END IF; XAT1.VALU(I); IF I /= IDENT_INT(1) THEN FAILED ("INCORRECT RETURN VALUE OF XAT1.VALU (1)"); END IF; IF XAK1 /= IDENT_INT(1) THEN FAILED ("INCORRECT VALUE OF XAK1 (1)"); END IF; PROC1(XAI1, XAA1, XAR1, XAP1, XAV1, XAT1, XAK1); IF XAI1 /= IDENT_INT(2) THEN FAILED ("INCORRECT VALUE OF XAI1 (2)"); END IF; IF XAA1 /= (IDENT_INT(2),IDENT_INT(2),IDENT_INT(2)) THEN FAILED ("INCORRECT VALUE OF XAA1 (2)"); END IF; IF XAR1 /= (D => 1, FIELD1 => IDENT_INT(2)) THEN FAILED ("INCORRECT VALUE OF XAR1 (2)"); END IF; IF XAP1 /= IDENT(AP1.ALL) OR XAP1.ALL /= IDENT_INT(2) THEN FAILED ("INCORRECT VALUE OF XAP1 (2)"); END IF; IF PACK1."/=" (XAV1, PACK1.IDENT(PACK1.TWO)) THEN FAILED ("INCORRECT VALUE OF XAV1 (2)"); END IF; XAT1.VALU(I); IF I /= IDENT_INT(2) THEN FAILED ("INCORRECT RETURN VALUE OF XAT1.VALU (2)"); END IF; IF XAK1 /= IDENT_INT(2) THEN FAILED ("INCORRECT VALUE OF XAK1 (2)"); END IF; A_CHK_TASK.ENTRY1(XAI1, XAA1, XAR1, XAP1, XAV1, XAT1, XAK1); IF XAI1 /= IDENT_INT(3) THEN FAILED ("INCORRECT VALUE OF XAI1 (3)"); END IF; IF XAA1 /= (IDENT_INT(3),IDENT_INT(3),IDENT_INT(3)) THEN FAILED ("INCORRECT VALUE OF XAA1 (3)"); END IF; IF XAR1 /= (D => 1, FIELD1 => IDENT_INT(3)) THEN FAILED ("INCORRECT VALUE OF XAR1 (3)"); END IF; IF XAP1 /= IDENT(AP1.ALL) OR XAP1.ALL /= IDENT_INT(3) THEN FAILED ("INCORRECT VALUE OF XAP1 (3)"); END IF; IF PACK1."/=" (XAV1, PACK1.IDENT(PACK1.THREE)) THEN FAILED ("INCORRECT VALUE OF XAV1 (3)"); END IF; XAT1.VALU(I); IF I /= IDENT_INT(3) THEN FAILED ("INCORRECT RETURN VALUE OF XAT1.VALU (3)"); END IF; IF XAK1 /= IDENT_INT(3) THEN FAILED ("INCORRECT VALUE OF XAK1 (3)"); END IF; XAI1 := XAI1 + 1; XAA1 := (XAA1(1)+1, XAA1(2)+1, XAA1(3)+1); XAR1 := (D => 1, FIELD1 => XAR1.FIELD1 + 1); XAP1 := NEW INTEGER'(XAP1.ALL + 1); XAV1 := PACK1.NEXT(XAV1); XAT1.NEXT; XAK1 := XAK1 + 1; IF XAI1 /= IDENT_INT(4) THEN FAILED ("INCORRECT VALUE OF XAI1 (4)"); END IF; IF XAA1 /= (IDENT_INT(4),IDENT_INT(4),IDENT_INT(4)) THEN FAILED ("INCORRECT VALUE OF XAA1 (4)"); END IF; IF XAR1 /= (D => 1, FIELD1 => IDENT_INT(4)) THEN FAILED ("INCORRECT VALUE OF XAR1 (4)"); END IF; IF XAP1 /= IDENT(AP1.ALL) OR XAP1.ALL /= IDENT_INT(4) THEN FAILED ("INCORRECT VALUE OF XAP1 (4)"); END IF; IF PACK1."/=" (XAV1, PACK1.IDENT(PACK1.FOUR)) THEN FAILED ("INCORRECT VALUE OF XAV1 (4)"); END IF; XAT1.VALU(I); IF I /= IDENT_INT(4) THEN FAILED ("INCORRECT RETURN VALUE OF XAT1.VALU (4)"); END IF; IF XAK1 /= IDENT_INT(4) THEN FAILED ("INCORRECT VALUE OF XAK1 (4)"); END IF; AI1.ALL := AI1.ALL + 1; AA1.ALL := (AA1.ALL(1)+1, AA1.ALL(2)+1, AA1.ALL(3)+1); AR1.ALL := (D => 1, FIELD1 => AR1.ALL.FIELD1 + 1); AP1.ALL := NEW INTEGER'(AP1.ALL.ALL + 1); AV1.ALL := PACK1.NEXT(AV1.ALL); AT1.NEXT; PACK1.AK1.ALL := PACK1.AK1.ALL + 1; IF XAI1 /= IDENT_INT(5) THEN FAILED ("INCORRECT VALUE OF XAI1 (5)"); END IF; IF XAA1 /= (IDENT_INT(5),IDENT_INT(5),IDENT_INT(5)) THEN FAILED ("INCORRECT VALUE OF XAA1 (5)"); END IF; IF XAR1 /= (D => 1, FIELD1 => IDENT_INT(5)) THEN FAILED ("INCORRECT VALUE OF XAR1 (5)"); END IF; IF XAP1 /= IDENT(AP1.ALL) OR XAP1.ALL /= IDENT_INT(5) THEN FAILED ("INCORRECT VALUE OF XAP1 (5)"); END IF; IF PACK1."/=" (XAV1, PACK1.IDENT(PACK1.FIVE)) THEN FAILED ("INCORRECT VALUE OF XAV1 (5)"); END IF; XAT1.VALU(I); IF I /= IDENT_INT(5) THEN FAILED ("INCORRECT RETURN VALUE OF XAT1.VALU (5)"); END IF; IF XAK1 /= IDENT_INT(5) THEN FAILED ("INCORRECT VALUE OF XAK1 (5)"); END IF; AT1.STOP; END; RESULT; END C85005E;
{ "source": "starcoderdata", "programming_language": "ada" }
with Arduino_Nano_33_Ble_Sense.IOs; with Ada.Real_Time; use Ada.Real_Time; procedure Main is TimeNow : Ada.Real_Time.Time := Ada.Real_Time.Clock; begin loop --6 13 41 16 24 Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(13, True); TimeNow := Ada.Real_Time.Clock; delay until TimeNow + Ada.Real_Time.Milliseconds(50); Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(41, True); TimeNow := Ada.Real_Time.Clock; delay until TimeNow + Ada.Real_Time.Milliseconds(50); Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(6, False); TimeNow := Ada.Real_Time.Clock; delay until TimeNow + Ada.Real_Time.Milliseconds(50); Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(13, False); TimeNow := Ada.Real_Time.Clock; delay until TimeNow + Ada.Real_Time.Milliseconds(50); Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(41, False); TimeNow := Ada.Real_Time.Clock; delay until TimeNow + Ada.Real_Time.Milliseconds(50); Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(6, True); TimeNow := Ada.Real_Time.Clock; delay until TimeNow + Ada.Real_Time.Milliseconds(50); Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(13, True); TimeNow := Ada.Real_Time.Clock; delay until TimeNow + Ada.Real_Time.Milliseconds(50); Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(41, True); TimeNow := Ada.Real_Time.Clock; delay until TimeNow + Ada.Real_Time.Milliseconds(50); Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(16, False); TimeNow := Ada.Real_Time.Clock; delay until TimeNow + Ada.Real_Time.Milliseconds(50); Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(13, False); TimeNow := Ada.Real_Time.Clock; delay until TimeNow + Ada.Real_Time.Milliseconds(50); Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(41, False); TimeNow := Ada.Real_Time.Clock; delay until TimeNow + Ada.Real_Time.Milliseconds(50); Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(16, True); TimeNow := Ada.Real_Time.Clock; delay until TimeNow + Ada.Real_Time.Milliseconds(50); Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(13, True); TimeNow := Ada.Real_Time.Clock; delay until TimeNow + Ada.Real_Time.Milliseconds(50); Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(41, True); TimeNow := Ada.Real_Time.Clock; delay until TimeNow + Ada.Real_Time.Milliseconds(50); Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(24, False); TimeNow := Ada.Real_Time.Clock; delay until TimeNow + Ada.Real_Time.Milliseconds(50); Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(13, False); TimeNow := Ada.Real_Time.Clock; delay until TimeNow + Ada.Real_Time.Milliseconds(50); Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(41, False); TimeNow := Ada.Real_Time.Clock; delay until TimeNow + Ada.Real_Time.Milliseconds(50); Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(24, True); TimeNow := Ada.Real_Time.Clock; delay until TimeNow + Ada.Real_Time.Milliseconds(50); end loop; end Main;
{ "source": "starcoderdata", "programming_language": "ada" }
with System; with Interfaces.C.Strings; package AdaBase.Bindings.SQLite is pragma Preelaborate; package SYS renames System; package IC renames Interfaces.C; package ICS renames Interfaces.C.Strings; ------------------------ -- Type Definitions -- ------------------------ type sql64 is new Interfaces.Integer_64; type sqlite3 is limited private; type sqlite3_Access is access all sqlite3; pragma Convention (C, sqlite3_Access); type sqlite3_stmt is limited private; type sqlite3_stmt_Access is access all sqlite3_stmt; pragma Convention (C, sqlite3_stmt_Access); type sqlite3_destructor is access procedure (text : ICS.char_array_access); pragma Convention (C, sqlite3_destructor); --------------- -- Constants -- --------------- type enum_field_types is (SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT, SQLITE_BLOB, SQLITE_NULL); pragma Convention (C, enum_field_types); for enum_field_types use (SQLITE_INTEGER => 1, SQLITE_FLOAT => 2, SQLITE_TEXT => 3, SQLITE_BLOB => 4, SQLITE_NULL => 5); SQLITE_OK : constant := 0; -- Successful result SQLITE_ROW : constant := 100; -- sqlite3_step() has another row ready SQLITE_DONE : constant := 101; -- sqlite3_step() has finished executing SQLITE_CONFIG_SINGLETHREAD : constant := 1; -- nil SQLITE_CONFIG_MULTITHREAD : constant := 2; -- nil SQLITE_CONFIG_SERIALIZED : constant := 3; -- nil SQLITE_STATIC : constant IC.int := IC.int (0); SQLITE_TRANSIENT : constant IC.int := IC.int (-1); --------------------- -- Library Calls -- ---------------------- -- For now, only support SQLITE_STATIC and SQLITE_TRANSIENT at the -- cost of sqlite3_destructor. Shame on them mixing pointers and integers -- Applies to bind_text and bind_blob function sqlite3_bind_text (Handle : sqlite3_stmt_Access; Index : IC.int; Text : ICS.chars_ptr; nBytes : IC.int; destructor : IC.int) return IC.int; pragma Import (C, sqlite3_bind_text); function sqlite3_bind_blob (Handle : sqlite3_stmt_Access; Index : IC.int; binary : ICS.char_array_access; nBytes : IC.int; destructor : IC.int) return IC.int; pragma Import (C, sqlite3_bind_blob); function sqlite3_bind_double (Handle : not null sqlite3_stmt_Access; Index : IC.int; Value : IC.double) return IC.int; pragma Import (C, sqlite3_bind_double); function sqlite3_bind_int64 (Handle : not null sqlite3_stmt_Access; Index : IC.int; Value : sql64) return IC.int; pragma Import (C, sqlite3_bind_int64); function sqlite3_bind_null (Handle : not null sqlite3_stmt_Access; Index : IC.int) return IC.int; pragma Import (C, sqlite3_bind_null); function sqlite3_bind_parameter_count (Handle : not null sqlite3_stmt_Access) return IC.int; pragma Import (C, sqlite3_bind_parameter_count); function sqlite3_column_count (Handle : not null sqlite3_stmt_Access) return IC.int; pragma Import (C, sqlite3_column_count); function sqlite3_column_table_name (Handle : not null sqlite3_stmt_Access; index : IC.int) return ICS.chars_ptr; pragma Import (C, sqlite3_column_table_name); function sqlite3_column_name (Handle : not null sqlite3_stmt_Access; index : IC.int) return ICS.chars_ptr; pragma Import (C, sqlite3_column_name); function sqlite3_column_origin_name (Handle : not null sqlite3_stmt_Access; index : IC.int) return ICS.chars_ptr; pragma Import (C, sqlite3_column_origin_name); function sqlite3_column_database_name (Handle : not null sqlite3_stmt_Access; index : IC.int) return ICS.chars_ptr; pragma Import (C, sqlite3_column_database_name); function sqlite3_table_column_metadata (Handle : not null sqlite3_Access; dbname : ICS.chars_ptr; table : ICS.chars_ptr; column : ICS.chars_ptr; datatype : access ICS.chars_ptr; collseq : access ICS.chars_ptr; notnull : access IC.int; primekey : access IC.int; autoinc : access IC.int) return IC.int; pragma Import (C, sqlite3_table_column_metadata); function sqlite3_close (db : not null sqlite3_Access) return IC.int; pragma Import (C, sqlite3_close); function sqlite3_column_type (Handle : not null sqlite3_stmt_Access; iCol : IC.int) return IC.int; pragma Import (C, sqlite3_column_type); function sqlite3_column_bytes (Handle : not null sqlite3_stmt_Access; iCol : IC.int) return IC.int; pragma Import (C, sqlite3_column_bytes); function sqlite3_column_double (Handle : not null sqlite3_stmt_Access; iCol : IC.int) return IC.double; pragma Import (C, sqlite3_column_double); function sqlite3_column_int64 (Handle : not null sqlite3_stmt_Access; iCol : IC.int) return sql64; pragma Import (C, sqlite3_column_int64); function sqlite3_column_text (Handle : not null sqlite3_stmt_Access; iCol : IC.int) return ICS.chars_ptr; pragma Import (C, sqlite3_column_text); function sqlite3_column_blob (Handle : not null sqlite3_stmt_Access; iCol : IC.int) return ICS.chars_ptr; pragma Import (C, sqlite3_column_blob); function sqlite3_config (Option : IC.int) return IC.int; pragma Import (C, sqlite3_config); function sqlite3_errmsg (db : not null sqlite3_Access) return ICS.chars_ptr; pragma Import (C, sqlite3_errmsg); function sqlite3_errcode (db : not null sqlite3_Access) return IC.int; pragma Import (C, sqlite3_errcode); function sqlite3_changes (db : not null sqlite3_Access) return IC.int; pragma Import (C, sqlite3_changes); function sqlite3_last_insert_rowid (db : not null sqlite3_Access) return sql64; pragma Import (C, sqlite3_last_insert_rowid); function sqlite3_exec (db : not null sqlite3_Access; sql : ICS.chars_ptr; callback : System.Address; firstarg : System.Address; errmsg : System.Address) return IC.int; pragma Import (C, sqlite3_exec); function sqlite3_open (File_Name : ICS.chars_ptr; Handle : not null access sqlite3_Access) return IC.int; pragma Import (C, sqlite3_open); function sqlite3_prepare_v2 (db : not null sqlite3_Access; zSql : ICS.chars_ptr; nByte : IC.int; ppStmt : not null access sqlite3_stmt_Access; pzTail : not null access ICS.chars_ptr) return IC.int; pragma Import (C, sqlite3_prepare_v2); function sqlite3_reset (pStmt : not null sqlite3_stmt_Access) return IC.int; pragma Import (C, sqlite3_reset); function sqlite3_step (Handle : not null sqlite3_stmt_Access) return IC.int; pragma Import (C, sqlite3_step); function sqlite3_finalize (Handle : not null sqlite3_stmt_Access) return IC.int; pragma Import (C, sqlite3_finalize); function sqlite3_libversion return ICS.chars_ptr; pragma Import (C, sqlite3_libversion); function sqlite3_sourceid return ICS.chars_ptr; pragma Import (C, sqlite3_sourceid); function sqlite3_get_autocommit (db : not null sqlite3_Access) return IC.int; pragma Import (C, sqlite3_get_autocommit); private type sqlite3 is limited null record; type sqlite3_stmt is limited null record; end AdaBase.Bindings.SQLite;
{ "source": "starcoderdata", "programming_language": "ada" }
----------------------------------------------------------------------- with Util.Http.Clients; with Ada.Strings.Unbounded; package Util.Http.Clients.Mockups is -- Register the Http manager. procedure Register; -- Set the path of the file that contains the response for the next -- <b>Do_Get</b> and <b>Do_Post</b> calls. procedure Set_File (Path : in String); private type File_Http_Manager is new Http_Manager with record File : Ada.Strings.Unbounded.Unbounded_String; end record; type File_Http_Manager_Access is access all File_Http_Manager'Class; procedure Create (Manager : in File_Http_Manager; Http : in out Client'Class); overriding procedure Do_Get (Manager : in File_Http_Manager; Http : in Client'Class; URI : in String; Reply : out Response'Class); overriding procedure Do_Head (Manager : in File_Http_Manager; Http : in Client'Class; URI : in String; Reply : out Response'Class); overriding procedure Do_Post (Manager : in File_Http_Manager; Http : in Client'Class; URI : in String; Data : in String; Reply : out Response'Class); overriding procedure Do_Put (Manager : in File_Http_Manager; Http : in Client'Class; URI : in String; Data : in String; Reply : out Response'Class); overriding procedure Do_Patch (Manager : in File_Http_Manager; Http : in Client'Class; URI : in String; Data : in String; Reply : out Response'Class); overriding procedure Do_Delete (Manager : in File_Http_Manager; Http : in Client'Class; URI : in String; Reply : out Response'Class); overriding procedure Do_Options (Manager : in File_Http_Manager; Http : in Client'Class; URI : in String; Reply : out Response'Class); -- Set the timeout for the connection. overriding procedure Set_Timeout (Manager : in File_Http_Manager; Http : in Client'Class; Timeout : in Duration); end Util.Http.Clients.Mockups;
{ "source": "starcoderdata", "programming_language": "ada" }
type Verbosity_Level_Type is (None, Low, Medium, High); Verbosity_Level : Verbosity_Level_Type := High; -- GNATMAKE, GPRMAKE -- Modified by gnatmake or gprmake switches -v, -vl, -vm, -vh. Indicates -- the level of verbosity of informational messages: -- -- In Low Verbosity, the reasons why a source is recompiled, the name -- of the executable and the reason it must be rebuilt is output. -- -- In Medium Verbosity, additional lines are output for each ALI file -- that is checked. -- -- In High Verbosity, additional lines are output when the ALI file -- is part of an Ada library, is read-only or is part of the runtime. Warn_On_Ada_2005_Compatibility : Boolean := True; -- GNAT -- Set to True to active all warnings on Ada 2005 compatibility issues, -- including warnings on Ada 2005 obsolescent features used in Ada 2005 -- mode. Set False by -gnatwY. Warn_On_Bad_Fixed_Value : Boolean := False; -- GNAT -- Set to True to generate warnings for static fixed-point expression -- values that are not an exact multiple of the small value of the type. Warn_On_Constant : Boolean := False; -- GNAT -- Set to True to generate warnings for variables that could be declared -- as constants. Modified by use of -gnatwk/K. Warn_On_Dereference : Boolean := False; -- GNAT -- Set to True to generate warnings for implicit dereferences for array -- indexing and record component access. Modified by use of -gnatwd/D. Warn_On_Export_Import : Boolean := True; -- GNAT -- Set to True to generate warnings for suspicious use of export or -- import pragmas. Modified by use of -gnatwx/X. Warn_On_Hiding : Boolean := False; -- GNAT -- Set to True to generate warnings if a declared entity hides another -- entity. The default is that this warning is suppressed. Warn_On_Modified_Unread : Boolean := False; -- GNAT -- Set to True to generate warnings if a variable is assigned but is never -- read. The default is that this warning is suppressed. Warn_On_No_Value_Assigned : Boolean := True; -- GNAT -- Set to True to generate warnings if no value is ever assigned to a -- variable that is at least partially uninitialized. Set to false to -- suppress such warnings. The default is that such warnings are enabled. Warn_On_Obsolescent_Feature : Boolean := False; -- GNAT -- Set to True to generate warnings on use of any feature in Annex or if a -- subprogram is called for which a pragma Obsolescent applies. Warn_On_Redundant_Constructs : Boolean := False; -- GNAT -- Set to True to generate warnings for redundant constructs (e.g. useless -- assignments/conversions). The default is that this warning is disabled. Warn_On_Unchecked_Conversion : Boolean := True; -- GNAT -- Set to True to generate warnings for unchecked conversions that may have -- non-portable semantics (e.g. because sizes of types differ). The default -- is that this warning is enabled. Warn_On_Unrecognized_Pragma : Boolean := True; -- GNAT -- Set to True to generate warnings for unrecognized pragmas. The default -- is that this warning is enabled. type Warning_Mode_Type is (Suppress, Normal, Treat_As_Error); Warning_Mode : Warning_Mode_Type := Normal; -- GNAT, GNATBIND -- Controls treatment of warning messages. If set to Suppress, warning -- messages are not generated at all. In Normal mode, they are generated -- but do not count as errors. In Treat_As_Error mode, warning messages -- are generated and are treated as errors. Wide_Character_Encoding_Method : WC_Encoding_Method := WCEM_Brackets; -- GNAT -- Method used for encoding wide characters in the source program. See -- description of type in unit System.WCh_Con for a list of the methods -- that are currently supported. Note that brackets notation is always -- recognized in source programs regardless of the setting of this -- variable. The default setting causes only the brackets notation to be -- recognized. If this is the main unit, this setting also controls the -- output of the W=? parameter in the ALI file, which is used to provide -- the default for Wide_Text_IO files. Xref_Active : Boolean := True; -- GNAT -- Set if cross-referencing is enabled (i.e. xref info in ALI files) ---------------------------- -- Configuration Settings -- ---------------------------- -- These are settings that are used to establish the mode at the start of -- each unit. The values defined below can be affected either by command -- line switches, or by the use of appropriate configuration pragmas in the -- gnat.adc file. Ada_Version_Config : Ada_Version_Type; -- GNAT -- This is the value of the configuration switch for the Ada 83 mode, as -- set by the command line switches -gnat83/95/05, and possibly modified by -- the use of configuration pragmas Ada_83/Ada95/Ada05. This switch is used -- to set the initial value for Ada_Version mode at the start of analysis -- of a unit. Note however, that the setting of this flag is ignored for -- internal and predefined units (which are always compiled in the most up -- to date version of Ada). Ada_Version_Explicit_Config : Ada_Version_Type; -- GNAT -- This is set in the same manner as Ada_Version_Config. The difference is -- that the setting of this flag is not ignored for internal and predefined -- units, which for some purposes do indeed access this value, regardless -- of the fact that they are compiled the the most up to date ada version). Assertions_Enabled_Config : Boolean; -- GNAT -- This is the value of the configuration switch for assertions enabled -- mode, as possibly set by the command line switch -gnata, and possibly -- modified by the use of the configuration pragma Assertion_Policy. Debug_Pragmas_Enabled_Config : Boolean; -- GNAT -- This is the value of the configuration switch for debug pragmas enabled -- mode, as possibly set by the command line switch -gnata and possibly -- modified by the use of the configuration pragma Debug_Policy. Dynamic_Elaboration_Checks_Config : Boolean := False; -- GNAT -- Set True for dynamic elaboration checking mode, as set by the -gnatE -- switch or by the use of pragma Elaboration_Checking (Dynamic). Exception_Locations_Suppressed_Config : Boolean := False; -- GNAT -- Set True by use of the configuration pragma Suppress_Exception_Messages Extensions_Allowed_Config : Boolean; -- GNAT -- This is the flag that indicates whether extensions are allowed. It can -- be set True either by use of the -gnatX switch, or by use of the -- configuration pragma Extensions_Allowed (On). It is always set to True -- for internal GNAT units, since extensions are always permitted in such -- units. External_Name_Exp_Casing_Config : External_Casing_Type; -- GNAT -- This is the value of the configuration switch that controls casing of -- external symbols for which an explicit external name is given. It can be -- set to Uppercase by the command line switch -gnatF, and further modified -- by the use of the configuration pragma External_Name_Casing in the -- gnat.adc file. This flag is used to set the initial value for -- External_Name_Exp_Casing at the start of analyzing each unit. Note -- however that the setting of this flag is ignored for internal and -- predefined units (which are always compiled with As_Is mode). External_Name_Imp_Casing_Config : External_Casing_Type; -- GNAT -- This is the value of the configuration switch that controls casing of -- external symbols where the external name is implicitly given. It can be -- set to Uppercase by the command line switch -gnatF, and further modified -- by the use of the configuration pragma External_Name_Casing in the -- gnat.adc file. This flag is used to set the initial value for -- External_Name_Imp_Casing at the start of analyzing each unit. Note -- however that the setting of this flag is ignored for internal and -- predefined units (which are always compiled with Lowercase mode). Persistent_BSS_Mode_Config : Boolean; -- GNAT -- This is the value of the configuration switch that controls whether -- potentially persistent data is to be placed in the persistent_bss -- section. It can be set True by use of the pragma Persistent_BSS. -- This flag is used to set the initial value of Persistent_BSS_Mode -- at the start of each compilation unit, except that it is always -- set False for predefined units. Polling_Required_Config : Boolean; -- GNAT -- This is the value of the configuration switch that controls polling -- mode. It can be set True by the command line switch -gnatP, and then -- further modified by the use of pragma Polling in the gnat.adc file. This -- flag is used to set the initial value for Polling_Required at the start -- of analyzing each unit. Use_VADS_Size_Config : Boolean; -- GNAT -- This is the value of the configuration switch that controls the use of -- VADS_Size instead of Size whereever the attribute Size is used. It can -- be set True by the use of the pragma Use_VADS_Size in the gnat.adc file. -- This flag is used to set the initial value for Use_VADS_Size at the -- start of analyzing each unit. Note however that the setting of this flag -- is ignored for internal and predefined units (which are always compiled -- with the standard Size semantics). type Config_Switches_Type is private; -- Type used to save values of the switches set from Config values procedure Save_Opt_Config_Switches (Save : out Config_Switches_Type); -- This procedure saves the current values of the switches which are -- initialized from the above Config values, and then resets these switches -- according to the Config value settings. procedure Set_Opt_Config_Switches (Internal_Unit : Boolean; Main_Unit : Boolean); -- This procedure sets the switches to the appropriate initial values. The -- parameter Internal_Unit is True for an internal or predefined unit, and -- affects the way the switches are set (see above). Main_Unit is true if -- switches are being set for the main unit (this affects setting of the -- assert/debug pragm switches, which are normally set false by default for -- an internal unit, except when the internal unit is the main unit, in -- which case we use the command line settings). procedure Restore_Opt_Config_Switches (Save : Config_Switches_Type); -- This procedure restores a set of switch values previously saved by a -- call to Save_Opt_Switches. procedure Register_Opt_Config_Switches; -- This procedure is called after processing the gnat.adc file to record -- the values of the Config switches, as possibly modified by the use of -- command line switches and configuration pragmas. ------------------------ -- Other Global Flags -- ------------------------ Expander_Active : Boolean := False; -- A flag that indicates if expansion is active (True) or deactivated -- (False). When expansion is deactivated all calls to expander routines -- have no effect. Note that the initial setting of False is merely to -- prevent saving of an undefined value for an initial call to the -- Expander_Mode_Save_And_Set procedure. For more information on the use of -- this flag, see package Expander. Indeed this flag might more logically -- be in the spec of Expander, but it is referenced by Errout, and it -- really seems wrong for Errout to depend on Expander. ----------------------- -- Tree I/O Routines -- ----------------------- procedure Tree_Read; -- Reads switch settings from current tree file using Tree_Read procedure Tree_Write; -- Writes out switch settings to current tree file using Tree_Write -------------------------- -- ASIS Version Control -- -------------------------- -- These two variables (Tree_Version_String and Tree_ASIS_Version_Number) -- are supposed to be used in the GNAT/ASIS version check performed in -- the ASIS code (this package is also a part of the ASIS implementation). -- They are set by Tree_Read procedure, so they represent the version -- number (and the version string) of the compiler which has created the -- tree, and they are supposed to be compared with the corresponding values -- from the Gnatvsn package which is a part of ASIS implementation. Tree_Version_String : String_Access; -- Used to store the compiler version string read from a tree file to check -- if it is from the same date as stored in the version string in Gnatvsn. -- We require that ASIS Pro can be used only with GNAT Pro, but we allow -- non-Pro ASIS and ASIS-based tools to be used with any version of the -- GNAT compiler. Therefore, we need the possibility to compare the dates -- of the corresponding source sets, using version strings that may be -- of different lengths. Tree_ASIS_Version_Number : Int; -- Used to store the ASIS version number read from a tree file to check if -- it is the same as stored in the ASIS version number in Gnatvsn. private -- The following type is used to save and restore settings of switches in -- Opt that represent the configuration (i.e. result of config pragmas). -- Note that Ada_Version_Explicit is not included, since this is a sticky -- flag that once set does not get reset, since the whole idea of this flag -- is to record the setting for the main unit. type Config_Switches_Type is record Ada_Version : Ada_Version_Type; Ada_Version_Explicit : Ada_Version_Type; Assertions_Enabled : Boolean; Debug_Pragmas_Enabled : Boolean; Dynamic_Elaboration_Checks : Boolean; Exception_Locations_Suppressed : Boolean; Extensions_Allowed : Boolean; External_Name_Exp_Casing : External_Casing_Type; External_Name_Imp_Casing : External_Casing_Type; Persistent_BSS_Mode : Boolean; Polling_Required : Boolean; Use_VADS_Size : Boolean; end record; end Opt;
{ "source": "starcoderdata", "programming_language": "ada" }
PDE at 0 range 2 .. 2; PUE at 0 range 3 .. 3; DRIVE at 0 range 4 .. 5; IE at 0 range 6 .. 6; OD at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; ----------------- -- Peripherals -- ----------------- type PADS_BANK0_Peripheral is record -- Voltage select. Per bank control VOLTAGE_SELECT : aliased VOLTAGE_SELECT_Register; -- Pad control register GPIO0 : aliased GPIO_Register; -- Pad control register GPIO1 : aliased GPIO_Register; -- Pad control register GPIO2 : aliased GPIO_Register; -- Pad control register GPIO3 : aliased GPIO_Register; -- Pad control register GPIO4 : aliased GPIO_Register; -- Pad control register GPIO5 : aliased GPIO_Register; -- Pad control register GPIO6 : aliased GPIO_Register; -- Pad control register GPIO7 : aliased GPIO_Register; -- Pad control register GPIO8 : aliased GPIO_Register; -- Pad control register GPIO9 : aliased GPIO_Register; -- Pad control register GPIO10 : aliased GPIO_Register; -- Pad control register GPIO11 : aliased GPIO_Register; -- Pad control register GPIO12 : aliased GPIO_Register; -- Pad control register GPIO13 : aliased GPIO_Register; -- Pad control register GPIO14 : aliased GPIO_Register; -- Pad control register GPIO15 : aliased GPIO_Register; -- Pad control register GPIO16 : aliased GPIO_Register; -- Pad control register GPIO17 : aliased GPIO_Register; -- Pad control register GPIO18 : aliased GPIO_Register; -- Pad control register GPIO19 : aliased GPIO_Register; -- Pad control register GPIO20 : aliased GPIO_Register; -- Pad control register GPIO21 : aliased GPIO_Register; -- Pad control register GPIO22 : aliased GPIO_Register; -- Pad control register GPIO23 : aliased GPIO_Register; -- Pad control register GPIO24 : aliased GPIO_Register; -- Pad control register GPIO25 : aliased GPIO_Register; -- Pad control register GPIO26 : aliased GPIO_Register; -- Pad control register GPIO27 : aliased GPIO_Register; -- Pad control register GPIO28 : aliased GPIO_Register; -- Pad control register GPIO29 : aliased GPIO_Register; -- Pad control register SWCLK : aliased SWCLK_Register; -- Pad control register SWD : aliased SWD_Register; end record with Volatile; for PADS_BANK0_Peripheral use record VOLTAGE_SELECT at 16#0# range 0 .. 31; GPIO0 at 16#4# range 0 .. 31; GPIO1 at 16#8# range 0 .. 31; GPIO2 at 16#C# range 0 .. 31; GPIO3 at 16#10# range 0 .. 31; GPIO4 at 16#14# range 0 .. 31; GPIO5 at 16#18# range 0 .. 31; GPIO6 at 16#1C# range 0 .. 31; GPIO7 at 16#20# range 0 .. 31; GPIO8 at 16#24# range 0 .. 31; GPIO9 at 16#28# range 0 .. 31; GPIO10 at 16#2C# range 0 .. 31; GPIO11 at 16#30# range 0 .. 31; GPIO12 at 16#34# range 0 .. 31; GPIO13 at 16#38# range 0 .. 31; GPIO14 at 16#3C# range 0 .. 31; GPIO15 at 16#40# range 0 .. 31; GPIO16 at 16#44# range 0 .. 31; GPIO17 at 16#48# range 0 .. 31; GPIO18 at 16#4C# range 0 .. 31; GPIO19 at 16#50# range 0 .. 31; GPIO20 at 16#54# range 0 .. 31; GPIO21 at 16#58# range 0 .. 31; GPIO22 at 16#5C# range 0 .. 31; GPIO23 at 16#60# range 0 .. 31; GPIO24 at 16#64# range 0 .. 31; GPIO25 at 16#68# range 0 .. 31; GPIO26 at 16#6C# range 0 .. 31; GPIO27 at 16#70# range 0 .. 31; GPIO28 at 16#74# range 0 .. 31; GPIO29 at 16#78# range 0 .. 31; SWCLK at 16#7C# range 0 .. 31; SWD at 16#80# range 0 .. 31; end record; PADS_BANK0_Periph : aliased PADS_BANK0_Peripheral with Import, Address => PADS_BANK0_Base; end RP_SVD.PADS_BANK0;
{ "source": "starcoderdata", "programming_language": "ada" }
with gel.World, gel.Camera, gel.Window; package gel.Applet.gui_and_sim_world -- -- Provides an applet configured with a single window and -- two worlds (generally a simulation world and a gui world). -- is type Item is limited new gel.Applet.item with private; type View is access all Item'Class; package Forge is function to_Applet (Name : in String; use_Window : in gel.Window.view) return Item; function new_Applet (Name : in String; use_Window : in gel.Window.view) return View; end Forge; gui_world_Id : constant gel. world_Id := 1; gui_camera_Id : constant gel.camera_Id := 1; sim_world_Id : constant gel. world_Id := 2; sim_camera_Id : constant gel.camera_Id := 1; function gui_World (Self : in Item) return gel.World .view; function gui_Camera (Self : in Item) return gel.Camera.view; function sim_World (Self : in Item) return gel.World .view; function sim_Camera (Self : in Item) return gel.Camera.view; private type Item is limited new gel.Applet.item with record null; end record; end gel.Applet.gui_and_sim_world;
{ "source": "starcoderdata", "programming_language": "ada" }
-- { dg-do run } -- { dg-options "-gnatp" } procedure Discr24 is type Family_Type is (Family_Inet, Family_Inet6); type Port_Type is new Natural; subtype Inet_Addr_Comp_Type is Natural range 0 .. 255; type Inet_Addr_VN_Type is array (Natural range <>) of Inet_Addr_Comp_Type; subtype Inet_Addr_V4_Type is Inet_Addr_VN_Type (1 .. 4); subtype Inet_Addr_V6_Type is Inet_Addr_VN_Type (1 .. 16); type Inet_Addr_Type (Family : Family_Type := Family_Inet) is record case Family is when Family_Inet => Sin_V4 : Inet_Addr_V4_Type := (others => 0); when Family_Inet6 => Sin_V6 : Inet_Addr_V6_Type := (others => 0); end case; end record; type Sock_Addr_Type (Family : Family_Type := Family_Inet) is record Addr : Inet_Addr_Type (Family); Port : Port_Type; end record; function F return Inet_Addr_Type is begin return Inet_Addr_Type' (Family => Family_Inet, Sin_V4 => (192, 168, 169, 170)); end F; SA : Sock_Addr_Type; begin SA.Addr.Sin_V4 := (172, 16, 17, 18); SA.Port := 1111; SA.Addr := F; if SA.Port /= 1111 then raise Program_Error; end if; end;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Numerics.Float_Random; with Ada.Numerics.Discrete_Random; with Ada.Numerics.Generic_Elementary_Functions; with Ada.Containers.Vectors; with Ada.Containers.Synchronized_Queue_Interfaces; with Ada.Containers.Unbounded_Priority_Queues; use type Ada.Containers.Count_Type; with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Fixed; use Ada.Strings.Fixed; separate (WFC) package body Extended_Interfaces is function Generic_Collapse_Within (Parameters : in Instance) return Boolean is X_Dim_Length : constant X_Dim := X_Dim'Last - X_Dim'First + 1; Y_Dim_Length : constant Y_Dim := Y_Dim'Last - Y_Dim'First + 1; Num_Tiles : Natural renames Parameters.Num_Tiles; Tile_Elements : Tile_Element_Array renames Parameters.Tile_Elements; Frequency_Total : Natural renames Parameters.Frequency_Total; Frequencies : Frequency_Array renames Parameters.Frequencies; Adjacencies : Adjacency_Matrix renames Parameters.Adjacencies; Init_Enablers : Enabler_Counts renames Parameters.Enablers; Unsatisfiable_Tile_Constraint : exception; subtype Tile_ID_Range is Tile_ID range 1 .. Num_Tiles; type Wave_Function is array (Tile_ID_Range) of Boolean with Pack; package Float_Functions is new Ada.Numerics.Generic_Elementary_Functions(Float); function Frequency_Log_Frequency (Frequency : Natural) return Float is Freq_Float : constant Float := Float(Frequency); begin return Freq_Float * Float_Functions.Log(Freq_Float); end; function Init_Log_Frequency_Total return Float is Total : Float := 0.0; begin for Frequency of Frequencies loop Total := Total + Frequency_Log_Frequency(Frequency); end loop; return Total; end; function Log_Frequency_Noise return Float is use Ada.Numerics.Float_Random; G : Generator; begin Reset(G); return Random(G) * 1.0E-4; end; Log_Frequency_Total : constant Float := Init_Log_Frequency_Total; type Entropy_Cell is record Frequency_Sum : Natural := Frequency_Total; Log_Frequency_Sum : Float := Log_Frequency_Total; Noise : Float := Log_Frequency_Noise; end record; type Wave_Function_Cell is record Collapsed : Boolean := False; Possible : Wave_Function := (others => True); Enablers : Enabler_Counts(Tile_ID_Range) := Init_Enablers; Entropy : Entropy_Cell; end record; function Num_Remaining_Possibilities (Cell : in Wave_Function_Cell) return Natural is Result : Natural := 0; begin for The_Tile_ID in Tile_ID_Range loop if Cell.Possible(The_Tile_ID) then Result := Result + 1; end if; end loop; return Result; end; function Random_Remaining_Tile (Cell : in Wave_Function_Cell) return Tile_ID_Range is subtype Choice_Range is Natural range 1 .. Cell.Entropy.Frequency_Sum; package Random_Choice is new Ada.Numerics.Discrete_Random(Choice_Range); use Random_Choice; G : Generator; Choice : Choice_Range; begin Reset(G); Choice := Random(G); for The_Tile_ID in Tile_ID_Range loop if Cell.Possible(The_Tile_ID) then if Choice <= Frequencies(The_Tile_ID) then return The_Tile_ID; else Choice := Choice - Frequencies(The_Tile_ID); end if; end if; end loop; raise Constraint_Error; end; function Entropy_Value (Cell : in Wave_Function_Cell) return Float is Float_Freq_Sum : constant Float := Float(Cell.Entropy.Frequency_Sum); Log_Freq_Sum : constant Float := Float_Functions.Log(Float_Freq_Sum); begin return Cell.Entropy.Noise + Log_Freq_Sum - (Cell.Entropy.Log_Frequency_Sum / Float_Freq_Sum); end; Remaining_Uncollapsed : Natural := Natural(X_Dim_Length) * Natural(Y_Dim_Length); type Wave_Function_Matrix_Type is array (X_Dim, Y_Dim) of Wave_Function_Cell; type Wave_Function_Matrix_Access is access Wave_Function_Matrix_Type; Wave_Function_Matrix : constant Wave_Function_Matrix_Access := new Wave_Function_Matrix_Type; type Info is new Collapse_Info with null record; overriding function Is_Possible (This : in Info; X : X_Dim; Y : Y_Dim; T : Tile_ID) return Boolean; overriding function Is_Possible (This : in Info; X : X_Dim; Y : Y_Dim; E : Element_Type) return Boolean; overriding function Is_Possible (This : in Info; X : X_Dim; Y : Y_Dim; T : Tile_ID) return Boolean is pragma Unreferenced (This); Cell : Wave_Function_Cell renames Wave_Function_Matrix(X, Y); begin return (T in Tile_ID_Range) and then Cell.Possible(T); end; overriding function Is_Possible (This : in Info; X : X_Dim; Y : Y_Dim; E : Element_Type) return Boolean is pragma Unreferenced (This); Cell : Wave_Function_Cell renames Wave_Function_Matrix(X, Y); begin return (for some Tile_ID in Tile_ID_Range => Cell.Possible(Tile_ID) and then Tile_Elements(Tile_ID) = E); end; Collapsed_Tile_Choices : array (X_Dim, Y_Dim) of Tile_ID_Range; type Cell_Coord is record X : X_Dim; Y : Y_Dim; end record; function Neighbor (Coord : in Cell_Coord; Direction : in Adjacency_Direction) return Cell_Coord is X : X_Dim renames Coord.X; Y : Y_Dim renames Coord.Y; begin return (case Direction is when Upwards => (X => X, Y => ((Y - 1 - Y_Dim'First) mod Y_Dim_Length) + Y_Dim'First), when Downwards => (X => X, Y => ((Y + 1 - Y_Dim'First) mod Y_Dim_Length) + Y_Dim'First), when Leftwards => (Y => Y, X => ((X - 1 - X_Dim'First) mod X_Dim_Length) + X_Dim'First), when Rightwards => (Y => Y, X => ((X + 1 - X_Dim'First) mod X_Dim_Length) + X_Dim'First) ); end; type Entropy_Cell_ID is record Coord : Cell_Coord; Entropy : Float; end record; function Entropy_Cell_At (X : X_Dim; Y : Y_Dim) return Entropy_Cell_ID is Cell : Wave_Function_Cell renames Wave_Function_Matrix(X, Y); Entropy : constant Float := Entropy_Value(Cell); begin return Entropy_Cell_ID'((X, Y), Entropy); end; function Entropy_Cell_Priority (Cell_ID : in Entropy_Cell_ID) return Float is ( Cell_ID.Entropy ); package Entropy_Queue_Interfaces is new Ada.Containers.Synchronized_Queue_Interfaces(Entropy_Cell_ID); package Entropy_Priority_Queues is new Ada.Containers.Unbounded_Priority_Queues ( Entropy_Queue_Interfaces , Queue_Priority => Float , Get_Priority => Entropy_Cell_Priority , Before => "<"); Entropy_Heap : Entropy_Priority_Queues.Queue; type Removal_Update is record Coord : Cell_Coord; Removed_Tile_ID : Tile_ID_Range; end record; package Removal_Vectors is new Ada.Containers.Vectors(Natural, Removal_Update); Propagation_Removals : Removal_Vectors.Vector; procedure Collapse (X : X_Dim; Y : Y_Dim) is Cell : Wave_Function_Cell renames Wave_Function_Matrix(X, Y); Collapsed_Tile : Tile_ID_Range; begin if Cell.Collapsed then return; end if; Collapsed_Tile := Random_Remaining_Tile(Cell); Cell.Collapsed := True; for Tile_Possibility in Tile_ID_Range loop if Tile_Possibility /= Collapsed_Tile and Cell.Possible(Tile_Possibility) then Cell.Possible(Tile_Possibility) := False; Propagation_Removals.Append( Removal_Update'((X, Y), Tile_Possibility)); end if; end loop; if Num_Remaining_Possibilities(Cell) = 0 then raise Unsatisfiable_Tile_Constraint with Cell.Entropy.Frequency_Sum'Image & " " & Cell.Entropy.Log_Frequency_Sum'Image & " " & X'Image & " " & Y'Image; end if; Collapsed_Tile_Choices(X, Y) := Collapsed_Tile; Remaining_Uncollapsed := Remaining_Uncollapsed - 1; Upon_Collapse(X, Y, Info'(null record)); end; procedure Remove_Tile_Possibility (X : X_Dim; Y : Y_Dim; T : Tile_ID_Range) is Cell : Wave_Function_Cell renames Wave_Function_Matrix(X, Y); T_Freq : constant Natural := Frequencies(T); begin if not Cell.Possible(T) then return; end if; Cell.Possible(T) := False; Cell.Entropy.Frequency_Sum := Cell.Entropy.Frequency_Sum - T_Freq; Cell.Entropy.Log_Frequency_Sum := Cell.Entropy.Log_Frequency_Sum - Frequency_Log_Frequency(T_Freq); if Num_Remaining_Possibilities(Cell) = 0 then raise Unsatisfiable_Tile_Constraint with Cell.Entropy.Frequency_Sum'Image & " " & Cell.Entropy.Log_Frequency_Sum'Image & " " & X'Image & " " & Y'Image; end if; Entropy_Heap.Enqueue(Entropy_Cell_At(X, Y)); Propagation_Removals.Append(Removal_Update'((X, Y), T)); end; procedure Handle_Propagation_Removal (Update : in Removal_Update) is Coord : Cell_Coord renames Update.Coord; Removed_Tile_ID : Tile_ID_Range renames Update.Removed_Tile_ID; begin for Direction in Adjacency_Direction loop for Adjacent_Tile in Tile_ID_Range loop if Adjacencies(Removed_Tile_ID, Adjacent_Tile)(Direction) then declare Nbor_Coord : constant Cell_Coord := Neighbor(Coord, Direction); Nbor_Cell : Wave_Function_Cell renames Wave_Function_Matrix(Nbor_Coord.X, Nbor_Coord.Y); Opposite : constant Adjacency_Direction := Opposite_Direction(Direction); Enablers : Enablers_By_Direction renames Nbor_Cell.Enablers(Adjacent_Tile); begin if (for all Count of Enablers => Count /= 0) then Enablers(Opposite) := Enablers(Opposite) - 1; if Enablers(Opposite) = 0 then Remove_Tile_Possibility(Nbor_Coord.X, Nbor_Coord.Y, Adjacent_Tile); end if; Upon_Removal(Nbor_Coord.X, Nbor_Coord.Y, Info'(null record)); end if; end; end if; end loop; end loop; end; procedure Put_Debug_Info is begin Put_Line(Standard_Error, "Tile_ID_Bytes =>" & Integer'Image(Tile_ID_Range'Object_Size / 8)); Put_Line(Standard_Error, " Small_Bytes =>" & Integer'Image(Small_Integer'Object_Size / 8)); Put_Line(Standard_Error, " Cell_Bytes =>" & Integer'Image(Wave_Function_Cell'Object_Size / 8)); Put_Line(Standard_Error, " Wave_Bytes =>" & Integer'Image(Wave_Function'Object_Size / 8)); Put_Line(Standard_Error, "Enabler_Bytes =>" & Integer'Image(Init_Enablers'Size / 8)); Put_Line(Standard_Error, " Matrix_Bytes =>" & Integer'Image(Wave_Function_Matrix.all'Size / 8)); New_Line(Standard_Error, 1); for Y in Y_Dim loop for X in X_Dim loop declare Collapsed_Tile : constant Tile_ID_Range := Collapsed_Tile_Choices(X, Y); begin Put(Standard_Error, Tail(Tile_ID'Image(Collapsed_Tile), 4)); end; end loop; New_Line(Standard_Error); end loop; New_Line(Standard_Error); end; begin declare type Settings is new Info and Collapse_Settings with null record; overriding procedure Require (This : Settings; X : X_Dim; Y : Y_Dim; T : Tile_ID); overriding procedure Require (This : Settings; X : X_Dim; Y : Y_Dim; E : Element_Type); overriding procedure Require (This : Settings; X : X_Dim; Y : Y_Dim; T : Tile_ID) is pragma Unreferenced (This); begin for Other_T in Tile_ID_Range loop if Other_T /= T then Remove_Tile_Possibility(X, Y, Other_T); end if; end loop; end; overriding procedure Require (This : Settings; X : X_Dim; Y : Y_Dim; E : Element_Type) is pragma Unreferenced (This); begin for T in Tile_ID_Range loop if Tile_Elements(T) /= E then Remove_Tile_Possibility(X, Y, T); end if; end loop; end; begin Set_Initial_Requirements(Settings'(null record)); while Propagation_Removals.Length > 0 loop declare Next_Update : constant Removal_Update := Propagation_Removals.Last_Element; begin Propagation_Removals.Delete_Last; Handle_Propagation_Removal(Next_Update); end; end loop; end; -- Initialize cell entropy heap for X in X_Dim loop for Y in Y_Dim loop Entropy_Heap.Enqueue(Entropy_Cell_At(X, Y)); end loop; end loop; while Remaining_Uncollapsed > 0 loop declare Min_Entropy : Entropy_Cell_ID; Min_X : X_Dim renames Min_Entropy.Coord.X; Min_Y : Y_Dim renames Min_Entropy.Coord.Y; Next_Update : Removal_Update; begin Entropy_Heap.Dequeue(Min_Entropy); Collapse(Min_X, Min_Y); while Propagation_Removals.Length > 0 loop Next_Update := Propagation_Removals.Last_Element; Propagation_Removals.Delete_Last; Handle_Propagation_Removal(Next_Update); end loop; exception when Unsatisfiable_Tile_Constraint => return False; end; end loop; pragma Debug (Put_Debug_Info); for X in X_Dim loop for Y in Y_Dim loop declare Collapsed_Tile : constant Tile_ID_Range := Collapsed_Tile_Choices(X, Y); begin Set_Resulting_Element(X, Y, Tile_Elements(Collapsed_Tile)); end; end loop; end loop; return True; end; end;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Finalization; generic type Data_Type is private; type Data_Access is access Data_Type; package kv.Ref_Counting_Mixin is type Control_Type is record Count : Natural := 0; Data : Data_Access; end record; type Control_Access is access Control_Type; type Ref_Type is new Ada.Finalization.Controlled with record Control : Control_Access; end record; overriding procedure Initialize(Self : in out Ref_Type); overriding procedure Adjust(Self : in out Ref_Type); overriding procedure Finalize(Self : in out Ref_Type); procedure Set(Self : in out Ref_Type; Data : in Data_Access); function Get(Self : Ref_Type) return Data_Access; end kv.Ref_Counting_Mixin;
{ "source": "starcoderdata", "programming_language": "ada" }
package body Selection with SPARK_Mode is procedure Sort (A: in out Arr) is Tmp: Integer; Min: Integer; begin for I in Integer range A'First .. A'Last loop Min := I; for J in Integer range I + 1 .. A'Last loop pragma Loop_Invariant (for all K in I .. J - 1 => A (Min) <= A (K)); pragma Loop_Invariant (Min in I .. A'Last); if A (J) < A(Min) then Min := J; end if; end loop; Tmp := A (I); A (I) := A (Min); A (Min) := Tmp; pragma Loop_Invariant (for all K in A'First .. I => (for all M in K + 1 .. A'Last => A (K) <= A (M))); end loop; end Sort; end Selection;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Calendar; package PortScan.Log is package CAL renames Ada.Calendar; overall_log : exception; -- Open log, dump diagnostic data and stop timer. function initialize_log (log_handle : in out TIO.File_Type; head_time : out CAL.Time; seq_id : port_id; slave_root : String; UNAME : String; BENV : String; COPTS : String; PTVAR : String; block_dog : Boolean) return Boolean; -- Stop time, write duration data, close log procedure finalize_log (log_handle : in out TIO.File_Type; head_time : CAL.Time; tail_time : out CAL.Time); -- Helper to format phase/section heading function log_section (title : String) return String; -- Format start of build phase in log procedure log_phase_begin (log_handle : TIO.File_Type; phase : String); -- Format end of build phase in log procedure log_phase_end (log_handle : TIO.File_Type); -- Standard log name based on port origin and variant. function log_name (sid : port_id) return String; -- Returns formatted difference in seconds between two times function elapsed_HH_MM_SS (start, stop : CAL.Time) return String; -- Returns formatted difference in seconds between overall start time and now. function elapsed_now return String; -- Establish times before the start and upon completion of a scan. procedure set_scan_start_time (mark : CAL.Time); procedure set_scan_complete (mark : CAL.Time); -- Establish times before the start and upon completion of a bulk run procedure set_overall_start_time (mark : CAL.Time); procedure set_overall_complete (mark : CAL.Time); -- build log operations procedure start_logging (flavor : count_type); procedure stop_logging (flavor : count_type); procedure scribe (flavor : count_type; line : String; flush_after : Boolean); procedure flush_log (flavor : count_type); -- Establish values of build counters procedure set_build_counters (A, B, C, D, E : Natural); -- Increments the indicated build counter by some quality. procedure increment_build_counter (flavor : count_type; quantity : Natural := 1); -- Open log to document packages that get deleted and the reason why procedure start_obsolete_package_logging; procedure stop_obsolete_package_logging; -- Write to log if open and optionally output a copy to screen. procedure obsolete_notice (message : String; write_to_screen : Boolean); -- Return WWW report-formatted timestamp of start time. function www_timestamp_start_time return String; -- Return current build queue size function ports_remaining_to_build return Integer; -- Return value of individual port counter function port_counter_value (flavor : count_type) return Integer; -- Return number of packages built since build started function hourly_build_rate return Natural; -- Return number of packages built in the last 600 seconds function impulse_rate return Natural; -- Show duration between overall start and stop times. function bulk_run_duration return String; -- Return formatted duration of scan function scan_duration return String; -- Former private function exposed for web page generator function timestamp (hack : CAL.Time; www_format : Boolean := False) return String; private type impulse_rec is record hack : CAL.Time; packages : Natural := 0; virgin : Boolean := True; end record; subtype logname_field is String (1 .. 19); subtype impulse_range is Integer range 1 .. 600; type dim_handlers is array (count_type) of TIO.File_Type; type dim_counters is array (count_type) of Natural; type dim_logname is array (count_type) of logname_field; type dim_impulse is array (impulse_range) of impulse_rec; function log_duration (start, stop : CAL.Time) return String; function split_collection (line : String; title : String) return String; procedure dump_port_variables (log_handle : TIO.File_Type; contents : String); -- Simple time calculation (guts) function get_packages_per_hour (packages_done : Natural; from_when : CAL.Time) return Natural; -- bulk run variables Flog : dim_handlers; start_time : CAL.Time; stop_time : CAL.Time; scan_start : CAL.Time; scan_stop : CAL.Time; bld_counter : dim_counters := (0, 0, 0, 0, 0); impulse_counter : impulse_range := impulse_range'Last; impulse_data : dim_impulse; obsolete_pkg_log : TIO.File_Type; obsolete_log_open : Boolean := False; bailing : constant String := " (ravenadm must exit)"; logname : constant dim_logname := ("00_last_results.log", "01_success_list.log", "02_failure_list.log", "03_ignored_list.log", "04_skipped_list.log"); end PortScan.Log;
{ "source": "starcoderdata", "programming_language": "ada" }
with Interfaces; use Interfaces; package body Natools.Static_Maps.Web.Fallback_Render.Commands is P : constant array (0 .. 4) of Natural := (1, 4, 9, 13, 16); T1 : constant array (0 .. 4) of Unsigned_8 := (34, 66, 52, 35, 47); T2 : constant array (0 .. 4) of Unsigned_8 := (5, 26, 36, 26, 50); G : constant array (0 .. 66) of Unsigned_8 := (0, 11, 0, 0, 2, 21, 0, 28, 16, 0, 0, 0, 0, 15, 0, 5, 0, 0, 12, 30, 0, 8, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 19, 0, 0, 27, 0, 17, 11, 0, 13, 0, 4, 18, 23, 20, 9, 0, 0, 27, 0, 14, 0, 0, 30, 6, 25, 25, 0, 4, 5, 0, 2, 14, 0); function Hash (S : String) return Natural is F : constant Natural := S'First - 1; L : constant Natural := S'Length; F1, F2 : Natural := 0; J : Natural; begin for K in P'Range loop exit when L < P (K); J := Character'Pos (S (P (K) + F)); F1 := (F1 + Natural (T1 (K)) * J) mod 67; F2 := (F2 + Natural (T2 (K)) * J) mod 67; end loop; return (Natural (G (F1)) + Natural (G (F2))) mod 33; end Hash; end Natools.Static_Maps.Web.Fallback_Render.Commands;
{ "source": "starcoderdata", "programming_language": "ada" }
--* -- OBJECTIVE: -- CHECK THAT FLOAT_IO GET RAISES CONSTRAINT_ERROR WHEN THE VALUE -- SUPPLIED BY WIDTH IS NEGATIVE, WIDTH IS GREATER THAN FIELD'LAST -- WHEN FIELD'LAST IS LESS THAN INTEGER'LAST, OR THE VALUE READ IS -- OUT OF RANGE OF THE ITEM PARAMETER, BUT WITHIN THE RANGE OF THE -- SUBTYPE USED TO INSTANTIATE FLOAT_IO. -- APPLICABILITY CRITERIA: -- THIS TEST IS APPLICABLE ONLY TO IMPLEMENTATIONS WHICH -- SUPPORT TEXT FILES. -- HISTORY: -- SPS 09/07/82 -- JBG 08/30/83 -- DWC 09/11/87 SPLIT CASE FOR FIXED_IO INTO CE3804P.ADA AND -- CORRECTED EXCEPTION HANDLING. -- JRL 06/07/96 Added call to Ident_Int in expressions involving -- Field'Last, to make the expressions non-static and -- prevent compile-time rejection. WITH REPORT; USE REPORT; WITH TEXT_IO; USE TEXT_IO; PROCEDURE CE3804F IS INCOMPLETE : EXCEPTION; BEGIN TEST ("CE3804F", "CHECK THAT FLOAT_IO GET RAISES " & "CONSTRAINT_ERROR WHEN THE VALUE SUPPLIED " & "BY WIDTH IS NEGATIVE, WIDTH IS GREATER THAN " & "FIELD'LAST WHEN FIELD'LAST IS LESS THAN " & "INTEGER'LAST, OR THE VALUE READ IS OUT OF " & "RANGE OF THE ITEM PARAMETER, BUT WITHIN THE " & "RANGE OF THE SUBTYPE USED TO INSTANTIATE " & "FLOAT_IO."); DECLARE FT : FILE_TYPE; TYPE FLT IS NEW FLOAT RANGE 1.0 .. 10.0; PACKAGE FL_IO IS NEW FLOAT_IO (FLT); USE FL_IO; X : FLT RANGE 1.0 .. 5.0; BEGIN BEGIN GET (FT, X, IDENT_INT(-3)); FAILED ("CONSTRAINT_ERROR NOT RAISED FOR NEGATIVE " & "WIDTH"); EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN STATUS_ERROR => FAILED ("STATUS_ERROR RAISED INSTEAD OF " & "CONSTRAINT_ERROR FOR NEGATIVE WIDTH"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED FOR NEGATIVE " & "WIDTH"); END; IF FIELD'LAST < INTEGER'LAST THEN BEGIN GET (X, FIELD'LAST + Ident_Int(1)); FAILED ("CONSTRAINT_ERROR NOT RAISED - " & "FIELD'LAST + 1 WIDTH - DEFAULT"); EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - " & "FIELD'LAST + 1 WIDTH - DEFAULT"); END; END IF; BEGIN CREATE (FT, OUT_FILE, LEGAL_FILE_NAME); EXCEPTION WHEN USE_ERROR => NOT_APPLICABLE ("USE_ERROR RAISED; TEXT CREATE " & "WITH OUT_FILE MODE"); RAISE INCOMPLETE; WHEN NAME_ERROR => NOT_APPLICABLE ("NAME_ERROR RAISED; TEXT CREATE " & "WITH OUT_FILE MODE"); RAISE INCOMPLETE; END; PUT (FT, "1.0"); NEW_LINE (FT); PUT (FT, "8.0"); NEW_LINE (FT); PUT (FT, "2.0"); NEW_LINE (FT); PUT (FT, "3.0"); CLOSE (FT); BEGIN OPEN (FT, IN_FILE, LEGAL_FILE_NAME); EXCEPTION WHEN USE_ERROR => NOT_APPLICABLE ("USE_ERROR RAISED; TEXT OPEN " & "FOR IN_FILE MODE"); RAISE INCOMPLETE; END; GET (FT, X); IF X /= 1.0 THEN FAILED ("WRONG VALUE READ WITH EXTERNAL FILE"); END IF; BEGIN GET (FT, X); FAILED ("CONSTRAINT_ERROR NOT RAISED - " & "VALUE OUT OF RANGE WITH EXTERNAL FILE"); EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - " & "VALUE OUT OF RANGE WITH EXTERNAL FILE"); END; BEGIN GET (FT, X, IDENT_INT(-1)); FAILED ("CONSTRAINT_ERROR NOT RAISED - " & "NEGATIVE WIDTH WITH EXTERNAL FILE"); EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - " & "NEGATIVE WIDTH WITH EXTERNAL FILE"); END; SKIP_LINE (FT); IF FIELD'LAST < INTEGER'LAST THEN BEGIN GET (FT, X, FIELD'LAST + Ident_Int(1)); FAILED ("CONSTRAINT_ERROR NOT RAISED - " & "FIELD'LAST + 1 WIDTH WITH " & "EXTERNAL FILE"); EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - " & "FIELD'LAST + 1 WIDTH WITH " & "EXTERNAL FILE"); END; END IF; SKIP_LINE (FT); BEGIN GET (FT, X, 3); EXCEPTION WHEN CONSTRAINT_ERROR => FAILED ("CONSTRAINT_ERROR RAISED - " & "OUT OF RANGE WITH EXTERNAL FILE"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - " & "OUT OF RANGE WITH EXTERNAL FILE"); END; BEGIN DELETE (FT); EXCEPTION WHEN USE_ERROR => NULL; END; EXCEPTION WHEN INCOMPLETE => NULL; END; RESULT; END CE3804F;
{ "source": "starcoderdata", "programming_language": "ada" }
------------------------------------------------------------- with Ada.Iterator_Interfaces; with Program.Elements; limited with Program.Element_Vectors; package Program.Element_Iterators is pragma Pure; type Child_Iterator is tagged; type Property_Name is (Aborted_Tasks, Actual_Parameter, Ancestor, Arguments, Aspect_Definition, Aspect_Mark, Aspects, Associated_Message, Attribute_Designator, Called_Name, Choice_Parameter, Choices, Clause_Name, Clause_Names, Clause_Range, Component_Clauses, Component_Definition, Component_Value, Components, Condition, Constraint, Declarations, Default_Expression, Definition, Delta_Expression, Digits_Expression, Discriminant, Discriminant_Part, Discriminant_Value, Discriminants, Element_Iterator, Else_Expression, Else_Statements, Elsif_Paths, Enclosing_Element, End_Name, End_Statement_Identifier, Entry_Barrier, Entry_Family_Definition, Entry_Index, Entry_Index_Subtype, Entry_Name, Exception_Handlers, Exception_Name, Exit_Loop_Name, Expression, Expressions, Formal_Parameter, Formal_Parameters, Generalized_Iterator, Generic_Function_Name, Generic_Package_Name, Generic_Procedure_Name, Goto_Label, Guard, Index_Subtypes, Initialization_Expression, Iterable_Name, Iterator_Name, Left, Literals, Loop_Parameter, Lower_Bound, Mod_Clause_Expression, Modulus, Name, Names, Object_Subtype, Operand, Operator, Parameter, Parameters, Parameter_Subtype, Parent, Paths, Position, Predicate, Prefix, Private_Declarations, Progenitors, Protected_Operations, Qualified_Expression, Raised_Exception, Range_Attribute, Ranges, Real_Range, Real_Range_Constraint, Record_Definition, Renamed_Exception, Renamed_Function, Renamed_Object, Renamed_Package, Renamed_Procedure, Result_Expression, Result_Subtype, Return_Object, Right, Selecting_Expression, Selector, Selector_Names, Slice_Range, Statement_Identifier, Statements, Subpool_Name, Subprogram_Default, Subtype_Indication, Subtype_Mark, Then_Abort_Statements, Then_Expression, Then_Statements, Upper_Bound, Variable_Name, Variants, Visible_Declarations); package Cursors is type Enclosing_Element_Cursor is record Element : Program.Elements.Element_Access; Level : Positive; end record; function Has_Enclosing_Element (Self : Enclosing_Element_Cursor) return Boolean; type Child_Cursor is tagged private; function Has_Element (Self : Child_Cursor) return Boolean; function Element (Self : Child_Cursor) return Program.Elements.Element_Access; function Property (Self : Child_Cursor) return Property_Name; -- Property name for element pointed by the cursor function Index (Self : Child_Cursor) return Positive; -- Index if the cursor in the middle of Element_Vector or 1 for single -- element. function Total (Self : Child_Cursor) return Positive; -- Vector length if the cursor in the middle of Element_Vector or 1 for -- single element. package Internal is procedure Step (Self : Child_Iterator'Class; Cursor : in out Child_Cursor; Reset : Boolean); end Internal; private type Child_Cursor is tagged record Element : Program.Elements.Element_Access; Property : Property_Name; Getter_Index : Positive; Item_Index : Positive; Total_Items : Positive; end record; end Cursors; package Enclosing_Element_Iterators is new Ada.Iterator_Interfaces (Cursors.Enclosing_Element_Cursor, Cursors.Has_Enclosing_Element); type Enclosing_Element_Iterator is new Enclosing_Element_Iterators.Forward_Iterator with private; function To_Enclosing_Element_Iterator (Parent : not null Program.Elements.Element_Access) return Enclosing_Element_Iterator; overriding function First (Self : Enclosing_Element_Iterator) return Cursors.Enclosing_Element_Cursor; overriding function Next (Self : Enclosing_Element_Iterator; Position : Cursors.Enclosing_Element_Cursor) return Cursors.Enclosing_Element_Cursor; package Child_Iterators is new Ada.Iterator_Interfaces (Cursors.Child_Cursor, Cursors.Has_Element); type Child_Iterator is new Child_Iterators.Forward_Iterator with private; overriding function First (Self : Child_Iterator) return Cursors.Child_Cursor; overriding function Next (Self : Child_Iterator; Position : Cursors.Child_Cursor) return Cursors.Child_Cursor; type Cursor_Checker is access function (Cursor : Cursors.Child_Cursor) return Boolean; function Only_If (Parent : Child_Iterator; Filter : not null Cursor_Checker) return Child_Iterator; type Element_Checker is access function (Element : not null Program.Elements.Element_Access) return Boolean; function Only_If (Parent : Child_Iterator; Filter : not null Element_Checker) return Child_Iterator; function To_Child_Iterator (Parent : not null Program.Elements.Element_Access; Filter : Element_Checker := null) return Child_Iterator; private type Getter (Is_Vector : Boolean := False) is record Property : Property_Name; case Is_Vector is when False => Get_Child : access function (Self : not null Program.Elements.Element_Access) return Program.Elements.Element_Access; when True => Get_Vector : access function (Self : not null Program.Elements.Element_Access) return Program.Element_Vectors.Element_Vector_Access; end case; end record; type Getter_Array is array (Positive range <>) of Getter; Empty : aliased constant Getter_Array := (1 .. 0 => <>); type Enclosing_Element_Iterator is new Enclosing_Element_Iterators.Forward_Iterator with record First : Program.Elements.Element_Access; end record; type Checker_Chain (Is_Cursor : Boolean := False) is record case Is_Cursor is when True => Cursor_Filter : Cursor_Checker; when False => Element_Filter : Element_Checker; end case; end record; type Checker_Chain_Array is array (Positive range <>) of Checker_Chain; function Check (Cursor : Cursors.Child_Cursor; List : Checker_Chain_Array) return Boolean; type Child_Iterator is new Child_Iterators.Forward_Iterator with record Parent : Program.Elements.Element_Access; Getters : access constant Getter_Array; Filter : Checker_Chain_Array (1 .. 3); Last : Natural := 0; end record; end Program.Element_Iterators;
{ "source": "starcoderdata", "programming_language": "ada" }
-- Lambda Calculus interpreter -- --------------------------- -- Parses and reduces Lamdba Calculus statements. -- -- Use a simple recursive parser for the simplest computer language. -- It would be nice to build an ADT for Instructions and hide the Multiway tree implementation. -- -- Source: -- lambda - [This file] definitions and helper functions -- lambda_REPL - REPL and command line parsers -- lambda_parser - parse tree generator -- lambda_reducer - optimises and reduces lambda expressions -- with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Containers; use Ada.Containers; with Ada.Containers.Multiway_Trees; with Ada.Strings.Unbounded; Package Lambda is subtype Statement is String; -- A Lambda Calculus Statement, eg fn x.x Max_Statement_Length : constant Integer := 80; Empty_Statement : constant String := Ada.Strings.Fixed.Head("", Max_Statement_Length,' '); subtype Name_Type is Character range 'a' .. 'z'; subtype Synonym_Type is Character range 'A' .. 'Z'; -- L_Variable : Variable name -- L_Synonym : Synonym name -- L_Function : Function definition -- L_Expression : Expression -- L_Definition : Synonym definition type Element_Type is (L_Variable, L_Synonym, L_Function, L_Expression, L_Definition, L_Comments); type Element_Record ( Element : Element_Type := L_Expression ) is record Name : Character; is_Explicit : Boolean := true; case Element is when L_Comments => Comments : Statement(1..Max_Statement_Length); when others => null; end case; end record; -- Exceptions Syntax_Error : exception; Recursion_Overflow : exception; Internal_Error : exception; Package SU renames Ada.Strings.Unbounded; package Instructions is new Ada.Containers.Multiway_Trees (Element_Type => Element_Record); use Instructions; function format ( I: Instructions.Tree ) return String; function format ( I: Instructions.Tree; Curs : Instructions.Cursor ) return String; function Indent( I : Natural ) return String; type Log_Type is ( Log_Parse, Log_Reduce, Log_Format ); procedure Log ( S: String ); procedure Log ( S: String; I: Instructions.Tree ); procedure Log ( S: String; I: Instructions.Tree; C: Instructions.Cursor ); procedure Log ( T: Log_Type; S: String ); procedure Log ( T: Log_Type; S: String; I: Instructions.Tree ); procedure Log ( T: Log_Type; S: String; I: Instructions.Tree; C: Instructions.Cursor ); procedure Log_Format ( I: Instructions.Tree ); procedure Add_Synonym ( Source : Instructions.Cursor ); procedure Remove_Synonym ( S : Statement ); procedure List_Synonyms; Trace : Boolean := FALSE; -- Trace the REPL Trace_Parse : Boolean := FALSE; -- Trace Parser detail Trace_Reduce : Boolean := FALSE; -- Trace Reducer detail Trace_Format : Boolean := FALSE; -- Trace Formatter detail private Synonyms : Instructions.Tree := Instructions.Empty_Tree; function format_Element ( I : Instructions.tree; Curs : Instructions.Cursor ) return SU.Unbounded_String; end Lambda;
{ "source": "starcoderdata", "programming_language": "ada" }
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- -- MA 02111-1307, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Butil; use Butil; with Namet; use Namet; with Opt; use Opt; with Output; use Output; package body Binderr is --------------- -- Error_Msg -- --------------- procedure Error_Msg (Msg : String) is begin if Msg (Msg'First) = '?' then if Warning_Mode = Suppress then return; end if; if Warning_Mode = Treat_As_Error then Errors_Detected := Errors_Detected + 1; else Warnings_Detected := Warnings_Detected + 1; end if; else Errors_Detected := Errors_Detected + 1; end if; if Brief_Output or else (not Verbose_Mode) then Set_Standard_Error; Error_Msg_Output (Msg, Info => False); Set_Standard_Output; end if; if Verbose_Mode then if Errors_Detected + Warnings_Detected = 0 then Write_Eol; end if; Error_Msg_Output (Msg, Info => False); end if; if Warnings_Detected + Errors_Detected > Maximum_Errors then raise Unrecoverable_Error; end if; end Error_Msg; -------------------- -- Error_Msg_Info -- -------------------- procedure Error_Msg_Info (Msg : String) is begin if Brief_Output or else (not Verbose_Mode) then Set_Standard_Error; Error_Msg_Output (Msg, Info => True); Set_Standard_Output; end if; if Verbose_Mode then Error_Msg_Output (Msg, Info => True); end if; end Error_Msg_Info; ---------------------- -- Error_Msg_Output -- ---------------------- procedure Error_Msg_Output (Msg : String; Info : Boolean) is Use_Second_Name : Boolean := False; begin if Warnings_Detected + Errors_Detected > Maximum_Errors then Write_Str ("error: maximum errors exceeded"); Write_Eol; return; end if; if Msg (Msg'First) = '?' then Write_Str ("warning: "); elsif Info then if not Info_Prefix_Suppress then Write_Str ("info: "); end if; else Write_Str ("error: "); end if; for I in Msg'Range loop if Msg (I) = '%' then if Use_Second_Name then Get_Name_String (Error_Msg_Name_2); else Use_Second_Name := True; Get_Name_String (Error_Msg_Name_1); end if; Write_Char ('"'); Write_Str (Name_Buffer (1 .. Name_Len)); Write_Char ('"'); elsif Msg (I) = '&' then Write_Char ('"'); if Use_Second_Name then Write_Unit_Name (Error_Msg_Name_2); else Use_Second_Name := True; Write_Unit_Name (Error_Msg_Name_1); end if; Write_Char ('"'); elsif Msg (I) /= '?' then Write_Char (Msg (I)); end if; end loop; Write_Eol; end Error_Msg_Output; ---------------------- -- Finalize_Binderr -- ---------------------- procedure Finalize_Binderr is begin -- Message giving number of errors detected (verbose mode only) if Verbose_Mode then Write_Eol; if Errors_Detected = 0 then Write_Str ("No errors"); elsif Errors_Detected = 1 then Write_Str ("1 error"); else Write_Int (Errors_Detected); Write_Str (" errors"); end if; if Warnings_Detected = 1 then Write_Str (", 1 warning"); elsif Warnings_Detected > 1 then Write_Str (", "); Write_Int (Warnings_Detected); Write_Str (" warnings"); end if; Write_Eol; end if; end Finalize_Binderr; ------------------------ -- Initialize_Binderr -- ------------------------ procedure Initialize_Binderr is begin Errors_Detected := 0; Warnings_Detected := 0; end Initialize_Binderr; end Binderr;
{ "source": "starcoderdata", "programming_language": "ada" }
----------------------------------------------------------------------- with Ada.Unchecked_Deallocation; package body Atlas.Applications.Models is use type ADO.Objects.Object_Record_Access; use type ADO.Objects.Object_Ref; use type ADO.Objects.Object_Record; -- -------------------- -- Get the bean attribute identified by the given name. -- -------------------- overriding function Get_Value (From : in User_Stat_Info; Name : in String) return Util.Beans.Objects.Object is begin if Name = "post_count" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Post_Count)); end if; if Name = "document_count" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Document_Count)); end if; if Name = "question_count" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Question_Count)); end if; if Name = "answer_count" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Answer_Count)); end if; if Name = "review_count" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Review_Count)); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- -------------------- -- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>. -- -------------------- procedure List (Object : in out User_Stat_Info_List_Bean'Class; Session : in out ADO.Sessions.Session'Class; Context : in out ADO.Queries.Context'Class) is begin List (Object.List, Session, Context); end List; -- -------------------- -- Stats about what the user did. -- -------------------- procedure List (Object : in out User_Stat_Info_Vector; Session : in out ADO.Sessions.Session'Class; Context : in out ADO.Queries.Context'Class) is procedure Read (Into : in out User_Stat_Info); Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Context); Pos : Natural := 0; procedure Read (Into : in out User_Stat_Info) is begin Into.Post_Count := Stmt.Get_Integer (0); Into.Document_Count := Stmt.Get_Integer (1); Into.Question_Count := Stmt.Get_Integer (2); Into.Answer_Count := Stmt.Get_Integer (3); Into.Review_Count := Stmt.Get_Integer (4); end Read; begin Stmt.Execute; User_Stat_Info_Vectors.Clear (Object); while Stmt.Has_Elements loop Object.Insert_Space (Before => Pos); Object.Update_Element (Index => Pos, Process => Read'Access); Pos := Pos + 1; Stmt.Next; end loop; end List; end Atlas.Applications.Models;
{ "source": "starcoderdata", "programming_language": "ada" }
with Types; use Types; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; generic type T_Element is digits <>; package Module_IO is -- Lire l'intégralité du fichier. procedure Lire(Fichier: in Unbounded_String; PagesNum: out Integer; Liens: out LC_Integer_Integer.T_LC); -- Ecrire les PageRank et les Poids. procedure Ecrire(Fichier: in Unbounded_String; PagesNum: in Integer; MaxIterations: in Integer; Alpha: in T_Digits; Rangs: in Vecteur_Poids.T_Vecteur); end Module_IO;
{ "source": "starcoderdata", "programming_language": "ada" }
package freetype_c.FT_Size_Metrics is type Item is record X_ppem : aliased FT_UShort; Y_ppem : aliased FT_UShort; X_Scale : aliased FT_Fixed; Y_Scale : aliased FT_Fixed; Ascender : aliased FT_Pos; Descender : aliased FT_Pos; Height : aliased FT_Pos; max_Advance : aliased FT_Pos; end record; type Item_array is array (C.Size_t range <>) of aliased FT_Size_Metrics.Item; type Pointer is access all freetype_c.FT_Size_Metrics.Item; type Pointer_array is array (C.Size_t range <>) of aliased freetype_c.FT_Size_Metrics.Pointer; type pointer_Pointer is access all freetype_c.FT_Size_Metrics.Pointer; end freetype_c.FT_Size_Metrics;
{ "source": "starcoderdata", "programming_language": "ada" }
with Interfaces; use Interfaces; package body Lithium.Comment_Cookie_Smaz_Hash is P : constant array (0 .. 2) of Natural := (1, 2, 4); T1 : constant array (0 .. 2) of Unsigned_8 := (44, 115, 66); T2 : constant array (0 .. 2) of Unsigned_8 := (27, 43, 74); G : constant array (0 .. 122) of Unsigned_8 := (0, 0, 25, 0, 0, 0, 55, 0, 0, 19, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 28, 2, 0, 0, 0, 0, 29, 45, 0, 0, 14, 59, 0, 60, 15, 2, 0, 38, 0, 0, 0, 25, 52, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 41, 0, 0, 35, 27, 5, 43, 32, 0, 0, 22, 0, 7, 21, 50, 0, 18, 0, 0, 0, 17, 0, 8, 37, 57, 0, 0, 0, 1, 8, 4, 3, 58, 27, 7, 0, 49, 0, 37, 54, 10, 0, 0, 0, 21, 41, 13, 30, 12, 19, 0, 0, 44, 3, 35, 26, 46, 54, 0, 0, 0, 37, 0, 0, 24, 41, 6); function Hash (S : String) return Natural is F : constant Natural := S'First - 1; L : constant Natural := S'Length; F1, F2 : Natural := 0; J : Natural; begin for K in P'Range loop exit when L < P (K); J := Character'Pos (S (P (K) + F)); F1 := (F1 + Natural (T1 (K)) * J) mod 123; F2 := (F2 + Natural (T2 (K)) * J) mod 123; end loop; return (Natural (G (F1)) + Natural (G (F2))) mod 61; end Hash; end Lithium.Comment_Cookie_Smaz_Hash;
{ "source": "starcoderdata", "programming_language": "ada" }
-- Environment with System; package Lumen.Internal is --------------------------------------------------------------------------- -- Xlib stuff needed for our window info record type Atom is new Long_Integer; type Display_Pointer is new System.Address; Null_Display_Pointer : constant Display_Pointer := Display_Pointer (System.Null_Address); type Screen_Depth is new Natural; type Screen_Number is new Natural; type Visual_ID is new Long_Integer; type Window_ID is new Long_Integer; type X_Visual_Info is record Visual : System.Address; Visual_Ident : Visual_ID; Screen : Screen_Number; Depth : Screen_Depth; Class : Integer; Red_Mask : Long_Integer; Green_Mask : Long_Integer; Blue_Mask : Long_Integer; Colormap_Size : Natural; Bits_Per_RGB : Natural; end record; type X_Visual_Info_Pointer is access all X_Visual_Info; --------------------------------------------------------------------------- -- The GL rendering context type type GLX_Context is new System.Address; Null_Context : constant GLX_Context := GLX_Context (System.Null_Address); --------------------------------------------------------------------------- -- The native window type type Window_Internal is record Display : Display_Pointer := Null_Display_Pointer; Window : Window_ID := 0; Visual : X_Visual_Info_Pointer := null; Width : Natural := 0; Height : Natural := 0; Context : GLX_Context := Null_Context; end record; --------------------------------------------------------------------------- -- Values used to compute record rep clause values that are portable -- between 32- and 64-bit systems Is_32 : constant := Boolean'Pos (System.Word_Size = 32); Is_64 : constant := 1 - Is_32; Word_Bytes : constant := Integer'Size / System.Storage_Unit; Word_Bits : constant := Integer'Size - 1; Long_Bytes : constant := Long_Integer'Size / System.Storage_Unit; Long_Bits : constant := Long_Integer'Size - 1; --------------------------------------------------------------------------- -- The maximum length of an event data record type Padding is array (1 .. 23) of Long_Integer; --------------------------------------------------------------------------- end Lumen.Internal;
{ "source": "starcoderdata", "programming_language": "ada" }
end if; end loop; end if; end uptate_state; ------------------------- -- update_cov ------------------------- procedure update_cov( P : in out State_Covariance_Matrix; K :Kalman_Gain_Matrix ) is begin -- update cov P := P - (K * G.H) * P; end update_cov; ------------------------- -- calculate_A ------------------------- procedure calculate_A( A : out State_Transition_Matrix; dt : Time_Type ) is begin A := (others => (others => 0.0)); A( map(X_LAT), map(X_LAT) ) := 1.0; A( map(X_LAT), map(X_GROUND_SPEED_X) ) := Base_Unit_Type(dt); A( map(X_LON), map(X_LON) ) := 1.0; A( map(X_LON), map(X_GROUND_SPEED_Y) ) := Base_Unit_Type(dt); A( map(X_ALT), map(X_ALT) ) := 1.0; A( map(X_ALT), map(X_GROUND_SPEED_Z) ) := -Base_Unit_Type(dt); A( map(X_ROLL), map(X_ROLL) ) := 1.0; A( map(X_ROLL), map(X_ROLL_RATE) ) := Base_Unit_Type(dt); A( map(X_ROLL), map(X_ROLL_BIAS) ) := -Base_Unit_Type(dt); A( map(X_PITCH), map(X_PITCH) ) := 1.0; A( map(X_PITCH), map(X_PITCH_RATE) ) := Base_Unit_Type(dt); A( map(X_PITCH), map(X_PITCH_BIAS) ) := -Base_Unit_Type(dt); A( map(X_YAW), map(X_YAW) ) := 1.0; A( map(X_YAW), map(X_YAW_RATE) ) := Base_Unit_Type(dt); A( map(X_YAW), map(X_YAW_BIAS) ) := -Base_Unit_Type(dt); A( map(X_ROLL_RATE), map(X_ROLL_RATE) ) := 1.0; A( map(X_PITCH_RATE), map(X_PITCH_RATE) ) := 1.0; A( map(X_YAW_RATE), map(X_YAW_RATE) ) := 1.0; A( map(X_ROLL_BIAS), map(X_ROLL_BIAS) ) := 1.0; A( map(X_PITCH_BIAS), map(X_PITCH_BIAS) ) := 1.0; A( map(X_YAW_BIAS), map(X_YAW_BIAS) ) := 1.0; end calculate_A; end Kalman;
{ "source": "starcoderdata", "programming_language": "ada" }
with System; package Init11 is type My_Integer is new Integer; for My_Integer'Alignment use 1; type Arr1 is array (1 .. 3) of My_Integer; for Arr1'Scalar_Storage_Order use System.Low_Order_First; type R1 is record I : My_Integer; A : Arr1; end record; for R1'Bit_Order use System.Low_Order_First; for R1'Scalar_Storage_Order use System.Low_Order_First; type Arr2 is array (1 .. 3) of My_Integer; for Arr2'Scalar_Storage_Order use System.High_Order_First; type R2 is record I : My_Integer; A : Arr2; end record; for R2'Bit_Order use System.High_Order_First; for R2'Scalar_Storage_Order use System.High_Order_First; My_R1 : constant R1 := (I => 16#12345678#, A => (16#AB0012#, 16#CD0034#, 16#EF0056#)); My_R2 : constant R2 := (I => 16#12345678#, A => (16#AB0012#, 16#CD0034#, 16#EF0056#)); end Init11;
{ "source": "starcoderdata", "programming_language": "ada" }
-- with Ada.Containers.Vectors; -- with Ada.Text_IO; with Ada.Long_Long_Integer_Text_IO; with Ada.Strings; with Ada.Strings.Bounded; with Ada.Containers; use Ada.Containers; -- Note that this package currently only handles positive numbers. package body BigInteger is use BigInteger.Int_Vector; -- Sadly we can't use this in our type because the compiler doesn't support -- modular types greater than 2**32. We have chosen a power of ten for now -- because it allows us to give a base 10 printed representation without -- needing to implement division. Base : constant Long_Long_Integer := 1_000_000_000_000_000_000; -- Used in multiplication to split the number into two halves Half_Base : constant Long_Long_Integer := 1_000_000_000; function Create(l : in Long_Long_Integer) return BigInt is bi : BigInt; num : Long_Long_Integer := l; begin -- The given Long_Long_Integer can be larger than our base, so we need -- to normalize it. if num >= Base then bi.bits.append(num mod Base); num := num / Base; end if; bi.bits.append(num); return bi; end Create; function Create(s : in String) return BigInt is bi : BigInt := Create(0); multiplier : BigInt := Create(1); begin for index in reverse s'Range loop declare c : constant Character := s(index); begin case c is when '0' .. '9' => declare value : constant Long_Long_Integer := Character'Pos(c) - Character'Pos('0'); begin bi := bi + multiplier * Create(value); if index > 0 then multiplier := multiplier * Create(10); end if; end; when others => null; end case; end; end loop; return bi; end Create; function "+" (Left, Right: in BigInt) return BigInt is result : BigInt; carry : Long_Long_Integer := 0; begin -- Normalize the input such that |left.bits| >= |right.bits| if Right.bits.Length > Left.bits.Length then return Right + Left; end if; result.bits := Int_Vector.Empty_Vector; result.negative := False; -- Sum all the bits that the numbers have in common. for index in 1 .. Integer(Right.bits.Length) loop carry := carry + Left.bits.Element(index) + Right.bits.Element(index); if carry >= Base then result.bits.Append(carry - Base); carry := 1; else result.bits.Append(carry); carry := 0; end if; end loop; -- Append all the bits that the left number has that the right number -- does not (remembering to continue the carry) for index in Integer(Right.bits.Length + 1) .. Integer(Left.bits.Length) loop carry := carry + Left.bits.Element(index); if carry >= Base then result.bits.append(carry - Base); carry := 1; else result.bits.append(carry); carry := 0; end if; end loop; -- Finally remember to add an extra '1' to the result if we ended up with -- a carry bit. if carry /= 0 then result.bits.append(carry); end if; return result; end "+"; function "-" (Left, Right: in BigInt) return BigInt is result : BigInt; carry_in : Long_Long_Integer := 0; begin -- Currently always assuming |left| >= |right| result.bits := Int_Vector.Empty_Vector; result.negative := False; -- Subtract all the bits they have in common for index in 1 .. Integer(Right.bits.Length) loop carry_in := Left.bits.Element(index) - Right.bits.Element(index) - carry_in; if carry_in < 0 then result.bits.Append(Base + carry_in); carry_in := 1; else result.bits.Append(carry_in); carry_in := 0; end if; end loop; -- Subtract the carry from any remaining bits in Left as neccessary for index in Integer(Right.bits.Length + 1) .. Integer(Left.bits.Length) loop carry_in := Left.bits.Element(index) - carry_in; if carry_in < 0 then result.bits.Append(Base + carry_in); carry_in := 1; else result.bits.Append(carry_in); carry_in := 0; end if; end loop; -- Handle left over carry bit -- Todo: We don't handle this right now return result; end "-"; function "*" (Left, Right: in BigInt) return BigInt is result : BigInt; Intermediate : Long_Long_Integer; Temporary : Long_Long_Integer; carry : Long_Long_Integer := 0; double_carry : Boolean; begin -- Normalize the input such that |left.bits| >= |right.bits| if Right.bits.Length > Left.bits.Length then return Right * Left; end if; result.bits := Int_Vector.Empty_Vector; result.negative := False; -- Multiplication is done by splitting the Left and Right base units into -- two half-base units representing the upper and lower bits of the -- number. These portions are then multiplied pairwise for left_index in 1 .. Integer(Left.bits.Length) loop if Left.bits.Element(left_index) = 0 then goto Next_Left; end if; declare Left_Lower : constant Long_Long_Integer := Left.bits.Element(left_index) mod Half_Base; Left_Upper : constant Long_Long_Integer := Left.bits.Element(left_index) / Half_Base; begin for right_index in 1 .. Integer(Right.bits.Length) loop if Right.bits.Element(right_index) = 0 then goto Next_Right; end if; declare Right_Lower : constant Long_Long_Integer := Right.bits.Element(right_index) mod Half_Base; Right_Upper : constant Long_Long_Integer := Right.bits.Element(right_index) / Half_Base; result_index : constant Integer := left_index + right_index - 1; begin double_carry := False; if Integer(result.bits.Length) > result_index then carry := result.bits.Element(result_index + 1); intermediate := result.bits.Element(result_index); elsif Integer(result.bits.Length) >= result_index then carry := 0; intermediate := result.bits.Element(result_index); else carry := 0; intermediate := 0; while Integer(result.bits.Length) < result_index loop result.bits.Append(0); end loop; end if; -- Left_Lower * Right_Lower Intermediate := Intermediate + Left_Lower * Right_Lower; if Intermediate >= Base then Intermediate := Intermediate - Base; carry := carry + 1; if carry = Base then carry := 0; double_carry := True; end if; end if; -- Left_Lower * Right_Upper Temporary := Left_Lower * Right_Upper; if Temporary >= Half_Base then Intermediate := Intermediate + (Temporary mod Half_Base) * Half_Base; carry := carry + (Temporary / Half_Base); if carry >= Base then carry := carry - Base; double_carry := True; end if; else Intermediate := Intermediate + Temporary * Half_Base; end if; if Intermediate >= Base then Intermediate := Intermediate - Base; carry := carry + 1; if carry = Base then carry := 0; double_carry := True; end if; end if; -- Left_Upper * Right_Lower Temporary := Left_Upper * Right_Lower; if Temporary >= Half_Base then Intermediate := Intermediate + (Temporary mod Half_Base) * Half_Base; carry := carry + (Temporary / Half_Base); if carry >= Base then carry := carry - Base; double_carry := True; end if; else Intermediate := Intermediate + Temporary * Half_Base; end if; if Intermediate >= Base then Intermediate := Intermediate - Base; carry := carry + 1; if carry = Base then carry := 0; double_carry := True; end if; end if; result.bits.Replace_Element(result_index, Intermediate); -- Left_Upper * Right_Upper carry := carry + Left_Upper * Right_Upper; if double_carry then if Integer(result.bits.Length) >= result_index + 2 then result.bits.Replace_Element(result_index + 2, result.bits.Element(result_index + 2) + 1); else result.bits.Append(1); end if; -- If we have a double carry, we know we had at least -- result_index + 1 elements in our vector because -- otherwise we wouldn't have overflown the carry capacity. result.bits.Replace_Element(result_index + 1, carry); elsif carry > 0 then if Integer(result.bits.Length ) > result_index then result.bits.Replace_Element(result_index + 1, carry); else result.bits.Append(carry); end if; end if; end; <<Next_Right>> null; end loop; end; <<Next_Left>> null; end loop; return result; end "*"; function "**"(Left : in BigInt; Right: in Natural) return BigInt is result : BigInt := Create(1); current_base : BigInt := Left; current_exponent : Long_Long_Integer := Long_Long_Integer(Right); begin while current_exponent > 0 loop if current_exponent mod 2 = 0 then current_base := current_base * current_base; current_exponent := current_exponent / 2; else result := result * current_base; current_exponent := current_exponent - 1; end if; end loop; return result; end; function Magnitude(bi : in BigInt) return Positive is function Log10(n : Long_Long_Integer) return Positive is begin if n >= 100_000_000_000_000_000 then return 18; elsif n >= 10_000_000_000_000_000 then return 17; elsif n >= 1_000_000_000_000_000 then return 16; elsif n >= 100_000_000_000_000 then return 15; elsif n >= 10_000_000_000_000 then return 14; elsif n >= 1_000_000_000_000 then return 13; elsif n >= 100_000_000_000 then return 12; elsif n >= 10_000_000_000 then return 11; elsif n >= 1_000_000_000 then return 10; elsif n >= 100_000_000 then return 9; elsif n >= 10_000_000 then return 8; elsif n >= 1_000_000 then return 7; elsif n >= 100_000 then return 6; elsif n >= 10_000 then return 5; elsif n >= 1_000 then return 4; elsif n >= 100 then return 3; elsif n >= 10 then return 2; else return 1; end if; end Log10; mag : constant Positive := Log10(bi.bits.Last_Element) + Natural(bi.bits.Length - 1) * 18; begin return mag; end Magnitude; function ToString(bi : in BigInt) return String is begin if bi.bits.Length > 0 then declare package Bounded is new Ada.Strings.Bounded.Generic_Bounded_Length(Integer(bi.bits.Length) * 18); bs : Bounded.Bounded_String := Bounded.Null_Bounded_String; temporary : String (1 .. 18); begin Ada.Long_Long_Integer_Text_IO.Put(temporary, bi.bits.Element(Integer(bi.bits.Length))); Bounded.Append(bs, temporary); Bounded.Trim(bs, Ada.Strings.Left); for index in reverse 1 .. Integer(bi.bits.Length - 1) loop Ada.Long_Long_Integer_Text_IO.Put(temporary, bi.bits.Element(index)); for ch_in in temporary'Range loop if temporary(ch_in) = ' ' then temporary(ch_in) := '0'; else exit; end if; end loop; Bounded.Append(bs, temporary); end loop; return Bounded.To_String(bs); end; else return "0"; end if; end; end BigInteger;
{ "source": "starcoderdata", "programming_language": "ada" }
with gnatcoll.SQL.Postgres; use gnatcoll.SQL.Postgres; with gnatcoll.SQL.Exec; use gnatcoll.SQL.Exec; with Ada.Text_IO; use Ada.Text_IO; with Ada.Containers.Vectors; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO.Unbounded_IO; with Formatter; with Ada.Containers.Doubly_Linked_Lists; with Ada.Containers; use Ada.Containers; with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; with GNAT.Regpat; use GNAT.Regpat; -- with Templates; -- with Dbase.DrackSpace; with Ada.Numerics.Generic_Elementary_Functions; package Dbase.Scroller is package SU renames Ada.Strings.Unbounded; package SUIO renames Ada.Text_IO.Unbounded_IO; type Scrl_Record is record ID : Integer; Prompt : Unbounded_String; -- Func : Function_Access; end record; package Scrl_List is new Ada.Containers.Doubly_Linked_Lists(Scrl_Record); use Scrl_List; -- package Drack is new Dbase.DrackSpace; Radar_Mode : Boolean := False; subtype Value_Type is Long_Long_Float; package Value_Functions is new Ada.Numerics.Generic_Elementary_Functions ( Value_Type); use Value_Functions; Definition_Ptr : Integer := 1; function Fld (CI : Direct_Cursor; FldNme : Unbounded_String) return String; function OpenDb return Boolean; procedure CloseDb; procedure Scroll (L_AckStatement : String; Down : Integer := 0; Left : Integer := 0; AltFunctions : Boolean := False); --; CI : in out Direct_Cursor); procedure Run; end Dbase.Scroller;
{ "source": "starcoderdata", "programming_language": "ada" }
-- Versions of the `struct stat' data structure. -- i386 versions of the `xmknod' interface. -- x86-64 versions of the `xmknod' interface. -- Device. type stat_uu_glibc_reserved_array is array (0 .. 2) of aliased CUPS.bits_types_h.uu_syscall_slong_t; type stat is record st_dev : aliased CUPS.bits_types_h.uu_dev_t; -- bits/stat.h:48 st_ino : aliased CUPS.bits_types_h.uu_ino_t; -- bits/stat.h:53 st_nlink : aliased CUPS.bits_types_h.uu_nlink_t; -- bits/stat.h:61 st_mode : aliased CUPS.bits_types_h.uu_mode_t; -- bits/stat.h:62 st_uid : aliased CUPS.bits_types_h.uu_uid_t; -- bits/stat.h:64 st_gid : aliased CUPS.bits_types_h.uu_gid_t; -- bits/stat.h:65 uu_pad0 : aliased int; -- bits/stat.h:67 st_rdev : aliased CUPS.bits_types_h.uu_dev_t; -- bits/stat.h:69 st_size : aliased CUPS.bits_types_h.uu_off_t; -- bits/stat.h:74 st_blksize : aliased CUPS.bits_types_h.uu_blksize_t; -- bits/stat.h:78 st_blocks : aliased CUPS.bits_types_h.uu_blkcnt_t; -- bits/stat.h:80 st_atim : aliased CUPS.time_h.timespec; -- bits/stat.h:91 st_mtim : aliased CUPS.time_h.timespec; -- bits/stat.h:92 st_ctim : aliased CUPS.time_h.timespec; -- bits/stat.h:93 uu_glibc_reserved : aliased stat_uu_glibc_reserved_array; -- bits/stat.h:106 end record; pragma Convention (C_Pass_By_Copy, stat); -- bits/stat.h:46 -- File serial number. -- 32bit file serial number. -- File mode. -- Link count. -- Link count. -- File mode. -- User ID of the file's owner. -- Group ID of the file's group. -- Device number, if device. -- Size of file, in bytes. -- Size of file, in bytes. -- Optimal block size for I/O. -- Number 512-byte blocks allocated. -- Number 512-byte blocks allocated. -- Nanosecond resolution timestamps are stored in a format -- equivalent to 'struct timespec'. This is the type used -- whenever possible but the Unix namespace rules do not allow the -- identifier 'timespec' to appear in the <sys/stat.h> header. -- Therefore we have to handle the use of this header in strictly -- standard-compliant sources special. -- Time of last access. -- Time of last modification. -- Time of last status change. -- Time of last access. -- Nscecs of last access. -- Time of last modification. -- Nsecs of last modification. -- Time of last status change. -- Nsecs of last status change. -- File serial number. -- Note stat64 has the same shape as stat for x86-64. -- Device. type stat64_uu_glibc_reserved_array is array (0 .. 2) of aliased CUPS.bits_types_h.uu_syscall_slong_t; type stat64 is record st_dev : aliased CUPS.bits_types_h.uu_dev_t; -- bits/stat.h:121 st_ino : aliased CUPS.bits_types_h.uu_ino64_t; -- bits/stat.h:123 st_nlink : aliased CUPS.bits_types_h.uu_nlink_t; -- bits/stat.h:124 st_mode : aliased CUPS.bits_types_h.uu_mode_t; -- bits/stat.h:125 st_uid : aliased CUPS.bits_types_h.uu_uid_t; -- bits/stat.h:132 st_gid : aliased CUPS.bits_types_h.uu_gid_t; -- bits/stat.h:133 uu_pad0 : aliased int; -- bits/stat.h:135 st_rdev : aliased CUPS.bits_types_h.uu_dev_t; -- bits/stat.h:136 st_size : aliased CUPS.bits_types_h.uu_off_t; -- bits/stat.h:137 st_blksize : aliased CUPS.bits_types_h.uu_blksize_t; -- bits/stat.h:143 st_blocks : aliased CUPS.bits_types_h.uu_blkcnt64_t; -- bits/stat.h:144 st_atim : aliased CUPS.time_h.timespec; -- bits/stat.h:152 st_mtim : aliased CUPS.time_h.timespec; -- bits/stat.h:153 st_ctim : aliased CUPS.time_h.timespec; -- bits/stat.h:154 uu_glibc_reserved : aliased stat64_uu_glibc_reserved_array; -- bits/stat.h:164 end record; pragma Convention (C_Pass_By_Copy, stat64); -- bits/stat.h:119 -- File serial number. -- Link count. -- File mode. -- 32bit file serial number. -- File mode. -- Link count. -- User ID of the file's owner. -- Group ID of the file's group. -- Device number, if device. -- Size of file, in bytes. -- Device number, if device. -- Size of file, in bytes. -- Optimal block size for I/O. -- Nr. 512-byte blocks allocated. -- Nanosecond resolution timestamps are stored in a format -- equivalent to 'struct timespec'. This is the type used -- whenever possible but the Unix namespace rules do not allow the -- identifier 'timespec' to appear in the <sys/stat.h> header. -- Therefore we have to handle the use of this header in strictly -- standard-compliant sources special. -- Time of last access. -- Time of last modification. -- Time of last status change. -- Time of last access. -- Nscecs of last access. -- Time of last modification. -- Nsecs of last modification. -- Time of last status change. -- Nsecs of last status change. -- File serial number. -- Tell code we have these members. -- Nanosecond resolution time values are supported. -- Encoding of the file mode. -- File types. -- POSIX.1b objects. Note that these macros always evaluate to zero. But -- they do it by enforcing the correct use of the macros. -- Protection bits. end CUPS.bits_stat_h;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Text_IO; procedure Hamming is generic type Int_Type is private; Zero : Int_Type; One : Int_Type; Two : Int_Type; Three : Int_Type; Five : Int_Type; with function "mod" (Left, Right : Int_Type) return Int_Type is <>; with function "/" (Left, Right : Int_Type) return Int_Type is <>; with function "+" (Left, Right : Int_Type) return Int_Type is <>; function Get_Hamming (Position : Positive) return Int_Type; function Get_Hamming (Position : Positive) return Int_Type is function Is_Hamming (Number : Int_Type) return Boolean is Temporary : Int_Type := Number; begin while Temporary mod Two = Zero loop Temporary := Temporary / Two; end loop; while Temporary mod Three = Zero loop Temporary := Temporary / Three; end loop; while Temporary mod Five = Zero loop Temporary := Temporary / Five; end loop; return Temporary = One; end Is_Hamming; Result : Int_Type := One; Previous : Positive := 1; begin while Previous /= Position loop Result := Result + One; if Is_Hamming (Result) then Previous := Previous + 1; end if; end loop; return Result; end Get_Hamming; -- up to 2**32 - 1 function Integer_Get_Hamming is new Get_Hamming (Int_Type => Integer, Zero => 0, One => 1, Two => 2, Three => 3, Five => 5); -- up to 2**64 - 1 function Long_Long_Integer_Get_Hamming is new Get_Hamming (Int_Type => Long_Long_Integer, Zero => 0, One => 1, Two => 2, Three => 3, Five => 5); begin Ada.Text_IO.Put ("1) First 20 Hamming numbers: "); for I in 1 .. 20 loop Ada.Text_IO.Put (Integer'Image (Integer_Get_Hamming (I))); end loop; Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line ("2) 1_691st Hamming number: " & Integer'Image (Integer_Get_Hamming (1_691))); -- even Long_Long_Integer overflows here Ada.Text_IO.Put_Line ("3) 1_000_000st Hamming number: " & Long_Long_Integer'Image (Long_Long_Integer_Get_Hamming (1_000_000))); end Hamming;
{ "source": "starcoderdata", "programming_language": "ada" }
package body AWS.Resources.Streams.Pipes is ------------ -- Append -- ------------ procedure Append (Resource : in out Stream_Type; Buffer : Stream_Element_Array; Trim : Boolean := False) is Lock : Lock_Type (Resource.Guard'Access) with Warnings => Off; begin if Resource.Has_Read then Streams.Memory.Stream_Type (Resource).Append (Buffer, Trim); Resource.Has_Write := True; end if; end Append; ------------ -- Append -- ------------ procedure Append (Resource : in out Stream_Type; Buffer : Stream_Element_Access) is Lock : Lock_Type (Resource.Guard'Access) with Warnings => Off; begin if Resource.Has_Read then Streams.Memory.Stream_Type (Resource).Append (Buffer); Resource.Has_Write := True; end if; end Append; ------------ -- Append -- ------------ procedure Append (Resource : in out Stream_Type; Buffer : Buffer_Access) is Lock : Lock_Type (Resource.Guard'Access) with Warnings => Off; begin if Resource.Has_Read then Streams.Memory.Stream_Type (Resource).Append (Buffer); Resource.Has_Write := True; end if; end Append; ---------- -- Read -- ---------- overriding procedure Read (Resource : in out Stream_Type; Buffer : out Stream_Element_Array; Last : out Stream_Element_Offset) is Lock : Lock_Type (Resource.Guard'Access) with Warnings => Off; begin Resource.Has_Read := True; while not Resource.Has_Write loop delay 0.01; end loop; Streams.Memory.Stream_Type (Resource).Read (Buffer, Last); end Read; ----------------- -- End_Of_File -- ----------------- overriding function End_Of_File (Resource : Stream_Type) return Boolean is begin return Streams.Memory.Stream_Type (Resource).End_Of_File; end End_Of_File; ----------- -- Clear -- ----------- procedure Clear (Resource : in out Stream_Type) is Lock : Lock_Type (Resource.Guard'Access) with Warnings => Off; begin Streams.Memory.Stream_Type (Resource).Clear; end Clear; ----------- -- Close -- ----------- overriding procedure Close (Resource : in out Stream_Type) is Lock : Lock_Type (Resource.Guard'Access) with Warnings => Off; begin Streams.Memory.Stream_Type (Resource).Close; end Close; ---------------- -- Initialize -- ---------------- procedure Initialize (Object : in out Lock_Type) is begin OBJECT.Guard.Seize; end Initialize; -------------- -- Finalize -- -------------- procedure Finalize (Object : in out Lock_Type) is begin OBJECT.Guard.Release; end Finalize; end AWS.Resources.Streams.Pipes;
{ "source": "starcoderdata", "programming_language": "ada" }
pragma Ada_2012; -- with Ada.Text_Io; use Ada.Text_Io; package body Protypo.Api.Engine_Values.Constant_Wrappers is ---------------- -- To_Handler -- ---------------- function To_Handler_Value (Value : Engine_Value) return Handler_Value is begin if Value in Handler_Value then return value; else declare Result : constant Engine_Value := Handlers.Create (Handlers.Constant_Interface_Access (Make_Wrapper (Value))); begin -- Put_Line (Result.Class'Image); -- Put_Line (Boolean'image(Result.Class in Handler_Classes)); -- Put_Line (Boolean'Image (Result in Handler_Value)); return Result; end; end if; end To_Handler_Value; end Protypo.Api.Engine_Values.Constant_Wrappers;
{ "source": "starcoderdata", "programming_language": "ada" }
-- generic type Element is private; type Buffer_Index is mod <>; package Generic_Realtime_Buffer is pragma Elaborate_Body; type Realtime_Buffer is private; procedure Put (B : in out Realtime_Buffer; Item : Element); procedure Get (B : in out Realtime_Buffer; Item : out Element); function Element_Available (B : Realtime_Buffer) return Boolean; Calling_Get_On_Empty_Buffer : exception; private type No_Of_Elements is new Natural range 0 .. Natural (Buffer_Index'Last) + 1; type Buffer_Array is array (Buffer_Index) of Element; type Realtime_Buffer is record Write_To, Read_From : Buffer_Index := Buffer_Index'First; Elements_In_Buffer : No_Of_Elements := 0; Buffer : Buffer_Array; end record; end Generic_Realtime_Buffer;
{ "source": "starcoderdata", "programming_language": "ada" }
with Text_IO; with Ada.Command_Line; with AWS.Client; with AWS.Headers; with AWS.Response; with AWS.Messages; use AWS.Messages; procedure main is hdrs : AWS.Headers.List := AWS.Headers.Empty_List; server_url : constant String := Ada.Command_Line.Argument(1); player_key : constant String := Ada.Command_Line.Argument(2); result : AWS.Response.Data; status : AWS.Messages.Status_Code; begin Text_IO.Put_Line("ServerURL: " & server_url & ", PlayerKey: " & player_key); AWS.Headers.Add(hdrs, "Content-Type", "text/plain"); result := AWS.Client.Post(URL => server_url, Data => player_key, Headers => hdrs); status := AWS.Response.Status_Code(result); if status = AWS.Messages.S200 then Text_IO.Put_Line("Server response: " & AWS.Response.Message_Body(result)); else Text_IO.Put_Line("Unexpected server response:"); Text_IO.Put_Line("HTTP code: " & AWS.Messages.Image(status) & " (" & AWS.Messages.Reason_Phrase(status) & ")"); Text_IO.Put_Line("Response body: " & AWS.Response.Message_Body(result)); Ada.Command_Line.Set_Exit_Status(2); end if; end main;
{ "source": "starcoderdata", "programming_language": "ada" }
--* -- OBJECTIVE: -- CHECK THAT AN IMPLICIT DECLARATION OF A PREDEFINED OPERATOR OR -- AN ENUMERATION LITERAL IS HIDDEN BY A DERIVED SUBPROGRAM -- HOMOGRAPH. -- HISTORY: -- VCL 08/10/88 CREATED ORIGINAL TEST. WITH REPORT; USE REPORT; PROCEDURE C83032A IS BEGIN TEST ("C83032A", "AN IMPLICIT DECLARATION OF A PREDEFINED " & "OPERATOR OR AN ENUMERATION LITERAL IS HIDDEN " & "BY A DERIVED SUBPROGRAM HOMOGRAPH"); DECLARE -- CHECK PREDEFINED OPERATOR. PACKAGE P IS TYPE INT IS RANGE -20 .. 20; FUNCTION "ABS" (X : INT) RETURN INT; END P; USE P; TYPE NINT IS NEW INT; I2 : NINT := -5; PACKAGE BODY P IS I1 : NINT := 5; FUNCTION "ABS" (X : INT) RETURN INT IS BEGIN RETURN INT (- (ABS (INTEGER (X)))); END "ABS"; BEGIN IF "ABS"(I1) /= -5 THEN FAILED ("INCORRECT VALUE FOR 'I1' AFTER CALL " & "TO DERIVED ""ABS"" - 1"); END IF; I1 := ABS (-10); IF ABS I1 /= NINT(IDENT_INT (-10)) THEN FAILED ("INCORRECT VALUE FOR 'I1' AFTER CALL " & "TO DERIVED ""ABS"" - 2"); END IF; END P; BEGIN IF "ABS"(I2) /= -5 THEN FAILED ("INCORRECT VALUE FOR 'I2' AFTER CALL " & "TO DERIVED ""ABS"" - 1"); END IF; I2 := ABS (10); IF ABS I2 /= NINT (IDENT_INT (-10)) THEN FAILED ("INCORRECT VALUE FOR 'I1' AFTER CALL " & "TO DERIVED ""ABS"" - 2"); END IF; END; DECLARE -- CHECK ENUMERATION LITERALS. PACKAGE P1 IS TYPE ENUM1 IS (E11, E12, E13); TYPE PRIV1 IS PRIVATE; FUNCTION E11 RETURN PRIV1; PRIVATE TYPE PRIV1 IS NEW ENUM1; TYPE NPRIV1 IS NEW PRIV1; END P1; USE P1; PACKAGE BODY P1 IS FUNCTION E11 RETURN PRIV1 IS BEGIN RETURN E13; END E11; BEGIN IF NPRIV1'(E11) /= E13 THEN FAILED ("INCORRECT VALUE FOR E11"); END IF; END P1; BEGIN NULL; END; RESULT; END C83032A;
{ "source": "starcoderdata", "programming_language": "ada" }
package Progress_Indicators.Work_Trackers is -- Tracker used in the tracking of homogenous groups of work farmed out to -- many tasks. The goal is to track the amount of outstanding elements to -- process, without caring too much about any individual element of work. type Status_Report is record Completed : Natural := 0; Total : Natural := 0; end record; protected type Work_Tracker is procedure Start_Work (Amount : Natural); procedure Finish_Work (Amount : Natural); function Report return Status_Report; private Current : Status_Report; end Work_Tracker; end Progress_Indicators.Work_Trackers;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Numerics.Long_Elementary_Functions; with Ada.Text_IO; use Ada.Text_IO; procedure Sequence_Of_Non_Squares_Test is use Ada.Numerics.Long_Elementary_Functions; function Non_Square (N : Positive) return Positive is begin return N + Positive (Long_Float'Rounding (Sqrt (Long_Float (N)))); end Non_Square; I : Positive; begin for N in 1..22 loop -- First 22 non-squares Put (Natural'Image (Non_Square (N))); end loop; New_Line; for N in 1..1_000_000 loop -- Check first million of I := Non_Square (N); if I = Positive (Sqrt (Long_Float (I)))**2 then Put_Line ("Found a square:" & Positive'Image (N)); end if; end loop; end Sequence_Of_Non_Squares_Test;
{ "source": "starcoderdata", "programming_language": "ada" }
pragma Ada_2012; with Protypo.Api.Engine_Values.Parameter_Lists; use Protypo.Api.Engine_Values.Parameter_Lists; package body User_Records is --------------- -- Split_Bit -- --------------- function Split_Bit (Params : Protypo.Api.Engine_Values.Engine_Value_Vectors.Vector) return Protypo.Api.Engine_Values.Engine_Value_Vectors.Vector is use Protypo.Api.Engine_Values; Parameters : Parameter_List := Create (Params); X : constant Integer := Get_Integer (Shift (Parameters)); Y : constant Integer := Get_Integer (Shift (Parameters), 2); Result : Engine_Value_Vectors.Vector; begin Result (1) := Create (X / Y); Result (2) := Create (X mod Y); return Result; end Split_Bit; end User_Records;
{ "source": "starcoderdata", "programming_language": "ada" }
With EPL.Types, EPL.Bracket, Ada.Strings.Fixed; Separate (Risi_Script.Types.Patterns) Package Body Conversions is Function Trimmed_Image( Input : Integer ) return String is Use Ada.Strings.Fixed, Ada.Strings; Begin return Trim(Side => Left, Source => Integer'Image(Input)); End Trimmed_Image; ------------------------- -- PATTERN TO STRING -- ------------------------- Function Convert( Pattern : Half_Pattern ) return String is Begin Return Result : String(Pattern'Range) do for Index in Result'Range loop Result(Index):= +Pattern(Index); end loop; End Return; End Convert; Function Convert( Pattern : Three_Quarter_Pattern ) return String is Function Internal_Convert( Pattern : Three_Quarter_Pattern ) return String is Subtype Tail is Positive Range Positive'Succ(Pattern'First)..Pattern'Last; Begin if Pattern'Length not in Positive then return ""; else Declare Head : Enumeration_Length renames Pattern(Pattern'First).All; Sigil : constant Character := +Head.Enum; Length : constant String := (if Head.Enum not in RT_String | RT_Array | RT_Hash then "" else '(' & Trimmed_Image(Head.Length) & ')'); Begin return Sigil & Length & String'(+Pattern(Tail)); End; end if; End Internal_Convert; Result : constant String := Internal_Convert( Pattern ); Parens : constant Boolean := Ada.Strings.Fixed.Index(Result, "(") in Positive; Begin Return ""; -- Return (if Parens then Result else ) End Convert; Function Convert( Pattern : Full_Pattern ) return String is (""); Function Convert( Pattern : Extended_Pattern ) return String is (""); Function Convert( Pattern : Square_Pattern ) return String is (""); Function Convert( Pattern : Cubic_Pattern ) return String is (""); Function Convert( Pattern : Power_Pattern ) return String is (""); ------------------------- -- STRING TO PATTERN -- ------------------------- -- Function Convert( Text : String ) return Half_Pattern is (""); -- Function Convert( Text : String ) return Three_Quarter_Pattern is (""); -- Function Convert( Text : String ) return Full_Pattern is (""); -- Function Convert( Text : String ) return Extended_Pattern is (""); -- Function Convert( Text : String ) return Square_Pattern is (""); -- Function Convert( Text : String ) return Cubic_Pattern is (""); -- Function Convert( Text : String ) return Power_Pattern is (""); -- -- Function "+"( Pattern : Half_Pattern ) return String is -- Subtype Tail is Positive Range Positive'Succ(Pattern'First)..Pattern'Last; -- begin -- if Pattern'Length not in Positive then -- return ""; -- else -- Declare -- Head : Enumeration renames Pattern(Pattern'First); -- Sigil : constant Character := +(+Head); -- Begin -- return Sigil & String'(+Pattern(Tail)); -- End; -- end if; -- end "+"; -- -- -- Function "+"( Text : String ) return Half_Pattern is -- Subtype Tail is Positive Range Positive'Succ(Text'First)..Text'Last; -- begin -- if Text'Length not in Positive then -- return (2..1 => <>); -- else -- Declare -- Element : constant Enumeration:= +(+Text(Text'First)); -- Begin -- return Element & (+Text(Tail)); -- End; -- end if; -- end "+"; End Conversions;
{ "source": "starcoderdata", "programming_language": "ada" }
------------------------------------------------------------------------ -- AMD Élan(tm) SC 520 embedded microprocessor -- -- MMCR -> SDRAM Controller Registers -- -- -- -- reference: Register Set Manual Chapter 7 -- ------------------------------------------------------------------------ with Elan520.Basic_Types; package Elan520.SDRAM_Controller_Registers is --------------------------------------------------------------------- -- SDRAM Control (DRCCTL) -- -- Memory Mapped, Read/Write -- -- MMCR Offset 10h -- --------------------------------------------------------------------- --------------------------------------------------------------------- -- sub types for SDRAM_Control type Operation_Mode_Select is (Normal, NOP_Command, All_Banks_Precharge, Load_Mode_Register, Auto_Refresh); for Operation_Mode_Select use (Normal => 2#000#, NOP_Command => 2#001#, All_Banks_Precharge => 2#010#, Load_Mode_Register => 2#100#, Auto_Refresh => 2#101#); for Operation_Mode_Select'Size use 3; DEFAULT_OPERATION_MODE_SELECT : constant Operation_Mode_Select := Normal; -- unit is 7.8 microseconds type Refresh_Request_Speed is range 1 .. 4; for Refresh_Request_Speed'Size use 2; DEFAULT_REFRESH_REQUEST_SPEED : constant Refresh_Request_Speed := 2; --------------------------------------------------------------------- -- SDRAM Control at MMCR offset 16#10# --------------------------------------------------------------------- MMCR_OFFSET_SDRAM_CONTROL : constant := 16#10#; SDRAM_CONTROL_SIZE : constant := 8; type SDRAM_Control is record Op_Mode_Sel : Operation_Mode_Select; Rfsh : Basic_Types.Positive_Bit; Rfsh_Spd : Refresh_Request_Speed; Wb_Tst : Basic_Types.Positive_Bit; end record; for SDRAM_Control use record Op_Mode_Sel at 0 range 0 .. 2; Rfsh at 0 range 3 .. 3; Rfsh_Spd at 0 range 4 .. 5; -- bit 6 is reserved Wb_Tst at 0 range 7 .. 7; end record; for SDRAM_Control'Size use SDRAM_CONTROL_SIZE; --------------------------------------------------------------------- -- SDRAM Timing Control (DRCTMCTL) -- -- Memory Mapped, Read/Write -- -- MMCR Offset 12h -- --------------------------------------------------------------------- --------------------------------------------------------------------- -- subtypes for SDRAM Timing Contol type RAS_CAS_Delay is range 2 .. 4; for RAS_CAS_Delay'Size use 2; DEFAULT_RAS_CAS_DELAY : constant RAS_CAS_Delay := 4; type RAS_Precharge_Delay is (Two_Cycles, Three_Cycles, Four_Cycles, Six_Cycles); for RAS_Precharge_Delay use (Two_Cycles => 2#00#, Three_Cycles => 2#01#, Four_Cycles => 2#10#, Six_Cycles => 2#11#); for RAS_Precharge_Delay'Size use 2; DEFAULT_RAS_PRECHARGE_DELAY : constant RAS_Precharge_Delay := Four_Cycles; type CAS_Latency is range 2 .. 3; for CAS_Latency'Size use 1; DEFAULT_CAS_LATENCY : constant CAS_Latency := 3; --------------------------------------------------------------------- -- SDRAM Timing Control at MMCR offset 16#12# --------------------------------------------------------------------- MMCR_OFFSET_SDRAM_TIMING_CONTROL : constant := 16#12#; SDRAM_TIMING_CONTROL_SIZE : constant := 8; type SDRAM_Timing_Control is record Ras_Cas_Dly : RAS_CAS_Delay; Ras_Pchg_Dly : RAS_Precharge_Delay; Cas_Lat : CAS_Latency; end record; for SDRAM_Timing_Control use record Ras_Cas_Dly at 0 range 0 .. 1; Ras_Pchg_Dly at 0 range 2 .. 3; Cas_Lat at 0 range 4 .. 4; -- bits 5-7 are reserved end record; for SDRAM_Timing_Control'Size use SDRAM_TIMING_CONTROL_SIZE; --------------------------------------------------------------------- -- SDRAM Bank Configuration (DRCCFG) -- -- Memory Mapped, Read/Write -- -- MMCR Offset 14h -- --------------------------------------------------------------------- --------------------------------------------------------------------- -- subtypes for SDRAM Bank Configuration type Bank_Count is (Two_Bank_Device, Four_Bank_Device); for Bank_Count use (Two_Bank_Device => 0, Four_Bank_Device => 1); for Bank_Count'Size use 1; type Column_Address_Width is range 8 .. 11; for Column_Address_Width'Size use 2; type Bank_Descriptor is record Col_Width : Column_Address_Width; Bnk_Cnt : Bank_Count; end record; for Bank_Descriptor use record Col_Width at 0 range 0 .. 1; -- bit 2 is reserved Bnk_Cnt at 0 range 3 .. 3; end record; for Bank_Descriptor'Size use 4; --------------------------------------------------------------------- -- SDRAM Bank Configuration at MMCR offset 16#14# --------------------------------------------------------------------- MMCR_OFFSET_SDRAM_BANK_CONFIGURATION : constant := 16#14#; SDRAM_BANK_CONFIGURATION_SIZE : constant := 16; type SDRAM_Bank_Configuration is record Bnk0 : Bank_Descriptor; Bnk1 : Bank_Descriptor; Bnk2 : Bank_Descriptor; Bnk3 : Bank_Descriptor; end record; for SDRAM_Bank_Configuration use record Bnk0 at 0 range 0 .. 3; Bnk1 at 0 range 4 .. 7; Bnk2 at 0 range 8 .. 11; Bnk3 at 0 range 12 .. 15; end record; for SDRAM_Bank_Configuration'Size use SDRAM_BANK_CONFIGURATION_SIZE; --------------------------------------------------------------------- -- SDRAM Bank 0 - 3 Ending Address (DRCBENDADR) -- -- Memory Mapped, Read/Write -- -- MMCR Offset 18h -- --------------------------------------------------------------------- --------------------------------------------------------------------- -- subtypes for SDRAM Bank Ending Address type Ending_Address is range 0 .. 2**7 - 1; type Ending_Address_Descriptor is record End_Address : Ending_Address; Bnk : Basic_Types.Positive_Bit; end record; for Ending_Address_Descriptor use record End_Address at 0 range 0 .. 6; Bnk at 0 range 7 .. 7; end record; for Ending_Address_Descriptor'Size use 8; --------------------------------------------------------------------- -- SDRAM Bank Ending Address at MMCR offset 16#18# --------------------------------------------------------------------- MMCR_OFFSET_SDRAM_BANK_ENDING_ADDRESS : constant := 16#18#; SDRAM_BANK_ENDING_ADDRESS_SIZE : constant := 32; type SDRAM_Bank_Ending_Address is record Bnk0 : Ending_Address_Descriptor; Bnk1 : Ending_Address_Descriptor; Bnk2 : Ending_Address_Descriptor; Bnk3 : Ending_Address_Descriptor; end record; for SDRAM_Bank_Ending_Address use record Bnk0 at 0 range 0 .. 7; Bnk1 at 0 range 8 .. 15; Bnk2 at 0 range 16 .. 23; Bnk3 at 0 range 24 .. 31; end record; for SDRAM_Bank_Ending_Address'Size use SDRAM_BANK_ENDING_ADDRESS_SIZE; --------------------------------------------------------------------- -- ECC Control (ECCCTL) -- -- Memory Mapped, Read/Write -- -- MMCR Offset 20h -- --------------------------------------------------------------------- --------------------------------------------------------------------- -- ECC Control at MMCR offset 16#20# --------------------------------------------------------------------- MMCR_OFFSET_ECC_CONTROL : constant := 16#20#; ECC_CONTROL_SIZE : constant := 8; type ECC_Control is record ECC_All : Basic_Types.Positive_Bit; Single_Bit_Interrupt : Basic_Types.Positive_Bit; Multi_Bit_Interrupt : Basic_Types.Positive_Bit; end record; for ECC_Control use record ECC_All at 0 range 0 .. 0; Single_Bit_Interrupt at 0 range 1 .. 1; Multi_Bit_Interrupt at 0 range 2 .. 2; -- bits 3 to 7 are reserved end record; for ECC_Control'Size use ECC_CONTROL_SIZE; --------------------------------------------------------------------- -- ECC Status (ECCSTA) -- -- Memory Mapped, Read/Write -- -- MMCR Offset 21h -- --------------------------------------------------------------------- --------------------------------------------------------------------- -- ECC Status at MMCR offset 16#21# --------------------------------------------------------------------- MMCR_OFFSET_ECC_STATUS : constant := 16#21#; ECC_STATUS_SIZE : constant := 8; type ECC_Status is record Single_Bit_Error : Basic_Types.Positive_Bit; Multi_Bit_Error : Basic_Types.Positive_Bit; end record; for ECC_Status use record Single_Bit_Error at 0 range 0 .. 0; Multi_Bit_Error at 0 range 1 .. 1; -- bits 2 to 7 are reserved end record; for ECC_Status'Size use ECC_STATUS_SIZE; --------------------------------------------------------------------- -- ECC Check Bit Position (ECCCKBPOS) -- -- Memory Mapped, Read Only -- -- MMCR Offset 22h -- --------------------------------------------------------------------- --------------------------------------------------------------------- -- ECC Status at MMCR offset 16#22# --------------------------------------------------------------------- MMCR_OFFSET_ECC_CHECK_BIT_POSITION : constant := 16#22#; ECC_CHECK_BIT_POSITION_SIZE : constant := 8; type ECC_Check_Bit_Position is range 0 .. 38; for ECC_Check_Bit_Position'Size use ECC_CHECK_BIT_POSITION_SIZE; --------------------------------------------------------------------- -- ECC Check Code Test (ECCCKTEST) -- -- Memory Mapped, Read/Write -- -- MMCR Offset 23h -- --------------------------------------------------------------------- --------------------------------------------------------------------- -- subtypes for ECC Check Code Test type Forced_ECC_Check_Bits is range 0 .. 2**7 - 1; --------------------------------------------------------------------- -- ECC Check Code Test at MMCR offset 16#23# --------------------------------------------------------------------- MMCR_OFFSET_ECC_CHECK_CODE_TEST : constant := 16#23#; ECC_CHECK_CODE_TEST_SIZE : constant := 8; type ECC_Check_Code_Test is record Force_Bad_ECC_Check_Bits : Forced_ECC_Check_Bits; Bad_Check : Basic_Types.Positive_Bit; end record; for ECC_Check_Code_Test use record Force_Bad_ECC_Check_Bits at 0 range 0 .. 6; Bad_Check at 0 range 7 .. 7; end record; for ECC_Check_Code_Test'Size use ECC_CHECK_CODE_TEST_SIZE; --------------------------------------------------------------------- -- subtypes for error addresses (single & multi-bit) type Error_Address is range 0 .. 2**26 - 1; --------------------------------------------------------------------- -- ECC Single-Bit Error Address (ECCSBADD) -- -- Memory Mapped, Read Only -- -- MMCR Offset 24h -- --------------------------------------------------------------------- MMCR_OFFSET_ECC_SINGLE_BIT_ERROR_ADDRESS : constant := 16#24#; ECC_SINGLE_BIT_ERROR_ADDRESS_SIZE : constant := 32; type ECC_Single_Bit_Error_Address is record SB_Addr : Error_Address; end record; for ECC_Single_Bit_Error_Address use record SB_Addr at 0 range 2 .. 27; end record; --------------------------------------------------------------------- -- ECC Multi-Bit Error Address (ECCMBADD) -- -- Memory Mapped, Read Only -- -- MMCR Offset 28h -- --------------------------------------------------------------------- MMCR_OFFSET_ECC_MULTI_BIT_ERROR_ADDRESS : constant := 16#28#; ECC_MULTI_BIT_ERROR_ADDRESS_SIZE : constant := 32; type ECC_Multi_Bit_Error_Address is record MB_Addr : Error_Address; end record; for ECC_Multi_Bit_Error_Address use record MB_Addr at 0 range 2 .. 27; end record; end Elan520.SDRAM_Controller_Registers;
{ "source": "starcoderdata", "programming_language": "ada" }
-- with Ada.Unchecked_Conversion; with Interfaces; with Interfaces.C.Strings; with Interfaces.C_Streams; with Interfaces.C; with Notcurses_Thin; package Notcurses is type Notcurses_Context is private; type Notcurses_Plane is private; type Notcurses_Input is record Id : Wide_Wide_Character; Y : Interfaces.C.int; X : Interfaces.C.int; Alt : Boolean; Shift : Boolean; Ctrl : Boolean; Seqnum : Interfaces.Unsigned_64; end record; type Coordinate is record Y, X : Integer; end record; function "+" (Left, Right : Coordinate) return Coordinate; function "-" (Left, Right : Coordinate) return Coordinate; Notcurses_Error : exception; function Version return String; private package Thin renames Notcurses_Thin; type Notcurses_Context is access all Thin.notcurses; type Notcurses_Plane is access all Thin.ncplane; Default_Options : aliased Thin.notcurses_options := (termtype => Interfaces.C.Strings.Null_Ptr, renderfp => Interfaces.C_Streams.NULL_Stream, loglevel => Thin.NCLOGLEVEL_ERROR, flags => 0, others => 0); Default_Context : Notcurses_Context := null; function To_Ada is new Ada.Unchecked_Conversion (Source => Thin.ncinput, Target => Notcurses_Input); function To_C is new Ada.Unchecked_Conversion (Source => Notcurses_Input, Target => Thin.ncinput); end Notcurses;
{ "source": "starcoderdata", "programming_language": "ada" }
with OpenGL.Thin; package body OpenGL.View is -- -- Viewport specification. -- procedure Depth_Range (Near : in OpenGL.Types.Clamped_Double_t; Far : in OpenGL.Types.Clamped_Double_t) is begin Thin.Depth_Range (Near_Value => Thin.Double_t (Near), Far_Value => Thin.Double_t (Far)); end Depth_Range; procedure Viewport (Left : in Natural; Bottom : in Natural; Width : in Positive; Height : in Positive) is begin Thin.Viewport (X => Thin.Integer_t (Left), Y => Thin.Integer_t (Bottom), Width => Thin.Size_t (Width), Height => Thin.Size_t (Height)); end Viewport; end OpenGL.View;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Strings.Maps.Constants; -- NIGET TOM PEIP2-B2 -- IMPORTANT ! -- Si vous utilisez GNAT ou une vieille version d'Ada pas aux normes, -- décommentez la ligne ci-dessous et commentez celle juste après --with Ada.Strings.Unbounded_Text_IO; use Ada.Strings.Unbounded_Text_IO; with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO; procedure tp3_niget is type T_Couleur_Vin is (Rouge, Blanc, Rose); -- pour l'affichage Couleur_Vin_Aff : array (T_Couleur_Vin) of Unbounded_String := ( To_Unbounded_String("rouge"), To_Unbounded_String("blanc"), To_Unbounded_String("rosé") ); type T_Région is ( Alsace, Beaujolais, Bordeaux, Bourgogne, Chablis, Champagne, Corse, Jura, Languedoc_Roussillon, Loire, Provence, Rhone, Savoie, Sud_Ouest ); -- pour l'affichage Région_Aff : array (T_Région) of Unbounded_String := ( To_Unbounded_String("Alsace"), To_Unbounded_String("Beaujolais"), To_Unbounded_String("Bordeaux"), To_Unbounded_String("Bourgogne"), To_Unbounded_String("Chablis"), To_Unbounded_String("Champagne"), To_Unbounded_String("Corse"), To_Unbounded_String("Jura"), To_Unbounded_String("Languedoc-Roussillon"), To_Unbounded_String("Loire"), To_Unbounded_String("Provence"), To_Unbounded_String("Rhône"), To_Unbounded_String("Savoie"), To_Unbounded_String("Sud-Ouest") ); type T_Vin is record Nom : Unbounded_String; Région : T_Région; Couleur : T_Couleur_Vin; Millésime : Integer; Quantité : Natural; end record; TAILLE_CAVE : constant Positive := 40; Cave : array (1..TAILLE_CAVE) of T_Vin; subtype Pos_Vin is Integer range Cave'Range; -- nombre de cases occupées de Cave Cave_NB : Natural range 0..TAILLE_CAVE := 0; -- pose une question fermée function Choix(Msg : Unbounded_String) return Boolean is Rep : Character; begin Put(Msg & " [O/N] "); Get(Rep); return Rep = 'O' or Rep = 'o'; end Choix; -- a < b : -1 -- a = b : 0 -- a > b : 1 subtype Comparaison is Integer range -1..1; -- compare deux chaînes sans se préoccuper de la casse function Compare_Chaines(A, B : Unbounded_String) return Comparaison is X : Unbounded_String := A; Y : Unbounded_String := B; begin -- passage en minuscule pour mettre X et Y sur un pied d'égalité -- pour éviter les 'z' > 'A' et autres loufoqueries des comparateurs d'Ada Ada.Strings.Unbounded.Translate(X, Ada.Strings.Maps.Constants.Lower_Case_Map); Ada.Strings.Unbounded.Translate(Y, Ada.Strings.Maps.Constants.Lower_Case_Map); if X > Y then return 1; elsif X < Y then return -1; else return 0; end if; end Compare_Chaines; -- détermine l'emplacement où insérer un nouveau vin -- par recherche dichotomique function Indice_Correct(Q : Unbounded_String) return Pos_Vin is -- bornes A : Pos_Vin := 1; B : Pos_Vin; -- milieu de l'intervalle Mid : Pos_Vin; -- valeur à comparer Val : Unbounded_String; -- résultat de comparaison Comp : Comparaison; begin -- si la cave est vide, on insère au début if Cave_NB = 0 then return 1; else B := Cave_NB; end if; while A < B loop Mid := (A + B) / 2; Val := Cave(Mid).Nom; Comp := Compare_Chaines(Q, Val); if Comp = 0 then return Mid + 1; -- +1 pour ajouter à la fin d'une suite d'éléments équivalents et non au début elsif Comp = -1 then B := Mid; elsif Comp = 1 then if A = Mid then return B + 1; end if; A := Mid; end if; end loop; return B; end Indice_Correct; -- vérifie si la cave est vide, affiche une erreur le cas échéant function Verif_Vide return Boolean is begin if Cave_NB = 0 then Put_Line("*** La cave est vide ! ***"); return True; end if; return False; end Verif_Vide; -- affiche les caractéristiques d'un vin procedure Aff_Vin(Vin : T_Vin) is begin Put_Line(Vin.Nom & " - vin " & Couleur_Vin_Aff(Vin.Couleur) & " d'origine " & Région_Aff(Vin.Région) & ", millésime" & Integer'Image(Vin.Millésime) & ", stock :" & Integer'Image(Vin.Quantité)); end Aff_Vin; -- liste les vins procedure A_Liste_Vins is begin if Verif_Vide then return; end if; Put_Line("Il y a" & Integer'Image(Cave_NB) & " vins :"); for i in 1..Cave_NB loop Put(Integer'Image(i) & "- "); Aff_Vin(Cave(i)); end loop; end A_Liste_Vins; -- demande à l'utilisateur de choisir un vin function Choisir_Vin return Pos_Vin is N_Vin : Integer; begin A_Liste_Vins; loop Put_Line("Veuillez saisir le numéro du vin."); Put("> "); Get(N_Vin); exit when N_Vin in 1..Cave_NB; Put_Line("*** Numéro de vin incorrect ! ***"); end loop; return N_Vin; end Choisir_Vin; -- insère un vin à la position spécifiée -- pour cela, décale vers la droite celles qui sont dans le chemin procedure Insérer_Vin(Vin : T_Vin; Pos : Pos_Vin) is begin for i in reverse Pos..Cave_NB loop Cave(i + 1) := Cave(i); end loop; Cave(Pos) := Vin; Cave_NB := Cave_NB + 1; end Insérer_Vin; -- supprime le vin à la position spécifiée procedure A_Suppr_Vin(N : Integer := -1) is N_Vin : Pos_Vin; begin if N not in Pos_Vin'Range then N_Vin := Choisir_Vin; else N_Vin := N; end if; if not Choix(To_Unbounded_String("*** Cette action est irréversible ! Êtes-vous sûr(e) ? ***")) then return; end if; Put_Line("*** Suppression de " & Cave(N_Vin).Nom & " ***"); for i in N_Vin..Cave_NB loop Cave(i) := Cave(i + 1); end loop; Cave_NB := Cave_NB - 1; end A_Suppr_Vin; procedure A_Ajout_Bouteille(N : Integer := -1) is N_Vin : Pos_Vin; Quant : Positive; begin if Verif_Vide then return; end if; if N not in Pos_Vin'Range then N_Vin := Choisir_Vin; else N_Vin := N; end if; Put("Nombre de bouteilles à ajouter au stock : "); Get(Quant); Cave(N_Vin).Quantité := Cave(N_Vin).Quantité + Quant; end A_Ajout_Bouteille; -- lit et ajoute un ou plusieurs vins procedure A_Ajout_Vin is Vin : T_Vin; Ent : Integer; Existe : Boolean := False; begin loop if Cave_NB = TAILLE_CAVE then Put_Line("*** La cave est pleine ! ***"); exit; end if; -- efface le buffer d'entrée pour éviter de -- relire le retour chariot précédemment entré -- lors du choix de l'opération Skip_Line; Put_Line("Veuillez saisir les informations du vin."); Put("Nom : "); Vin.Nom := Get_Line; Existe := False; for i in Cave'Range loop if Compare_Chaines(Cave(i).Nom, Vin.Nom) = 0 then Put_Line("*** Le vin est déjà présent dans la base, entrée en mode ajout de bouteille ***"); A_Ajout_Bouteille(i); Existe := True; end if; end loop; if not Existe then for r in T_Région'Range loop Put_Line(Integer'Image(T_Région'Pos(r) + 1) & "- " & Région_Aff(r)); end loop; loop Put("Région : "); Get(Ent); exit when Ent in 1..(T_Région'Pos(T_Région'Last) + 1); Put_Line("*** Numéro de région incorrect ! ***"); end loop; Vin.Région := T_Région'Val(Ent - 1); for r in T_Couleur_Vin'Range loop Put_Line(Integer'Image(T_Couleur_Vin'Pos(r) + 1) & "- " & Couleur_Vin_Aff(r)); end loop; loop Put("Couleur : "); Get(Ent); exit when Ent in 1..(T_Couleur_Vin'Pos(T_Couleur_Vin'Last) + 1); Put_Line("*** Numéro de couleur incorrect ! ***"); end loop; Vin.Couleur := T_Couleur_Vin'Val(Ent - 1); Put("Millésime : "); Get(Vin.Millésime); Put("Quantité : "); Get(Vin.Quantité); Insérer_Vin(Vin, Indice_Correct(Vin.Nom)); end if; exit when not Choix(To_Unbounded_String("Voulez-vous ajouter un autre vin ?")); end loop; end A_Ajout_Vin; -- lit et sort une ou plusieures bouteilles procedure A_Sortir_Bouteille is N_Vin : Integer; N_Quant : Integer; begin loop if Verif_Vide then return; end if; N_Vin := Choisir_Vin; loop Put_Line("Combien de bouteilles voulez-vous sortir ?"); Put("> "); Get(N_Quant); exit when N_Quant in 1..Cave(N_Vin).Quantité; Put_Line("*** La quantité doit être entre 1 et " & Integer'Image(Cave(N_Vin).Quantité) & " ! ***"); end loop; Cave(N_Vin).Quantité := Cave(N_Vin).Quantité - N_Quant; if Cave(N_Vin).Quantité = 0 then Put_Line("*** Le vin est en rupture de stock ***"); if Choix(To_Unbounded_String("*** Voulez-vous le supprimer de la base ? ***")) then A_Suppr_Vin(N_Vin); end if; end if; A_Liste_Vins; exit when not Choix(To_Unbounded_String("Voulez-vous sortir une autre bouteille ?")); end loop; end A_Sortir_Bouteille; Action : Character; begin -- mettre à True pour charger des données d'exemple -- pour ne pas avoir à tout saisir à la main if True then Cave := ( (To_Unbounded_String("Beaujolais AOC"),Beaujolais,Rouge,2000,7), (To_Unbounded_String("Chablis AOC"),Bourgogne,Blanc,2017,11), (To_Unbounded_String("Côtes de Provence"),Provence,Rose,1999,11), (To_Unbounded_String("Saint-Emilion"),Bordeaux,Rouge,2003,3), others => <> ); Cave_NB := 4; end if; loop -- affichage du menu Put_Line("Choisissez une opération à effectuer :"); Put_Line(" 1- Ajouter un vin"); Put_Line(" 2- Supprimer un vin"); Put_Line(" 3- Ajouter une bouteille"); Put_Line(" 4- Sortir une bouteille"); Put_Line(" 5- Afficher la liste des vins"); Put_Line(" 6- Quitter"); Put("> "); Get(Action); New_Line; case Action is when '1' => A_Ajout_Vin; when '2' => A_Suppr_Vin; when '3' => A_Ajout_Bouteille; when '4' => A_Sortir_Bouteille; when '5' => A_Liste_Vins; when '6' => exit; when others => Put_Line("*** Numéro d'opération incorrect ! ***"); end case; New_Line; end loop; end tp3_niget;
{ "source": "starcoderdata", "programming_language": "ada" }
with Interfaces; use Interfaces; with HIL; -- @summary -- read/write from/to a non-volatile location. Every "variable" -- has one byte. When the compilation date/time changed, all -- variables are reset to their respective defaults. Otherwise -- NVRAM keeps values across reboot/loss of power. package NVRAM with SPARK_Mode, Abstract_State => Memory_State is procedure Init; -- initialize this module and possibly underlying hardware procedure Self_Check (Status : out Boolean); -- check whether initialization was successful -- List of all variables stored in NVRAM. Add new ones when needed. type Variable_Name is (VAR_MISSIONSTATE, VAR_BOOTCOUNTER, VAR_EXCEPTION_LINE_L, VAR_EXCEPTION_LINE_H, VAR_START_TIME_A, VAR_START_TIME_B, VAR_START_TIME_C, VAR_START_TIME_D, VAR_HOME_HEIGHT_L, VAR_HOME_HEIGHT_H, VAR_GPS_TARGET_LONG_A, VAR_GPS_TARGET_LONG_B, VAR_GPS_TARGET_LONG_C, VAR_GPS_TARGET_LONG_D, VAR_GPS_TARGET_LAT_A, VAR_GPS_TARGET_LAT_B, VAR_GPS_TARGET_LAT_C, VAR_GPS_TARGET_LAT_D, VAR_GPS_TARGET_ALT_A, VAR_GPS_TARGET_ALT_B, VAR_GPS_TARGET_ALT_C, VAR_GPS_TARGET_ALT_D, VAR_GPS_LAST_LONG_A, VAR_GPS_LAST_LONG_B, VAR_GPS_LAST_LONG_C, VAR_GPS_LAST_LONG_D, VAR_GPS_LAST_LAT_A, VAR_GPS_LAST_LAT_B, VAR_GPS_LAST_LAT_C, VAR_GPS_LAST_LAT_D, VAR_GPS_LAST_ALT_A, VAR_GPS_LAST_ALT_B, VAR_GPS_LAST_ALT_C, VAR_GPS_LAST_ALT_D, VAR_GYRO_BIAS_X, VAR_GYRO_BIAS_Y, VAR_GYRO_BIAS_Z ); -- Default values for all variables (obligatory) type Defaults_Table is array (Variable_Name'Range) of HIL.Byte; Variable_Defaults : constant Defaults_Table := (VAR_MISSIONSTATE => 0, VAR_BOOTCOUNTER => 0, VAR_EXCEPTION_LINE_L => 0, VAR_EXCEPTION_LINE_H => 0, VAR_START_TIME_A => 0, VAR_START_TIME_B => 0, VAR_START_TIME_C => 0, VAR_START_TIME_D => 0, VAR_HOME_HEIGHT_L => 0, VAR_HOME_HEIGHT_H => 0, VAR_GPS_TARGET_LONG_A => 0, VAR_GPS_TARGET_LONG_B => 0, VAR_GPS_TARGET_LONG_C => 0, VAR_GPS_TARGET_LONG_D => 0, VAR_GPS_TARGET_LAT_A => 0, VAR_GPS_TARGET_LAT_B => 0, VAR_GPS_TARGET_LAT_C => 0, VAR_GPS_TARGET_LAT_D => 0, VAR_GPS_TARGET_ALT_A => 0, VAR_GPS_TARGET_ALT_B => 0, VAR_GPS_TARGET_ALT_C => 0, VAR_GPS_TARGET_ALT_D => 0, VAR_GPS_LAST_LONG_A => 0, VAR_GPS_LAST_LONG_B => 0, VAR_GPS_LAST_LONG_C => 0, VAR_GPS_LAST_LONG_D => 0, VAR_GPS_LAST_LAT_A => 0, VAR_GPS_LAST_LAT_B => 0, VAR_GPS_LAST_LAT_C => 0, VAR_GPS_LAST_LAT_D => 0, VAR_GPS_LAST_ALT_A => 0, VAR_GPS_LAST_ALT_B => 0, VAR_GPS_LAST_ALT_C => 0, VAR_GPS_LAST_ALT_D => 0, VAR_GYRO_BIAS_X => 20, -- Bias in deci degree VAR_GYRO_BIAS_Y => 26, VAR_GYRO_BIAS_Z => 128-3+128 -- most evil hack ever ); procedure Load (variable : in Variable_Name; data : out HIL.Byte); -- read variable with given name from NVRAM and return value procedure Load (variable : in Variable_Name; data : out Float) with Pre => Variable_Name'Pos (variable) < Variable_Name'Pos (Variable_Name'Last) - 3; -- same, but with Float convenience conversion. Point to first variable of the quadrupel. procedure Store (variable : in Variable_Name; data : in HIL.Byte); -- write variable with given name to NVRAM. procedure Store (variable : in Variable_Name; data : in Float) with Pre => Variable_Name'Pos (variable) < Variable_Name'Pos (Variable_Name'Last) - 3; -- same, but with Float convenience conversion. Point to first variable of the quadrupel. procedure Reset; -- explicit reset of NVRAM to defaults; same effect as re-compiling. end NVRAM;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Exceptions; with Ada.Strings.Equal_Case_Insensitive; with Ada.Text_IO; with Extraction.Bodies_For_Decls; with Extraction.Bodies_For_Entries; with Extraction.Decls; with Extraction.Deferred_Constants; with Extraction.Derived_Type_Defs; with Extraction.Direct_Calls; with Extraction.File_System; with Extraction.Generic_Instantiations; with Extraction.Graph_Operations; with Extraction.Node_Edge_Types; with Extraction.Primitive_Subps; with Extraction.Project_Files; with Extraction.References_Of_Decls; with Extraction.Renamings; with Extraction.Source_Files_From_Projects; with Extraction.Subp_Overrides; with Extraction.Decl_Types; with Extraction.Utilities; with Extraction.With_Clauses; package body Extraction is -- TODO: Improve node naming such that line numbers are not needed -- TODO: Relate arguments in generic instantiations with formal parameters -- of generics use type VFS.Filesystem_String; use type VFS.Virtual_File; function Node_Attributes return GW.Attribute_Definition_Sets.Map renames Node_Edge_Types.Node_Attributes; function Edge_Attributes return GW.Attribute_Definition_Sets.Map renames Node_Edge_Types.Edge_Attributes; procedure Extract_Dependency_Graph (Project_Filename : String; Recurse_Projects : Boolean; Directory_Prefix : VFS.Virtual_File; Graph_File : in out GW.GraphML_File) is Context : constant Utilities.Project_Context := Utilities.Open_Project (Project_Filename); Projects : constant Utilities.Project_Vectors.Vector := Utilities.Get_Projects (Context, Recurse_Projects); Units : constant Utilities.Analysis_Unit_Vectors.Vector := Utilities.Open_Analysis_Units (Context, Recurse_Projects); Graph : constant Graph_Operations.Graph_Context := Graph_Operations.Create_Graph_Context (Graph_File'Unchecked_Access, Directory_Prefix, Context); procedure Handle_Exception (E : Ada.Exceptions.Exception_Occurrence; Node : LAL.Ada_Node'Class); procedure Handle_Exception (E : Ada.Exceptions.Exception_Occurrence; Node : LAL.Ada_Node'Class) is Message : constant String := Ada.Exceptions.Exception_Message (E); begin if not Ada.Strings.Equal_Case_Insensitive (Message, "memoized error") then Ada.Text_IO.Put_Line ("Encountered Libadalang problem: " & Message); Node.Print; end if; end Handle_Exception; function Node_Visitor (Node : LAL.Ada_Node'Class) return LALCO.Visit_Status; function Node_Visitor (Node : LAL.Ada_Node'Class) return LALCO.Visit_Status is begin -- TODO: Remove exception block once all libadalang problems -- have been fixed. begin Decls.Extract_Nodes (Node, Graph); Subp_Overrides.Extract_Nodes (Node, Graph); Primitive_Subps.Extract_Nodes (Node, Graph); References_Of_Decls.Extract_Nodes (Node, Graph); exception when E : LALCO.Property_Error => Handle_Exception (E, Node); end; return LALCO.Into; end Node_Visitor; function Edge_Visitor (Node : LAL.Ada_Node'Class) return LALCO.Visit_Status; function Edge_Visitor (Node : LAL.Ada_Node'Class) return LALCO.Visit_Status is begin -- TODO: Remove exception block once all libadalang problems -- have been fixed. begin Decls.Extract_Edges (Node, Graph); Subp_Overrides.Extract_Edges (Node, Graph); Primitive_Subps.Extract_Edges (Node, Graph); Generic_Instantiations.Extract_Edges (Node, Graph); References_Of_Decls.Extract_Edges (Node, Graph); Bodies_For_Decls.Extract_Edges (Node, Graph); Bodies_For_Entries.Extract_Edges (Node, Graph); Renamings.Extract_Edges (Node, Graph); Direct_Calls.Extract_Edges (Node, Graph); With_Clauses.Extract_Edges (Node, Graph); Derived_Type_Defs.Extract_Edges (Node, Graph); Decl_Types.Extract_Edges (Node, Graph); Deferred_Constants.Extract_Edges (Node, Graph); exception when E : LALCO.Property_Error => Handle_Exception (E, Node); end; return LALCO.Into; end Edge_Visitor; begin -- Node extraction -- File_System.Extract_Nodes should occur before the extraction of any -- other kind of node (see also the implementation of -- Get_Node_Attributes in Extraction.Node_Edge_Types). if Directory_Prefix /= VFS.No_File then File_System.Extract_Nodes (Directory_Prefix, Graph); end if; for Project of Projects loop Ada.Text_IO.Put_Line ("-- " & (+Project.Project_Path.Full_Name) & " --"); Project_Files.Extract_Nodes (Project, Graph); Source_Files_From_Projects.Extract_Nodes (Project, Graph); end loop; for Unit of Units loop Ada.Text_IO.Put_Line ("-- " & Unit.Get_Filename & " --"); Unit.Root.Traverse (Node_Visitor'Access); end loop; -- Edge extraction. if Directory_Prefix /= VFS.No_File then File_System.Extract_Edges (Directory_Prefix, Graph); end if; for Project of Projects loop Ada.Text_IO.Put_Line ("== " & (+Project.Project_Path.Full_Name) & " =="); Project_Files.Extract_Edges (Project, Recurse_Projects, Graph); Source_Files_From_Projects.Extract_Edges (Project, Context, Recurse_Projects, Graph); end loop; for Unit of Units loop Ada.Text_IO.Put_Line ("== " & Unit.Get_Filename & " =="); Unit.Root.Traverse (Edge_Visitor'Access); end loop; end Extract_Dependency_Graph; end Extraction;
{ "source": "starcoderdata", "programming_language": "ada" }
-- ****h* Bases/BTrade -- FUNCTION -- Provide code for hiring recruits, buying recipes, heal and train crew -- members in bases. -- SOURCE package Bases.Trade is -- **** -- ****e* BTrade/BTrade.Trade_Already_Known -- FUNCTION -- Raised when player known selected recipe -- SOURCE Trade_Already_Known: exception; -- **** -- ****e* BTrade/BTrade.Trade_Cant_Heal -- FUNCTION -- Raised when no crew members are wounded -- SOURCE Trade_Cant_Heal: exception; -- **** -- ****f* BTrade/BTrade.HireRecruit -- FUNCTION -- Hire selected recruit from bases and add him/her to player ship crew -- PARAMETERS -- RecruitIndex - Index of recruit, from base recruits list to hire -- Cost - Cost of hire of selected recruit -- DailyPayment - Daily payment of selected recruit -- TradePayment - Percent of earnings from each trade which this recruit -- will take -- ContractLength - Length of the contract with this recruit in days. 0 -- means infinite contract -- SOURCE procedure HireRecruit (RecruitIndex: Recruit_Container.Extended_Index; Cost: Positive; DailyPayment, TradePayment: Natural; ContractLenght: Integer) with Test_Case => (Name => "Test_HireRecruit", Mode => Robustness); -- **** -- ****f* BTrade/BTrade.BuyRecipe -- FUNCTION -- Buy new crafting recipe -- PARAMETERS -- RecipeIndex - Index of the recipe from base recipes list to buy -- SOURCE procedure BuyRecipe(RecipeIndex: Unbounded_String) with Pre => (RecipeIndex /= Null_Unbounded_String), Test_Case => (Name => "Test_BuyRecipe", Mode => Nominal); -- **** -- ****f* BTrade/BTrade.HealWounded -- FUNCTION -- Heals wounded crew members in bases -- PARAMETERS -- MemberIndex - Index of player ship crew member to heal or 0 for heal -- all wounded crew members -- SOURCE procedure HealWounded(MemberIndex: Crew_Container.Extended_Index) with Pre => (MemberIndex <= Player_Ship.Crew.Last_Index), Test_Case => (Name => "Test_HealWounded", Mode => Nominal); -- **** -- ****f* BTrade/BTrade.HealCost -- FUNCTION -- Count cost of healing action -- PARAMETERS -- Cost - Overall cost of heal wounded player ship crew member(s) -- Time - Time needed to heal wounded player ship crew member(s) -- MemberIndex - Index of player ship crew member to heal or 0 for heal -- all wounded crew members -- RESULT -- Parameters Cost and Time -- SOURCE procedure HealCost (Cost, Time: in out Natural; MemberIndex: Crew_Container.Extended_Index) with Pre => MemberIndex <= Player_Ship.Crew.Last_Index, Post => Cost > 0 and Time > 0, Test_Case => (Name => "Test_HealCost", Mode => Nominal); -- **** -- ****f* BTrade/BTrade.TrainCost -- FUNCTION -- Count cost of training action -- PARAMETERS -- MemberIndex - Index of player ship crew member which will be training -- SkillIndex - Index of skill of selected crew member which will be -- training -- RESULT -- Overall cost of training selected skill by selected crew member. -- Return 0 if the skill can't be trained because is maxed. -- SOURCE function TrainCost (MemberIndex: Crew_Container.Extended_Index; SkillIndex: Skills_Container.Extended_Index) return Natural with Pre => MemberIndex in Player_Ship.Crew.First_Index .. Player_Ship.Crew.Last_Index and SkillIndex in 1 .. Skills_Amount, Test_Case => (Name => "Test_TrainCost", Mode => Nominal); -- **** -- ****f* BTrade/BTrade.TrainSkill -- FUNCTION -- Train selected skill -- PARAMETERS -- MemberIndex - Index of Player_Ship crew member which train -- SkillIndex - Index of skill of selected crew member to train -- Amount - How many times train or how many money spend on training -- Is_Amount - If true, Amount variable is how many times train, -- otherwise it is amount of money to spend -- SOURCE procedure TrainSkill (MemberIndex: Crew_Container.Extended_Index; SkillIndex: Skills_Container.Extended_Index; Amount: Positive; Is_Amount: Boolean := True) with Pre => MemberIndex in Player_Ship.Crew.First_Index .. Player_Ship.Crew.Last_Index and SkillIndex in 1 .. Skills_Amount, Test_Case => (Name => "Test_TrainSkill", Mode => Nominal); -- **** end Bases.Trade;
{ "source": "starcoderdata", "programming_language": "ada" }
-- ----------------------------------------------------------------------------- with Language_Defs, Language_Utils; package Mapcodes.Languages is -- The supported languages -- The language names in Roman are the Mixed_Str images of these enums type Language_List is new Language_Defs.Language_List; -- Roman, Greek, Cyrillic, Hebrew, Devanagari, Malayalam, Georgian, Katakana, -- Thai, Lao, Armenian, Bengali, Gurmukhi, Tibetan, Arabic, Korean, Burmese, -- Khmer, Sinhalese, Thaana, Chinese, Tifinagh, Tamil, Amharic, Telugu, Odia, -- Kannada, Gujarati -- The unicode sequence to provide a language name in its language subtype Unicode_Sequence is Language_Utils.Unicode_Sequence; -- Get the Language from its name in its language -- Raises, if the output language is not known: Unknown_Language : exception; function Get_Language (Name : Unicode_Sequence) return Language_List; -- Get the language of a text (territory name or mapcode) -- All the characters must be of the same language, otherwise raises Invalid_Text : exception; function Get_Language (Input : Wide_String) return Language_List; -- The default language Default_Language : constant Language_List := Roman; -- Conversion of a text (territory name or mapcode) into a given language -- The language of the input is detected automatically -- Raises Invalid_Text if the input is not valid function Convert (Input : Wide_String; Output_Language : Language_List := Default_Language) return Wide_String; end Mapcodes.Languages;
{ "source": "starcoderdata", "programming_language": "ada" }
with foo; use foo; with Interfaces; use Interfaces; -- GNATprove GPL 2016 seems to miss a failed precondition check -- in the call at line 18. Reason is insufficient knowledge on -- others=>, causing a false negative there, which in turn hides -- a serious bug. -- Fixed in GNATprove Pro 18 (and presumably later in GPL 2017) procedure main with SPARK_Mode is -- inlined callee procedure bar (d : out Data_Type) is begin --pragma Assert (d'Length > 0); d := (others => 0); -- with this, GNATprove does not find violation in line 18 pragma Annotate (GNATprove, False_Positive, "length check might fail", "insufficient solver knowledge"); pragma Assert_And_Cut (d'Length >= 0); --d (d'First) := 0; -- with this, GNATprove indeed finds a violation in line 18 end bar; arr : Data_Type (0 .. 91) := (others => 0); i32 : Integer_32; begin bar (arr); -- essential i32 := foo.toInteger_32 (arr (60 .. 64)); -- length check proved, but actually exception end main;
{ "source": "starcoderdata", "programming_language": "ada" }
with Parse_Args.Generic_Discrete_Array_Options; package Parse_Args.Integer_Array_Options is type Integer_Array is array (Integer range <>) of Integer; type Integer_Array_Access is access Integer_Array; package Inner is new Generic_Discrete_Array_Options(Element => Integer, Element_Array => Integer_Array, Element_Array_Access => Integer_Array_Access ); subtype Element_Array_Option is Inner.Element_Array_Option; function Image (O : in Element_Array_Option) return String renames Inner.Image; function Value (O : in Element_Array_Option) return Integer_Array_Access renames Inner.Value; function Value(A : in Argument_Parser; Name : in String) return Integer_Array_Access renames Inner.Value; function Make_Option return Option_Ptr renames Inner.Make_Option; end Parse_Args.Integer_Array_Options;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Numerics.Generic_Real_Arrays; with GA_Maths; package SVD is type Real is digits 18; package Real_Arrays is new Ada.Numerics.Generic_Real_Arrays (Real); type SVD (Num_Rows, Num_Cols, Num_Singular, Work_Vector_Rows : Natural) is private; SVD_Exception : Exception; function Condition_Number (aMatrix : GA_Maths.Float_Matrix) return Float; function Singular_Value_Decomposition (aMatrix : Real_Arrays.Real_Matrix) return SVD; function Singular_Value_Decomposition (aMatrix : GA_Maths.Float_Matrix) return SVD; private type SVD (Num_Rows, Num_Cols, Num_Singular, Work_Vector_Rows : Natural) is record Matrix_U : Real_Arrays.Real_Matrix (1 .. Num_Rows, 1 .. Num_Cols) := (others => (others => 0.0)); Matrix_V : Real_Arrays.Real_Matrix (1 .. Num_Rows, 1 .. Num_Cols) := (others => (others => 0.0)); Matrix_W : Real_Arrays.Real_Vector (1 .. Work_Vector_Rows) :=(others => 0.0); Sorted_Singular_Values : Real_Arrays.Real_Vector (1 .. Num_Singular); end record; end SVD;
{ "source": "starcoderdata", "programming_language": "ada" }
-- DESCRIPTION used for compressed tables only -- NOTES somewhat complicated but works fast and generates efficient scanners -- $Header: /co/ua/self/arcadia/aflex/ada/src/RCS/tblcmpS.a,v 1.3 90/01/12 15:20:47 self Exp Locker: self $ with misc_defs; use misc_defs; package tblcmp is -- bldtbl - build table entries for dfa state procedure BLDTBL(STATE : in UNBOUNDED_INT_ARRAY; STATENUM, TOTALTRANS, COMSTATE, COMFREQ : in INTEGER); procedure CMPTMPS; -- expand_nxt_chk - expand the next check arrays procedure EXPAND_NXT_CHK; -- find_table_space - finds a space in the table for a state to be placed function FIND_TABLE_SPACE(STATE : in UNBOUNDED_INT_ARRAY; NUMTRANS : in INTEGER) return INTEGER; -- inittbl - initialize transition tables procedure INITTBL; -- mkdeftbl - make the default, "jam" table entries procedure MKDEFTBL; -- mkentry - create base/def and nxt/chk entries for transition array procedure MKENTRY(STATE : in UNBOUNDED_INT_ARRAY; NUMCHARS, STATENUM, DEFLINK, TOTALTRANS : in INTEGER); -- mk1tbl - create table entries for a state (or state fragment) which -- has only one out-transition procedure MK1TBL(STATE, SYM, ONENXT, ONEDEF : in INTEGER); -- mkprot - create new proto entry procedure MKPROT(STATE : in UNBOUNDED_INT_ARRAY; STATENUM, COMSTATE : in INTEGER); -- mktemplate - create a template entry based on a state, and connect the state -- to it procedure MKTEMPLATE(STATE : in UNBOUNDED_INT_ARRAY; STATENUM, COMSTATE : in INTEGER); -- mv2front - move proto queue element to front of queue procedure MV2FRONT(QELM : in INTEGER); -- place_state - place a state into full speed transition table procedure PLACE_STATE(STATE : in UNBOUNDED_INT_ARRAY; STATENUM, TRANSNUM : in INTEGER); -- stack1 - save states with only one out-transition to be processed later procedure STACK1(STATENUM, SYM, NEXTSTATE, DEFLINK : in INTEGER); -- tbldiff - compute differences between two state tables procedure TBLDIFF(STATE : in UNBOUNDED_INT_ARRAY; PR : in INTEGER; EXT : out UNBOUNDED_INT_ARRAY; RESULT : out INTEGER); end tblcmp;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Unchecked_Deallocation; package body Regions.Shared_Lists is procedure Reference (Self : not null List_Node_Access) with Inline; procedure Unreference (Self : in out List_Node_Access) with Inline; procedure Free is new Ada.Unchecked_Deallocation (List_Node, List_Node_Access); --------- -- "=" -- --------- function "=" (Left, Right : List) return Boolean is function Compare (L, R : List_Node_Access) return Boolean; -- Compare item in node chains function Compare (L, R : List_Node_Access) return Boolean is begin if L = R then return True; elsif L.Next = null then return L.Data = R.Data; elsif L.Data = R.Data then return Compare (L.Next, R.Next); else return False; end if; end Compare; begin return Left.Length = Right.Length and then Compare (Left.Head, Right.Head); end "="; ------------ -- Adjust -- ------------ overriding procedure Adjust (Self : in out List) is begin if Self.Head /= null then Reference (Self.Head); end if; end Adjust; ----------------------- -- Constant_Indexing -- ----------------------- function Constant_Indexing (Self : List; Position : Cursor) return Element_Type is pragma Unreferenced (Self); begin return Position.Item.Data; end Constant_Indexing; ---------------- -- Empty_List -- ---------------- function Empty_List return List is begin return (Ada.Finalization.Controlled with Head => null, Length => 0); end Empty_List; -------------- -- Finalize -- -------------- overriding procedure Finalize (Self : in out List) is begin Unreference (Self.Head); Self.Length := 0; end Finalize; ----------- -- First -- ----------- overriding function First (Self : Forward_Iterator) return Cursor is begin return Self.First; end First; ------------------- -- First_Element -- ------------------- function First_Element (Self : List) return Element_Type is begin return Self.Head.Data; end First_Element; ----------------- -- Has_Element -- ----------------- function Has_Element (Self : Cursor) return Boolean is begin return Self.Item /= null; end Has_Element; -------------- -- Is_Empty -- -------------- function Is_Empty (Self : List) return Boolean is begin return Self.Head = null; end Is_Empty; ------------- -- Iterate -- ------------- function Iterate (Self : List'Class) return Forward_Iterator is begin return (First => (Item => Self.Head)); end Iterate; ------------ -- Length -- ------------ function Length (Self : List) return Natural is begin return Self.Length; end Length; ---------- -- Next -- ---------- overriding function Next (Self : Forward_Iterator; Position : Cursor) return Cursor is pragma Unreferenced (Self); begin if Position.Item = null then return Position; else return (Item => Position.Item.Next); end if; end Next; ------------- -- Prepend -- ------------- procedure Prepend (Self : in out List; Item : Element_Type) is begin Self.Head := new List_Node'(Self.Head, 1, Item); Self.Length := Self.Length + 1; end Prepend; --------------- -- Reference -- --------------- procedure Reference (Self : not null List_Node_Access) is begin Self.Counter := Self.Counter + 1; end Reference; ----------------- -- Unreference -- ----------------- procedure Unreference (Self : in out List_Node_Access) is begin if Self /= null then Self.Counter := Self.Counter - 1; if Self.Counter = 0 then Destroy (Self.Data); Unreference (Self.Next); Free (Self); else Self := null; end if; end if; end Unreference; end Regions.Shared_Lists;
{ "source": "starcoderdata", "programming_language": "ada" }
------------------------------------------------------------------------------ package Asis.Gela.Elements.Defs is -------------------------- -- Type_Definition_Node -- -------------------------- type Type_Definition_Node is abstract new Definition_Node with private; type Type_Definition_Ptr is access all Type_Definition_Node; for Type_Definition_Ptr'Storage_Pool use Lists.Pool; function Corresponding_Type_Operators (Element : Type_Definition_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Add_To_Corresponding_Type_Operators (Element : in out Type_Definition_Node; Item : in Asis.Element); function Definition_Kind (Element : Type_Definition_Node) return Asis.Definition_Kinds; ----------------------------- -- Subtype_Indication_Node -- ----------------------------- type Subtype_Indication_Node is new Definition_Node with private; type Subtype_Indication_Ptr is access all Subtype_Indication_Node; for Subtype_Indication_Ptr'Storage_Pool use Lists.Pool; function New_Subtype_Indication_Node (The_Context : ASIS.Context) return Subtype_Indication_Ptr; function Get_Subtype_Mark (Element : Subtype_Indication_Node) return Asis.Expression; procedure Set_Subtype_Mark (Element : in out Subtype_Indication_Node; Value : in Asis.Expression); function Subtype_Constraint (Element : Subtype_Indication_Node) return Asis.Constraint; procedure Set_Subtype_Constraint (Element : in out Subtype_Indication_Node; Value : in Asis.Constraint); function Has_Null_Exclusion (Element : Subtype_Indication_Node) return Boolean; procedure Set_Has_Null_Exclusion (Element : in out Subtype_Indication_Node; Value : in Boolean); function Definition_Kind (Element : Subtype_Indication_Node) return Asis.Definition_Kinds; function Children (Element : access Subtype_Indication_Node) return Traverse_List; function Clone (Element : Subtype_Indication_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Subtype_Indication_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); --------------------- -- Constraint_Node -- --------------------- type Constraint_Node is abstract new Definition_Node with private; type Constraint_Ptr is access all Constraint_Node; for Constraint_Ptr'Storage_Pool use Lists.Pool; function Definition_Kind (Element : Constraint_Node) return Asis.Definition_Kinds; ------------------------------- -- Component_Definition_Node -- ------------------------------- type Component_Definition_Node is new Definition_Node with private; type Component_Definition_Ptr is access all Component_Definition_Node; for Component_Definition_Ptr'Storage_Pool use Lists.Pool; function New_Component_Definition_Node (The_Context : ASIS.Context) return Component_Definition_Ptr; function Component_Subtype_Indication (Element : Component_Definition_Node) return Asis.Subtype_Indication; procedure Set_Component_Subtype_Indication (Element : in out Component_Definition_Node; Value : in Asis.Subtype_Indication); function Trait_Kind (Element : Component_Definition_Node) return Asis.Trait_Kinds; procedure Set_Trait_Kind (Element : in out Component_Definition_Node; Value : in Asis.Trait_Kinds); function Definition_Kind (Element : Component_Definition_Node) return Asis.Definition_Kinds; function Children (Element : access Component_Definition_Node) return Traverse_List; function Clone (Element : Component_Definition_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Component_Definition_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); -------------------------------------- -- Discrete_Subtype_Definition_Node -- -------------------------------------- type Discrete_Subtype_Definition_Node is abstract new Definition_Node with private; type Discrete_Subtype_Definition_Ptr is access all Discrete_Subtype_Definition_Node; for Discrete_Subtype_Definition_Ptr'Storage_Pool use Lists.Pool; function Definition_Kind (Element : Discrete_Subtype_Definition_Node) return Asis.Definition_Kinds; ------------------------- -- Discrete_Range_Node -- ------------------------- type Discrete_Range_Node is abstract new Definition_Node with private; type Discrete_Range_Ptr is access all Discrete_Range_Node; for Discrete_Range_Ptr'Storage_Pool use Lists.Pool; function Definition_Kind (Element : Discrete_Range_Node) return Asis.Definition_Kinds; ------------------------------------ -- Unknown_Discriminant_Part_Node -- ------------------------------------ type Unknown_Discriminant_Part_Node is new Definition_Node with private; type Unknown_Discriminant_Part_Ptr is access all Unknown_Discriminant_Part_Node; for Unknown_Discriminant_Part_Ptr'Storage_Pool use Lists.Pool; function New_Unknown_Discriminant_Part_Node (The_Context : ASIS.Context) return Unknown_Discriminant_Part_Ptr; function Definition_Kind (Element : Unknown_Discriminant_Part_Node) return Asis.Definition_Kinds; function Clone (Element : Unknown_Discriminant_Part_Node; Parent : Asis.Element) return Asis.Element; ---------------------------------- -- Known_Discriminant_Part_Node -- ---------------------------------- type Known_Discriminant_Part_Node is new Definition_Node with private; type Known_Discriminant_Part_Ptr is access all Known_Discriminant_Part_Node; for Known_Discriminant_Part_Ptr'Storage_Pool use Lists.Pool; function New_Known_Discriminant_Part_Node (The_Context : ASIS.Context) return Known_Discriminant_Part_Ptr; function Discriminants (Element : Known_Discriminant_Part_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Set_Discriminants (Element : in out Known_Discriminant_Part_Node; Value : in Asis.Element); function Discriminants_List (Element : Known_Discriminant_Part_Node) return Asis.Element; function Definition_Kind (Element : Known_Discriminant_Part_Node) return Asis.Definition_Kinds; function Children (Element : access Known_Discriminant_Part_Node) return Traverse_List; function Clone (Element : Known_Discriminant_Part_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Known_Discriminant_Part_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); ---------------------------- -- Record_Definition_Node -- ---------------------------- type Record_Definition_Node is new Definition_Node with private; type Record_Definition_Ptr is access all Record_Definition_Node; for Record_Definition_Ptr'Storage_Pool use Lists.Pool; function New_Record_Definition_Node (The_Context : ASIS.Context) return Record_Definition_Ptr; function Record_Components (Element : Record_Definition_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Set_Record_Components (Element : in out Record_Definition_Node; Value : in Asis.Element); function Record_Components_List (Element : Record_Definition_Node) return Asis.Element; function Implicit_Components (Element : Record_Definition_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Add_To_Implicit_Components (Element : in out Record_Definition_Node; Item : in Asis.Element); function Definition_Kind (Element : Record_Definition_Node) return Asis.Definition_Kinds; function Children (Element : access Record_Definition_Node) return Traverse_List; function Clone (Element : Record_Definition_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Record_Definition_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); --------------------------------- -- Null_Record_Definition_Node -- --------------------------------- type Null_Record_Definition_Node is new Definition_Node with private; type Null_Record_Definition_Ptr is access all Null_Record_Definition_Node; for Null_Record_Definition_Ptr'Storage_Pool use Lists.Pool; function New_Null_Record_Definition_Node (The_Context : ASIS.Context) return Null_Record_Definition_Ptr; function Definition_Kind (Element : Null_Record_Definition_Node) return Asis.Definition_Kinds; function Clone (Element : Null_Record_Definition_Node; Parent : Asis.Element) return Asis.Element; ------------------------- -- Null_Component_Node -- ------------------------- type Null_Component_Node is new Definition_Node with private; type Null_Component_Ptr is access all Null_Component_Node; for Null_Component_Ptr'Storage_Pool use Lists.Pool; function New_Null_Component_Node (The_Context : ASIS.Context) return Null_Component_Ptr; function Pragmas (Element : Null_Component_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Set_Pragmas (Element : in out Null_Component_Node; Value : in Asis.Element); function Pragmas_List (Element : Null_Component_Node) return Asis.Element; function Definition_Kind (Element : Null_Component_Node) return Asis.Definition_Kinds; function Clone (Element : Null_Component_Node; Parent : Asis.Element) return Asis.Element; ----------------------- -- Variant_Part_Node -- ----------------------- type Variant_Part_Node is new Definition_Node with private; type Variant_Part_Ptr is access all Variant_Part_Node; for Variant_Part_Ptr'Storage_Pool use Lists.Pool; function New_Variant_Part_Node (The_Context : ASIS.Context) return Variant_Part_Ptr; function Discriminant_Direct_Name (Element : Variant_Part_Node) return Asis.Name; procedure Set_Discriminant_Direct_Name (Element : in out Variant_Part_Node; Value : in Asis.Name); function Variants (Element : Variant_Part_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Set_Variants (Element : in out Variant_Part_Node; Value : in Asis.Element); function Variants_List (Element : Variant_Part_Node) return Asis.Element; function Pragmas (Element : Variant_Part_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Set_Pragmas (Element : in out Variant_Part_Node; Value : in Asis.Element); function Pragmas_List (Element : Variant_Part_Node) return Asis.Element; function End_Pragmas (Element : Variant_Part_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Set_End_Pragmas (Element : in out Variant_Part_Node; Value : in Asis.Element); function End_Pragmas_List (Element : Variant_Part_Node) return Asis.Element; function Definition_Kind (Element : Variant_Part_Node) return Asis.Definition_Kinds; function Children (Element : access Variant_Part_Node) return Traverse_List; function Clone (Element : Variant_Part_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Variant_Part_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); ------------------ -- Variant_Node -- ------------------ type Variant_Node is new Definition_Node with private; type Variant_Ptr is access all Variant_Node; for Variant_Ptr'Storage_Pool use Lists.Pool; function New_Variant_Node (The_Context : ASIS.Context) return Variant_Ptr; function Record_Components (Element : Variant_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Set_Record_Components (Element : in out Variant_Node; Value : in Asis.Element); function Record_Components_List (Element : Variant_Node) return Asis.Element; function Implicit_Components (Element : Variant_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Add_To_Implicit_Components (Element : in out Variant_Node; Item : in Asis.Element); function Variant_Choices (Element : Variant_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Set_Variant_Choices (Element : in out Variant_Node; Value : in Asis.Element); function Variant_Choices_List (Element : Variant_Node) return Asis.Element; function Definition_Kind (Element : Variant_Node) return Asis.Definition_Kinds; function Children (Element : access Variant_Node) return Traverse_List; function Clone (Element : Variant_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Variant_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); ------------------------ -- Others_Choice_Node -- ------------------------ type Others_Choice_Node is new Definition_Node with private; type Others_Choice_Ptr is access all Others_Choice_Node; for Others_Choice_Ptr'Storage_Pool use Lists.Pool; function New_Others_Choice_Node (The_Context : ASIS.Context) return Others_Choice_Ptr; function Definition_Kind (Element : Others_Choice_Node) return Asis.Definition_Kinds; function Clone (Element : Others_Choice_Node; Parent : Asis.Element) return Asis.Element; ---------------------------- -- Access_Definition_Node -- ---------------------------- type Access_Definition_Node is abstract new Definition_Node with private; type Access_Definition_Ptr is access all Access_Definition_Node; for Access_Definition_Ptr'Storage_Pool use Lists.Pool; function Has_Null_Exclusion (Element : Access_Definition_Node) return Boolean; procedure Set_Has_Null_Exclusion (Element : in out Access_Definition_Node; Value : in Boolean); function Definition_Kind (Element : Access_Definition_Node) return Asis.Definition_Kinds; ------------------------------------- -- Incomplete_Type_Definition_Node -- ------------------------------------- type Incomplete_Type_Definition_Node is new Definition_Node with private; type Incomplete_Type_Definition_Ptr is access all Incomplete_Type_Definition_Node; for Incomplete_Type_Definition_Ptr'Storage_Pool use Lists.Pool; function New_Incomplete_Type_Definition_Node (The_Context : ASIS.Context) return Incomplete_Type_Definition_Ptr; function Definition_Kind (Element : Incomplete_Type_Definition_Node) return Asis.Definition_Kinds; function Clone (Element : Incomplete_Type_Definition_Node; Parent : Asis.Element) return Asis.Element; -------------------------------------------- -- Tagged_Incomplete_Type_Definition_Node -- -------------------------------------------- type Tagged_Incomplete_Type_Definition_Node is new Incomplete_Type_Definition_Node with private; type Tagged_Incomplete_Type_Definition_Ptr is access all Tagged_Incomplete_Type_Definition_Node; for Tagged_Incomplete_Type_Definition_Ptr'Storage_Pool use Lists.Pool; function New_Tagged_Incomplete_Type_Definition_Node (The_Context : ASIS.Context) return Tagged_Incomplete_Type_Definition_Ptr; function Has_Tagged (Element : Tagged_Incomplete_Type_Definition_Node) return Boolean; procedure Set_Has_Tagged (Element : in out Tagged_Incomplete_Type_Definition_Node; Value : in Boolean); function Definition_Kind (Element : Tagged_Incomplete_Type_Definition_Node) return Asis.Definition_Kinds; function Clone (Element : Tagged_Incomplete_Type_Definition_Node; Parent : Asis.Element) return Asis.Element; ---------------------------------- -- Private_Type_Definition_Node -- ---------------------------------- type Private_Type_Definition_Node is new Definition_Node with private; type Private_Type_Definition_Ptr is access all Private_Type_Definition_Node; for Private_Type_Definition_Ptr'Storage_Pool use Lists.Pool; function New_Private_Type_Definition_Node (The_Context : ASIS.Context) return Private_Type_Definition_Ptr; function Trait_Kind (Element : Private_Type_Definition_Node) return Asis.Trait_Kinds; procedure Set_Trait_Kind (Element : in out Private_Type_Definition_Node; Value : in Asis.Trait_Kinds); function Corresponding_Type_Operators (Element : Private_Type_Definition_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Add_To_Corresponding_Type_Operators (Element : in out Private_Type_Definition_Node; Item : in Asis.Element); function Has_Limited (Element : Private_Type_Definition_Node) return Boolean; procedure Set_Has_Limited (Element : in out Private_Type_Definition_Node; Value : in Boolean); function Has_Private (Element : Private_Type_Definition_Node) return Boolean; procedure Set_Has_Private (Element : in out Private_Type_Definition_Node; Value : in Boolean); function Definition_Kind (Element : Private_Type_Definition_Node) return Asis.Definition_Kinds; function Clone (Element : Private_Type_Definition_Node; Parent : Asis.Element) return Asis.Element; ----------------------------------------- -- Tagged_Private_Type_Definition_Node -- ----------------------------------------- type Tagged_Private_Type_Definition_Node is new Private_Type_Definition_Node with private; type Tagged_Private_Type_Definition_Ptr is access all Tagged_Private_Type_Definition_Node; for Tagged_Private_Type_Definition_Ptr'Storage_Pool use Lists.Pool; function New_Tagged_Private_Type_Definition_Node (The_Context : ASIS.Context) return Tagged_Private_Type_Definition_Ptr; function Has_Abstract (Element : Tagged_Private_Type_Definition_Node) return Boolean; procedure Set_Has_Abstract (Element : in out Tagged_Private_Type_Definition_Node; Value : in Boolean); function Has_Tagged (Element : Tagged_Private_Type_Definition_Node) return Boolean; procedure Set_Has_Tagged (Element : in out Tagged_Private_Type_Definition_Node; Value : in Boolean); function Definition_Kind (Element : Tagged_Private_Type_Definition_Node) return Asis.Definition_Kinds; function Clone (Element : Tagged_Private_Type_Definition_Node; Parent : Asis.Element) return Asis.Element; --------------------------------------- -- Private_Extension_Definition_Node -- --------------------------------------- type Private_Extension_Definition_Node is new Private_Type_Definition_Node with private; type Private_Extension_Definition_Ptr is access all Private_Extension_Definition_Node; for Private_Extension_Definition_Ptr'Storage_Pool use Lists.Pool; function New_Private_Extension_Definition_Node (The_Context : ASIS.Context) return Private_Extension_Definition_Ptr; function Ancestor_Subtype_Indication (Element : Private_Extension_Definition_Node) return Asis.Subtype_Indication; procedure Set_Ancestor_Subtype_Indication (Element : in out Private_Extension_Definition_Node; Value : in Asis.Subtype_Indication); function Implicit_Inherited_Declarations (Element : Private_Extension_Definition_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Add_To_Implicit_Inherited_Declarations (Element : in out Private_Extension_Definition_Node; Item : in Asis.Element); function Implicit_Inherited_Subprograms (Element : Private_Extension_Definition_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Add_To_Implicit_Inherited_Subprograms (Element : in out Private_Extension_Definition_Node; Item : in Asis.Element); function Has_Synchronized (Element : Private_Extension_Definition_Node) return Boolean; procedure Set_Has_Synchronized (Element : in out Private_Extension_Definition_Node; Value : in Boolean); function Has_Abstract (Element : Private_Extension_Definition_Node) return Boolean; procedure Set_Has_Abstract (Element : in out Private_Extension_Definition_Node; Value : in Boolean); function Definition_Kind (Element : Private_Extension_Definition_Node) return Asis.Definition_Kinds; function Children (Element : access Private_Extension_Definition_Node) return Traverse_List; function Clone (Element : Private_Extension_Definition_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Private_Extension_Definition_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); ------------------------------- -- Protected_Definition_Node -- ------------------------------- type Protected_Definition_Node is new Definition_Node with private; type Protected_Definition_Ptr is access all Protected_Definition_Node; for Protected_Definition_Ptr'Storage_Pool use Lists.Pool; function New_Protected_Definition_Node (The_Context : ASIS.Context) return Protected_Definition_Ptr; function Is_Private_Present (Element : Protected_Definition_Node) return Boolean; procedure Set_Is_Private_Present (Element : in out Protected_Definition_Node; Value : in Boolean); function Visible_Part_Items (Element : Protected_Definition_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Set_Visible_Part_Items (Element : in out Protected_Definition_Node; Value : in Asis.Element); function Visible_Part_Items_List (Element : Protected_Definition_Node) return Asis.Element; function Private_Part_Items (Element : Protected_Definition_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Set_Private_Part_Items (Element : in out Protected_Definition_Node; Value : in Asis.Element); function Private_Part_Items_List (Element : Protected_Definition_Node) return Asis.Element; function Get_Identifier (Element : Protected_Definition_Node) return Asis.Element; procedure Set_Identifier (Element : in out Protected_Definition_Node; Value : in Asis.Element); function Corresponding_Type_Operators (Element : Protected_Definition_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Add_To_Corresponding_Type_Operators (Element : in out Protected_Definition_Node; Item : in Asis.Element); function Definition_Kind (Element : Protected_Definition_Node) return Asis.Definition_Kinds; function Children (Element : access Protected_Definition_Node) return Traverse_List; function Clone (Element : Protected_Definition_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Protected_Definition_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); -------------------------- -- Task_Definition_Node -- -------------------------- type Task_Definition_Node is new Protected_Definition_Node with private; type Task_Definition_Ptr is access all Task_Definition_Node; for Task_Definition_Ptr'Storage_Pool use Lists.Pool; function New_Task_Definition_Node (The_Context : ASIS.Context) return Task_Definition_Ptr; function Is_Task_Definition_Present (Element : Task_Definition_Node) return Boolean; procedure Set_Is_Task_Definition_Present (Element : in out Task_Definition_Node; Value : in Boolean); function Definition_Kind (Element : Task_Definition_Node) return Asis.Definition_Kinds; function Clone (Element : Task_Definition_Node; Parent : Asis.Element) return Asis.Element; procedure Copy (Source : in Asis.Element; Target : access Task_Definition_Node; Cloner : in Cloner_Class; Parent : in Asis.Element); --------------------------------- -- Formal_Type_Definition_Node -- --------------------------------- type Formal_Type_Definition_Node is abstract new Definition_Node with private; type Formal_Type_Definition_Ptr is access all Formal_Type_Definition_Node; for Formal_Type_Definition_Ptr'Storage_Pool use Lists.Pool; function Corresponding_Type_Operators (Element : Formal_Type_Definition_Node; Include_Pragmas : in Boolean := False) return Asis.Element_List; procedure Add_To_Corresponding_Type_Operators (Element : in out Formal_Type_Definition_Node; Item : in Asis.Element); function Definition_Kind (Element : Formal_Type_Definition_Node) return Asis.Definition_Kinds; private type Type_Definition_Node is abstract new Definition_Node with record Corresponding_Type_Operators : aliased Secondary_Declaration_Lists.List_Node; end record; type Subtype_Indication_Node is new Definition_Node with record Subtype_Mark : aliased Asis.Expression; Subtype_Constraint : aliased Asis.Constraint; Has_Null_Exclusion : aliased Boolean := False; end record; type Constraint_Node is abstract new Definition_Node with record null; end record; type Component_Definition_Node is new Definition_Node with record Component_Subtype_Indication : aliased Asis.Subtype_Indication; Trait_Kind : aliased Asis.Trait_Kinds := An_Ordinary_Trait; end record; type Discrete_Subtype_Definition_Node is abstract new Definition_Node with record null; end record; type Discrete_Range_Node is abstract new Definition_Node with record null; end record; type Unknown_Discriminant_Part_Node is new Definition_Node with record null; end record; type Known_Discriminant_Part_Node is new Definition_Node with record Discriminants : aliased Primary_Declaration_Lists.List; end record; type Record_Definition_Node is new Definition_Node with record Record_Components : aliased Primary_Declaration_Lists.List; Implicit_Components : aliased Secondary_Declaration_Lists.List_Node; end record; type Null_Record_Definition_Node is new Definition_Node with record null; end record; type Null_Component_Node is new Definition_Node with record Pragmas : aliased Primary_Pragma_Lists.List; end record; type Variant_Part_Node is new Definition_Node with record Discriminant_Direct_Name : aliased Asis.Name; Variants : aliased Primary_Variant_Lists.List; Pragmas : aliased Primary_Pragma_Lists.List; End_Pragmas : aliased Primary_Pragma_Lists.List; end record; type Variant_Node is new Definition_Node with record Record_Components : aliased Primary_Declaration_Lists.List; Implicit_Components : aliased Secondary_Declaration_Lists.List_Node; Variant_Choices : aliased Primary_Choise_Lists.List; end record; type Others_Choice_Node is new Definition_Node with record null; end record; type Access_Definition_Node is abstract new Definition_Node with record Has_Null_Exclusion : aliased Boolean := False; end record; type Incomplete_Type_Definition_Node is new Definition_Node with record null; end record; type Tagged_Incomplete_Type_Definition_Node is new Incomplete_Type_Definition_Node with record Has_Tagged : aliased Boolean := False; end record; type Private_Type_Definition_Node is new Definition_Node with record Trait_Kind : aliased Asis.Trait_Kinds := An_Ordinary_Trait; Corresponding_Type_Operators : aliased Secondary_Declaration_Lists.List_Node; Has_Limited : aliased Boolean := False; Has_Private : aliased Boolean := False; end record; type Tagged_Private_Type_Definition_Node is new Private_Type_Definition_Node with record Has_Abstract : aliased Boolean := False; Has_Tagged : aliased Boolean := False; end record; type Private_Extension_Definition_Node is new Private_Type_Definition_Node with record Ancestor_Subtype_Indication : aliased Asis.Subtype_Indication; Implicit_Inherited_Declarations : aliased Secondary_Declaration_Lists.List_Node; Implicit_Inherited_Subprograms : aliased Secondary_Declaration_Lists.List_Node; Has_Synchronized : aliased Boolean := False; Has_Abstract : aliased Boolean := False; end record; type Protected_Definition_Node is new Definition_Node with record Is_Private_Present : aliased Boolean := False; Visible_Part_Items : aliased Primary_Declaration_Lists.List; Private_Part_Items : aliased Primary_Declaration_Lists.List; Identifier : aliased Asis.Element; Corresponding_Type_Operators : aliased Secondary_Declaration_Lists.List_Node; end record; type Task_Definition_Node is new Protected_Definition_Node with record Is_Task_Definition_Present : aliased Boolean := False; end record; type Formal_Type_Definition_Node is abstract new Definition_Node with record Corresponding_Type_Operators : aliased Secondary_Declaration_Lists.List_Node; end record; end Asis.Gela.Elements.Defs;
{ "source": "starcoderdata", "programming_language": "ada" }
-- package Edc_Client.LED is -------------------------------------------------------------------------- -- Command string for controlling the LEDs -------------------------------------------------------------------------- subtype LED_String is String (1 .. 4); -------------------------------------------------------------------------- -- Procedures to control the red LED -------------------------------------------------------------------------- procedure Red_On with Pre => Initialized; procedure Red_Off with Pre => Initialized; procedure Red_Toggle with Pre => Initialized; -------------------------------------------------------------------------- -- Procedures to control the amber LED -------------------------------------------------------------------------- procedure Amber_On with Pre => Initialized; procedure Amber_Off with Pre => Initialized; procedure Amber_Toggle with Pre => Initialized; -------------------------------------------------------------------------- -- Procedures to control the green LED -------------------------------------------------------------------------- procedure Green_On with Pre => Initialized; procedure Green_Off with Pre => Initialized; procedure Green_Toggle with Pre => Initialized; -------------------------------------------------------------------------- -- Procedures to control the white LED -------------------------------------------------------------------------- procedure White_On with Pre => Initialized; procedure White_Off with Pre => Initialized; procedure White_Toggle with Pre => Initialized; -------------------------------------------------------------------------- -- Procedures to control the blue LED -------------------------------------------------------------------------- procedure Blue_On with Pre => Initialized; procedure Blue_Off with Pre => Initialized; procedure Blue_Toggle with Pre => Initialized; end Edc_Client.LED;
{ "source": "starcoderdata", "programming_language": "ada" }
-- a legal notice, here is a blessing: -- -- May you do good and not evil. -- May you find forgiveness for yourself and forgive others. -- May you share freely, not taking more than you give. -- with Ada.Text_IO; package body Symbols.IO is procedure Put_Named (Session : in Sessions.Session_Type; Set : in Symbol_Sets.Set_Type) is pragma Unreferenced (Session); use Ada.Text_IO; First : Boolean := True; begin Put ("["); for Index in Symbol_Sets.First_Index .. Symbol_Sets.Last_Index loop if Symbol_Sets.Set_Find (Set, Index) then if not First then Put (" "); end if; Put (Name_Of (Element_At (Index))); First := False; end if; end loop; Put ("]"); end Put_Named; -- -- Debug -- procedure JQ_Dump_Symbols (Session : in Sessions.Session_Type; Mode : in Integer) is use Ada.Text_IO; use Symbol_Sets; begin for Index in 0 .. Last_Index loop declare Symbol : Symbol_Access renames Element_At (Index); begin Put ("SYM "); Put (To_String (Symbol.Name)); Put (" INDEX"); Put (Symbol_Index'Image (Symbol.Index)); Put (" NSUB"); Put (Symbol.Sub_Symbol.Length'Img); Put (" KIND"); Put (Symbol_Kind'Pos (Symbol.Kind)'Img); if Mode = 1 then Put (" PREC"); if Symbol.Kind = Multi_Terminal then Put (" ("); for J in Symbol.Sub_Symbol.First_Index .. Symbol.Sub_Symbol.Last_Index loop Put (Natural'Image (Symbol.Sub_Symbol.Element (J).Precedence)); Put (" "); end loop; Put (")"); else if Symbol.Precedence = -1 then Put (" -1"); -- Hack else Put (Natural'Image (Symbol.Precedence)); end if; end if; Put (" LAMB "); Put (Boolean'Image (Symbol.Lambda)); Put (" FS "); if Symbol.First_Set = Null_Set then Put ("<null>"); else Put_Named (Session, Symbol.First_Set); end if; end if; New_Line; end; end loop; end JQ_Dump_Symbols; end Symbols.IO;
{ "source": "starcoderdata", "programming_language": "ada" }
-- implementation unit specialized for Darwin with System.Storage_Elements; private with C.malloc.malloc; package System.Unbounded_Allocators is -- Separated storage pool for local scope. pragma Preelaborate; type Unbounded_Allocator is limited private; procedure Initialize (Object : in out Unbounded_Allocator); procedure Finalize (Object : in out Unbounded_Allocator); procedure Allocate ( Allocator : Unbounded_Allocator; Storage_Address : out Address; Size_In_Storage_Elements : Storage_Elements.Storage_Count; Alignment : Storage_Elements.Storage_Count); procedure Deallocate ( Allocator : Unbounded_Allocator; Storage_Address : Address; Size_In_Storage_Elements : Storage_Elements.Storage_Count; Alignment : Storage_Elements.Storage_Count); function Allocator_Of (Storage_Address : Address) return Unbounded_Allocator; private type Unbounded_Allocator is new C.malloc.malloc.malloc_zone_t_ptr; end System.Unbounded_Allocators;
{ "source": "starcoderdata", "programming_language": "ada" }
ASSIGN (X, CREATE (30)); IF NOT EQUAL (T'(X), CON (30)) THEN FAILED ("INCORRECT QUALIFICATION"); END IF; IF NOT EQUAL (T (X), CON (30)) THEN FAILED ("INCORRECT SELF CONVERSION"); END IF; ASSIGN (W, CREATE (-30)); IF NOT EQUAL (T (W), CON (-30)) THEN FAILED ("INCORRECT CONVERSION FROM PARENT"); END IF; IF NOT EQUAL (PARENT (X), CON (30)) THEN FAILED ("INCORRECT CONVERSION TO PARENT"); END IF; IF NOT (X IN T) THEN FAILED ("INCORRECT ""IN"""); END IF; IF X NOT IN T THEN FAILED ("INCORRECT ""NOT IN"""); END IF; B := FALSE; A (X'ADDRESS); IF NOT B THEN FAILED ("INCORRECT 'ADDRESS"); END IF; IF X'SIZE < T'SIZE THEN FAILED ("INCORRECT OBJECT'SIZE"); END IF; RESULT; END C34009G;
{ "source": "starcoderdata", "programming_language": "ada" }
generic type Fixed_Point_Type is delta <>; package Fmt.Generic_Ordinary_Fixed_Point_Argument is function To_Argument (X : Fixed_Point_Type) return Argument_Type'Class with Inline; function "&" (Args : Arguments; X : Fixed_Point_Type) return Arguments with Inline; private type Fixed_Point_Argument_Type is new Argument_Type with record Value : Fixed_Point_Type; Width : Natural := 0; Fill : Character := ' '; Fore : Natural := Fixed_Point_Type'Fore; Aft : Natural := Fixed_Point_Type'Aft; end record; overriding procedure Parse ( Self : in out Fixed_Point_Argument_Type; Edit : String); overriding function Get_Length ( Self : in out Fixed_Point_Argument_Type) return Natural; overriding procedure Put ( Self : in out Fixed_Point_Argument_Type; Edit : String; To : in out String); end Fmt.Generic_Ordinary_Fixed_Point_Argument;
{ "source": "starcoderdata", "programming_language": "ada" }
package body agar.gui.widget.toolbar is package cbinds is function allocate (parent : widget_access_t; bar_type : type_t; num_rows : c.int; flags : flags_t) return toolbar_access_t; pragma import (c, allocate, "AG_ToolbarNew"); procedure row (toolbar : toolbar_access_t; row_name : c.int); pragma import (c, row, "AG_ToolbarRow"); end cbinds; function allocate (parent : widget_access_t; bar_type : type_t; num_rows : natural; flags : flags_t) return toolbar_access_t is begin return cbinds.allocate (parent => parent, bar_type => bar_type, num_rows => c.int (num_rows), flags => flags); end allocate; procedure row (toolbar : toolbar_access_t; row_name : natural) is begin cbinds.row (toolbar => toolbar, row_name => c.int (row_name)); end row; function widget (toolbar : toolbar_access_t) return widget_access_t is begin return agar.gui.widget.box.widget (toolbar.box'access); end widget; end agar.gui.widget.toolbar;
{ "source": "starcoderdata", "programming_language": "ada" }
Function INI.Section_to_Vector( Object : in Instance; Section: in String:= "" ) return NSO.Types.String_Vector.Vector is Use NSO.Types.String_Vector; Begin Return Result : Vector do For Item in Object(Section).Iterate loop Declare Key : String renames KEY_VALUE_MAP.Key( Item ); Value : Value_Object renames KEY_Value_MAP.Element(Item); Image : String renames -- "ABS"(Value); String'(if Value.Kind = vt_String then Value.String_Value else ABS Value); Begin Result.Append( Image ); End; end loop; Exception when CONSTRAINT_ERROR => null; End return; End INI.Section_to_Vector;
{ "source": "starcoderdata", "programming_language": "ada" }
------------------------------------------------------------------------------ -- -- SPARK Proof Analysis Tool -- -- S.P.A.T. - Object representing a JSON "proof attempt" object. -- ------------------------------------------------------------------------------ private with Ada.Tags; with SPAT.Entity; with SPAT.Field_Names; with SPAT.Preconditions; package SPAT.Proof_Attempt is use all type GNATCOLL.JSON.JSON_Value_Type; --------------------------------------------------------------------------- -- Has_Required_Fields --------------------------------------------------------------------------- function Has_Required_Fields (Object : JSON_Value) return Boolean is (Preconditions.Ensure_Field (Object => Object, Field => Field_Names.Result, Kind => JSON_String_Type) and Preconditions.Ensure_Field (Object => Object, Field => Field_Names.Time, Kinds_Allowed => Preconditions.Number_Kind)); type T is new Entity.T with private; --------------------------------------------------------------------------- -- Create --------------------------------------------------------------------------- not overriding function Create (Object : JSON_Value; Prover : Subject_Name) return T with Pre => Has_Required_Fields (Object => Object); Trivial_True : constant T; -- Special Proof_Attempt instance that represents a trivially true proof. -- -- Since GNAT_CE_2020 we can also have a "trivial_true" in the check_tree -- which - unlike a proper proof attempt - has no Result nor Time value, so -- we assume "Valid" and "no time" (i.e. 0.0 s). These kind of proof -- attempts are registered to a special prover object "Trivial" (which -- subsequently appears in the "stats" objects). -- Sorting instantiations. --------------------------------------------------------------------------- -- "<" -- -- Comparison operator. --------------------------------------------------------------------------- not overriding function "<" (Left : in T; Right : in T) return Boolean; --------------------------------------------------------------------------- -- Prover --------------------------------------------------------------------------- not overriding function Prover (This : in T) return Subject_Name; --------------------------------------------------------------------------- -- Result --------------------------------------------------------------------------- not overriding function Result (This : in T) return Subject_Name; --------------------------------------------------------------------------- -- Time --------------------------------------------------------------------------- not overriding function Time (This : in T) return Duration; private type T is new Entity.T with record Prover : Subject_Name; -- Prover involved. Result : Subject_Name; -- "Valid", "Unknown", etc. Time : Duration; -- time spent during proof -- Steps -- part of the JSON data, but we don't care. end record; --------------------------------------------------------------------------- -- Image --------------------------------------------------------------------------- overriding function Image (This : in T) return String is (Ada.Tags.External_Tag (T'Class (This)'Tag) & ": (" & "Prover => " & To_String (This.Prover) & ", Result => " & To_String (This.Result) & ", Time => " & This.Time'Image & ")"); Trivial_True : constant T := T'(Entity.T with Prover => To_Name ("Trivial"), Result => To_Name ("Valid"), Time => 0.0); --------------------------------------------------------------------------- -- Prover --------------------------------------------------------------------------- not overriding function Prover (This : in T) return Subject_Name is (This.Prover); --------------------------------------------------------------------------- -- Result --------------------------------------------------------------------------- not overriding function Result (This : in T) return Subject_Name is (This.Result); --------------------------------------------------------------------------- -- Time --------------------------------------------------------------------------- not overriding function Time (This : in T) return Duration is (This.Time); end SPAT.Proof_Attempt;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Containers; use Ada.Containers; with Ada.Directories; use Ada.Directories; with Blueprint; use Blueprint; with AAA.Strings; use AAA.Strings; with Ada.Command_Line; with Ada.Text_IO; with Templates_Parser; with CLIC.TTY; with Filesystem; with Commands; package body Commands.Destroy is ------------- -- Execute -- ------------- overriding procedure Execute ( Cmd : in out Command; Args : AAA.Strings.Vector) is begin if Args.Length > 1 then declare Name : String := Element (Args, 2); Blueprint : String := Args.First_Element; Blueprint_Path : String := Compose(Get_Blueprint_Folder,Blueprint); Current : String := Current_Directory; begin Templates_Parser.Insert (Commands.Translations, Templates_Parser.Assoc ("NAME", Name)); if Exists (Blueprint_Path) then Iterate (Blueprint_Path, Current, Delete); IO.Put_Line (TT.Success("Successfully deleted " & Blueprint) & " " & TT.Warn (TT.Bold (Name))); else IO.Put_Line (TT.Error("Blueprint" & " " & Blueprint_Path & " " & "not found")); end if; end; else IO.Put_Line(TT.Error("Command requires a blueprint and a name to be specified.")); end if; end Execute; -------------------- -- Setup_Switches -- -------------------- overriding procedure Setup_Switches (Cmd : in out Command; Config : in out CLIC.Subcommand.Switches_Configuration) is use CLIC.Subcommand; begin null; end Setup_Switches; end Commands.Destroy;
{ "source": "starcoderdata", "programming_language": "ada" }
package ANSI with Pure is Reset_All : constant String; -- Resets the device to its original state. This may include (if -- applicable): reset graphic rendition, clear tabulation stops, reset -- to default font, and more. type States is (Off, On); function Shorten (Sequence : String) return String is (Sequence); -- Some consecutive commands can be combined, resulting in a shorter -- string. Currently does nothing, but included for future optimization. ----------- -- COLOR -- ----------- type Colors is (Default, -- Implementation defined according to ANSI Black, Red, Green, Yellow, Blue, Magenta, Cyan, Grey, -- Note: these light variants might not work in older terminals. In -- general, the bold + [light] color combination will result in the -- same bright color Light_Black, Light_Red, Light_Green, Light_Yellow, Light_Blue, Light_Magenta, Light_Cyan, Light_Grey); Reset : constant String; -- Back to defaults. Applies to colors & styles. function Foreground (Color : Colors) return String; function Background (Color : Colors) return String; -- Basic palette, 8/16 colors subtype Palette_RGB is Natural range 0 .. 5; -- Used for the 256-palette colors. Actual colors in this index-mode -- palette can slightly vary from terminal to terminal. function Palette_Fg (R, G, B : Palette_RGB) return String; function Palette_Bg (R, G, B : Palette_RGB) return String; subtype Greyscale is Natural range 0 .. 23; -- Drawn from the same palette mode. 0 is black, 23 is white function Foreground (Level : Greyscale) return String; function Background (Level : Greyscale) return String; subtype True_RGB is Natural range 0 .. 255; -- Modern terminals support true 24-bit RGB color function Foreground (R, G, B : True_RGB) return String; function Background (R, G, B : True_RGB) return String; Default_Foreground : constant String; Default_Background : constant String; function Color_Wrap (Text : String; Foreground : String := ""; Background : String := "") return String; -- Wraps text between opening color and closing Defaults. See the combo -- color+styles below. ------------ -- STYLES -- ------------ type Styles is (Default, -- equivalent to Default_Foreground/Background Bright, -- aka Bold Dim, -- aka Faint Italic, Underline, Blink, Rapid_Blink, -- ansi.sys only Invert, -- swaps fg/bg, aka reverse video Conceal, -- aka hide Strike, -- aka crossed-out Fraktur, -- rarely supported, gothic style Double_Underline); function Style (Style : Styles; Active : States := On) return String; -- Apply/Remove a style function Style_Wrap (Text : String; Style : Styles) return String; -- Wraps Text in the given style between On/Off sequences function Wrap (Text : String; Style : Styles; Foreground : String := ""; Background : String := "") return String; ------------ -- CURSOR -- ------------ -- Cursor movement. No effect if at edge of screen. function Back (Cells : Positive := 1) return String; function Down (Lines : Positive := 1) return String; function Forward (Cells : Positive := 1) return String; function Up (Lines : Positive := 1) return String; function Next (Lines : Positive := 1) return String; function Previous (Lines : Positive := 1) return String; -- Move to the beginning of the next/prev lines. Not in ansi.sys function Horizontal (Column : Positive := 1) return String; -- Move to a certain absolute column. Not in ansy.sys function Position (Row, Column : Positive := 1) return String; -- 1, 1 is top-left Store : constant String; -- Store cursor position. Private SCO extension, may work in current vts Restore : constant String; -- Restore cursor position to the previously stored one Hide : constant String; Show : constant String; -- DECTCEM private extension, may work in current vts -------------- -- CLEARING -- -------------- Clear_Screen : constant String; Clear_Screen_And_Buffer : constant String; -- Clear also the backscroll buffer Clear_To_Beginning_Of_Screen : constant String; Clear_To_End_Of_Screen : constant String; -- From the cursor position Clear_Line : constant String; -- Does not change cursor position (neither the two following). Clear_To_Beginning_Of_Line : constant String; Clear_To_End_Of_Line : constant String; function Scroll_Up (Lines : Positive) return String; -- Adds lines at bottom function Scroll_Down (Lines : Positive) return String; -- Adds lines at top private ESC : constant Character := ASCII.ESC; CSI : constant String := ESC & '['; Reset_All : constant String := ESC & "c"; -- Helpers for the many int-to-str conversions function Tail (S : String) return String is (S (S'First + 1 .. S'Last)); function Img (I : Natural) return String is (Tail (I'Img)); ------------ -- COLORS -- ------------ Reset : constant String := CSI & "0m"; -- Back to defaults. Applies to colors & styles. function Foreground (Color : Colors) return String is (CSI & (case Color is when Default => "39", when Black => "30", when Red => "31", when Green => "32", when Yellow => "33", when Blue => "34", when Magenta => "35", when Cyan => "36", when Grey => "37", when Light_Black => "90", when Light_Red => "91", when Light_Green => "92", when Light_Yellow => "93", when Light_Blue => "94", when Light_Magenta => "95", when Light_Cyan => "96", when Light_Grey => "97") & "m"); function Background (Color : Colors) return String is (CSI & (case Color is when Default => "49", when Black => "40", when Red => "41", when Green => "42", when Yellow => "43", when Blue => "44", when Magenta => "45", when Cyan => "46", when Grey => "47", when Light_Black => "100", when Light_Red => "101", when Light_Green => "102", when Light_Yellow => "103", when Light_Blue => "104", when Light_Magenta => "105", when Light_Cyan => "106", when Light_Grey => "107") & "m"); function Bit8 (R, G, B : Palette_RGB) return String is (Img (16 + 36 * R + 6 * G + B)); Fg : constant String := "38"; Bg : constant String := "48"; function Palette_Fg (R, G, B : Palette_RGB) return String is (CSI & Fg & ";5;" & Bit8 (R, G, B) & "m"); function Palette_Bg (R, G, B : Palette_RGB) return String is (CSI & Bg & ";5;" & Bit8 (R, G, B) & "m"); function Foreground (Level : Greyscale) return String is (CSI & Fg & ";5;" & Img (232 + Level) & "m"); function Background (Level : Greyscale) return String is (CSI & Bg & ";5;" & Img (232 + Level) & "m"); function Foreground (R, G, B : True_RGB) return String is (CSI & Fg & ";2;" & Img (R) & ";" & Img (G) & ";" & Img (B) & "m"); function Background (R, G, B : True_RGB) return String is (CSI & Bg & ";2;" & Img (R) & ";" & Img (G) & ";" & Img (B) & "m"); Default_Foreground : constant String := CSI & "39m"; Default_Background : constant String := CSI & "49m"; function Color_Wrap (Text : String; Foreground : String := ""; Background : String := "") return String is ((if Foreground /= "" then Foreground else "") & (if Background /= "" then Background else "") & Text & (if Background /= "" then Default_Background else "") & (if Foreground /= "" then Default_Foreground else "")); ------------ -- STYLES -- ------------ function Style (Style : Styles; Active : States := On) return String is (CSI & (case Active is when On => (case Style is when Default => "39", when Bright => "1", when Dim => "2", when Italic => "3", when Underline => "4", when Blink => "5", when Rapid_Blink => "6", when Invert => "7", when Conceal => "8", when Strike => "9", when Fraktur => "20", when Double_Underline => "21" ), when Off => (case Style is when Default => "49", when Bright => "22", when Dim => "22", when Italic => "23", when Underline => "24", when Blink => "25", when Rapid_Blink => "25", when Invert => "27", when Conceal => "28", when Strike => "29", when Fraktur => "23", when Double_Underline => "24" )) & "m"); function Style_Wrap (Text : String; Style : Styles) return String is (ANSI.Style (Style, On) & Text & ANSI.Style (Style, Off)); function Wrap (Text : String; Style : Styles; Foreground : String := ""; Background : String := "") return String is (Style_Wrap (Style => Style, Text => Color_Wrap (Text => Text, Foreground => Foreground, Background => Background))); ------------ -- CURSOR -- ------------ function Cursor (N : Positive; Code : Character) return String is (CSI & Img (N) & Code) with Inline_Always; -- For common Cursor sequences function Back (Cells : Positive := 1) return String is (Cursor (Cells, 'D')); function Down (Lines : Positive := 1) return String is (Cursor (Lines, 'B')); function Forward (Cells : Positive := 1) return String is (Cursor (Cells, 'C')); function Up (Lines : Positive := 1) return String is (Cursor (Lines, 'A')); function Next (Lines : Positive := 1) return String is (Cursor (Lines, 'E')); function Previous (Lines : Positive := 1) return String is (Cursor (Lines, 'F')); function Horizontal (Column : Positive := 1) return String is (Cursor (Column, 'G')); function Position (Row, Column : Positive := 1) return String is (CSI & Img (Row) & ";" & Img (Column) & "H"); Store : constant String := CSI & "s"; Restore : constant String := CSI & "u"; Hide : constant String := CSI & "?25l"; Show : constant String := CSI & "?25h"; -------------- -- CLEARING -- -------------- Clear_Screen : constant String := CSI & "2J"; Clear_Screen_And_Buffer : constant String := CSI & "3J"; Clear_To_Beginning_Of_Screen : constant String := CSI & "2J"; Clear_To_End_Of_Screen : constant String := CSI & "0J"; Clear_Line : constant String := CSI & "2K"; Clear_To_Beginning_Of_Line : constant String := CSI & "1K"; Clear_To_End_Of_Line : constant String := CSI & "0K"; function Scroll_Up (Lines : Positive) return String is (CSI & Img (Lines) & "S"); function Scroll_Down (Lines : Positive) return String is (CSI & Img (Lines) & "T"); end ANSI;
{ "source": "starcoderdata", "programming_language": "ada" }
-- -- -- GNAT is maintained by AdaCore (http://www.adacore.com). -- -- -- ------------------------------------------------------------------------------ -- Base Test Case or Test Suite -- -- This base type allows composition of both test cases and sub-suites into a -- test suite (Composite pattern) package AUnit.Tests is type Test is abstract tagged limited private; type Test_Access is access all Test'Class; private type Test is abstract tagged limited null record; end AUnit.Tests;
{ "source": "starcoderdata", "programming_language": "ada" }
with ada.Text_IO, ada.Strings.unbounded, ada.Strings.Maps; package body any_Math.any_Geometry.any_d3.any_Modeller.any_Forge is function to_Box_Model (half_Extents : in Vector_3 := (0.5, 0.5, 0.5)) return a_Model is pragma Unreferenced (half_Extents); Modeller : any_Modeller.item; begin Modeller.add_Triangle ((0.0, 0.0, 0.0), (1.0, 0.0, 0.0), (1.0, 1.0, 0.0)); Modeller.add_Triangle ((1.0, 1.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 0.0)); -- TODO: Add the rest. return Modeller.Model; end to_Box_Model; function to_Capsule_Model (Length : in Real := 1.0; Radius : in Real := 0.5) return a_Model is use Functions; quality_Level : constant Positive := 4; sides_Count : constant Positive := Positive (quality_Level * 4); -- Number of sides to the cylinder (divisible by 4). type Edge is -- 'Barrel' edge. record Fore : Site; Aft : Site; end record; type Edges is array (Positive range 1 .. sides_Count) of Edge; type arch_Edges is array (Positive range 1 .. quality_Level) of Sites (1 .. sides_Count); tmp, ny, nz, start_nx, start_ny : Real; a : constant Real := Pi * 2.0 / Real (sides_Count); ca : constant Real := Cos (a); sa : constant Real := Sin (a); L : constant Real := Length * 0.5; the_Edges : Edges; Modeller : any_Modeller.item; begin -- Define cylinder body. -- ny := 1.0; nz := 0.0; -- Normal vector = (0, ny, nz) for Each in Edges'Range loop the_Edges (Each).Fore (1) := ny * Radius; the_Edges (Each).Fore (2) := nz * Radius; the_Edges (Each).Fore (3) := L; the_Edges (Each).Aft (1) := ny * Radius; the_Edges (Each).Aft (2) := nz * Radius; the_Edges (Each).Aft (3) := -L; -- Rotate ny, nz. -- tmp := ca * ny - sa * nz; nz := sa * ny + ca * nz; ny := tmp; end loop; for Each in Edges'Range loop if Each /= Edges'Last then Modeller.add_Triangle (the_Edges (Each) .Fore, the_Edges (Each) .Aft, the_Edges (Each + 1).Aft); Modeller.add_Triangle (the_Edges (Each + 1).Aft, the_Edges (Each + 1).Fore, the_Edges (Each) .Fore); else Modeller.add_Triangle (the_Edges (Each) .Fore, the_Edges (Each) .Aft, the_Edges (edges'First).Aft); Modeller.add_Triangle (the_Edges (edges'First).Aft, the_Edges (edges'First).Fore, the_Edges (Each) .Fore); end if; end loop; -- Define fore cylinder cap. -- declare the_arch_Edges : arch_Edges; begin start_nx := 0.0; start_ny := 1.0; for each_Hoop in 1 .. quality_Level loop -- Get start_n2 = rotated start_n. -- declare start_nx2 : constant Real := ca * start_nx + sa * start_ny; start_ny2 : constant Real := -sa * start_nx + ca * start_ny; begin -- Get n = start_n and n2 = start_n2. -- ny := start_ny; nz := 0.0; declare nx2 : constant Real := start_nx2; ny2 : Real := start_ny2; nz2 : Real := 0.0; begin for Each in 1 .. sides_Count loop the_arch_Edges (each_Hoop)(Each) (1) := ny2 * Radius; the_arch_Edges (each_Hoop)(Each) (2) := nz2 * Radius; the_arch_Edges (each_Hoop)(Each) (3) := nx2 * Radius + L; -- Rotate n, n2. -- tmp := ca * ny - sa * nz; nz := sa * ny + ca * nz; ny := tmp; tmp := ca * ny2 - sa * nz2; nz2 := sa * ny2 + ca * nz2; ny2 := tmp; end loop; end; start_nx := start_nx2; start_ny := start_ny2; end; end loop; for Each in 1 .. sides_Count loop if Each /= sides_Count then Modeller.add_Triangle (the_Edges (Each) .Fore, the_Edges (Each + 1).Fore, the_arch_Edges (1) (Each)); else Modeller.add_Triangle (the_Edges (Each).Fore, the_Edges (1) .Fore, the_arch_Edges (1) (Each)); end if; if Each /= sides_Count then Modeller.add_Triangle (the_Edges (Each + 1).Fore, the_arch_Edges (1) (Each + 1), the_arch_Edges (1) (Each)); else Modeller.add_Triangle (the_Edges (1).Fore, the_arch_Edges (1) (1), the_arch_Edges (1) (Each)); end if; end loop; for each_Hoop in 1 .. quality_Level - 1 loop for Each in 1 .. sides_Count loop declare function next_Hoop_Vertex return Positive is begin if Each = sides_Count then return 1; else return Each + 1; end if; end next_Hoop_Vertex; begin Modeller.add_Triangle (the_arch_Edges (each_Hoop) (Each), the_arch_Edges (each_Hoop) (next_Hoop_Vertex), the_arch_Edges (each_Hoop + 1) (Each)); if each_Hoop /= quality_Level - 1 then Modeller.add_Triangle (the_arch_Edges (each_Hoop) (next_Hoop_Vertex), the_arch_Edges (each_Hoop + 1) (next_Hoop_Vertex), the_arch_Edges (each_Hoop + 1) (Each)); end if; end; end loop; end loop; end; -- Define aft cylinder cap. -- declare the_arch_Edges : arch_Edges; begin start_nx := 0.0; start_ny := 1.0; for each_Hoop in 1 .. quality_Level loop declare -- Get start_n2 = rotated start_n. -- start_nx2 : constant Real := ca * start_nx - sa * start_ny; start_ny2 : constant Real := sa * start_nx + ca * start_ny; begin -- Get n = start_n and n2 = start_n2. -- ny := start_ny; nz := 0.0; declare nx2 : constant Real := start_nx2; ny2 : Real := start_ny2; nz2 : Real := 0.0; begin for Each in 1 .. sides_Count loop the_arch_Edges (each_Hoop) (Each) (1) := ny2 * Radius; the_arch_Edges (each_Hoop) (Each) (2) := nz2 * Radius; the_arch_Edges (each_Hoop) (Each) (3) := nx2 * Radius - L; -- Rotate n, n2 -- tmp := ca * ny - sa * nz; nz := sa * ny + ca * nz; ny := tmp; tmp := ca * ny2 - sa * nz2; nz2 := sa * ny2 + ca * nz2; ny2 := tmp; end loop; end; start_nx := start_nx2; start_ny := start_ny2; end; end loop; for Each in 1 .. sides_Count loop if Each /= sides_Count then Modeller.add_Triangle (the_Edges (Each).Aft, the_arch_Edges (1) (Each), the_Edges (Each + 1).Aft); else Modeller.add_Triangle (the_Edges (Each).Aft, the_arch_Edges (1) (Each), the_Edges (1).Aft); end if; if Each /= sides_Count then Modeller.add_Triangle (The_Edges (Each + 1).Aft, the_arch_Edges (1) (Each), the_arch_Edges (1) (Each + 1)); else Modeller.add_Triangle (the_Edges (1).Aft, the_arch_Edges (1) (Each), the_arch_Edges (1) (1)); end if; end loop; for each_Hoop in 1 .. quality_Level - 1 loop for Each in 1 .. sides_Count loop declare function next_Hoop_Vertex return Positive is begin if Each = sides_Count then return 1; else return Each + 1; end if; end next_hoop_Vertex; begin Modeller.add_Triangle (the_arch_Edges (each_Hoop) (Each), the_arch_Edges (each_Hoop + 1) (Each), the_arch_Edges (each_Hoop) (next_Hoop_Vertex)); if each_Hoop /= quality_Level - 1 then Modeller.add_Triangle (the_arch_Edges (each_Hoop) (next_hoop_Vertex), the_arch_Edges (each_Hoop + 1) (Each), the_arch_Edges (each_Hoop + 1) (next_Hoop_Vertex)); end if; end; end loop; end loop; end; return Modeller.Model; end to_capsule_Model; -- Polar to euclidian shape models. -- function to_Radians (From : in Latitude) return Radians is begin return Radians (From) * Pi / 180.0; end to_Radians; function to_Radians (From : in Longitude) return Radians is begin return Radians (From) * Pi / 180.0; end to_Radians; function polar_Model_from (model_Filename : in String) return polar_Model -- TODO: Handle different file formats. is use Functions, ada.Text_IO, ada.Strings.unbounded; the_File : File_type; the_Text : unbounded_String; begin open (the_File, in_File, model_Filename); while not end_of_File (the_File) loop append (the_Text, get_Line (the_File) & " "); end loop; declare text_Length : constant Natural := Length (the_Text); First : Positive := 1; function get_Real return Real is use ada.Strings, ada.Strings.Maps; real_Set : constant Character_Set := to_Set (Span => (Low => '0', High => '9')) or to_Set ('-' & '.'); Last : Positive; Result : Real; begin find_Token (the_Text, Set => real_Set, From => First, Test => Inside, First => First, Last => Last); Result := Real'Value (Slice (the_Text, Low => First, High => Last)); First := Last + 1; return Result; end get_Real; Lat : Latitude; Long : Longitude; Value : Integer; Distance : Real; Scale : constant Real := 10.0; -- TODO: Add a 'Scale' parameter. the_Model : polar_Model; begin while First < text_Length loop Value := Integer (get_Real); exit when Value = 360; Long := Longitude (Value); Lat := Latitude (get_Real); Distance := get_Real; the_Model (Long) (Lat).Site (1) := Scale * Distance * Cos (to_Radians (Lat)) * Sin (to_Radians (Long)); the_Model (Long) (Lat).Site (2) := Scale * Distance * Sin (to_Radians (Lat)); the_Model (Long) (Lat).Site (3) := Scale * Distance * Cos (to_Radians (Lat)) * Cos (to_Radians (Long)); end loop; return the_Model; end; end polar_Model_from; function mesh_Model_from (Model : in polar_Model) return a_Model is the_raw_Model : polar_Model := Model; the_mesh_Model : a_Model (site_Count => 2522, tri_Count => 73 * (16 * 4 + 6)); the_longitude : Longitude := 0; the_latitude : Latitude ; the_Vertex : Positive := 1; the_Triangle : Positive := 1; the_North_Pole : Positive; the_South_Pole : Positive; function Sum (the_Longitude : in Longitude; Increment : in Integer) return Longitude is Result : Integer := Integer (the_Longitude) + Increment; begin if Result >= 360 then Result := Result - 360; end if; return longitude (Result); end Sum; begin the_mesh_Model.Sites (the_Vertex) := (the_raw_model (0) (-90).Site); the_North_Pole := the_Vertex; the_raw_Model (0) (-90).Id := the_Vertex; the_Vertex := the_Vertex + 1; the_mesh_Model.Sites (the_Vertex) := (the_raw_model (0) (90).Site); the_south_Pole := the_Vertex; the_raw_Model (0) (90).Id := the_Vertex; the_Vertex := the_Vertex + 1; loop the_latitude := -90; loop if the_Latitude = -90 then the_raw_Model (the_Longitude) (the_Latitude).Id := the_North_Pole; elsif the_Latitude = 90 then the_raw_Model (the_Longitude) (the_Latitude).Id := the_South_Pole; else the_mesh_Model.Sites (the_Vertex) := the_raw_model (the_Longitude) (the_Latitude).Site; the_raw_Model (the_Longitude) (the_Latitude).Id := the_Vertex; the_Vertex := the_Vertex + 1; end if; exit when the_Latitude = 90; the_Latitude := the_Latitude + 5; end loop; exit when the_Longitude = 355; the_Longitude := the_Longitude + 5; end loop; the_Longitude := 0; loop the_mesh_Model.Triangles (the_Triangle) := (1 => the_North_Pole, 2 => the_raw_Model (Sum (the_Longitude, 5)) (-85).Id, 3 => the_raw_Model ( the_Longitude ) (-85).Id); the_Triangle := the_Triangle + 1; the_mesh_Model.Triangles (the_Triangle) := (1 => the_South_Pole, 2 => the_raw_Model (the_Longitude) (85).Id, 3 => the_raw_Model (Sum (the_Longitude, 5)) (85).Id); the_Triangle := the_Triangle + 1; the_Latitude := -85; loop the_mesh_Model.Triangles (the_Triangle) := (1 => the_raw_Model ( the_Longitude) (the_Latitude ).Id, 2 => the_raw_Model (Sum (the_Longitude, 5)) (the_Latitude ).Id, 3 => the_raw_Model ( the_Longitude) (the_Latitude + 5).Id); the_Triangle := the_Triangle + 1; the_mesh_Model.Triangles (the_Triangle) := (1 => the_raw_Model (the_Longitude) (the_Latitude + 5).Id, 2 => the_raw_Model (Sum (the_Longitude, 5)) (the_Latitude ).Id, 3 => the_raw_Model (Sum (the_Longitude, 5)) (the_Latitude + 5).Id); the_Triangle := the_Triangle + 1; the_Latitude := the_Latitude + 5; exit when the_Latitude = 85; end loop; exit when the_Longitude = 355; the_Longitude := the_Longitude + 5; end loop; the_mesh_Model.Triangles (the_Triangle) := (1 => the_North_Pole, 2 => the_raw_Model (5) (-85).Id, 3 => the_raw_Model (0) (-85).Id); the_Triangle := the_Triangle + 1; the_mesh_Model.Triangles (the_Triangle) := (1 => the_South_Pole, 2 => the_raw_Model (0) (85).Id, 3 => the_raw_Model (5) (85).Id); the_Triangle := the_Triangle + 1; the_latitude := -85; loop the_mesh_Model.Triangles (the_Triangle) := (1 => the_raw_Model (0) (the_Latitude ).Id, 2 => the_raw_Model (5) (the_Latitude ).Id, 3 => the_raw_Model (0) (the_Latitude + 5).Id); the_Triangle := the_Triangle + 1; the_mesh_Model.Triangles (the_Triangle) := (1 => the_raw_Model (0) (the_Latitude + 5).Id, 2 => the_raw_Model (5) (the_Latitude ).Id, 3 => the_raw_Model (5) (the_Latitude + 5).Id); the_Triangle := the_Triangle + 1; the_Latitude := the_Latitude + 5; exit when the_Latitude = 85; end loop; return the_mesh_Model; end mesh_Model_from; end any_Math.any_Geometry.any_d3.any_Modeller.any_Forge;
{ "source": "starcoderdata", "programming_language": "ada" }