text
stringlengths 437
491k
| meta
dict |
|---|---|
package body labels is
function last_label return label_t is
begin
return last;
end last_label;
function get_by_name (str : string) return label_t is
cur : labels_t.cursor := labels_t.find(labels, str);
begin
if cur = labels_t.no_element then
return null_label;
end if;
return (cursor => cur);
end get_by_name;
function create (str : string; addr : pos_addr_t := null_pos_addr) return label_t is
cur : labels_t.cursor;
tb : boolean;
begin
labels_t.insert(labels, str, addr, cur, tb);
if not tb then
raise error_label_exist;
end if;
last := (cursor => cur);
return last_label;
end create;
procedure create (str : string; addr : pos_addr_t := null_pos_addr) is
begin
void(create(str, addr));
end create;
procedure set (label : label_t; addr : pos_addr_t) is
begin
if label.cursor = labels_t.no_element then
raise error_label_is_null;
end if;
labels_t.replace_element(labels, label.cursor, addr);
end set;
function set (label : label_t; addr : pos_addr_t) return label_t is
begin
set(label, addr);
return label;
end set;
function get (label : label_t) return pos_addr_t is
begin
if label.cursor = labels_t.no_element then
raise error_label_is_null;
end if;
return labels_t.element(label.cursor);
end get;
function name (label : label_t) return string is
begin
if label.cursor = labels_t.no_element then
raise error_label_is_null;
end if;
return labels_t.key(label.cursor);
end name;
procedure void (label : label_t) is
begin
null;
end void;
end labels;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line; use Ada.Command_Line;
with Cellular; use Cellular;
procedure Main is
Width, Number : Natural;
begin
if Argument_Count < 2 then
Put("usage: cellular <width> <lines>");
return;
end if;
Width := Natural'Value(Argument(1));
Number := Natural'Value(Argument(2));
declare
Current : Cellular.CellularArray (Integer range 1..Width);
begin
Generate(Current);
Cellular.Put(Current);
New_Line;
for I in 1..Number loop
Current := Cellular.NextArray(Current);
Cellular.Put(Current);
New_Line;
end loop;
end;
end Main;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Real_Time; use Ada.Real_Time;
with Logging_Support;
with Ada.Text_IO; use Ada.Text_IO;
with System; use System;
with Epoch_Support; use Epoch_Support;
with XAda.Dispatching.TTS;
with TT_Utilities;
with TT_Patterns;
package body TTS_Example_A is
Number_Of_Work_Ids : constant := 6;
Number_Of_Sync_Ids : constant := 2;
package TTS is new XAda.Dispatching.TTS
(Number_Of_Work_Ids, Number_Of_Sync_Ids, Priority'Last - 1);
package TT_Util is new TT_Utilities (TTS);
use TT_Util;
package TT_Patt is new TT_Patterns (TTS);
use TT_Patt;
-- Variables incremented by two TT sequences of IMs-F tasks
Var_1, Var_2 : Natural := 0;
pragma Volatile (Var_1);
pragma Volatile (Var_2);
-- Auxiliary for printing times --
function Now (Current : Time) return String is
(Duration'Image ( To_Duration (Current - TTS.Get_First_Plan_Release) * 1000) & " ms " &
"|" & Duration'Image ( To_Duration (Current - TTS.Get_Last_Plan_Release) * 1000) & " ms ");
-- TT tasks --
type First_Init_Task is new Simple_Task_State with null record;
procedure Initialize (S : in out First_Init_Task) is null;
procedure Main_Code (S : in out First_Init_Task);
Wk1_Code : aliased First_Init_Task;
Wk1 : Simple_TT_Task
(Work_Id => 1,
Task_State => Wk1_Code'Access,
Synced_Init => False);
type First_IMF_Task is new Initial_Mandatory_Final_Task_State
with
record
Counter : Natural := 0;
end record;
procedure Initialize (S : in out First_IMF_Task) is null;
procedure Initial_Code (S : in out First_IMF_Task);
procedure Mandatory_Code (S : in out First_IMF_Task);
procedure Final_Code (S : in out First_IMF_Task);
Wk2_State : aliased First_IMF_Task;
Wk2 : InitialMandatorySliced_Final_TT_Task
(Work_Id => 2,
Task_State => Wk2_State'Access,
Synced_Init => False);
type Second_Init_Task is new Simple_Task_State with null record;
procedure Initialize (S : in out Second_Init_Task) is null;
procedure Main_Code (S : in out Second_Init_Task);
Wk3_Code : aliased Second_Init_Task;
Wk3 : Simple_TT_Task
(Work_Id => 3,
Task_State => Wk3_Code'Access,
Synced_Init => False);
type Second_IMF_Task is new Initial_Mandatory_Final_Task_State with
record
Counter : Natural := 0;
end record;
procedure Initialize (S : in out Second_IMF_Task) is null;
procedure Initial_Code (S : in out Second_IMF_Task);
procedure Mandatory_Code (S : in out Second_IMF_Task);
procedure Final_Code (S : in out Second_IMF_Task);
Wk4_Code : aliased Second_IMF_Task;
Wk4 : InitialMandatorySliced_Final_TT_Task
(Work_Id => 4,
Task_State => Wk4_Code'Access,
Synced_Init => False);
type End_Of_Plan_IF_Task is new Initial_Final_Task_State with null record;
procedure Initialize (S : in out End_Of_Plan_IF_Task) is null;
procedure Initial_Code (S : in out End_Of_Plan_IF_Task);
procedure Final_Code (S : in out End_Of_Plan_IF_Task);
Wk5_Code : aliased End_Of_Plan_IF_Task;
Wk5 : Initial_Final_TT_Task
(Work_Id => 5,
Task_State => Wk5_Code'Access,
Synced_Init => False);
type Synced_ET_Task is new Initial_OptionalFinal_Task_State with
record
Counter : Natural := 0;
end record;
procedure Initialize (S : in out Synced_ET_Task) is null;
procedure Initial_Code (S : in out Synced_ET_Task);
function Final_Is_Required (S : in out Synced_ET_Task) return Boolean;
procedure Final_Code (S : in out Synced_ET_Task);
Wk6_Code : aliased Synced_ET_Task;
Wk6 : SyncedInitial_OptionalFinal_ET_Task
(Sync_Id => 1,
Work_Id => 6,
Task_State => Wk6_Code'Access,
Synced_Init => False);
task type SyncedSporadic_ET_Task
(Sync_Id : TTS.TT_Sync_Id;
Offset : Natural)
with Priority => Priority'Last;
task body SyncedSporadic_ET_Task is
Release_Time : Time;
begin
loop
TTS.Wait_For_Sync (Sync_Id, Release_Time);
delay until Release_Time + Milliseconds (Offset);
Put_Line ("Sporadic task interrupting at " & Now (Clock));
end loop;
end SyncedSporadic_ET_Task;
Sp1 : SyncedSporadic_ET_Task
(Sync_Id => 2, Offset => 158);
ms : constant Time_Span := Milliseconds (1);
-- The TT plan
TT_Plan : aliased TTS.Time_Triggered_Plan :=
( TT_Slot (Regular, 50*ms, 1), -- #00 Single slot for 1st seq. start
TT_Slot (Empty, 150*ms ), -- #01
TT_Slot (Regular, 50*ms, 3), -- #02 Single slot for 2nd seq. start
TT_Slot (Sync, 150*ms, 2), -- #03 Sync point for sporadic task SP1
TT_Slot (Regular, 50*ms, 2), -- #04 Seq. 1, IMs part
TT_Slot (Regular, 50*ms, 4), -- #05 Seq. 2, IMs part
TT_Slot (Empty, 300*ms ), -- #06
TT_Slot (Continuation, 50*ms, 2), -- #07 Seq. 1, continuation of Ms part
TT_Slot (Empty, 150*ms ), -- #08
TT_Slot (Terminal, 100*ms, 4), -- #09 Seq. 2, terminal of Ms part
TT_Slot (Empty, 100*ms ), -- #10
TT_Slot (Terminal, 50*ms, 2), -- #11 Seq. 1, terminal of Ms part
TT_Slot (Sync, 150*ms, 1), -- #12 Sync Point for ET Task 1 + Empty
TT_Slot (Regular, 50*ms, 4), -- #13 Seq. 2, F part
TT_Slot (Empty, 100*ms ), -- #14
TT_Slot (Regular, 50*ms, 2), -- #15 Seq. 1, F part
TT_Slot (Empty, 80*ms ), -- #16
TT_Slot (Regular, 50*ms, 5), -- #17 I part of end of plan
TT_Slot (Empty, 70*ms ), -- #18
TT_Slot (Optional, 70*ms, 6), -- #19 F part of synced ET Task 1
TT_Slot (Regular, 50*ms, 5), -- #20 F part of end of plan
TT_Slot (Mode_Change, 80*ms) ); -- #21
-- Actions of sequence initialisations
procedure Main_Code (S : in out First_Init_Task) is -- Simple_TT task with ID = 1
Jitter : Time_Span := Clock - S.Release_Time;
begin
New_Line;
Put_Line ("------------------------");
Put_Line ("Starting plan!");
Put_Line ("------------------------");
New_Line;
-- Log --
Put_line( "Worker" & Integer (S.Work_Id)'Image & " Jitter = " &
Duration'Image (1000.0 * To_Duration (Jitter)) & " ms.");
-- Log --
Var_1 := 0;
Put_Line ("First_Init_Task.Main_Code ended at " & Now (Clock));
end Main_Code;
procedure Main_Code (S : in out Second_Init_Task) is -- Simple_TT task with ID = 3
Jitter : Time_Span := Clock - S.Release_Time;
begin
-- Log --
Put_line( "Worker" & Integer (S.Work_Id)'Image & " Jitter = " &
Duration'Image (1000.0 * To_Duration (Jitter)) & " ms.");
-- Log --
Var_2 := 0;
Put_Line ("Second_Init_Task.Main_Code ended at " & Now (Clock));
end Main_Code;
-- Actions of first sequence: IMs-F task with ID = 2
procedure Initial_Code (S : in out First_IMF_Task) is
Jitter : Time_Span := Clock - S.Release_Time;
begin
-- Log --
Put_line( "Worker" & Integer (S.Work_Id)'Image & " Jitter = " &
Duration'Image (1000.0 * To_Duration (Jitter)) & " ms.");
-- Log --
S.Counter := Var_1;
Put_Line ("First_IMF_Task.Initial_Code ended at " & Now (Clock));
end Initial_Code;
procedure Mandatory_Code (S : in out First_IMF_Task) is
begin
Put_Line ("First_IMF_Task.Mandatory_Code sliced started at " & Now (Clock));
while S.Counter < 250_000 loop
S.Counter := S.Counter + 1;
if S.Counter mod 20_000 = 0 then
Put_Line ("First_IMF_Task.Mandatory_Code sliced step " & Now (Clock));
end if;
end loop;
Put_Line ("First_IMF_Task.Mandatory_Code sliced ended at " & Now (Clock));
end Mandatory_Code;
procedure Final_Code (S : in out First_IMF_Task) is
Jitter : Time_Span := Clock - S.Release_Time;
begin
-- Log --
Put_line( "Worker" & Integer (S.Work_Id)'Image & " Jitter = " &
Duration'Image (1000.0 * To_Duration (Jitter)) & " ms.");
-- Log --
Var_1 := S.Counter;
Put_Line ("First_IMF_Task.Final_Code Seq. 1 with Var_1 =" & Var_1'Image & " at" & Now (Clock));
end Final_Code;
-- Actions of Second sequence: IMs-F task with ID = 4
procedure Initial_Code (S : in out Second_IMF_Task) is
Jitter : Time_Span := Clock - S.Release_Time;
begin
-- Log --
Put_line( "Worker" & Integer (S.Work_Id)'Image & " Jitter = " &
Duration'Image (1000.0 * To_Duration (Jitter)) & " ms.");
-- Log --
S.Counter := Var_2;
Put_Line ("Second_IMF_Task.Initial_Code ended at " & Now (Clock));
end Initial_Code;
procedure Mandatory_Code (S : in out Second_IMF_Task) is
begin
Put_Line ("Second_IMF_Task.Mandatory_Code sliced started at " & Now (Clock));
while S.Counter < 100_000 loop
S.Counter := S.Counter + 1;
if S.Counter mod 20_000 = 0 then
Put_Line ("Second_IMF_Task.Mandatory_Code sliced step " & Now (Clock));
end if;
end loop;
Put_Line ("Second_IMF_Task.Mandatory_Code sliced ended at " & Now (Clock));
end Mandatory_Code;
procedure Final_Code (S : in out Second_IMF_Task) is
Jitter : Time_Span := Clock - S.Release_Time;
begin
-- Log --
Put_line( "Worker" & Integer (S.Work_Id)'Image & " Jitter = " &
Duration'Image (1000.0 * To_Duration (Jitter)) & " ms.");
-- Log --
Var_2 := S.Counter;
Put_Line ("Second_IMF_Task.Final_Code Seq. 2 with Var_2 =" & Var_2'Image & " at" & Now (Clock));
end Final_Code;
-- End of plan actions: I-F task with ID = 4
procedure Initial_Code (S : in out End_Of_Plan_IF_Task) is
Jitter : Time_Span := Clock - S.Release_Time;
begin
-- Log --
Put_line( "Worker" & Integer (S.Work_Id)'Image & " Jitter = " &
Duration'Image (1000.0 * To_Duration (Jitter)) & " ms.");
-- Log --
Put_Line ("End_Of_Plan_IF_Task.Initial_Code at" & Now (Clock));
Put_Line ("Value of Var_1 =" & Var_1'Image);
Put_Line ("Value of Var_2 =" & Var_2'Image);
end Initial_Code;
procedure Final_Code (S : in out End_Of_Plan_IF_Task) is
Jitter : Time_Span := Clock - S.Release_Time;
begin
-- Log --
Put_line( "Worker" & Integer (S.Work_Id)'Image & " Jitter = " &
Duration'Image (1000.0 * To_Duration (Jitter)) & " ms.");
-- Log --
Put_Line ("End_Of_Plan_IF_Task.Final_Code at" & Now (Clock));
New_Line;
Put_Line ("------------------------");
Put_Line ("Starting all over again!");
Put_Line ("------------------------");
New_Line;
end Final_Code;
procedure Initial_Code (S : in out Synced_ET_Task) is
Jitter : Time_Span := Clock - S.Release_Time;
begin
-- Log --
Put_line( "Synced" & Integer (S.Sync_Id)'Image & " Jitter = " &
Duration'Image (1000.0 * To_Duration (Jitter)) & " ms.");
-- Log --
S.Counter := S.Counter + 1;
Put_Line ("Synced_ET_Task.Synced_Code with counter = " & S.Counter'Image & " at" & Now (Clock));
end Initial_Code;
function Final_Is_Required (S : in out Synced_ET_Task) return Boolean is
Condition : Boolean;
begin
Condition := (S.Counter mod 2 = 0);
Put_Line ("Synced_ET_Task.Final_Is_Required with condition = " & Condition'Image & " at" & Now (Clock));
return Condition;
end Final_Is_Required;
procedure Final_Code (S : in out Synced_ET_Task) is
Jitter : Time_Span := Clock - S.Release_Time;
begin
-- Log --
Put_line( "Worker" & Integer (S.Work_Id)'Image & " Jitter = " &
Duration'Image (1000.0 * To_Duration (Jitter)) & " ms.");
-- Log --
Put_Line ("Synced_ET_Task.Final_Code with counter = " & S.Counter'Image & " at" & Now (Clock));
end Final_Code;
----------
-- Main --
----------
procedure Main is
begin
delay until Epoch_Support.Epoch;
TTS.Set_Plan(TT_Plan'Access);
delay until Ada.Real_Time.Time_Last;
end Main;
end TTS_Example_A;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with
Interfaces.C,
System;
use type
System.Address;
package body FLTK.Widgets.Groups.Windows.Double is
procedure double_window_set_draw_hook
(W, D : in System.Address);
pragma Import (C, double_window_set_draw_hook, "double_window_set_draw_hook");
pragma Inline (double_window_set_draw_hook);
procedure double_window_set_handle_hook
(W, H : in System.Address);
pragma Import (C, double_window_set_handle_hook, "double_window_set_handle_hook");
pragma Inline (double_window_set_handle_hook);
function new_fl_double_window
(X, Y, W, H : in Interfaces.C.int;
Text : in Interfaces.C.char_array)
return System.Address;
pragma Import (C, new_fl_double_window, "new_fl_double_window");
pragma Inline (new_fl_double_window);
function new_fl_double_window2
(X, Y : in Interfaces.C.int;
Text : in Interfaces.C.char_array)
return System.Address;
pragma Import (C, new_fl_double_window2, "new_fl_double_window2");
pragma Inline (new_fl_double_window2);
procedure free_fl_double_window
(W : in System.Address);
pragma Import (C, free_fl_double_window, "free_fl_double_window");
pragma Inline (free_fl_double_window);
procedure fl_double_window_show
(W : in System.Address);
pragma Import (C, fl_double_window_show, "fl_double_window_show");
pragma Inline (fl_double_window_show);
procedure fl_double_window_hide
(W : in System.Address);
pragma Import (C, fl_double_window_hide, "fl_double_window_hide");
pragma Inline (fl_double_window_hide);
procedure fl_double_window_flush
(W : in System.Address);
pragma Import (C, fl_double_window_flush, "fl_double_window_flush");
pragma Inline (fl_double_window_flush);
procedure fl_double_window_draw
(W : in System.Address);
pragma Import (C, fl_double_window_draw, "fl_double_window_draw");
pragma Inline (fl_double_window_draw);
function fl_double_window_handle
(W : in System.Address;
E : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_double_window_handle, "fl_double_window_handle");
pragma Inline (fl_double_window_handle);
procedure Finalize
(This : in out Double_Window) is
begin
if This.Void_Ptr /= System.Null_Address and then
This in Double_Window'Class
then
This.Clear;
free_fl_double_window (This.Void_Ptr);
This.Void_Ptr := System.Null_Address;
end if;
Finalize (Window (This));
end Finalize;
package body Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Double_Window is
begin
return This : Double_Window do
This.Void_Ptr := new_fl_double_window
(Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.To_C (Text));
fl_group_end (This.Void_Ptr);
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
double_window_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
double_window_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
end return;
end Create;
function Create
(W, H : in Integer;
Text : in String)
return Double_Window is
begin
return This : Double_Window do
This.Void_Ptr := new_fl_double_window2
(Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.To_C (Text));
fl_group_end (This.Void_Ptr);
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
double_window_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
double_window_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
end return;
end Create;
end Forge;
procedure Show
(This : in out Double_Window) is
begin
fl_double_window_show (This.Void_Ptr);
end Show;
procedure Hide
(This : in out Double_Window) is
begin
fl_double_window_hide (This.Void_Ptr);
end Hide;
procedure Flush
(This : in out Double_Window) is
begin
fl_double_window_flush (This.Void_Ptr);
end Flush;
procedure Draw
(This : in out Double_Window) is
begin
fl_double_window_draw (This.Void_Ptr);
end Draw;
function Handle
(This : in out Double_Window;
Event : in Event_Kind)
return Event_Outcome is
begin
return Event_Outcome'Val
(fl_double_window_handle (This.Void_Ptr, Event_Kind'Pos (Event)));
end Handle;
end FLTK.Widgets.Groups.Windows.Double;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- extended unit
package Ada.References.Wide_Strings is
-- Returning access values to sliced Wide_String from functions.
pragma Pure;
type Constant_Reference_Type (
Element : not null access constant Wide_String) is null record
with Implicit_Dereference => Element;
pragma Suppress_Initialization (Constant_Reference_Type);
type Reference_Type (Element : not null access Wide_String) is null record
with Implicit_Dereference => Element;
pragma Suppress_Initialization (Reference_Type);
package Slicing is
new Generic_Slicing (Positive, Wide_Character, Wide_String);
end Ada.References.Wide_Strings;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- This is the main Asis_Tool_2 class.
private with Asis_Tool_2.Context;
private with Dot;
with A_Nodes;
with a_nodes_h;
package Asis_Tool_2.Tool is
type Class is tagged limited private;
-- Runs in the current directory.
-- Uses project file "default.gpr" in containing directory of File_Name.
-- Creates .adt file in project file Object_Dir.
-- Creates .dot file in Output_Dir. If Output_Dir = "", uses current directory.
--
-- LEAKS. Only intended to be called once per program execution:
procedure Process
(This : in out Class;
File_Name : in String;
Output_Dir : in String := "";
GNAT_Home : in String;
Debug : in Boolean);
-- Call Process first:
function Get_Nodes
(This : in out Class)
return a_nodes_h.Nodes_Struct;
private
type Class is tagged limited -- Initialized
record
My_Context : Asis_Tool_2.Context.Class; -- Initialized
Outputs : Outputs_Record; -- Initialized
end record;
end Asis_Tool_2.Tool;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with AUnit.Assertions.Generic_Helpers;
package AUnit.Assertions.Typed is
procedure Assert is new Generic_Helpers.Assert_Integer_Image
(Num => Short_Short_Integer);
procedure Assert is new Generic_Helpers.Assert_Integer_Image
(Num => Short_Integer);
procedure Assert is new Generic_Helpers.Assert_Integer_Image
(Num => Integer);
procedure Assert is new Generic_Helpers.Assert_Integer_Image
(Num => Long_Integer);
procedure Assert is new Generic_Helpers.Assert_Integer_Image
(Num => Long_Long_Integer);
procedure Assert is new Generic_Helpers.Assert_Float_Image
(Num => Short_Float);
procedure Assert is new Generic_Helpers.Assert_Float_Image
(Num => Float);
procedure Assert is new Generic_Helpers.Assert_Float_Image
(Num => Long_Float);
procedure Assert is new Generic_Helpers.Assert_Float_Image
(Num => Long_Long_Float);
procedure Assert is new Generic_Helpers.Assert_Enumeration_Image
(Enum => Boolean);
end AUnit.Assertions.Typed;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
package body Semantica.Declsc3a is
-- Taula Procediments
procedure Nouproc
(Tp : in out T_Procs;
Idp : out Num_Proc) is
begin
Posa(Tp, Info_Proc_Nul, Idp);
end Nouproc;
function Consulta
(Tp : in T_Procs;
Idp : in Num_Proc) return Info_Proc is
begin
return Tp.Tp(Idp);
end Consulta;
-- Taula Variables
function Consulta
(Tv : in T_Vars;
Idv : in Num_Var) return Info_Var is
begin
return Tv.Tv(Idv);
end Consulta;
procedure Modif_Descripcio
(Tv : in out T_Vars;
Idv : in Num_Var;
Iv : in Info_Var) is
begin
Tv.Tv(Idv) := Iv;
end Modif_Descripcio;
procedure Novavar
(Tv : in out T_Vars;
Idpr : in Num_Proc;
Idv : out Num_Var) is
Ip : Info_Proc := Info_Proc_Nul;
Iv : Info_Var := Info_Var_Nul;
Numvar : Integer := Integer (Tv.Nv) + 1;
Nomvar : String := "_var" &
Integer'Image(Numvar);
Idn : Id_Nom;
begin
Nomvar(Nomvar'First + 4) := '_' ;
Posa_Id(Tn, Idn, Nomvar);
Ip:=Consulta(Tp, Idpr);
Iv:=(Id => Idn,
Np => Idpr,
Ocup => Integer'Size / 8,
Desp => 0,
Tsub => Tsent,
Param => False,
Const => False,
Valconst => 0);
Ip.Ocup_Var := Ip.Ocup_Var + Iv.Ocup;
Posa(Tv, Iv, Idv);
Modif_Descripcio(Tp, Idpr, Ip);
end Novavar;
procedure Novaconst
(Tv : in out T_Vars;
Vc : in Valor;
Tsub : in Tipussubjacent;
Idpr : in Num_Proc;
Idc : out Num_Var) is
Idn : Id_Nom;
E : Boolean;
Iv : Info_Var;
D : Descrip;
Ocup : Despl;
Nconst : Num_Var := Tv.Nv + 1;
Nomconst : String := "_cnt" & Nconst'img;
begin
Nomconst(Nomconst'First + 4) := '_';
if Tsub=Tsarr then
Ocup:=16*Integer'Size;
Nomconst(2..4):="str";
else
Ocup:=Integer'Size/8;
end if;
Posa_Id(Tn, Idn, Nomconst);
Iv:=(Id => Idn,
Np => Idpr,
Ocup => Integer'Size / 8,
Desp => 0,
Tsub => Tsub,
Param => False,
Const => True,
Valconst => Vc);
Posa(Tv, Iv, Idc);
D:=(Dconst,
Id_Nul,
Vc,
Nconst);
Posa(Ts, Idn, D, E);
end Novaconst;
function Nova_Etiq return Num_Etiq is
begin
Ne := Ne + 1;
return Ne;
end Nova_Etiq;
function Etiqueta
(Idpr : in num_Proc) return String is
Nomproc : String := Cons_Nom
(Tn, Consulta(Tp, Idpr).Idn);
begin
return "_" & Trim(Nomproc, Both);
end Etiqueta;
function Etiqueta
(N : in Integer) return String is
Text : String := "_etq" & Integer'Image (N);
begin
Text(Text'First+4):='_';
return Trim(Text, Both);
end Etiqueta;
function Etiqueta
(Ipr : in Info_Proc) return String is
begin
case Ipr.Tp is
when Intern =>
return "_etq_" & Trim(Ipr.Etiq'Img, Both);
when Extern =>
return "_" &
Trim(Cons_Nom(Tn, Ipr.Etiq_Extern), Both);
end case;
end Etiqueta;
--Fitxers
procedure Crea_Fitxer
(Nom_Fitxer : in String) is
begin
Create(F3as, Out_File, Nom_Fitxer&".c3as");
Create(F3at, Out_File, Nom_Fitxer&".c3at");
end Crea_Fitxer;
procedure Obrir_Fitxer
(Nom_Fitxer : in String) is
begin
Open(F3as, In_File, Nom_Fitxer&".c3as");
end Obrir_Fitxer;
procedure Tanca_Fitxer is
begin
Close(F3as);
end Tanca_Fitxer;
procedure Llegir_Fitxer
(Instruccio : out c3a) is
begin
Read(F3as, Instruccio);
end Llegir_Fitxer;
procedure Escriure_Fitxer
(Instruccio : in c3a) is
begin
-- Escriptura a arxiu binari
Write(F3as, Instruccio);
-- Escriptura a arxiu de text
Put(F3at, Instruccio.Instr'Img & Ascii.Ht);
if Instruccio.Instr <= Branc_Inc then
-- 1 operand
case Instruccio.Camp1.Tc is
when Proc =>
Put_Line(F3at, Instruccio.Camp1.Idp'Img);
when Var =>
Put_Line(F3at, Instruccio.Camp1.Idv'Img);
when Const =>
Put_Line(F3at, Instruccio.Camp1.Idc'Img);
when Etiq =>
Put_Line(F3at, Instruccio.Camp1.Ide'Img);
when others =>
null;
end case;
elsif Instruccio.Instr <= Paramc then
-- 2 operands
case Instruccio.Camp1.Tc is
when Proc =>
Put(F3at, Instruccio.Camp1.Idp'Img &
Ascii.Ht);
when Var =>
Put(F3at, Instruccio.Camp1.Idv'Img &
Ascii.Ht);
when Const =>
Put(F3at, Instruccio.Camp1.Idc'Img &
Ascii.Ht);
when Etiq =>
Put(F3at, Instruccio.Camp1.Ide'Img &
Ascii.Ht);
when others =>
null;
end case;
case Instruccio.Camp2.Tc is
when Proc =>
Put_Line(F3at, Instruccio.Camp2.Idp'Img);
when Var =>
Put_Line(F3at, Instruccio.Camp2.Idv'Img);
when Const =>
Put_Line(F3at, Instruccio.Camp2.Idc'Img);
when Etiq =>
Put_Line(F3at, Instruccio.Camp1.Ide'Img);
when others =>
null;
end case;
else
-- 3 operands
case Instruccio.Camp1.Tc is
when Proc =>
Put(F3at, Instruccio.Camp1.Idp'Img &
Ascii.Ht);
when Var =>
Put(F3at, Instruccio.Camp1.Idv'Img &
Ascii.Ht);
when Const =>
Put(F3at, Instruccio.Camp1.Idc'Img &
Ascii.Ht);
when Etiq =>
Put(F3at, Instruccio.Camp1.Ide'Img &
Ascii.Ht);
when others =>
null;
end case;
case Instruccio.Camp2.Tc is
when Proc =>
Put(F3at, Instruccio.Camp2.Idp'Img &
Ascii.Ht);
when Var =>
Put(F3at, Instruccio.Camp2.Idv'Img &
Ascii.Ht);
when Const =>
Put(F3at, Instruccio.Camp2.Idc'Img &
Ascii.Ht);
when Etiq =>
Put(F3at, Instruccio.Camp1.Ide'Img &
Ascii.Ht);
when others =>
null;
end case;
case Instruccio.Camp3.Tc is
when Proc =>
Put_Line(F3at, Instruccio.Camp3.Idp'Img);
when Var =>
Put_Line(F3at, Instruccio.Camp3.Idv'Img);
when Const =>
Put_Line(F3at, Instruccio.Camp3.Idc'Img);
when Etiq =>
Put_Line(F3at, Instruccio.Camp3.Ide'Img);
when others =>
null;
end case;
end if;
end Escriure_Fitxer;
function Fi_Fitxer return Boolean is
begin
return End_Of_File(F3as);
end Fi_Fitxer;
end Semantica.Declsc3a;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Text_IO.Unbounded_IO;
package body AdaBase.Logger.Base.Screen is
package TIO renames Ada.Text_IO;
package UIO renames Ada.Text_IO.Unbounded_IO;
overriding
procedure reaction (listener : Screen_Logger) is
begin
if listener.is_error then
UIO.Put_Line (File => TIO.Standard_Error,
Item => listener.composite);
else
UIO.Put_Line (File => TIO.Standard_Output,
Item => listener.composite);
end if;
end reaction;
end AdaBase.Logger.Base.Screen;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
pragma Ada_95;
pragma Warnings (Off);
pragma Source_File_Name (ada_main, Spec_File_Name => "b__lr-main.ads");
pragma Source_File_Name (ada_main, Body_File_Name => "b__lr-main.adb");
pragma Suppress (Overflow_Check);
with System.Restrictions;
with Ada.Exceptions;
package body ada_main is
E013 : Short_Integer; pragma Import (Ada, E013, "system__soft_links_E");
E019 : Short_Integer; pragma Import (Ada, E019, "system__exception_table_E");
E021 : Short_Integer; pragma Import (Ada, E021, "system__exceptions_E");
E009 : Short_Integer; pragma Import (Ada, E009, "system__secondary_stack_E");
E336 : Short_Integer; pragma Import (Ada, E336, "ada__containers_E");
E067 : Short_Integer; pragma Import (Ada, E067, "ada__io_exceptions_E");
E304 : Short_Integer; pragma Import (Ada, E304, "ada__numerics_E");
E344 : Short_Integer; pragma Import (Ada, E344, "ada__strings_E");
E077 : Short_Integer; pragma Import (Ada, E077, "interfaces__c_E");
E087 : Short_Integer; pragma Import (Ada, E087, "interfaces__c__strings_E");
E079 : Short_Integer; pragma Import (Ada, E079, "system__os_lib_E");
E399 : Short_Integer; pragma Import (Ada, E399, "system__task_info_E");
E051 : Short_Integer; pragma Import (Ada, E051, "ada__tags_E");
E066 : Short_Integer; pragma Import (Ada, E066, "ada__streams_E");
E082 : Short_Integer; pragma Import (Ada, E082, "system__file_control_block_E");
E075 : Short_Integer; pragma Import (Ada, E075, "system__finalization_root_E");
E073 : Short_Integer; pragma Import (Ada, E073, "ada__finalization_E");
E072 : Short_Integer; pragma Import (Ada, E072, "system__file_io_E");
E364 : Short_Integer; pragma Import (Ada, E364, "ada__streams__stream_io_E");
E095 : Short_Integer; pragma Import (Ada, E095, "system__storage_pools_E");
E089 : Short_Integer; pragma Import (Ada, E089, "system__finalization_masters_E");
E109 : Short_Integer; pragma Import (Ada, E109, "system__storage_pools__subpools_E");
E372 : Short_Integer; pragma Import (Ada, E372, "ada__calendar_E");
E370 : Short_Integer; pragma Import (Ada, E370, "ada__calendar__delays_E");
E064 : Short_Integer; pragma Import (Ada, E064, "ada__text_io_E");
E128 : Short_Integer; pragma Import (Ada, E128, "system__assertions_E");
E350 : Short_Integer; pragma Import (Ada, E350, "ada__strings__maps_E");
E346 : Short_Integer; pragma Import (Ada, E346, "ada__strings__unbounded_E");
E384 : Short_Integer; pragma Import (Ada, E384, "ada__real_time_E");
E097 : Short_Integer; pragma Import (Ada, E097, "system__pool_global_E");
E443 : Short_Integer; pragma Import (Ada, E443, "system__random_seed_E");
E417 : Short_Integer; pragma Import (Ada, E417, "system__tasking__initialization_E");
E425 : Short_Integer; pragma Import (Ada, E425, "system__tasking__protected_objects_E");
E427 : Short_Integer; pragma Import (Ada, E427, "system__tasking__protected_objects__entries_E");
E431 : Short_Integer; pragma Import (Ada, E431, "system__tasking__queuing_E");
E437 : Short_Integer; pragma Import (Ada, E437, "system__tasking__stages_E");
E085 : Short_Integer; pragma Import (Ada, E085, "glib_E");
E126 : Short_Integer; pragma Import (Ada, E126, "gtkada__types_E");
E179 : Short_Integer; pragma Import (Ada, E179, "gdk__frame_timings_E");
E130 : Short_Integer; pragma Import (Ada, E130, "glib__glist_E");
E162 : Short_Integer; pragma Import (Ada, E162, "gdk__visual_E");
E132 : Short_Integer; pragma Import (Ada, E132, "glib__gslist_E");
E124 : Short_Integer; pragma Import (Ada, E124, "gtkada__c_E");
E105 : Short_Integer; pragma Import (Ada, E105, "glib__object_E");
E122 : Short_Integer; pragma Import (Ada, E122, "glib__values_E");
E120 : Short_Integer; pragma Import (Ada, E120, "glib__types_E");
E107 : Short_Integer; pragma Import (Ada, E107, "glib__type_conversion_hooks_E");
E114 : Short_Integer; pragma Import (Ada, E114, "gtkada__bindings_E");
E143 : Short_Integer; pragma Import (Ada, E143, "cairo_E");
E145 : Short_Integer; pragma Import (Ada, E145, "cairo__region_E");
E149 : Short_Integer; pragma Import (Ada, E149, "gdk__rectangle_E");
E152 : Short_Integer; pragma Import (Ada, E152, "glib__generic_properties_E");
E173 : Short_Integer; pragma Import (Ada, E173, "gdk__color_E");
E154 : Short_Integer; pragma Import (Ada, E154, "gdk__rgba_E");
E147 : Short_Integer; pragma Import (Ada, E147, "gdk__event_E");
E282 : Short_Integer; pragma Import (Ada, E282, "glib__key_file_E");
E164 : Short_Integer; pragma Import (Ada, E164, "glib__properties_E");
E244 : Short_Integer; pragma Import (Ada, E244, "glib__string_E");
E242 : Short_Integer; pragma Import (Ada, E242, "glib__variant_E");
E240 : Short_Integer; pragma Import (Ada, E240, "glib__g_icon_E");
E310 : Short_Integer; pragma Import (Ada, E310, "gtk__actionable_E");
E187 : Short_Integer; pragma Import (Ada, E187, "gtk__builder_E");
E224 : Short_Integer; pragma Import (Ada, E224, "gtk__buildable_E");
E256 : Short_Integer; pragma Import (Ada, E256, "gtk__cell_area_context_E");
E272 : Short_Integer; pragma Import (Ada, E272, "gtk__css_section_E");
E167 : Short_Integer; pragma Import (Ada, E167, "gtk__enums_E");
E230 : Short_Integer; pragma Import (Ada, E230, "gtk__orientable_E");
E284 : Short_Integer; pragma Import (Ada, E284, "gtk__paper_size_E");
E280 : Short_Integer; pragma Import (Ada, E280, "gtk__page_setup_E");
E292 : Short_Integer; pragma Import (Ada, E292, "gtk__print_settings_E");
E195 : Short_Integer; pragma Import (Ada, E195, "gtk__target_entry_E");
E193 : Short_Integer; pragma Import (Ada, E193, "gtk__target_list_E");
E380 : Short_Integer; pragma Import (Ada, E380, "lr__synchro_E");
E382 : Short_Integer; pragma Import (Ada, E382, "lr__synchro__fifo_E");
E200 : Short_Integer; pragma Import (Ada, E200, "pango__enums_E");
E218 : Short_Integer; pragma Import (Ada, E218, "pango__attributes_E");
E204 : Short_Integer; pragma Import (Ada, E204, "pango__font_metrics_E");
E206 : Short_Integer; pragma Import (Ada, E206, "pango__language_E");
E202 : Short_Integer; pragma Import (Ada, E202, "pango__font_E");
E298 : Short_Integer; pragma Import (Ada, E298, "gtk__text_attributes_E");
E300 : Short_Integer; pragma Import (Ada, E300, "gtk__text_tag_E");
E210 : Short_Integer; pragma Import (Ada, E210, "pango__font_face_E");
E208 : Short_Integer; pragma Import (Ada, E208, "pango__font_family_E");
E212 : Short_Integer; pragma Import (Ada, E212, "pango__fontset_E");
E214 : Short_Integer; pragma Import (Ada, E214, "pango__matrix_E");
E198 : Short_Integer; pragma Import (Ada, E198, "pango__context_E");
E288 : Short_Integer; pragma Import (Ada, E288, "pango__font_map_E");
E220 : Short_Integer; pragma Import (Ada, E220, "pango__tabs_E");
E216 : Short_Integer; pragma Import (Ada, E216, "pango__layout_E");
E286 : Short_Integer; pragma Import (Ada, E286, "gtk__print_context_E");
E139 : Short_Integer; pragma Import (Ada, E139, "gdk__display_E");
E290 : Short_Integer; pragma Import (Ada, E290, "gtk__print_operation_preview_E");
E262 : Short_Integer; pragma Import (Ada, E262, "gtk__tree_model_E");
E250 : Short_Integer; pragma Import (Ada, E250, "gtk__entry_buffer_E");
E248 : Short_Integer; pragma Import (Ada, E248, "gtk__editable_E");
E246 : Short_Integer; pragma Import (Ada, E246, "gtk__cell_editable_E");
E228 : Short_Integer; pragma Import (Ada, E228, "gtk__adjustment_E");
E191 : Short_Integer; pragma Import (Ada, E191, "gtk__style_E");
E185 : Short_Integer; pragma Import (Ada, E185, "gtk__accel_group_E");
E177 : Short_Integer; pragma Import (Ada, E177, "gdk__frame_clock_E");
E181 : Short_Integer; pragma Import (Ada, E181, "gdk__pixbuf_E");
E268 : Short_Integer; pragma Import (Ada, E268, "gtk__icon_source_E");
E160 : Short_Integer; pragma Import (Ada, E160, "gdk__screen_E");
E136 : Short_Integer; pragma Import (Ada, E136, "gdk__device_E");
E175 : Short_Integer; pragma Import (Ada, E175, "gdk__drag_contexts_E");
E296 : Short_Integer; pragma Import (Ada, E296, "gtk__text_iter_E");
E234 : Short_Integer; pragma Import (Ada, E234, "gdk__window_E");
E189 : Short_Integer; pragma Import (Ada, E189, "gtk__selection_data_E");
E171 : Short_Integer; pragma Import (Ada, E171, "gtk__widget_E");
E274 : Short_Integer; pragma Import (Ada, E274, "gtk__misc_E");
E169 : Short_Integer; pragma Import (Ada, E169, "gtk__style_provider_E");
E158 : Short_Integer; pragma Import (Ada, E158, "gtk__settings_E");
E270 : Short_Integer; pragma Import (Ada, E270, "gtk__style_context_E");
E266 : Short_Integer; pragma Import (Ada, E266, "gtk__icon_set_E");
E264 : Short_Integer; pragma Import (Ada, E264, "gtk__image_E");
E260 : Short_Integer; pragma Import (Ada, E260, "gtk__cell_renderer_E");
E226 : Short_Integer; pragma Import (Ada, E226, "gtk__container_E");
E236 : Short_Integer; pragma Import (Ada, E236, "gtk__bin_E");
E222 : Short_Integer; pragma Import (Ada, E222, "gtk__box_E");
E294 : Short_Integer; pragma Import (Ada, E294, "gtk__status_bar_E");
E276 : Short_Integer; pragma Import (Ada, E276, "gtk__notebook_E");
E258 : Short_Integer; pragma Import (Ada, E258, "gtk__cell_layout_E");
E254 : Short_Integer; pragma Import (Ada, E254, "gtk__cell_area_E");
E252 : Short_Integer; pragma Import (Ada, E252, "gtk__entry_completion_E");
E232 : Short_Integer; pragma Import (Ada, E232, "gtk__window_E");
E156 : Short_Integer; pragma Import (Ada, E156, "gtk__dialog_E");
E278 : Short_Integer; pragma Import (Ada, E278, "gtk__print_operation_E");
E238 : Short_Integer; pragma Import (Ada, E238, "gtk__gentry_E");
E141 : Short_Integer; pragma Import (Ada, E141, "gtk__arguments_E");
E320 : Short_Integer; pragma Import (Ada, E320, "glib__menu_model_E");
E308 : Short_Integer; pragma Import (Ada, E308, "gtk__action_E");
E312 : Short_Integer; pragma Import (Ada, E312, "gtk__activatable_E");
E306 : Short_Integer; pragma Import (Ada, E306, "gtk__button_E");
E314 : Short_Integer; pragma Import (Ada, E314, "gtk__grange_E");
E134 : Short_Integer; pragma Import (Ada, E134, "gtk__main_E");
E330 : Short_Integer; pragma Import (Ada, E330, "gtk__marshallers_E");
E322 : Short_Integer; pragma Import (Ada, E322, "gtk__menu_item_E");
E324 : Short_Integer; pragma Import (Ada, E324, "gtk__menu_shell_E");
E318 : Short_Integer; pragma Import (Ada, E318, "gtk__menu_E");
E316 : Short_Integer; pragma Import (Ada, E316, "gtk__label_E");
E332 : Short_Integer; pragma Import (Ada, E332, "gtk__tree_view_column_E");
E333 : Short_Integer; pragma Import (Ada, E333, "gtkada__handlers_E");
E326 : Short_Integer; pragma Import (Ada, E326, "gtkada__builder_E");
E378 : Short_Integer; pragma Import (Ada, E378, "lr__tasks_E");
E368 : Short_Integer; pragma Import (Ada, E368, "lr__simu_E");
E303 : Short_Integer; pragma Import (Ada, E303, "lr__affic_E");
Local_Priority_Specific_Dispatching : constant String := "";
Local_Interrupt_States : constant String := "";
Is_Elaborated : Boolean := False;
procedure finalize_library is
begin
declare
procedure F1;
pragma Import (Ada, F1, "gtkada__builder__finalize_body");
begin
E326 := E326 - 1;
F1;
end;
declare
procedure F2;
pragma Import (Ada, F2, "gtkada__builder__finalize_spec");
begin
F2;
end;
declare
procedure F3;
pragma Import (Ada, F3, "gtkada__handlers__finalize_spec");
begin
E333 := E333 - 1;
F3;
end;
E332 := E332 - 1;
declare
procedure F4;
pragma Import (Ada, F4, "gtk__tree_view_column__finalize_spec");
begin
F4;
end;
E316 := E316 - 1;
declare
procedure F5;
pragma Import (Ada, F5, "gtk__label__finalize_spec");
begin
F5;
end;
E318 := E318 - 1;
declare
procedure F6;
pragma Import (Ada, F6, "gtk__menu__finalize_spec");
begin
F6;
end;
E324 := E324 - 1;
declare
procedure F7;
pragma Import (Ada, F7, "gtk__menu_shell__finalize_spec");
begin
F7;
end;
E322 := E322 - 1;
declare
procedure F8;
pragma Import (Ada, F8, "gtk__menu_item__finalize_spec");
begin
F8;
end;
E314 := E314 - 1;
declare
procedure F9;
pragma Import (Ada, F9, "gtk__grange__finalize_spec");
begin
F9;
end;
E306 := E306 - 1;
declare
procedure F10;
pragma Import (Ada, F10, "gtk__button__finalize_spec");
begin
F10;
end;
E308 := E308 - 1;
declare
procedure F11;
pragma Import (Ada, F11, "gtk__action__finalize_spec");
begin
F11;
end;
E320 := E320 - 1;
declare
procedure F12;
pragma Import (Ada, F12, "glib__menu_model__finalize_spec");
begin
F12;
end;
E139 := E139 - 1;
E177 := E177 - 1;
E185 := E185 - 1;
E171 := E171 - 1;
E191 := E191 - 1;
E226 := E226 - 1;
E228 := E228 - 1;
E156 := E156 - 1;
E232 := E232 - 1;
E250 := E250 - 1;
E260 := E260 - 1;
E252 := E252 - 1;
E254 := E254 - 1;
E262 := E262 - 1;
E238 := E238 - 1;
E270 := E270 - 1;
E276 := E276 - 1;
E278 := E278 - 1;
E294 := E294 - 1;
declare
procedure F13;
pragma Import (Ada, F13, "gtk__gentry__finalize_spec");
begin
F13;
end;
declare
procedure F14;
pragma Import (Ada, F14, "gtk__print_operation__finalize_spec");
begin
F14;
end;
declare
procedure F15;
pragma Import (Ada, F15, "gtk__dialog__finalize_spec");
begin
F15;
end;
declare
procedure F16;
pragma Import (Ada, F16, "gtk__window__finalize_spec");
begin
F16;
end;
declare
procedure F17;
pragma Import (Ada, F17, "gtk__entry_completion__finalize_spec");
begin
F17;
end;
declare
procedure F18;
pragma Import (Ada, F18, "gtk__cell_area__finalize_spec");
begin
F18;
end;
declare
procedure F19;
pragma Import (Ada, F19, "gtk__notebook__finalize_spec");
begin
F19;
end;
declare
procedure F20;
pragma Import (Ada, F20, "gtk__status_bar__finalize_spec");
begin
F20;
end;
E222 := E222 - 1;
declare
procedure F21;
pragma Import (Ada, F21, "gtk__box__finalize_spec");
begin
F21;
end;
E236 := E236 - 1;
declare
procedure F22;
pragma Import (Ada, F22, "gtk__bin__finalize_spec");
begin
F22;
end;
declare
procedure F23;
pragma Import (Ada, F23, "gtk__container__finalize_spec");
begin
F23;
end;
declare
procedure F24;
pragma Import (Ada, F24, "gtk__cell_renderer__finalize_spec");
begin
F24;
end;
E264 := E264 - 1;
declare
procedure F25;
pragma Import (Ada, F25, "gtk__image__finalize_spec");
begin
F25;
end;
E266 := E266 - 1;
declare
procedure F26;
pragma Import (Ada, F26, "gtk__icon_set__finalize_spec");
begin
F26;
end;
declare
procedure F27;
pragma Import (Ada, F27, "gtk__style_context__finalize_spec");
begin
F27;
end;
E158 := E158 - 1;
declare
procedure F28;
pragma Import (Ada, F28, "gtk__settings__finalize_spec");
begin
F28;
end;
E274 := E274 - 1;
declare
procedure F29;
pragma Import (Ada, F29, "gtk__misc__finalize_spec");
begin
F29;
end;
declare
procedure F30;
pragma Import (Ada, F30, "gtk__widget__finalize_spec");
begin
F30;
end;
E189 := E189 - 1;
declare
procedure F31;
pragma Import (Ada, F31, "gtk__selection_data__finalize_spec");
begin
F31;
end;
E136 := E136 - 1;
E175 := E175 - 1;
declare
procedure F32;
pragma Import (Ada, F32, "gdk__drag_contexts__finalize_spec");
begin
F32;
end;
declare
procedure F33;
pragma Import (Ada, F33, "gdk__device__finalize_spec");
begin
F33;
end;
E160 := E160 - 1;
declare
procedure F34;
pragma Import (Ada, F34, "gdk__screen__finalize_spec");
begin
F34;
end;
E181 := E181 - 1;
E268 := E268 - 1;
declare
procedure F35;
pragma Import (Ada, F35, "gtk__icon_source__finalize_spec");
begin
F35;
end;
declare
procedure F36;
pragma Import (Ada, F36, "gdk__pixbuf__finalize_spec");
begin
F36;
end;
declare
procedure F37;
pragma Import (Ada, F37, "gdk__frame_clock__finalize_spec");
begin
F37;
end;
declare
procedure F38;
pragma Import (Ada, F38, "gtk__accel_group__finalize_spec");
begin
F38;
end;
declare
procedure F39;
pragma Import (Ada, F39, "gtk__style__finalize_spec");
begin
F39;
end;
declare
procedure F40;
pragma Import (Ada, F40, "gtk__adjustment__finalize_spec");
begin
F40;
end;
declare
procedure F41;
pragma Import (Ada, F41, "gtk__entry_buffer__finalize_spec");
begin
F41;
end;
declare
procedure F42;
pragma Import (Ada, F42, "gtk__tree_model__finalize_spec");
begin
F42;
end;
declare
procedure F43;
pragma Import (Ada, F43, "gdk__display__finalize_spec");
begin
F43;
end;
E286 := E286 - 1;
declare
procedure F44;
pragma Import (Ada, F44, "gtk__print_context__finalize_spec");
begin
F44;
end;
E216 := E216 - 1;
declare
procedure F45;
pragma Import (Ada, F45, "pango__layout__finalize_spec");
begin
F45;
end;
E220 := E220 - 1;
declare
procedure F46;
pragma Import (Ada, F46, "pango__tabs__finalize_spec");
begin
F46;
end;
E288 := E288 - 1;
declare
procedure F47;
pragma Import (Ada, F47, "pango__font_map__finalize_spec");
begin
F47;
end;
E198 := E198 - 1;
declare
procedure F48;
pragma Import (Ada, F48, "pango__context__finalize_spec");
begin
F48;
end;
E212 := E212 - 1;
declare
procedure F49;
pragma Import (Ada, F49, "pango__fontset__finalize_spec");
begin
F49;
end;
E208 := E208 - 1;
declare
procedure F50;
pragma Import (Ada, F50, "pango__font_family__finalize_spec");
begin
F50;
end;
E210 := E210 - 1;
declare
procedure F51;
pragma Import (Ada, F51, "pango__font_face__finalize_spec");
begin
F51;
end;
E300 := E300 - 1;
declare
procedure F52;
pragma Import (Ada, F52, "gtk__text_tag__finalize_spec");
begin
F52;
end;
E202 := E202 - 1;
declare
procedure F53;
pragma Import (Ada, F53, "pango__font__finalize_spec");
begin
F53;
end;
E206 := E206 - 1;
declare
procedure F54;
pragma Import (Ada, F54, "pango__language__finalize_spec");
begin
F54;
end;
E204 := E204 - 1;
declare
procedure F55;
pragma Import (Ada, F55, "pango__font_metrics__finalize_spec");
begin
F55;
end;
E218 := E218 - 1;
declare
procedure F56;
pragma Import (Ada, F56, "pango__attributes__finalize_spec");
begin
F56;
end;
E193 := E193 - 1;
declare
procedure F57;
pragma Import (Ada, F57, "gtk__target_list__finalize_spec");
begin
F57;
end;
E292 := E292 - 1;
declare
procedure F58;
pragma Import (Ada, F58, "gtk__print_settings__finalize_spec");
begin
F58;
end;
E280 := E280 - 1;
declare
procedure F59;
pragma Import (Ada, F59, "gtk__page_setup__finalize_spec");
begin
F59;
end;
E284 := E284 - 1;
declare
procedure F60;
pragma Import (Ada, F60, "gtk__paper_size__finalize_spec");
begin
F60;
end;
E272 := E272 - 1;
declare
procedure F61;
pragma Import (Ada, F61, "gtk__css_section__finalize_spec");
begin
F61;
end;
E256 := E256 - 1;
declare
procedure F62;
pragma Import (Ada, F62, "gtk__cell_area_context__finalize_spec");
begin
F62;
end;
E187 := E187 - 1;
declare
procedure F63;
pragma Import (Ada, F63, "gtk__builder__finalize_spec");
begin
F63;
end;
E242 := E242 - 1;
declare
procedure F64;
pragma Import (Ada, F64, "glib__variant__finalize_spec");
begin
F64;
end;
E105 := E105 - 1;
declare
procedure F65;
pragma Import (Ada, F65, "glib__object__finalize_spec");
begin
F65;
end;
E179 := E179 - 1;
declare
procedure F66;
pragma Import (Ada, F66, "gdk__frame_timings__finalize_spec");
begin
F66;
end;
E085 := E085 - 1;
declare
procedure F67;
pragma Import (Ada, F67, "glib__finalize_spec");
begin
F67;
end;
E427 := E427 - 1;
declare
procedure F68;
pragma Import (Ada, F68, "system__tasking__protected_objects__entries__finalize_spec");
begin
F68;
end;
E097 := E097 - 1;
declare
procedure F69;
pragma Import (Ada, F69, "system__pool_global__finalize_spec");
begin
F69;
end;
E346 := E346 - 1;
declare
procedure F70;
pragma Import (Ada, F70, "ada__strings__unbounded__finalize_spec");
begin
F70;
end;
E064 := E064 - 1;
declare
procedure F71;
pragma Import (Ada, F71, "ada__text_io__finalize_spec");
begin
F71;
end;
E109 := E109 - 1;
declare
procedure F72;
pragma Import (Ada, F72, "system__storage_pools__subpools__finalize_spec");
begin
F72;
end;
E089 := E089 - 1;
declare
procedure F73;
pragma Import (Ada, F73, "system__finalization_masters__finalize_spec");
begin
F73;
end;
E364 := E364 - 1;
declare
procedure F74;
pragma Import (Ada, F74, "ada__streams__stream_io__finalize_spec");
begin
F74;
end;
declare
procedure F75;
pragma Import (Ada, F75, "system__file_io__finalize_body");
begin
E072 := E072 - 1;
F75;
end;
declare
procedure Reraise_Library_Exception_If_Any;
pragma Import (Ada, Reraise_Library_Exception_If_Any, "__gnat_reraise_library_exception_if_any");
begin
Reraise_Library_Exception_If_Any;
end;
end finalize_library;
procedure adafinal is
procedure s_stalib_adafinal;
pragma Import (C, s_stalib_adafinal, "system__standard_library__adafinal");
procedure Runtime_Finalize;
pragma Import (C, Runtime_Finalize, "__gnat_runtime_finalize");
begin
if not Is_Elaborated then
return;
end if;
Is_Elaborated := False;
Runtime_Finalize;
s_stalib_adafinal;
end adafinal;
type No_Param_Proc is access procedure;
procedure adainit is
Main_Priority : Integer;
pragma Import (C, Main_Priority, "__gl_main_priority");
Time_Slice_Value : Integer;
pragma Import (C, Time_Slice_Value, "__gl_time_slice_val");
WC_Encoding : Character;
pragma Import (C, WC_Encoding, "__gl_wc_encoding");
Locking_Policy : Character;
pragma Import (C, Locking_Policy, "__gl_locking_policy");
Queuing_Policy : Character;
pragma Import (C, Queuing_Policy, "__gl_queuing_policy");
Task_Dispatching_Policy : Character;
pragma Import (C, Task_Dispatching_Policy, "__gl_task_dispatching_policy");
Priority_Specific_Dispatching : System.Address;
pragma Import (C, Priority_Specific_Dispatching, "__gl_priority_specific_dispatching");
Num_Specific_Dispatching : Integer;
pragma Import (C, Num_Specific_Dispatching, "__gl_num_specific_dispatching");
Main_CPU : Integer;
pragma Import (C, Main_CPU, "__gl_main_cpu");
Interrupt_States : System.Address;
pragma Import (C, Interrupt_States, "__gl_interrupt_states");
Num_Interrupt_States : Integer;
pragma Import (C, Num_Interrupt_States, "__gl_num_interrupt_states");
Unreserve_All_Interrupts : Integer;
pragma Import (C, Unreserve_All_Interrupts, "__gl_unreserve_all_interrupts");
Detect_Blocking : Integer;
pragma Import (C, Detect_Blocking, "__gl_detect_blocking");
Default_Stack_Size : Integer;
pragma Import (C, Default_Stack_Size, "__gl_default_stack_size");
Leap_Seconds_Support : Integer;
pragma Import (C, Leap_Seconds_Support, "__gl_leap_seconds_support");
Bind_Env_Addr : System.Address;
pragma Import (C, Bind_Env_Addr, "__gl_bind_env_addr");
procedure Runtime_Initialize (Install_Handler : Integer);
pragma Import (C, Runtime_Initialize, "__gnat_runtime_initialize");
Finalize_Library_Objects : No_Param_Proc;
pragma Import (C, Finalize_Library_Objects, "__gnat_finalize_library_objects");
begin
if Is_Elaborated then
return;
end if;
Is_Elaborated := True;
Main_Priority := -1;
Time_Slice_Value := -1;
WC_Encoding := 'b';
Locking_Policy := ' ';
Queuing_Policy := ' ';
Task_Dispatching_Policy := ' ';
System.Restrictions.Run_Time_Restrictions :=
(Set =>
(False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False,
False, False, False, False, False, True, False, False,
False, False, False, False, True, False, False, False,
False, False, False, False, False, False, False, False,
False, False, False),
Value => (0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
Violated =>
(False, False, False, True, True, True, False, True,
False, False, True, True, True, True, False, False,
True, False, False, True, True, False, True, True,
False, True, True, True, True, False, True, False,
False, False, True, False, False, True, False, True,
False, False, True, False, True, False, True, True,
False, True, True, False, True, True, False, False,
False, False, True, True, True, True, True, False,
False, True, False, True, True, True, False, True,
True, False, True, True, True, True, False, False,
True, False, False, False, False, True, True, True,
False, False, False),
Count => (0, 0, 0, 0, 3, 4, 2, 0, 0, 0),
Unknown => (False, False, False, False, False, False, True, False, False, False));
Priority_Specific_Dispatching :=
Local_Priority_Specific_Dispatching'Address;
Num_Specific_Dispatching := 0;
Main_CPU := -1;
Interrupt_States := Local_Interrupt_States'Address;
Num_Interrupt_States := 0;
Unreserve_All_Interrupts := 0;
Detect_Blocking := 0;
Default_Stack_Size := -1;
Leap_Seconds_Support := 0;
Runtime_Initialize (1);
Finalize_Library_Objects := finalize_library'access;
System.Soft_Links'Elab_Spec;
System.Exception_Table'Elab_Body;
E019 := E019 + 1;
System.Exceptions'Elab_Spec;
E021 := E021 + 1;
System.Soft_Links'Elab_Body;
E013 := E013 + 1;
System.Secondary_Stack'Elab_Body;
E009 := E009 + 1;
Ada.Containers'Elab_Spec;
E336 := E336 + 1;
Ada.Io_Exceptions'Elab_Spec;
E067 := E067 + 1;
Ada.Numerics'Elab_Spec;
E304 := E304 + 1;
Ada.Strings'Elab_Spec;
E344 := E344 + 1;
Interfaces.C'Elab_Spec;
E077 := E077 + 1;
Interfaces.C.Strings'Elab_Spec;
E087 := E087 + 1;
System.Os_Lib'Elab_Body;
E079 := E079 + 1;
System.Task_Info'Elab_Spec;
E399 := E399 + 1;
Ada.Tags'Elab_Spec;
Ada.Tags'Elab_Body;
E051 := E051 + 1;
Ada.Streams'Elab_Spec;
E066 := E066 + 1;
System.File_Control_Block'Elab_Spec;
E082 := E082 + 1;
System.Finalization_Root'Elab_Spec;
E075 := E075 + 1;
Ada.Finalization'Elab_Spec;
E073 := E073 + 1;
System.File_Io'Elab_Body;
E072 := E072 + 1;
Ada.Streams.Stream_Io'Elab_Spec;
E364 := E364 + 1;
System.Storage_Pools'Elab_Spec;
E095 := E095 + 1;
System.Finalization_Masters'Elab_Spec;
System.Finalization_Masters'Elab_Body;
E089 := E089 + 1;
System.Storage_Pools.Subpools'Elab_Spec;
E109 := E109 + 1;
Ada.Calendar'Elab_Spec;
Ada.Calendar'Elab_Body;
E372 := E372 + 1;
Ada.Calendar.Delays'Elab_Body;
E370 := E370 + 1;
Ada.Text_Io'Elab_Spec;
Ada.Text_Io'Elab_Body;
E064 := E064 + 1;
System.Assertions'Elab_Spec;
E128 := E128 + 1;
Ada.Strings.Maps'Elab_Spec;
E350 := E350 + 1;
Ada.Strings.Unbounded'Elab_Spec;
E346 := E346 + 1;
Ada.Real_Time'Elab_Spec;
Ada.Real_Time'Elab_Body;
E384 := E384 + 1;
System.Pool_Global'Elab_Spec;
E097 := E097 + 1;
System.Random_Seed'Elab_Body;
E443 := E443 + 1;
System.Tasking.Initialization'Elab_Body;
E417 := E417 + 1;
System.Tasking.Protected_Objects'Elab_Body;
E425 := E425 + 1;
System.Tasking.Protected_Objects.Entries'Elab_Spec;
E427 := E427 + 1;
System.Tasking.Queuing'Elab_Body;
E431 := E431 + 1;
System.Tasking.Stages'Elab_Body;
E437 := E437 + 1;
Glib'Elab_Spec;
E085 := E085 + 1;
Gtkada.Types'Elab_Spec;
E126 := E126 + 1;
Gdk.Frame_Timings'Elab_Spec;
E179 := E179 + 1;
E130 := E130 + 1;
Gdk.Visual'Elab_Body;
E162 := E162 + 1;
E132 := E132 + 1;
E124 := E124 + 1;
Glib.Object'Elab_Spec;
Glib.Values'Elab_Body;
E122 := E122 + 1;
E107 := E107 + 1;
E120 := E120 + 1;
E114 := E114 + 1;
E105 := E105 + 1;
Cairo'Elab_Spec;
E143 := E143 + 1;
E145 := E145 + 1;
E149 := E149 + 1;
Glib.Generic_Properties'Elab_Spec;
Glib.Generic_Properties'Elab_Body;
E152 := E152 + 1;
Gdk.Color'Elab_Spec;
E173 := E173 + 1;
E154 := E154 + 1;
E147 := E147 + 1;
E282 := E282 + 1;
E164 := E164 + 1;
E244 := E244 + 1;
Glib.Variant'Elab_Spec;
E242 := E242 + 1;
E240 := E240 + 1;
Gtk.Actionable'Elab_Spec;
E310 := E310 + 1;
Gtk.Builder'Elab_Spec;
Gtk.Builder'Elab_Body;
E187 := E187 + 1;
E224 := E224 + 1;
Gtk.Cell_Area_Context'Elab_Spec;
Gtk.Cell_Area_Context'Elab_Body;
E256 := E256 + 1;
Gtk.Css_Section'Elab_Spec;
E272 := E272 + 1;
E167 := E167 + 1;
Gtk.Orientable'Elab_Spec;
E230 := E230 + 1;
Gtk.Paper_Size'Elab_Spec;
E284 := E284 + 1;
Gtk.Page_Setup'Elab_Spec;
Gtk.Page_Setup'Elab_Body;
E280 := E280 + 1;
Gtk.Print_Settings'Elab_Spec;
Gtk.Print_Settings'Elab_Body;
E292 := E292 + 1;
E195 := E195 + 1;
Gtk.Target_List'Elab_Spec;
E193 := E193 + 1;
E380 := E380 + 1;
LR.SYNCHRO.FIFO'ELAB_BODY;
E382 := E382 + 1;
E200 := E200 + 1;
Pango.Attributes'Elab_Spec;
E218 := E218 + 1;
Pango.Font_Metrics'Elab_Spec;
E204 := E204 + 1;
Pango.Language'Elab_Spec;
E206 := E206 + 1;
Pango.Font'Elab_Spec;
Pango.Font'Elab_Body;
E202 := E202 + 1;
E298 := E298 + 1;
Gtk.Text_Tag'Elab_Spec;
Gtk.Text_Tag'Elab_Body;
E300 := E300 + 1;
Pango.Font_Face'Elab_Spec;
Pango.Font_Face'Elab_Body;
E210 := E210 + 1;
Pango.Font_Family'Elab_Spec;
Pango.Font_Family'Elab_Body;
E208 := E208 + 1;
Pango.Fontset'Elab_Spec;
Pango.Fontset'Elab_Body;
E212 := E212 + 1;
E214 := E214 + 1;
Pango.Context'Elab_Spec;
Pango.Context'Elab_Body;
E198 := E198 + 1;
Pango.Font_Map'Elab_Spec;
Pango.Font_Map'Elab_Body;
E288 := E288 + 1;
Pango.Tabs'Elab_Spec;
E220 := E220 + 1;
Pango.Layout'Elab_Spec;
Pango.Layout'Elab_Body;
E216 := E216 + 1;
Gtk.Print_Context'Elab_Spec;
Gtk.Print_Context'Elab_Body;
E286 := E286 + 1;
Gdk.Display'Elab_Spec;
Gtk.Tree_Model'Elab_Spec;
Gtk.Entry_Buffer'Elab_Spec;
Gtk.Cell_Editable'Elab_Spec;
Gtk.Adjustment'Elab_Spec;
Gtk.Style'Elab_Spec;
Gtk.Accel_Group'Elab_Spec;
Gdk.Frame_Clock'Elab_Spec;
Gdk.Pixbuf'Elab_Spec;
Gtk.Icon_Source'Elab_Spec;
E268 := E268 + 1;
E181 := E181 + 1;
Gdk.Screen'Elab_Spec;
Gdk.Screen'Elab_Body;
E160 := E160 + 1;
Gdk.Device'Elab_Spec;
Gdk.Drag_Contexts'Elab_Spec;
Gdk.Drag_Contexts'Elab_Body;
E175 := E175 + 1;
Gdk.Device'Elab_Body;
E136 := E136 + 1;
E296 := E296 + 1;
Gdk.Window'Elab_Spec;
E234 := E234 + 1;
Gtk.Selection_Data'Elab_Spec;
E189 := E189 + 1;
Gtk.Widget'Elab_Spec;
Gtk.Misc'Elab_Spec;
Gtk.Misc'Elab_Body;
E274 := E274 + 1;
E169 := E169 + 1;
Gtk.Settings'Elab_Spec;
Gtk.Settings'Elab_Body;
E158 := E158 + 1;
Gtk.Style_Context'Elab_Spec;
Gtk.Icon_Set'Elab_Spec;
E266 := E266 + 1;
Gtk.Image'Elab_Spec;
Gtk.Image'Elab_Body;
E264 := E264 + 1;
Gtk.Cell_Renderer'Elab_Spec;
Gtk.Container'Elab_Spec;
Gtk.Bin'Elab_Spec;
Gtk.Bin'Elab_Body;
E236 := E236 + 1;
Gtk.Box'Elab_Spec;
Gtk.Box'Elab_Body;
E222 := E222 + 1;
Gtk.Status_Bar'Elab_Spec;
Gtk.Notebook'Elab_Spec;
E258 := E258 + 1;
Gtk.Cell_Area'Elab_Spec;
Gtk.Entry_Completion'Elab_Spec;
Gtk.Window'Elab_Spec;
Gtk.Dialog'Elab_Spec;
Gtk.Print_Operation'Elab_Spec;
Gtk.Gentry'Elab_Spec;
Gtk.Status_Bar'Elab_Body;
E294 := E294 + 1;
E290 := E290 + 1;
Gtk.Print_Operation'Elab_Body;
E278 := E278 + 1;
Gtk.Notebook'Elab_Body;
E276 := E276 + 1;
Gtk.Style_Context'Elab_Body;
E270 := E270 + 1;
Gtk.Gentry'Elab_Body;
E238 := E238 + 1;
E262 := E262 + 1;
Gtk.Cell_Area'Elab_Body;
E254 := E254 + 1;
Gtk.Entry_Completion'Elab_Body;
E252 := E252 + 1;
Gtk.Cell_Renderer'Elab_Body;
E260 := E260 + 1;
Gtk.Entry_Buffer'Elab_Body;
E250 := E250 + 1;
E248 := E248 + 1;
E246 := E246 + 1;
Gtk.Window'Elab_Body;
E232 := E232 + 1;
Gtk.Dialog'Elab_Body;
E156 := E156 + 1;
Gtk.Adjustment'Elab_Body;
E228 := E228 + 1;
Gtk.Container'Elab_Body;
E226 := E226 + 1;
Gtk.Style'Elab_Body;
E191 := E191 + 1;
Gtk.Widget'Elab_Body;
E171 := E171 + 1;
Gtk.Accel_Group'Elab_Body;
E185 := E185 + 1;
Gdk.Frame_Clock'Elab_Body;
E177 := E177 + 1;
E141 := E141 + 1;
Gdk.Display'Elab_Body;
E139 := E139 + 1;
Glib.Menu_Model'Elab_Spec;
Glib.Menu_Model'Elab_Body;
E320 := E320 + 1;
Gtk.Action'Elab_Spec;
Gtk.Action'Elab_Body;
E308 := E308 + 1;
Gtk.Activatable'Elab_Spec;
E312 := E312 + 1;
Gtk.Button'Elab_Spec;
Gtk.Button'Elab_Body;
E306 := E306 + 1;
Gtk.Grange'Elab_Spec;
Gtk.Grange'Elab_Body;
E314 := E314 + 1;
E134 := E134 + 1;
E330 := E330 + 1;
Gtk.Menu_Item'Elab_Spec;
Gtk.Menu_Item'Elab_Body;
E322 := E322 + 1;
Gtk.Menu_Shell'Elab_Spec;
Gtk.Menu_Shell'Elab_Body;
E324 := E324 + 1;
Gtk.Menu'Elab_Spec;
Gtk.Menu'Elab_Body;
E318 := E318 + 1;
Gtk.Label'Elab_Spec;
Gtk.Label'Elab_Body;
E316 := E316 + 1;
Gtk.Tree_View_Column'Elab_Spec;
Gtk.Tree_View_Column'Elab_Body;
E332 := E332 + 1;
Gtkada.Handlers'Elab_Spec;
E333 := E333 + 1;
Gtkada.Builder'Elab_Spec;
Gtkada.Builder'Elab_Body;
E326 := E326 + 1;
LR.TASKS'ELAB_SPEC;
LR.SIMU'ELAB_BODY;
E368 := E368 + 1;
LR.TASKS'ELAB_BODY;
E378 := E378 + 1;
LR.AFFIC'ELAB_BODY;
E303 := E303 + 1;
end adainit;
procedure Ada_Main_Program;
pragma Import (Ada, Ada_Main_Program, "_ada_lr__main");
function main
(argc : Integer;
argv : System.Address;
envp : System.Address)
return Integer
is
procedure Initialize (Addr : System.Address);
pragma Import (C, Initialize, "__gnat_initialize");
procedure Finalize;
pragma Import (C, Finalize, "__gnat_finalize");
SEH : aliased array (1 .. 2) of Integer;
Ensure_Reference : aliased System.Address := Ada_Main_Program_Name'Address;
pragma Volatile (Ensure_Reference);
begin
gnat_argc := argc;
gnat_argv := argv;
gnat_envp := envp;
Initialize (SEH'Address);
adainit;
Ada_Main_Program;
adafinal;
Finalize;
return (gnat_exit_status);
end;
-- BEGIN Object file/option list
-- /home/hmoudden/Bureau/TP-Ada-LR/lr.o
-- /home/hmoudden/Bureau/TP-Ada-LR/lr-synchro.o
-- /home/hmoudden/Bureau/TP-Ada-LR/lr-synchro-fifo.o
-- /home/hmoudden/Bureau/TP-Ada-LR/lr-simu.o
-- /home/hmoudden/Bureau/TP-Ada-LR/lr-tasks.o
-- /home/hmoudden/Bureau/TP-Ada-LR/lr-affic.o
-- /home/hmoudden/Bureau/TP-Ada-LR/lr-main.o
-- -L/home/hmoudden/Bureau/TP-Ada-LR/
-- -L/home/hmoudden/Bureau/TP-Ada-LR/
-- -L/usr/lib/x86_64-linux-gnu/ada/adalib/gtkada/
-- -L/usr/lib/gcc/x86_64-linux-gnu/7/adalib/
-- -shared
-- -shared-libgcc
-- -shared-libgcc
-- -lgthread-2.0
-- -shared-libgcc
-- -lgnarl-7
-- -lgnat-7
-- -lpthread
-- -lrt
-- END Object file/option list
end ada_main;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Loopinv is
A : array (1 .. 20) of Integer;
package IO is new Integer_IO (Integer);
begin
-- let's fill the array with data
for I in A'Range loop
A (I) := (if I mod 2 = 0 then I-1 else I);
IO.Put (A (I));
end loop;
New_Line (2);
for I in A'First .. A'Last / 2 loop
for J in I + 1 .. I + A'Last / 2 loop
pragma Loop_Invariant (A (I) <= A (J));
IO.Put (A (I)); IO.Put (A (J)); New_Line;
end loop;
end loop;
end Loopinv;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--
-- Ada version by yt
--
with Ada.Text_IO;
with Ada.Unchecked_Conversion;
with C.stdio;
with C.stdlib;
with C.string;
with C.libxml.xmlreader;
with C.libxml.parser;
with C.libxml.xmlmemory;
with C.libxml.xmlstring;
with C.libxml.tree;
with C.libxml.xmlversion;
--pragma Compile_Time_Error (
-- not C.libxml.xmlversion.LIBXML_READER_ENABLED
-- or else not C.libxml.xmlversion.LIBXML_PATTERN_ENABLED
-- or else not C.libxml.xmlversion.LIBXML_OUTPUT_ENABLED,
-- "Reader, Pattern or output support not compiled in");
procedure test_reader is
pragma Linker_Options ("-lxml2");
use type C.char;
use type C.char_array;
use type C.signed_int;
use type C.size_t;
use type C.unsigned_int;
use type C.libxml.tree.xmlDocPtr;
use type C.libxml.xmlreader.xmlTextReaderPtr;
use type C.libxml.xmlstring.xmlChar_const_ptr;
function To_char_const_ptr is
new Ada.Unchecked_Conversion (
C.libxml.xmlstring.xmlChar_const_ptr,
C.char_const_ptr);
function To_xmlChar_const_ptr is
new Ada.Unchecked_Conversion (
C.char_const_ptr,
C.libxml.xmlstring.xmlChar_const_ptr);
Write_Mode : constant C.char_array := "w" & C.char'Val (0);
stdout : access C.stdio.FILE;
procedure fwrite (
ptr : not null access constant C.char;
size : in C.size_t;
nitems : in C.size_t;
stream : access C.stdio.FILE)
is
Dummy_size_t : C.size_t;
begin
Dummy_size_t :=
C.stdio.fwrite (
C.void_const_ptr (ptr.all'Address),
size,
nitems,
stream);
end fwrite;
procedure fputs (
s : not null access constant C.char;
stream : access C.stdio.FILE)
is
Dummy_signed_int : C.signed_int;
begin
Dummy_signed_int := C.stdio.fputs (s, stream);
end fputs;
procedure fputs (
s : in C.char_array;
stream : access C.stdio.FILE) is
begin
fputs (s (s'First)'Access, stream);
end fputs;
procedure fputd (
d : in C.signed_int;
stream : access C.stdio.FILE)
is
s : C.char_array (0 .. 10);
i : C.size_t := s'Last;
r : C.signed_int := d;
begin
if r < 0 then
fputs (' ' & C.char'Val (0), stream);
r := -r;
end if;
s (i) := C.char'Val (0);
loop
i := i - 1;
s (i) := C.char'Val (C.char'Pos ('0') + r rem 10);
r := r / 10;
exit when r = 0;
end loop;
fputs (s (i)'Access, stream);
end fputd;
procedure processNode_For_1_and_2 (
reader : C.libxml.xmlreader.xmlTextReaderPtr)
is
name, value : C.libxml.xmlstring.xmlChar_const_ptr;
S1 : constant C.char_array := "--" & C.char'Val (0);
begin
name := C.libxml.xmlreader.xmlTextReaderConstName (reader);
if name = null then
name := To_xmlChar_const_ptr (S1 (S1'First)'Unchecked_Access);
end if;
value := C.libxml.xmlreader.xmlTextReaderConstValue (reader);
fputd (C.libxml.xmlreader.xmlTextReaderDepth (reader), stdout);
fputs (' ' & C.char'Val (0), stdout);
fputd (C.libxml.xmlreader.xmlTextReaderNodeType (reader), stdout);
fputs (' ' & C.char'Val (0), stdout);
fputs (To_char_const_ptr (name), stdout);
fputs (' ' & C.char'Val (0), stdout);
fputd (C.libxml.xmlreader.xmlTextReaderIsEmptyElement (reader), stdout);
fputs (' ' & C.char'Val (0), stdout);
fputd (C.libxml.xmlreader.xmlTextReaderHasValue (reader), stdout);
if value = null then
fputs (C.char'Val (10) & C.char'Val (0), stdout);
else
if C.libxml.xmlstring.xmlStrlen (value) > 40 then
fputs (' ' & C.char'Val (0), stdout);
fwrite (To_char_const_ptr (value), 1, 40, stdout);
fputs ("..." & C.char'Val (10) & C.char'Val (0), stdout);
else
fputs (' ' & C.char'Val (0), stdout);
fputs (To_char_const_ptr (value), stdout);
fputs (C.char'Val (10) & C.char'Val (0), stdout);
end if;
end if;
end processNode_For_1_and_2;
-- do as reader1.c
procedure reader1 (argv1, output : in C.char_array) is
-- processNode:
-- @reader: the xmlReader
--
-- Dump information about the current node
procedure processNode (reader : C.libxml.xmlreader.xmlTextReaderPtr)
renames processNode_For_1_and_2;
-- streamFile:
-- @filename: the file name to parse
--
-- Parse and print information about an XML file.
procedure streamFile (filename : access constant C.char) is
reader : C.libxml.xmlreader.xmlTextReaderPtr;
ret : C.signed_int;
begin
reader := C.libxml.xmlreader.xmlReaderForFile (filename, null, 0);
if reader /= null then
ret := C.libxml.xmlreader.xmlTextReaderRead (reader);
while ret = 1 loop
processNode (reader);
ret := C.libxml.xmlreader.xmlTextReaderRead (reader);
end loop;
C.libxml.xmlreader.xmlFreeTextReader (reader);
if ret /= 0 then
fputs (filename, C.stdio.stderr);
fputs (
" : failed to parse" & C.char'Val (10) & C.char'Val (0),
C.stdio.stderr);
end if;
else
fputs ("Unable to open " & C.char'Val (0), C.stdio.stderr);
fputs (filename, C.stdio.stderr);
fputs (C.char'Val (10) & C.char'Val (0), C.stdio.stderr);
end if;
end streamFile;
Dummy_signed_int : C.signed_int;
begin
stdout :=
C.stdio.fopen (
output (output'First)'Access,
Write_Mode (Write_Mode'First)'Access);
streamFile (argv1 (argv1'First)'Access);
Dummy_signed_int := C.stdio.fclose (stdout);
end reader1;
-- do as reader2.c
procedure reader2 (argv1, output : in C.char_array) is
-- processNode:
-- @reader: the xmlReader
--
-- Dump information about the current node
procedure processNode (reader : C.libxml.xmlreader.xmlTextReaderPtr)
renames processNode_For_1_and_2;
-- streamFile:
-- @filename: the file name to parse
--
-- Parse, validate and print information about an XML file.
procedure streamFile (filename : access constant C.char) is
reader : C.libxml.xmlreader.xmlTextReaderPtr;
ret : C.signed_int;
begin
-- Pass some special parsing options to activate DTD attribute defaulting,
-- entities substitution and DTD validation
reader :=
C.libxml.xmlreader.xmlReaderForFile (
filename,
null,
C.signed_int (
C.unsigned_int'(
C.libxml.parser.xmlParserOption'Enum_Rep (
C.libxml.parser.XML_PARSE_DTDATTR) -- default DTD attributes
or C.libxml.parser.xmlParserOption'Enum_Rep (
C.libxml.parser.XML_PARSE_NOENT) -- substitute entities
or C.libxml.parser.xmlParserOption'Enum_Rep (
C.libxml.parser.XML_PARSE_DTDVALID)))); -- validate with the DTD
if reader /= null then
ret := C.libxml.xmlreader.xmlTextReaderRead (reader);
while ret = 1 loop
processNode (reader);
ret := C.libxml.xmlreader.xmlTextReaderRead (reader);
end loop;
-- Once the document has been fully parsed check the validation results
if C.libxml.xmlreader.xmlTextReaderIsValid (reader) /= 1 then
fputs ("Document " & C.char'Val (0), C.stdio.stderr);
fputs (filename, C.stdio.stderr);
fputs (
" does not validate" & C.char'Val (10) & C.char'Val (0),
C.stdio.stderr);
end if;
C.libxml.xmlreader.xmlFreeTextReader (reader);
if ret /= 0 then
fputs (filename, C.stdio.stderr);
fputs (
" : failed to parse" & C.char'Val (10) & C.char'Val (0),
C.stdio.stderr);
end if;
else
fputs ("Unable to open " & C.char'Val (0), C.stdio.stderr);
fputs (filename, C.stdio.stderr);
fputs (C.char'Val (10) & C.char'Val (0), C.stdio.stderr);
end if;
end streamFile;
Dummy_signed_int : C.signed_int;
begin
stdout :=
C.stdio.fopen (
output (output'First)'Access,
Write_Mode (Write_Mode'First)'Access);
streamFile (argv1 (argv1'First)'Access);
Dummy_signed_int := C.stdio.fclose (stdout);
end reader2;
-- do as reader3.c
procedure reader3 (output : in C.char_array) is
-- streamFile:
-- @filename: the file name to parse
--
-- Parse and print information about an XML file.
--
-- Returns the resulting doc with just the elements preserved.
function extractFile (
filename : access constant C.char;
pattern : C.libxml.xmlstring.xmlChar_const_ptr)
return C.libxml.tree.xmlDocPtr
is
doc : C.libxml.tree.xmlDocPtr;
reader : C.libxml.xmlreader.xmlTextReaderPtr;
ret : C.signed_int;
begin
-- build an xmlReader for that file
reader := C.libxml.xmlreader.xmlReaderForFile (filename, null, 0);
if reader /= null then
-- add the pattern to preserve
if C.libxml.xmlreader.xmlTextReaderPreservePattern (
reader,
pattern,
null) < 0
then
fputs (filename, C.stdio.stderr);
fputs (
" : failed add preserve pattern " & C.char'Val (0),
C.stdio.stderr);
fputs (To_char_const_ptr (pattern), C.stdio.stderr);
fputs (C.char'Val (10) & C.char'Val (0), C.stdio.stderr);
end if;
-- Parse and traverse the tree, collecting the nodes in the process
ret := C.libxml.xmlreader.xmlTextReaderRead (reader);
while ret = 1 loop
ret := C.libxml.xmlreader.xmlTextReaderRead (reader);
end loop;
if ret /= 0 then
fputs (filename, C.stdio.stderr);
fputs (
" : failed to parse" & C.char'Val (10) & C.char'Val (0),
C.stdio.stderr);
C.libxml.xmlreader.xmlFreeTextReader (reader);
return null;
end if;
-- get the resulting nodes
doc := C.libxml.xmlreader.xmlTextReaderCurrentDoc (reader);
-- Free up the reader
C.libxml.xmlreader.xmlFreeTextReader (reader);
else
fputs ("Unable to open " & C.char'Val (0), C.stdio.stderr);
fputs (filename, C.stdio.stderr);
fputs (C.char'Val (10) & C.char'Val (0), C.stdio.stderr);
return null;
end if;
return doc;
end extractFile;
filename : constant C.char_array := "test3.xml" & C.char'Val (0);
pattern : constant C.char_array := "preserved" & C.char'Val (0);
doc : C.libxml.tree.xmlDocPtr;
Dummy_signed_int : C.signed_int;
begin
stdout :=
C.stdio.fopen (
output (output'First)'Access,
Write_Mode (Write_Mode'First)'Access);
doc :=
extractFile (
filename (filename'First)'Access,
To_xmlChar_const_ptr (pattern (pattern'First)'Unchecked_Access));
if doc /= null then
-- ouptut the result.
Dummy_signed_int := C.libxml.tree.xmlDocDump (stdout, doc);
-- don't forget to free up the doc
C.libxml.tree.xmlFreeDoc (doc);
end if;
Dummy_signed_int := C.stdio.fclose (stdout);
end reader3;
-- do as reader4.c
procedure reader4 (argv1, argv2, argv3, output : in C.char_array) is
procedure processDoc (readerPtr : C.libxml.xmlreader.xmlTextReaderPtr) is
ret : C.signed_int;
docPtr : C.libxml.tree.xmlDocPtr;
URL : C.libxml.xmlstring.xmlChar_const_ptr;
begin
ret := C.libxml.xmlreader.xmlTextReaderRead (readerPtr);
while ret = 1 loop
ret := C.libxml.xmlreader.xmlTextReaderRead (readerPtr);
end loop;
-- One can obtain the document pointer to get insteresting
-- information about the document like the URL, but one must also
-- be sure to clean it up at the end (see below).
docPtr := C.libxml.xmlreader.xmlTextReaderCurrentDoc (readerPtr);
if null = docPtr then
fputs (
"failed to obtain document" & C.char'Val (10) & C.char'Val (0),
C.stdio.stderr);
return;
end if;
URL := docPtr.URL;
if null = URL then
fputs (To_char_const_ptr (URL), C.stdio.stderr);
fputs (
": Failed to obtain URL" & C.char'Val (10) & C.char'Val (0),
C.stdio.stderr);
end if;
if ret /= 0 then
fputs (To_char_const_ptr (URL), C.stdio.stderr);
fputs (
" : failed to parse" & C.char'Val (10) & C.char'Val (0),
C.stdio.stderr);
return;
end if;
fputs (To_char_const_ptr (URL), stdout);
fputs (": Processed ok" & C.char'Val (10) & C.char'Val (0), stdout);
end processDoc;
readerPtr : C.libxml.xmlreader.xmlTextReaderPtr;
docPtr : C.libxml.tree.xmlDocPtr;
Dummy_signed_int : C.signed_int;
begin
stdout :=
C.stdio.fopen (
output (output'First)'Access,
Write_Mode (Write_Mode'First)'Access);
-- Create a new reader for the first file and process the document.
readerPtr :=
C.libxml.xmlreader.xmlReaderForFile (argv1 (argv1'First)'Access, null, 0);
if null = readerPtr then
fputs (argv1, C.stdio.stderr);
fputs (
": failed to create reader" & C.char'Val (10) & C.char'Val (0),
C.stdio.stderr);
raise Program_Error;
end if;
processDoc (readerPtr);
-- The reader can be reused for subsequent files.
for i in 2 .. 3 loop
declare
argv_i : access constant C.char;
begin
case i is
when 2 =>
argv_i := argv2 (argv2'First)'Access;
when 3 =>
argv_i := argv3 (argv3'First)'Access;
end case;
if C.libxml.xmlreader.xmlReaderNewFile (readerPtr, argv_i, null, 0) < 0 then
raise Program_Error;
end if;
if null = readerPtr then
fputs (argv_i, C.stdio.stderr);
fputs (
": failed to create reader" & C.char'Val (10) & C.char'Val (0),
C.stdio.stderr);
raise Program_Error;
end if;
processDoc (readerPtr);
end;
end loop;
-- Since we've called xmlTextReaderCurrentDoc, we now have to
-- clean up after ourselves. We only have to do this the last
-- time, because xmlReaderNewFile calls xmlCtxtReset which takes
-- care of it.
docPtr := C.libxml.xmlreader.xmlTextReaderCurrentDoc (readerPtr);
if docPtr /= null then
C.libxml.tree.xmlFreeDoc (docPtr);
end if;
-- Clean up the reader.
C.libxml.xmlreader.xmlFreeTextReader (readerPtr);
Dummy_signed_int := C.stdio.fclose (stdout);
end reader4;
begin
-- this initialize the library and check potential ABI mismatches
-- between the version it was compiled for and the actual shared
-- library used.
C.libxml.xmlversion.xmlCheckVersion (C.libxml.xmlversion.LIBXML_VERSION);
Tests : declare
Default_Temp : constant C.char_array (0 .. 4) := "/tmp" & C.char'Val (0);
function Get_Temp return access constant C.char is
TMPDIR : constant C.char_array (0 .. 6) := "TMPDIR" & C.char'Val (0);
Temp : access constant C.char := C.stdlib.getenv (TMPDIR (0)'Access);
begin
if Temp = null or else Temp.all = C.char'Val (0) then
Temp := Default_Temp (0)'Access;
end if;
return Temp;
end Get_Temp;
Temp : constant not null access constant C.char := Get_Temp;
Dummy_char_ptr : C.char_ptr;
begin
declare
argv1 : constant C.char_array := "test2.xml" & C.char'Val (0);
output_Name : constant C.char_array := "/reader1.tmp" & C.char'Val (0);
output : aliased C.char_array (0 .. C.string.strlen (Temp) + 256);
begin
Dummy_char_ptr := C.string.strcpy (output (0)'Access, Temp);
Dummy_char_ptr := C.string.strcat (output (0)'Access, output_Name (0)'Access);
reader1 (argv1, output);
end;
declare
argv1 : constant C.char_array := "test2.xml" & C.char'Val (0);
output_Name : constant C.char_array := "/reader2.tmp" & C.char'Val (0);
output : aliased C.char_array (0 .. C.string.strlen (Temp) + 256);
begin
Dummy_char_ptr := C.string.strcpy (output (0)'Access, Temp);
Dummy_char_ptr := C.string.strcat (output (0)'Access, output_Name (0)'Access);
reader2 (argv1, output);
end;
declare
output_Name : constant C.char_array := "/reader3.tmp" & C.char'Val (0);
output : aliased C.char_array (0 .. C.string.strlen (Temp) + 256);
begin
Dummy_char_ptr := C.string.strcpy (output (0)'Access, Temp);
Dummy_char_ptr := C.string.strcat (output (0)'Access, output_Name (0)'Access);
reader3 (output);
end;
declare
argv1 : constant C.char_array := "test1.xml" & C.char'Val (0);
argv2 : constant C.char_array := "test2.xml" & C.char'Val (0);
argv3 : constant C.char_array := "test3.xml" & C.char'Val (0);
output_Name : constant C.char_array := "/reader4.tmp" & C.char'Val (0);
output : aliased C.char_array (0 .. C.string.strlen (Temp) + 256);
begin
Dummy_char_ptr := C.string.strcpy (output (0)'Access, Temp);
Dummy_char_ptr := C.string.strcat (output (0)'Access, output_Name (0)'Access);
reader4 (argv1, argv2, argv3, output);
end;
end Tests;
-- Cleanup function for the XML library.
C.libxml.parser.xmlCleanupParser;
-- this is to debug memory for regression tests
C.libxml.xmlmemory.xmlMemoryDump;
-- finish
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error.all, "ok");
end test_reader;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
package body AWA.Commands.Info is
use type AWA.Modules.Module_Access;
-- ------------------------------
-- Print the configuration identified by the given name.
-- ------------------------------
procedure Print (Command : in out Command_Type;
Name : in String;
Value : in String;
Default : in String;
Context : in out Context_Type) is
pragma Unreferenced (Default);
Pos : Natural;
begin
Context.Console.Start_Row;
Context.Console.Print_Field (1, Name);
Pos := Value'First;
while Pos <= Value'Last loop
if Value'Last - Pos > Command.Value_Length then
Context.Console.Print_Field (2, Value (Pos .. Pos + Command.Value_Length - 1));
Pos := Pos + Command.Value_Length;
Context.Console.End_Row;
Context.Console.Start_Row;
Context.Console.Print_Field (1, "");
else
Context.Console.Print_Field (2, Value (Pos .. Value'Last));
Pos := Pos + Value'Length;
end if;
end loop;
Context.Console.End_Row;
end Print;
procedure Print (Command : in out Command_Type;
Application : in out AWA.Applications.Application'Class;
Name : in String;
Default : in String;
Context : in out Context_Type) is
Value : constant String := Application.Get_Init_Parameter (Name, Default);
begin
Command.Print (Name, Value, Default, Context);
end Print;
procedure Print (Command : in out Command_Type;
Module : in AWA.Modules.Module'Class;
Name : in String;
Default : in String;
Context : in out Context_Type) is
Value : constant String := Module.Get_Config (Name, Default);
begin
Command.Print (Module.Get_Name & "." & Name, Value, Default, Context);
end Print;
-- ------------------------------
-- Print the configuration about the application.
-- ------------------------------
overriding
procedure Execute (Command : in out Command_Type;
Application : in out AWA.Applications.Application'Class;
Args : in Argument_List'Class;
Context : in out Context_Type) is
pragma Unreferenced (Args);
Module : AWA.Modules.Module_Access;
begin
if Command.Long_List then
Command.Value_Length := Natural'Last;
end if;
Application.Load_Bundle (Name => "commands",
Locale => "en",
Bundle => Command.Bundle);
Context.Console.Start_Title;
Context.Console.Print_Title (1, "", 30);
Context.Console.Print_Title (2, "", Command.Value_Length);
Context.Console.End_Title;
Context.Console.Notice (N_INFO, "Database configuration");
Context.Console.Notice (N_INFO, "----------------------");
Command.Print (Application, "database", "", Context);
Command.Print (Application, "ado.queries.paths", "", Context);
Command.Print (Application, "ado.queries.load", "", Context);
Command.Print (Application, "ado.drivers.load", "", Context);
Context.Console.Start_Title;
Context.Console.Print_Title (1, "", 30);
Context.Console.Print_Title (2, "", Command.Value_Length);
Context.Console.End_Title;
Context.Console.Notice (N_INFO, "Server faces configuration");
Context.Console.Notice (N_INFO, "--------------------------");
Command.Print (Application, "view.dir",
ASF.Applications.DEF_VIEW_DIR, Context);
Command.Print (Application, "view.escape_unknown_tags",
ASF.Applications.DEF_ESCAPE_UNKNOWN_TAGS, Context);
Command.Print (Application, "view.ext",
ASF.Applications.DEF_VIEW_EXT, Context);
Command.Print (Application, "view.file_ext",
ASF.Applications.DEF_VIEW_FILE_EXT, Context);
Command.Print (Application, "view.ignore_spaces",
ASF.Applications.DEF_IGNORE_WHITE_SPACES, Context);
Command.Print (Application, "view.ignore_empty_lines",
ASF.Applications.DEF_IGNORE_EMPTY_LINES, Context);
Command.Print (Application, "view.static.dir",
ASF.Applications.DEF_STATIC_DIR, Context);
Command.Print (Application, "bundle.dir", "bundles", Context);
Context.Console.Start_Title;
Context.Console.Print_Title (1, "", 30);
Context.Console.Print_Title (2, "", Command.Value_Length);
Context.Console.End_Title;
Context.Console.Notice (N_INFO, "AWA Application");
Context.Console.Notice (N_INFO, "--------------------------");
Command.Print (Application, "app_name", "", Context);
Command.Print (Application, "app_search_dirs", ".", Context);
Command.Print (Application, "app.modules.dir", "", Context);
Command.Print (Application, "app_url_base", "", Context);
Command.Print (Application, "awa_url_host", "", Context);
Command.Print (Application, "awa_url_port", "", Context);
Command.Print (Application, "awa_url_scheme", "", Context);
Command.Print (Application, "app.config", "awa.xml", Context);
Command.Print (Application, "app.config.plugins", "", Context);
Command.Print (Application, "contextPath", "", Context);
Command.Print (Application, "awa_dispatcher_count", "", Context);
Command.Print (Application, "awa_dispatcher_priority", "", Context);
Module := Application.Find_Module ("users");
if Module /= null then
Context.Console.Start_Title;
Context.Console.Print_Title (1, "", 30);
Context.Console.Print_Title (2, "", Command.Value_Length);
Context.Console.End_Title;
Context.Console.Notice (N_INFO, "Users Module");
Context.Console.Notice (N_INFO, "------------");
Command.Print (Application, "openid.realm", "", Context);
Command.Print (Application, "openid.callback_url", "", Context);
Command.Print (Application, "openid.success_url", "", Context);
Command.Print (Application, "auth.url.orange", "", Context);
Command.Print (Application, "auth.provider.orange", "", Context);
Command.Print (Application, "auth.url.yahoo", "", Context);
Command.Print (Application, "auth.provider.yahoo", "", Context);
Command.Print (Application, "auth.url.google", "", Context);
Command.Print (Application, "auth.provider.google", "", Context);
Command.Print (Application, "auth.url.facebook", "", Context);
Command.Print (Application, "auth.provider.facebook", "", Context);
Command.Print (Application, "auth.url.google-plus", "", Context);
Command.Print (Application, "auth.provider.google-plus", "", Context);
Command.Print (Application, "facebook.callback_url", "", Context);
Command.Print (Application, "facebook.request_url", "", Context);
Command.Print (Application, "facebook.scope", "", Context);
Command.Print (Application, "facebook.client_id", "", Context);
Command.Print (Application, "facebook.secret", "", Context);
Command.Print (Application, "google-plus.issuer", "", Context);
Command.Print (Application, "google-plus.callback_url", "", Context);
Command.Print (Application, "google-plus.request_url", "", Context);
Command.Print (Application, "google-plus.scope", "", Context);
Command.Print (Application, "google-plus.client_id", "", Context);
Command.Print (Application, "google-plus.secret", "", Context);
Command.Print (Application, "auth-filter.redirect", "", Context);
Command.Print (Application, "verify-filter.redirect", "", Context);
Command.Print (Application, "users.auth_key", "", Context);
Command.Print (Application, "users.server_id", "", Context);
end if;
Module := Application.Find_Module ("mail");
if Module /= null then
Context.Console.Start_Title;
Context.Console.Print_Title (1, "", 30);
Context.Console.Print_Title (2, "", Command.Value_Length);
Context.Console.End_Title;
Context.Console.Notice (N_INFO, "Mail Module");
Context.Console.Notice (N_INFO, "-----------");
Command.Print (Application, "mail.smtp.host", "", Context);
Command.Print (Application, "mail.smtp.port", "", Context);
Command.Print (Application, "mail.smtp.enable", "true", Context);
Command.Print (Application, "mail.mailer", "smtp", Context);
Command.Print (Application, "mail.file.maildir", "mail", Context);
Command.Print (Application, "app_mail_name", "", Context);
Command.Print (Application, "app_mail_from", "", Context);
end if;
Module := Application.Find_Module ("workspaces");
if Module /= null then
Context.Console.Start_Title;
Context.Console.Print_Title (1, "", 30);
Context.Console.Print_Title (2, "", Command.Value_Length);
Context.Console.End_Title;
Context.Console.Notice (N_INFO, "Workspace Module");
Context.Console.Notice (N_INFO, "----------------");
Command.Print (Module.all, "permissions_list", "", Context);
Command.Print (Module.all, "allow_workspace_create", "", Context);
end if;
Module := Application.Find_Module ("storages");
if Module /= null then
Context.Console.Start_Title;
Context.Console.Print_Title (1, "", 30);
Context.Console.Print_Title (2, "", Command.Value_Length);
Context.Console.End_Title;
Context.Console.Notice (N_INFO, "Storage Module");
Context.Console.Notice (N_INFO, "--------------------------");
Command.Print (Module.all, "database_max_size", "100000", Context);
Command.Print (Module.all, "storage_root", "storage", Context);
Command.Print (Module.all, "tmp_storage_root", "tmp", Context);
Module := Application.Find_Module ("images");
if Module /= null then
Command.Print (Module.all, "thumbnail_command", "", Context);
end if;
end if;
Module := Application.Find_Module ("wikis");
if Module /= null then
Context.Console.Start_Title;
Context.Console.Print_Title (1, "", 30);
Context.Console.Print_Title (2, "", Command.Value_Length);
Context.Console.End_Title;
Context.Console.Notice (N_INFO, "Wiki Module");
Context.Console.Notice (N_INFO, "-----------");
Command.Print (Module.all, "image_prefix", "", Context);
Command.Print (Module.all, "page_prefix", "", Context);
Command.Print (Module.all, "wiki_copy_list", "", Context);
Module := Application.Find_Module ("wiki_previews");
if Module /= null then
Command.Print (Module.all, "wiki_preview_tmp", "tmp", Context);
Command.Print (Module.all, "wiki_preview_dir", "web/preview", Context);
Command.Print (Module.all, "wiki_preview_template", "", Context);
Command.Print (Module.all, "wiki_preview_html", "", Context);
Command.Print (Module.all, "wiki_preview_command", "", Context);
end if;
end if;
Module := Application.Find_Module ("counters");
if Module /= null then
Context.Console.Start_Title;
Context.Console.Print_Title (1, "", 30);
Context.Console.Print_Title (2, "", Command.Value_Length);
Context.Console.End_Title;
Context.Console.Notice (N_INFO, "Counter Module");
Context.Console.Notice (N_INFO, "--------------");
Command.Print (Module.all, "counter_age_limit", "300", Context);
Command.Print (Module.all, "counter_limit", "1000", Context);
end if;
end Execute;
-- ------------------------------
-- Setup the command before parsing the arguments and executing it.
-- ------------------------------
overriding
procedure Setup (Command : in out Command_Type;
Config : in out GNAT.Command_Line.Command_Line_Configuration;
Context : in out Context_Type) is
begin
GC.Set_Usage (Config => Config,
Usage => Command.Get_Name & " [arguments]",
Help => Command.Get_Description);
Command_Drivers.Application_Command_Type (Command).Setup (Config, Context);
GC.Define_Switch (Config => Config,
Output => Command.Long_List'Access,
Switch => "-l",
Long_Switch => "--long-lines",
Help => -("Use long lines to print configuration values"));
end Setup;
-- ------------------------------
-- 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, Context);
begin
null;
end Help;
begin
Command_Drivers.Driver.Add_Command ("info",
-("report configuration information"),
Command'Access);
end AWA.Commands.Info;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--
with HW.GFX.GMA.Registers;
package body HW.GFX.GMA.PCH.Sideband is
SBI_CTL_DEST_ICLK : constant := 0 * 2 ** 16;
SBI_CTL_DEST_MPHY : constant := 1 * 2 ** 16;
SBI_CTL_OP_IORD : constant := 2 * 2 ** 8;
SBI_CTL_OP_IOWR : constant := 3 * 2 ** 8;
SBI_CTL_OP_CRRD : constant := 6 * 2 ** 8;
SBI_CTL_OP_CRWR : constant := 7 * 2 ** 8;
SBI_RESPONSE_FAIL : constant := 1 * 2 ** 1;
SBI_BUSY : constant := 1 * 2 ** 0;
type Register_Array is array (Register_Type) of Word32;
Register_Addr : constant Register_Array := Register_Array'
(SBI_SSCDIVINTPHASE6 => 16#0600_0000#,
SBI_SSCCTL6 => 16#060c_0000#,
SBI_SSCAUXDIV => 16#0610_0000#);
----------------------------------------------------------------------------
procedure Read
(Dest : in Destination_Type;
Register : in Register_Type;
Value : out Word32)
is
begin
Registers.Wait_Unset_Mask
(Register => Registers.SBI_CTL_STAT,
Mask => SBI_BUSY);
Registers.Write
(Register => Registers.SBI_ADDR,
Value => Register_Addr (Register));
if Dest = SBI_ICLK then
Registers.Write
(Register => Registers.SBI_CTL_STAT,
Value => SBI_CTL_DEST_ICLK or SBI_CTL_OP_CRRD or SBI_BUSY);
else
Registers.Write
(Register => Registers.SBI_CTL_STAT,
Value => SBI_CTL_DEST_MPHY or SBI_CTL_OP_IORD or SBI_BUSY);
end if;
Registers.Wait_Unset_Mask
(Register => Registers.SBI_CTL_STAT,
Mask => SBI_BUSY);
Registers.Read
(Register => Registers.SBI_DATA,
Value => Value);
end Read;
procedure Write
(Dest : in Destination_Type;
Register : in Register_Type;
Value : in Word32)
is
begin
Registers.Wait_Unset_Mask
(Register => Registers.SBI_CTL_STAT,
Mask => SBI_BUSY);
Registers.Write
(Register => Registers.SBI_ADDR,
Value => Register_Addr (Register));
Registers.Write
(Register => Registers.SBI_DATA,
Value => Value);
if Dest = SBI_ICLK then
Registers.Write
(Register => Registers.SBI_CTL_STAT,
Value => SBI_CTL_DEST_ICLK or SBI_CTL_OP_CRWR or SBI_BUSY);
else
Registers.Write
(Register => Registers.SBI_CTL_STAT,
Value => SBI_CTL_DEST_MPHY or SBI_CTL_OP_IOWR or SBI_BUSY);
end if;
Registers.Wait_Unset_Mask
(Register => Registers.SBI_CTL_STAT,
Mask => SBI_BUSY);
end Write;
----------------------------------------------------------------------------
procedure Unset_Mask
(Dest : in Destination_Type;
Register : in Register_Type;
Mask : in Word32)
is
Value : Word32;
begin
Read (Dest, Register, Value);
Write (Dest, Register, Value and not Mask);
end Unset_Mask;
procedure Set_Mask
(Dest : in Destination_Type;
Register : in Register_Type;
Mask : in Word32)
is
Value : Word32;
begin
Read (Dest, Register, Value);
Write (Dest, Register, Value or Mask);
end Set_Mask;
procedure Unset_And_Set_Mask
(Dest : in Destination_Type;
Register : in Register_Type;
Mask_Unset : in Word32;
Mask_Set : in Word32)
is
Value : Word32;
begin
Read (Dest, Register, Value);
Write (Dest, Register, (Value and not Mask_Unset) or Mask_Set);
end Unset_And_Set_Mask;
end HW.GFX.GMA.PCH.Sideband;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
package body Angle is
function Find_Angle (X_Coordinate, Y_Coordinate : Float) return Float is
begin
if Y_Coordinate = 0.0 then
return Arctan(X_Coordinate/0.0000001); -- Might use exception instead later
end if;
return Arctan(X_Coordinate/Y_Coordinate);
end Find_Angle;
function To_Degrees (Radians : Float) return Float is
begin
return Radians * (Max_Deg/Pi_As_Float);
end To_Degrees;
function To_Radians (Degrees : Float) return Float is
begin
return Degrees * (Pi_As_Float/Max_Deg);
end To_Radians;
end Angle;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
---------------------------------------------------------------------------
package Ada.Strings is
pragma Pure (Strings);
Space : constant Character := ' ';
Wide_Space : constant Wide_Character := ' ';
Wide_Wide_Space : constant Wide_Wide_Character := ' ';
Length_Error, Pattern_Error, Index_Error, Translation_Error
: exception;
type Alignment is (Left, Right, Center);
type Truncation is (Left, Right, Error);
type Membership is (Inside, Outside);
type Direction is (Forward, Backward);
type Trim_End is (Left, Right, Both);
end Ada.Strings;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
----------------------------------------------------------------------------
with Symbolic_Expressions;
package Test is
function Get_Int (X : String) return String;
type Int_Array is array (Positive range <>) of Integer;
function Call (Name : String; Param : Int_Array)
return Integer;
package Int_Expr is
new Symbolic_Expressions (Scalar_Type => Integer,
Scalar_Array => Int_Array,
Read_Scalar => Get_Int,
Value => Integer'Value,
Image => Integer'Image);
end Test;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with HAL; use HAL;
with STM32.GPIO; use STM32.GPIO;
with STM32.ADC; use STM32.ADC;
with STM_Board; use STM_Board;
package Inverter_ADC is
-- Performs analog to digital conversions in a timed manner.
-- The timer starts ADC conversions and, at the end of conversion, it
-- produces an interrupt that actualizes the buffer of ADC values and
-- corrects the duty cycle for variations in battery voltage.
Sensor_Frequency_Hz : constant := 5_000;
-- Timer PWM frequency that controls start of ADC convertion.
subtype Voltage is Float;
-- Represents an electric measure.
ADC_Vref : constant Voltage := 3.3;
-- ADC full scale voltage.
Battery_V : constant Voltage := 12.0;
-- Battery nominal voltage.
subtype Battery_V_Range is Voltage range (Battery_V * 0.8) .. (Battery_V * 1.2);
-- Battery voltage tolerance is Battery_V ± 20%.
Battery_Relation : Float := 10_000.0 / 90_900.0; -- 10 kΩ / 90.9 kΩ
-- Resistive relation between the measured ADC input and the battery
-- voltage. This depends on the electronic circuitry.
Inverter_Power : constant Voltage := 300.0;
-- Inverter nominal electric power.
Battery_I : constant Voltage := Inverter_Power / Battery_V_Range'First;
-- Battery nominal current with maximum inverter power and
-- minimum battery voltage.
subtype Battery_I_Range is Voltage range 0.0 .. (Battery_I * 1.1);
-- Battery current tolerance is Battery_I + 10%.
Output_V : constant Voltage := 220.0;
-- AC output RMS voltage.
subtype Output_V_Range is Voltage range (Output_V * 0.9) .. (Output_V * 1.1);
-- AC ouput voltage tolerance is Output_V ± 10%.
Output_Relation : Float := 10_000.0 / 90_900.0; -- 10 kΩ / 90.9 kΩ
-- Resistive relation between the measured ADC input and the AC output
-- voltage. This depends on the electronic circuitry.
type ADC_Reading is
(V_Battery, I_Battery, V_Output);
-- Specifies the available readings.
procedure Initialize_ADC;
-- Initialize the ADCs.
function Get_Sample (Reading : in ADC_Reading) return Voltage
with
Pre => Is_Initialized;
-- Get the specified ADC reading.
subtype Gain_Range is Float range 0.0 .. 1.0;
-- For correcting battery voltage and AC output variation.
Sine_Gain : Gain_Range := 0.0;
function Battery_Gain
(V_Setpoint : Battery_V_Range := Battery_V_Range'First;
V_Actual : Voltage := Get_Sample (V_Battery)) return Gain_Range;
-- Calculate the gain of the sinusoid as a function of the
-- battery voltage.
function Test_V_Battery return Boolean
with
Pre => Is_Initialized;
-- Test if battery voltage is between maximum and minimum.
function Test_I_Battery return Boolean
with
Pre => Is_Initialized;
-- Test if battery current is below maximum.
function Test_V_Output return Boolean
with
Pre => Is_Initialized;
-- Test if output voltage is between maximum and minimum.
function Is_Initialized return Boolean;
private
Initialized : Boolean := False;
ADC_V_Per_Lsb : constant Float := ADC_Vref / 4_095.0; -- 12 bit
type Regular_Samples_Array is array (ADC_Reading'Range) of UInt16;
for Regular_Samples_Array'Component_Size use 16;
Regular_Samples : Regular_Samples_Array := (others => 0) with Volatile;
type ADC_Settings is record
GPIO_Entry : GPIO_Point;
ADC_Entry : ADC_Point;
Channel_Rank : Regular_Channel_Rank;
end record;
type ADC_Readings is array (ADC_Reading'Range) of ADC_Settings;
ADC_Reading_Settings : constant ADC_Readings :=
((V_Battery) => (GPIO_Entry => ADC_Battery_V_Pin,
ADC_Entry => ADC_Battery_V_Point,
Channel_Rank => 1),
(I_Battery) => (GPIO_Entry => ADC_Battery_I_Pin,
ADC_Entry => ADC_Battery_I_Point,
Channel_Rank => 2),
(V_Output) => (GPIO_Entry => ADC_Output_V_Pin,
ADC_Entry => ADC_Output_V_Point,
Channel_Rank => 3));
protected Sensor_Handler is
pragma Interrupt_Priority (Sensor_ISR_Priority);
private
Rank : ADC_Reading := ADC_Reading'First;
Counter : Integer := 0;
-- For testing the output.
procedure Sensor_ADC_Handler with
Attach_Handler => Sensor_Interrupt;
end Sensor_Handler;
end Inverter_ADC;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
------------------------------------------------------
--| Semaphores |
------------------------------------------------------
--| Author | Jack (Yevhenii) Shendrikov |
--| Group | IO-82 |
--| Variant | #25 |
--| Date | 29.11.2020 |
------------------------------------------------------
--| Function 1 | D = SORT(A)+SORT(B)+SORT(C)*(MA*ME) |
--| Function 2 | MF = (MG*MH)*TRANS(MK) |
--| Function 3 | S = (MO*MP)*V+t*MR*(O+P) |
------------------------------------------------------
with Data;
with Ada.Integer_Text_IO, Ada.Text_IO, Ada.Characters.Latin_1;
use Ada.Integer_Text_IO, Ada.Text_IO, Ada.Characters.Latin_1;
with System.Multiprocessors; use System.Multiprocessors;
with Semaphores;
use Semaphores;
procedure Lab1 is
N: Integer;
MY_SIMA : SIMA (1,2);
procedure Tasks is
package My_Data is new Data(N);
use My_Data;
CPU_0: CPU_Range := 0;
CPU_1: CPU_Range := 1;
CPU_2: CPU_Range := 2;
task T1 is
pragma Task_Name("T1");
pragma Priority(4);
pragma Storage_Size(500000000);
pragma CPU (CPU_0);
end T1;
task T2 is
pragma Task_Name("T2");
pragma Priority(3);
pragma Storage_Size(500000000);
pragma CPU (CPU_1);
end T2;
task T3 is
pragma Task_Name("T3");
pragma Priority(7);
pragma Storage_Size(500000000);
pragma CPU (CPU_2);
end T3;
task body T1 is
A,B,C,D: Vector;
MA,ME: Matrix;
begin
Put_Line("Task T1 started");
delay 0.7;
Put_Line("T1 is waiting for a permit.");
-- Generate Input Values
MY_SIMA.P; -- Acquire the semaphore
New_Line; Put_Line("T1 gets a permit.");
delay 1.0;
Input_Val_F1(A,B,C,MA,ME);
Put_Line("T1 releases the permit.");
MY_SIMA.V; -- Release the semaphore
New_Line; Put_Line("T1 is waiting for a permit.");
-- Calculate The Result
D := Func1(A,B,C,MA,ME);
delay 1.0;
-- Output
MY_SIMA.P; -- Acquire the semaphore
Put_Line("T1 gets a permit.");
Put("T1 | ");
Vector_Output(D, "D");
Put_Line("T1 releases the permit."); New_Line;
MY_SIMA.V; -- Release the semaphore
Put_Line("Task T1 finished"); New_Line;
end T1;
task body T2 is
MG,MH,MK,MF: Matrix;
begin
Put_Line("Task T2 started");
delay 1.0;
Put_Line("T2 is waiting for a permit.");
-- Generate Input Values
MY_SIMA.P; -- Acquire the semaphore
New_Line; Put_Line("T2 gets a permit.");
delay 1.0;
Input_Val_F2(MG,MH,MK);
Put_Line("T2 releases the permit."); New_Line;
MY_SIMA.V; -- Release the semaphore
New_Line; Put_Line("T2 is waiting for a permit.");
-- Calculate The Result
MF := Func2(MG,MH,MK);
delay 1.0;
-- Output
MY_SIMA.P; -- Acquire the semaphore
Put_Line("T2 gets a permit.");
Put_Line("T2 | ");
Matrix_Output(MF, "MF");
Put_Line("T2 releases the permit.");
MY_SIMA.V; -- Release the semaphore
Put_Line("Task T2 finished"); New_Line;
end T2;
task body T3 is
t: Integer;
V,O,P,S: Vector;
MO,MP,MR: Matrix;
begin
Put_Line("Task T3 started");
delay 0.5;
Put_Line("T3 is waiting for a permit.");
-- Generate Input Values
MY_SIMA.P; -- Acquire the semaphore
New_Line; Put_Line("T3 gets a permit.");
delay 1.0;
Input_Val_F3(t,V,O,P,MO,MP,MR);
Put_Line("T3 releases the permit.");
MY_SIMA.V; -- Release the semaphore
New_Line; Put_Line("T3 is waiting for a permit.");
-- Calculate The Result
S := Func3(t,V,O,P,MO,MP,MR);
delay 1.0;
-- Output
MY_SIMA.P; -- Acquire the semaphore
Put_Line("T3 gets a permit.");
Put("T3 | ");
Vector_Output(S, "S");
Put_Line("T3 releases the permit."); New_Line;
MY_SIMA.V; -- Release the semaphore
Put_Line("Task T3 finished"); New_Line;
end T3;
begin
Put_Line("Calculations started");
New_Line;
end Tasks;
begin
Put_Line("Function 1: D = SORT(A)+SORT(B)+SORT(C)*(MA*ME)" & CR & LF
& "Function 2: MF = (MG*MH)*TRANS(MK)" & CR & LF
& "Function 3: S = (MO*MP)*V+t*MR*(O+P)" & CR & LF);
Put_Line("!!! Note that if the value of N > 10 -> the result will not be displayed !!!" & CR & LF
& "!!! If you enter N <= 0 - execution will be terminated !!!" & CR & LF);
Put("Enter N: ");
Get(N);
New_Line;
Tasks;
Put_Line("All task finished");
end Lab1;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- Version for sqlite
with GNATCOLL.SQL_Impl; use GNATCOLL.SQL_Impl;
with GNATCOLL.SQL.Exec; use GNATCOLL.SQL.Exec;
with GNATCOLL.SQL.Sqlite; use GNATCOLL.SQL;
procedure Prepared_Query is
DB_Descr : Database_Description;
Conn : Database_Connection;
Query : Prepared_Statement;
--sqlite does not support boolean fields
True_Str : aliased String := "TRUE";
Param : SQL_Parameters (1 .. 4) :=
(1 => (Parameter_Text, null),
2 => (Parameter_Integer, 0),
3 => (Parameter_Text, null),
4 => (Parameter_Integer, 0));
begin
-- Allocate and initialize the description of the connection
Setup_Database (DB_Descr, "rosetta.db", "", "", "", DBMS_Sqlite);
-- Allocate the connection
Conn := Sqlite.Build_Sqlite_Connection (DB_Descr);
-- Initialize the connection
Reset_Connection (DB_Descr, Conn);
Query :=
Prepare
("UPDATE players SET name = ?, score = ?, active = ? " &
" WHERE jerseyNum = ?");
declare
Name : aliased String := "<NAME>";
begin
Param := ("+" (Name'Access), "+" (42), "+" (True_Str'Access), "+" (99));
Execute (Conn, Query, Param);
end;
Commit_Or_Rollback (Conn);
Free (Conn);
Free (DB_Descr);
end Prepared_Query;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--
with Ada.Unchecked_Conversion;
with HW.Debug;
with GNAT.Source_Info;
with HW.GFX.DP_Defs;
use type HW.Word8;
package body HW.GFX.DP_Info is
procedure Read_Caps
(Link : in out DP_Link;
Port : in T;
Success : out Boolean)
is
Data : DP_Defs.Aux_Payload;
Length : DP_Defs.Aux_Payload_Length;
Caps_Size : constant := 15;
begin
pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
Length := Caps_Size;
Aux_Ch.Aux_Read
(Port => Port,
Address => 16#00000#,
Length => Length,
Data => Data,
Success => Success);
Success := Success and Length = Caps_Size;
if Length = Caps_Size then
Link.Receiver_Caps.Rev := Data (0);
case Data (1) is
when 16#06# =>
Link.Receiver_Caps.Max_Link_Rate := DP_Bandwidth_1_62;
when 16#0a# =>
Link.Receiver_Caps.Max_Link_Rate := DP_Bandwidth_2_7;
when 16#14# =>
Link.Receiver_Caps.Max_Link_Rate := DP_Bandwidth_5_4;
when others =>
if Data (1) > 16#14# then
Link.Receiver_Caps.Max_Link_Rate := DP_Bandwidth_5_4;
else
Link.Receiver_Caps.Max_Link_Rate := DP_Bandwidth_1_62;
end if;
end case;
case Data (2) and 16#1f# is
when 0 | 1 =>
Link.Receiver_Caps.Max_Lane_Count := DP_Lane_Count_1;
when 2 | 3 =>
Link.Receiver_Caps.Max_Lane_Count := DP_Lane_Count_2;
when others =>
Link.Receiver_Caps.Max_Lane_Count := DP_Lane_Count_4;
end case;
Link.Receiver_Caps.TPS3_Supported := (Data (2) and 16#40#) /= 0;
Link.Receiver_Caps.Enhanced_Framing := (Data (2) and 16#80#) /= 0;
Link.Receiver_Caps.No_Aux_Handshake := (Data (3) and 16#40#) /= 0;
Link.Receiver_Caps.Aux_RD_Interval := Data (14);
pragma Debug (Debug.New_Line);
pragma Debug (Debug.Put_Line ("DPCD:"));
pragma Debug (Debug.Put_Reg8 (" Rev ", Data (0)));
pragma Debug (Debug.Put_Reg8 (" Max_Link_Rate ", Data (1)));
pragma Debug (Debug.Put_Reg8 (" Max_Lane_Count ", Data (2) and 16#1f#));
pragma Debug (Debug.Put_Reg8 (" TPS3_Supported ", Data (2) and 16#40#));
pragma Debug (Debug.Put_Reg8 (" Enhanced_Framing", Data (2) and 16#80#));
pragma Debug (Debug.Put_Reg8 (" No_Aux_Handshake", Data (3) and 16#40#));
pragma Debug (Debug.Put_Reg8 (" Aux_RD_Interval ", Data (14)));
pragma Debug (Debug.New_Line);
end if;
end Read_Caps;
procedure Minimum_Lane_Count
(Link : in out DP_Link;
Mode : in Mode_Type;
Success : out Boolean)
with
Depends => ((Link, Success) => (Link, Mode))
is
function Link_Pixel_Per_Second
(Link_Rate : DP_Bandwidth)
return Positive
with
Post => Pos64 (Link_Pixel_Per_Second'Result) <=
((DP_Symbol_Rate_Type'Last * 8) / 3) / BPC_Type'First
is
begin
-- Link_Rate is brutto with 8/10 bit symbols; three colors
pragma Assert (Positive (DP_Symbol_Rate (Link_Rate)) <= (Positive'Last / 8) * 3);
pragma Assert ((Int64 (DP_Symbol_Rate (Link_Rate)) * 8) / 3
>= Int64 (BPC_Type'Last));
return Positive
(((Int64 (DP_Symbol_Rate (Link_Rate)) * 8) / 3)
/ Int64 (Mode.BPC));
end Link_Pixel_Per_Second;
Count : Natural;
begin
Count := Link_Pixel_Per_Second (Link.Bandwidth);
Count := (Positive (Mode.Dotclock) + Count - 1) / Count;
Success := True;
case Count is
when 1 => Link.Lane_Count := DP_Lane_Count_1;
when 2 => Link.Lane_Count := DP_Lane_Count_2;
when 3 | 4 => Link.Lane_Count := DP_Lane_Count_4;
when others => Success := False;
end case;
end Minimum_Lane_Count;
procedure Preferred_Link_Setting
(Link : in out DP_Link;
Mode : in Mode_Type;
Success : out Boolean)
is
begin
Link.Bandwidth := Link.Receiver_Caps.Max_Link_Rate;
Link.Enhanced_Framing := Link.Receiver_Caps.Enhanced_Framing;
Minimum_Lane_Count (Link, Mode, Success);
Success := Success and
Link.Lane_Count <= Link.Receiver_Caps.Max_Lane_Count;
pragma Debug (not Success, Debug.Put_Line
("Mode requirements exceed available bandwidth!"));
end Preferred_Link_Setting;
procedure Next_Link_Setting
(Link : in out DP_Link;
Mode : in Mode_Type;
Success : out Boolean)
is
begin
if Link.Bandwidth > DP_Bandwidth'First then
Link.Bandwidth := DP_Bandwidth'Pred (Link.Bandwidth);
Minimum_Lane_Count (Link, Mode, Success);
Success := Success and
Link.Lane_Count <= Link.Receiver_Caps.Max_Lane_Count;
else
Success := False;
end if;
end Next_Link_Setting;
procedure Dump_Link_Setting (Link : DP_Link)
is
begin
Debug.Put ("Trying DP settings: Symbol Rate = ");
Debug.Put_Int32 (Int32 (DP_Symbol_Rate (Link.Bandwidth)));
Debug.Put ("; Lane Count = ");
Debug.Put_Int32 (Int32 (Lane_Count_As_Integer (Link.Lane_Count)));
Debug.New_Line;
Debug.New_Line;
end Dump_Link_Setting;
----------------------------------------------------------------------------
procedure Calculate_M_N
(Link : in DP_Link;
Mode : in Mode_Type;
Data_M : out M_Type;
Data_N : out N_Type;
Link_M : out M_Type;
Link_N : out N_Type)
is
DATA_N_MAX : constant := 16#800000#;
LINK_N_MAX : constant := 16#100000#;
subtype Calc_M_Type is Int64 range 0 .. 2 ** 36;
subtype Calc_N_Type is Int64 range 0 .. 2 ** 36;
subtype N_Rounded_Type is Int64 range
0 .. Int64'Max (DATA_N_MAX, LINK_N_MAX);
M : Calc_M_Type;
N : Calc_N_Type;
procedure Cancel_M_N
(M : in out Calc_M_Type;
N : in out Calc_N_Type;
N_Max : in N_Rounded_Type)
with
Depends => ((M, N) => (M, N, N_max)),
Pre => (N > 0 and M in 0 .. Calc_M_Type'Last / 2),
Post => (M <= M_N_Max and N <= M_N_Max)
is
Orig_N : constant Calc_N_Type := N;
function Round_N (N : Calc_N_Type) return N_Rounded_Type
with
Post => (Round_N'Result <= N * 2)
is
RN : Calc_N_Type;
RN2 : Calc_N_Type := N_Max;
begin
loop
RN := RN2;
RN2 := RN2 / 2;
exit when RN2 < N;
pragma Loop_Invariant (RN2 = RN / 2 and RN2 in N .. N_Max);
end loop;
return RN;
end Round_N;
begin
N := Round_N (N);
-- The automatic provers need a little nudge here.
pragma Assert
(if M <= Calc_M_Type'Last/2 and
N <= Orig_N * 2 and
Orig_N > 0 and
M > 0
then
M * N / Orig_N <= Calc_M_Type'Last);
pragma Annotate (GNATprove, False_Positive,
"assertion might fail",
"The property cannot be proven automatically. An Isabelle proof is included as an axiom");
M := M * N / Orig_N;
-- This loop is never hit for sane values (i.e. M <= N) but
-- we have to make sure returned values are always in range.
while M > M_N_Max loop
pragma Loop_Invariant (N <= M_N_Max);
M := M / 2;
N := N / 2;
end loop;
end Cancel_M_N;
begin
pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
pragma Assert (3
* Mode.BPC
* Mode.Dotclock
in Pos64);
M := 3
* Mode.BPC
* Mode.Dotclock;
pragma Assert (8
* DP_Symbol_Rate (Link.Bandwidth)
* Lane_Count_As_Integer (Link.Lane_Count)
in Pos64);
N := 8
* DP_Symbol_Rate (Link.Bandwidth)
* Lane_Count_As_Integer (Link.Lane_Count);
Cancel_M_N (M, N, DATA_N_MAX);
Data_M := M;
Data_N := N;
-------------------------------------------------------------------
M := Pos64 (Mode.Dotclock);
N := Pos64 (DP_Symbol_Rate (Link.Bandwidth));
Cancel_M_N (M, N, LINK_N_MAX);
Link_M := M;
Link_N := N;
end Calculate_M_N;
----------------------------------------------------------------------------
procedure Read_Link_Status
(Port : in T;
Status : out Link_Status;
Success : out Boolean)
is
subtype Status_Index is DP_Defs.Aux_Payload_Index range 0 .. 5;
subtype Status_Buffer is Buffer (Status_Index);
function Buffer_As_Status is new Ada.Unchecked_Conversion
(Source => Status_Buffer, Target => Link_Status);
Data : DP_Defs.Aux_Payload;
Length : DP_Defs.Aux_Payload_Length;
begin
pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
Length := Status_Index'Last + 1;
Aux_Ch.Aux_Read
(Port => Port,
Address => 16#00202#,
Length => Length,
Data => Data,
Success => Success);
Success := Success and Length = Status_Index'Last + 1;
Status := Buffer_As_Status (Data (Status_Index));
end Read_Link_Status;
function All_CR_Done
(Status : Link_Status;
Link : DP_Link)
return Boolean
is
CR_Done : Boolean := True;
begin
for Lane in Lane_Index
range 0 .. Lane_Index (Lane_Count_As_Integer (Link.Lane_Count) - 1)
loop
CR_Done := CR_Done and Status.Lanes (Lane).CR_Done;
end loop;
return CR_Done;
end All_CR_Done;
function All_EQ_Done
(Status : Link_Status;
Link : DP_Link)
return Boolean
is
EQ_Done : Boolean := True;
begin
for Lane in Lane_Index
range 0 .. Lane_Index (Lane_Count_As_Integer (Link.Lane_Count) - 1)
loop
EQ_Done := EQ_Done and Status.Lanes (Lane).CR_Done
and Status.Lanes (Lane).Channel_EQ_Done
and Status.Lanes (Lane).Symbol_Locked;
end loop;
return EQ_Done and Status.Interlane_Align_Done;
end All_EQ_Done;
function Max_Requested_VS
(Status : Link_Status;
Link : DP_Link)
return DP_Voltage_Swing
is
VS : DP_Voltage_Swing := DP_Voltage_Swing'First;
begin
for Lane in Lane_Index
range 0 .. Lane_Index (Lane_Count_As_Integer (Link.Lane_Count) - 1)
loop
if Status.Adjust_Requests (Lane).Voltage_Swing > VS then
VS := Status.Adjust_Requests (Lane).Voltage_Swing;
end if;
end loop;
return VS;
end Max_Requested_VS;
function Max_Requested_Emph
(Status : Link_Status;
Link : DP_Link)
return DP_Pre_Emph
is
Emph : DP_Pre_Emph := DP_Pre_Emph'First;
begin
for Lane in Lane_Index
range 0 .. Lane_Index (Lane_Count_As_Integer (Link.Lane_Count) - 1)
loop
if Status.Adjust_Requests (Lane).Pre_Emph > Emph then
Emph := Status.Adjust_Requests (Lane).Pre_Emph;
end if;
end loop;
return Emph;
end Max_Requested_Emph;
end HW.GFX.DP_Info;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Containers.Vectors;
with Ada.Exceptions;
with Ada.Strings;
with Ada.Strings.Fixed;
with Ada.Text_IO;
with Rejuvenation.Factory;
with Rejuvenation.Finder;
with Rejuvenation.Navigation;
with Libadalang.Analysis;
with Libadalang.Common;
with Langkit_Support.Slocs;
with Langkit_Support.Text;
with Basic_Declaration;
with Basic_Subprogram_Calls;
with Generic_Subprogram_Calls;
with Task_Subprogram_Calls;
with Aspect_Subprogram_Calls;
with Tagged_Subprogram_Calls;
with Operator_Subprogram_Calls;
with Test_Call_Filtering;
with Test_Operator_Attribute;
with Package_Without_Body;
with Subprogram_Unit;
with Subprogram_Unit_2;
with Deferred_Constant;
with Forward_Declaration;
procedure Main is
package LAL renames Libadalang.Analysis;
package LALCO renames Libadalang.Common;
Context : Rejuvenation.Factory.Project_Context := Rejuvenation.Factory.Open_Project("syntax_examples.gpr");
Units : Rejuvenation.Factory.Analysis_Unit_Vectors.Vector := Rejuvenation.Factory.Open_Files_From_Project(Context, False);
function Get_Filename(Node : LAL.Ada_Node'Class) return String is
use Ada.Strings;
use Ada.Strings.Fixed;
Unit_Filename : constant String := Node.Unit.Get_Filename;
Filename_Start : constant Natural := Index(Unit_Filename, "\", Backward);
begin
return Delete(Unit_Filename, Unit_Filename'First, Filename_Start);
end Get_Filename;
function Get_Location(Node : LAL.Ada_Node'Class) return String is
Filename : constant String := Get_Filename(Node);
Sloc_Range : constant String := Langkit_Support.Slocs.Image(Node.Sloc_Range);
begin
return Filename & "[" & Sloc_Range & "]";
end Get_Location;
function Find_Node_Of_Kind(Node : LAL.Ada_Node'Class; Node_Kind : LALCO.Ada_Node_Kind_Type) return Boolean is
Filename : constant String := Get_Filename(Node);
Found : Boolean := False;
begin
for Node_Of_Kind of Rejuvenation.Finder.Find(Node, Node_Kind) loop
Found := True;
Ada.Text_IO.New_Line;
Node_Of_Kind.Print(Line_Prefix => Filename & ": ");
Ada.Text_IO.New_Line;
end loop;
return Found;
end Find_Node_Of_Kind;
procedure Find_Basic_Decls is
use type LALCO.Ada_Basic_Decl;
package Ada_Basic_Decl_Vectors is new Ada.Containers.Vectors(Positive, LALCO.Ada_Basic_Decl);
use Ada_Basic_Decl_Vectors;
Unit_Specification, Unit_Body : LAL.Analysis_Unit;
Missing_Basic_Decls : Vector;
begin
Unit_Specification := Rejuvenation.Factory.Open_File("src/basic_declaration.ads", Context);
Unit_Body := Rejuvenation.Factory.Open_File("src/basic_declaration.adb", Context);
for Node_Kind in LALCO.Ada_Basic_Decl loop
if Node_Kind not in LALCO.Synthetic_Nodes then
Ada.Text_IO.Put_Line("=== " & Node_Kind'Image & " ===");
if not Find_Node_Of_Kind(Unit_Specification.Root, Node_Kind)
and not Find_Node_Of_Kind(Unit_Body.Root, Node_Kind) then
Missing_Basic_Decls.Append(Node_Kind);
end if;
end if;
end loop;
if Missing_Basic_Decls /= Empty_Vector then
Ada.Text_IO.Put_Line("Missing basic declarations:");
for Node_Kind of Missing_Basic_Decls loop
Ada.Text_IO.Put_Line(" - " & Node_Kind'Image);
end loop;
end if;
end Find_Basic_Decls;
procedure Find_Calls is
Unit : LAL.Analysis_Unit;
function Visit(Node : LAL.Ada_Node'Class) return LALCO.Visit_Status is
use LAL;
use LALCO;
use Langkit_Support.Text;
begin
--if Node.Kind = Ada_Identifier
-- and then Node.Parent.Kind = Ada_Attribute_Ref
-- and then Node.Parent.As_Attribute_Ref.F_Attribute = Node
--then
-- Node.Parent.Parent.Print;
-- Ada.Text_IO.Put_Line(Node.As_Identifier.P_Is_Defining'Image);
-- Ada.Text_IO.Put_Line(Node.As_Identifier.P_Referenced_Decl.Is_Null'Image);
-- Ada.Text_IO.Put_Line(Node.As_Identifier.P_Is_Call'Image);
-- Ada.Text_IO.Put_Line(Node.Parent.As_Attribute_Ref.P_Referenced_Decl.Is_Null'Image);
--end if;
if Node.Kind = Ada_Identifier
and then not Node.As_Identifier.P_Is_Defining
and then Node.As_Identifier.P_Is_Call
then
declare
Identifier : LAL.Identifier := Node.As_Identifier;
Identifier_Parent : LAL.Basic_Decl := Identifier.P_Parent_Basic_Decl;
Identifier_Parent_Name : String :=
Encode(Identifier_Parent.P_Fully_Qualified_Name, Identifier_Parent.Unit.Get_Charset) & " at " & Get_Location(Identifier);
Basic_Decl : LAL.Basic_Decl := Identifier.P_Referenced_Decl;
Basic_Decl_Name : String :=
Encode(Basic_Decl.P_Fully_Qualified_Name, Basic_Decl.Unit.Get_Charset) & " at " & Get_Location(Basic_Decl);
begin
Ada.Text_IO.Put_Line("1) " & Identifier_Parent_Name & " calls " & Basic_Decl_Name);
Ada.Text_IO.Put_Line(" - full path of " & Identifier_Parent_Name & " is " & Identifier.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Basic_Decl_Name & " is " & Basic_Decl.Unit.Get_Filename);
-- below should be
-- - look at parent, and if dotted name look at type of prefix
-- - look at parent (or parent of parent), and if call expr look at types of parameters
--if Call_Expr /= No_Ada_Node
-- and then (for some E of Call_Expr.As_Call_Expr.F_Suffix.As_Assoc_List => E.As_Param_Assoc.F_R_Expr.P_Expression_Type.Kind = Ada_Classwide_Type_Decl)
--then
-- Ada.Text_IO.Put_Line(" - is dispatching");
--end if;
--if Identifier.P_Is_Dot_Call
-- and then not Dotted_Name.As_Dotted_Name.F_Prefix.P_Expression_Type.Is_Null
--then
-- if Dotted_Name.As_Dotted_Name.F_Prefix.P_Expression_Type.Kind = Ada_Classwide_Type_Decl then -- Crashes in print if this check is missing
-- Dotted_Name.As_Dotted_Name.F_Prefix.Print;
-- Dotted_Name.As_Dotted_Name.F_Prefix.P_Expression_Type.Print;
-- if Call_Expr /= No_Ada_Node
-- and then not Call_Expr.As_Call_Expr.P_Expression_Type.Is_Null
-- then
-- Call_Expr.As_Call_Expr.P_Expression_Type.Print;
-- end if;
-- end if;
--end if;
end;
elsif Node.Kind = Ada_Identifier
and then Node.Parent.Kind /= Ada_End_Name
and then not Node.As_Identifier.P_Is_Defining
and then not Node.As_Identifier.P_Referenced_Decl.Is_Null
and then Node.Parent.Kind not in Ada_Accept_Stmt_Range
and then (Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Subp_Decl
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Null_Subp_Decl
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Expr_Function
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Entry_Decl
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Entry_Body
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Subp_Body
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Subp_Renaming_Decl
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Generic_Subp_Decl
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Generic_Subp_Renaming_Decl
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Generic_Subp_Instantiation
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Subp_Body_Stub
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Abstract_Subp_Decl
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Abstract_Formal_Subp_Decl
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Concrete_Formal_Subp_Decl
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Enum_Literal_Decl) -- Enum literals are parameterless functions
and then (Rejuvenation.Navigation.Get_Ancestor_Of_Type(Node, Ada_Generic_Package_Instantiation) = No_Ada_Node -- Skip designator in instantiation
or else Rejuvenation.Navigation.Get_Ancestor_Of_Type(Node, Ada_Param_Assoc) = No_Ada_Node
or else Rejuvenation.Navigation.Get_Ancestor_Of_Type(Node, Ada_Param_Assoc).As_Param_Assoc.F_Designator /= Node)
and then (Rejuvenation.Navigation.Get_Ancestor_Of_Type(Node, Ada_Generic_Subp_Instantiation) = No_Ada_Node -- Skip designator in instantiation
or else Rejuvenation.Navigation.Get_Ancestor_Of_Type(Node, Ada_Param_Assoc) = No_Ada_Node
or else Rejuvenation.Navigation.Get_Ancestor_Of_Type(Node, Ada_Param_Assoc).As_Param_Assoc.F_Designator /= Node)
then
declare
Identifier : LAL.Identifier := Node.As_Identifier;
Identifier_Parent : LAL.Basic_Decl:= Identifier.P_Parent_Basic_Decl;
Identifier_Parent_Name : String :=
Encode(Identifier_Parent.P_Fully_Qualified_Name, Identifier.Unit.Get_Charset) & " at " & Get_Location(Identifier);
Basic_Decl : LAL.Basic_Decl := Identifier.P_Referenced_Decl;
Basic_Decl_Name : String :=
Encode(Basic_Decl.P_Fully_Qualified_Name, Node.Unit.Get_Charset) & " at " & Get_Location(Basic_Decl);
begin
Ada.Text_IO.Put_Line("2) " & Identifier_Parent_Name & " references " & Basic_Decl_Name);
Ada.Text_IO.Put_Line(" - full path of " & Identifier_Parent_Name & " is " & Identifier.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Basic_Decl_Name & " is " & Basic_Decl.Unit.Get_Filename);
end;
elsif Node.Kind = Ada_Subp_Decl
then
declare
Subp_Decl : LAL.Subp_Decl := Node.As_Subp_Decl;
Subp_Decl_Name : String :=
Encode(Subp_Decl.P_Fully_Qualified_Name, Subp_Decl.Unit.Get_Charset) & " at " & Get_Location(Subp_Decl);
Subp_Body : LAL.Body_Node := Subp_Decl.P_Body_Part_For_Decl;
Subp_Body_Name : String :=
Encode(Subp_Body.P_Fully_Qualified_Name, Subp_Body.Unit.Get_Charset) & " at " & Get_Location(Subp_Body);
-- Foo : Basic_Decl_Array := Subp_Decl.P_Base_Subp_Declarations; -- Finds subprograms overriden (including the current one)
begin
Ada.Text_IO.Put_Line("3) " & Subp_Decl_Name & " is implemented by " & Subp_Body_Name);
Ada.Text_IO.Put_Line(" - full path of " & Subp_Decl_Name & " is " & Subp_Decl.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Subp_Body_Name & " is " & Subp_Body.Unit.Get_Filename);
-- for I in Foo'Range loop
-- Foo(I).Print;
--end loop;
end;
elsif Node.Kind = Ada_Generic_Subp_Decl
then
declare
Subp_Decl : LAL.Generic_Subp_Decl := Node.As_Generic_Subp_Decl;
Subp_Decl_Name : String :=
Encode(Subp_Decl.P_Fully_Qualified_Name, Subp_Decl.Unit.Get_Charset) & " at " & Get_Location(Subp_Decl);
Subp_Body : LAL.Body_Node := Subp_Decl.P_Body_Part_For_Decl;
Subp_Body_Name : String :=
Encode(Subp_Body.P_Fully_Qualified_Name, Subp_Body.Unit.Get_Charset) & " at " & Get_Location(Subp_Body);
begin
Ada.Text_IO.Put_Line("4) " & Subp_Decl_Name & " is implemented by " & Subp_Body_Name);
Ada.Text_IO.Put_Line(" - full path of " & Subp_Decl_Name & " is " & Subp_Decl.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Subp_Body_Name & " is " & Subp_Body.Unit.Get_Filename);
end;
elsif Node.Kind = Ada_Subp_Body_Stub then
declare
Subp_Body_Stub : LAL.Subp_Body_Stub := Node.As_Subp_Body_Stub;
Subp_Body_Stub_Name : String :=
Encode(Subp_Body_Stub.P_Fully_Qualified_Name, Subp_Body_Stub.Unit.Get_Charset) & " at " & Get_Location(Subp_Body_Stub);
Subp_Body : LAL.Body_Node := Subp_Body_Stub.P_Body_Part_For_Decl;
Subp_Body_Name : String :=
Encode(Subp_Body.P_Fully_Qualified_Name, Subp_Body.Unit.Get_Charset) & " at " & Get_Location(Subp_Body);
begin
Ada.Text_IO.Put_Line("5) " & Subp_Body_Stub_Name & " is implemented by " & Subp_Body_Name);
Ada.Text_IO.Put_Line(" - full path of " & Subp_Body_Stub_Name & " is " & Subp_Body_Stub.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Subp_Body_Name & " is " & Subp_Body.Unit.Get_Filename);
end;
elsif Node.Kind = Ada_Subp_Renaming_Decl
and then not Node.As_Subp_Renaming_Decl.F_Renames.F_Renamed_Object.P_Referenced_Decl.Is_Null
then
declare
Subp_Renaming_Decl : LAL.Subp_Renaming_Decl := Node.As_Subp_Renaming_Decl;
Subp_Renaming_Decl_Name : String :=
Encode(Subp_Renaming_Decl.P_Fully_Qualified_Name, Subp_Renaming_Decl.Unit.Get_Charset) & " at " & Get_Location(Subp_Renaming_Decl);
Basic_Decl : LAL.Basic_Decl := Subp_Renaming_Decl.F_Renames.F_Renamed_Object.P_Referenced_Decl;
Basic_Decl_Name : String :=
Encode(Basic_Decl.P_Fully_Qualified_Name, Node.Unit.Get_Charset) & " at " & Get_Location(Basic_Decl);
begin
Ada.Text_IO.Put_Line("6) " & Subp_Renaming_Decl_Name & " renames " & Basic_Decl_Name);
Ada.Text_IO.Put_Line(" - full path of " & Subp_Renaming_Decl_Name & " is " & Subp_Renaming_Decl.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Basic_Decl_Name & " is " & Basic_Decl.Unit.Get_Filename);
end;
elsif Node.Kind = Ada_Generic_Subp_Renaming_Decl then
declare
Subp_Renaming_Decl : LAL.Generic_Subp_Renaming_Decl := Node.As_Generic_Subp_Renaming_Decl;
Subp_Renaming_Decl_Name : String :=
Encode(Subp_Renaming_Decl.P_Fully_Qualified_Name, Subp_Renaming_Decl.Unit.Get_Charset) & " at " & Get_Location(Subp_Renaming_Decl);
Basic_Decl : LAL.Basic_Decl := Subp_Renaming_Decl.F_Renames.P_Referenced_Decl;
Basic_Decl_Name : String :=
Encode(Basic_Decl.P_Fully_Qualified_Name, Node.Unit.Get_Charset) & " at " & Get_Location(Basic_Decl);
begin
Ada.Text_IO.Put_Line("7) " & Subp_Renaming_Decl_Name & " renames " & Basic_Decl_Name);
Ada.Text_IO.Put_Line(" - full path of " & Subp_Renaming_Decl_Name & " is " & Subp_Renaming_Decl.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Basic_Decl_Name & " is " & Basic_Decl.Unit.Get_Filename);
end;
elsif Node.Kind = Ada_Generic_Subp_Instantiation then
declare
Subp_Instantiation : LAL.Generic_Subp_Instantiation := Node.As_Generic_Subp_Instantiation;
Subp_Instantiation_Name : String :=
Encode(Subp_Instantiation.P_Fully_Qualified_Name, Subp_Instantiation.Unit.Get_Charset) & " at " & Get_Location(Subp_Instantiation);
Basic_Decl : LAL.Basic_Decl := Subp_Instantiation.F_Generic_Subp_Name.P_Referenced_Decl;
Basic_Decl_Name : String :=
Encode(Basic_Decl.P_Fully_Qualified_Name, Node.Unit.Get_Charset) & " at " & Get_Location(Basic_Decl);
begin
Ada.Text_IO.Put_Line("8) " & Subp_Instantiation_Name & " instantiates " & Basic_Decl_Name);
Ada.Text_IO.Put_Line(" - full path of " & Subp_Instantiation_Name & " is " & Subp_Instantiation.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Basic_Decl_Name & " is " & Basic_Decl.Unit.Get_Filename);
end;
elsif Node.Kind = Ada_Entry_Body then -- We do not reason starting from the entry declaration, to be consistent with accept statements
declare
Entry_Body : LAL.Entry_Body := Node.As_Entry_Body;
Entry_Body_Name : String :=
Encode(Entry_Body.P_Fully_Qualified_Name, Entry_Body.Unit.Get_Charset) & " at " & Get_Location(Entry_Body);
Entry_Decl : LAL.Basic_Decl := Entry_Body.P_Decl_Part;
Entry_Decl_Name : String :=
Encode(Entry_Decl.P_Fully_Qualified_Name, Entry_Decl.Unit.Get_Charset) & " at " & Get_Location(Entry_Decl);
begin
Ada.Text_IO.Put_Line("9) " & Entry_Body_Name & " implements " & Entry_Decl_Name);
Ada.Text_IO.Put_Line(" - full path of " & Entry_Body_Name & " is " & Entry_Body.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Entry_Decl_Name & " is " & Entry_Decl.Unit.Get_Filename);
end;
elsif Node.Kind = Ada_Accept_Stmt then -- We do not reason starting from the entry declaration, because there can be multiple accepts for the same entry.
declare
Accept_Stmt : LAL.Accept_Stmt := Node.As_Accept_Stmt;
Accept_Stmt_Line : String := Accept_Stmt.Sloc_Range.Start_Line'Image;
Accept_Stmt_Parent : LAL.Basic_Decl := Accept_Stmt.P_Parent_Basic_Decl;
Accept_Stmt_Parent_Name : String :=
Encode(Accept_Stmt_Parent.P_Fully_Qualified_Name, Accept_Stmt.Unit.Get_Charset) & " at " & Get_Location(Accept_Stmt);
Entry_Decl : LAL.Entry_Decl := Accept_Stmt.F_Name.P_Referenced_Decl.As_Entry_Decl;
Entry_Decl_Name : String :=
Encode(Entry_Decl.P_Fully_Qualified_Name, Entry_Decl.Unit.Get_Charset) & " at " & Get_Location(Entry_Decl);
begin
Ada.Text_IO.Put_Line("10) " & Accept_Stmt_Parent_Name & " accepts " & Entry_Decl_Name);
Ada.Text_IO.Put_Line(" - full path of " & Accept_Stmt_Parent_Name & " is " & Accept_Stmt.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Entry_Decl_Name & " is " & Entry_Decl.Unit.Get_Filename);
end;
elsif Node.Kind = Ada_Accept_Stmt_With_Stmts then -- We do not reason starting from the entry declaration, because there can be multiple accepts for the same entry.
declare
Accept_Stmt : LAL.Accept_Stmt_With_Stmts := Node.As_Accept_Stmt_With_Stmts;
Accept_Stmt_Line : String := Accept_Stmt.Sloc_Range.Start_Line'Image;
Accept_Stmt_Parent : LAL.Basic_Decl := Accept_Stmt.P_Parent_Basic_Decl;
Accept_Stmt_Parent_Name : String :=
Encode(Accept_Stmt_Parent.P_Fully_Qualified_Name, Accept_Stmt.Unit.Get_Charset) & " at " & Get_Location(Accept_Stmt);
Entry_Decl : LAL.Entry_Decl := Accept_Stmt.F_Name.P_Referenced_Decl.As_Entry_Decl;
Entry_Decl_Name : String :=
Encode(Entry_Decl.P_Fully_Qualified_Name, Entry_Decl.Unit.Get_Charset) & " at " & Get_Location(Entry_Decl);
begin
Ada.Text_IO.Put_Line("11) " & Accept_Stmt_Parent_Name & " accepts " & Entry_Decl_Name);
Ada.Text_IO.Put_Line(" - full path of " & Accept_Stmt_Parent_Name & " is " & Accept_Stmt.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Entry_Decl_Name & " is " & Entry_Decl.Unit.Get_Filename);
end;
elsif Node.Kind in Ada_Op
and then not Node.As_Op.P_Referenced_Decl.Is_Null
then
declare
Op : LAL.Op := Node.As_Op;
Op_Line : String := Op.Sloc_Range.Start_Line'Image;
Op_Parent : LAL.Basic_Decl := Op.P_Parent_Basic_Decl;
Op_Parent_Name : String :=
Encode(Op_Parent.P_Fully_Qualified_Name, Op.Unit.Get_Charset) & " at " & Get_Location(Op);
Basic_Decl : LAL.Basic_Decl := Op.P_Referenced_Decl;
Basic_Decl_Name : String :=
Encode(Basic_Decl.P_Fully_Qualified_Name, Node.Unit.Get_Charset) & " at " & Get_Location(Basic_Decl);
begin
Ada.Text_IO.Put_Line("12) " & Op_Parent_Name & " calls " & Basic_Decl_Name);
Ada.Text_IO.Put_Line(" - full path of " & Op_Parent_Name & " is " & Op.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Basic_Decl_Name & " is " & Basic_Decl.Unit.Get_Filename);
end;
end if;
return Into;
exception when E : Property_Error =>
Ada.Text_IO.Put_Line("Encountered Libadalang problem: " & Ada.Exceptions.Exception_Message (E));
Node.Print;
return Into;
end Visit;
begin
for Unit of Units loop
Ada.Text_IO.Put_Line("== " & Unit.Get_Filename & " ==");
Unit.Root.Traverse(Visit'Access);
end loop;
end Find_Calls;
begin
-- Find_Basic_Decls;
Find_Calls;
end Main;
|
{
"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.Float_Text_IO; use Ada.Float_Text_IO;
with Ada.Unchecked_Deallocation;
package body Vecteurs_Creux is
procedure Free is
new Ada.Unchecked_Deallocation (T_Cellule, T_Vecteur_Creux);
procedure Initialiser (V : out T_Vecteur_Creux) is
begin
V := Null;
end Initialiser;
procedure Detruire (V: in out T_Vecteur_Creux) is
begin
if (V /= Null) then
Detruire (V.all.Suivant);
free (V);
else
Null;
end if;
end Detruire;
function Est_Nul (V : in T_Vecteur_Creux) return Boolean is
begin
return V = Null;
end Est_Nul;
function Composante_Recursif (V : in T_Vecteur_Creux ; Indice : in Integer) return Float is
begin
if (Est_Nul (V)) then
return 0.0;
end if;
if (V.all.Indice > Indice) then
return 0.0;
end if;
if (V.all.Indice = Indice) then
return V.all.Valeur;
else
return Composante_Recursif (V.all.Suivant , Indice);
end if;
end Composante_Recursif;
function Composante_Iteratif (V : in T_Vecteur_Creux ; Indice : in Integer) return Float is
Temp : T_Vecteur_Creux;
begin
Temp := V;
while (Temp /= Null and then Temp.all.Indice <= Indice) loop
if (Temp.all.Indice = Indice) then
return Temp.all.Valeur;
end if;
Temp := Temp.all.Suivant;
end loop;
return 0.0;
end Composante_Iteratif;
procedure Supprimer (V : in out T_Vecteur_Creux; Indice : in Integer) is
begin
if (V.all.Indice = Indice) then
V := V.all.Suivant;
else
Supprimer (V.all.Suivant, Indice);
end if;
end Supprimer;
procedure Modifier (V : in out T_Vecteur_Creux ; Indice : in Integer ; Valeur : in Float ) is
Nouvelle_Cellule, Temp : T_Vecteur_Creux;
begin
Nouvelle_Cellule := New T_Cellule;
Nouvelle_Cellule.all.Indice := Indice;
Nouvelle_Cellule.all.Valeur := Valeur;
if (V = Null or else V.all.Indice > Indice) then
if (Valeur /= 0.0) then
Nouvelle_Cellule.all.Suivant := v;
V := Nouvelle_Cellule;
end if;
else
Temp := V;
while (Temp.all.Suivant /= Null and then Temp.all.Suivant.all.Indice <= Indice) loop
Temp := Temp.all.Suivant;
end loop;
if (Temp.all.Indice = Indice) then
if (Valeur /= 0.0) then
temp.all.Valeur := Valeur;
else
Supprimer(V, Indice);
end if;
else
if (Valeur /= 0.0) then
Nouvelle_Cellule.all.Suivant := Temp.all.Suivant;
Temp.all.Suivant := Nouvelle_Cellule;
end if;
end if;
end if;
end Modifier;
function Sont_Egaux_Recursif (V1, V2 : in T_Vecteur_Creux) return Boolean is
begin
if (Est_Nul (V1) and Est_Nul (V2)) then
return True;
end if;
if (not (Est_Nul (V1)) and not (Est_Nul (V2))) then
return (V1.all.Indice = V2.all.Indice and V1.all.Valeur = V2.all.Valeur) and Sont_Egaux_Recursif (V1.all.Suivant, V2.all.Suivant);
end if;
return false;
end Sont_Egaux_Recursif;
function Sont_Egaux_Iteratif (V1, V2 : in T_Vecteur_Creux) return Boolean is
Temp1, Temp2 : T_Vecteur_Creux;
begin
if (Est_Nul (V1) /= Est_Nul (V2)) then
return False;
else
Temp1 := V1;
Temp2 := V2;
while (Temp1 /= Null and Temp2 /= Null) loop
if (Temp1.all.Indice /= Temp2.all.Indice or Temp1.all.Valeur /= Temp2.all.Valeur) then
return False;
end if;
Temp1 := Temp1.all.Suivant;
Temp2 := Temp2.all.Suivant;
end loop;
if (Est_Nul (Temp1) /= Est_Nul (Temp2)) then
return False;
else
return True;
end if;
end if;
end Sont_Egaux_Iteratif;
procedure Additionner (V1 : in out T_Vecteur_Creux; V2 : in out T_Vecteur_Creux) is
Temp1, Temp2 : T_Vecteur_Creux;
begin
Temp1 := V1;
Temp2 := V2;
if Temp1 = Null then
Temp1 := Temp2;
elsif Temp2 = Null then
Temp2 := Temp1;
elsif Nombre_Composantes_Non_Nulles (V1) >= Nombre_Composantes_Non_Nulles (V2) then
while (Temp1 /= Null) loop
Modifier (V1, Temp1.all.Indice, Temp1.all.Valeur + Composante_Recursif (V2, Temp1.all.Indice));
Temp1 := Temp1.all.Suivant;
end loop;
while (Temp2 /= Null) or else (Composante_Recursif (V1, Temp2.all.Indice) = 0.0) loop
Modifier (V1, Temp2.all.Indice, Temp2.all.Valeur);
Temp2 := Temp2.all.Suivant;
end loop;
else
while (Temp2 /= Null) loop
afficher (Temp1);
Afficher (Temp2);
Modifier (V2, Temp1.all.Indice, Temp2.all.Valeur + Composante_Recursif (V1, Temp2.all.Indice));
Temp2 := Temp2.all.Suivant;
end loop;
afficher (Temp1);
Afficher (Temp2);
while (Temp1 /= Null) or else (Composante_Recursif (V1, Temp2.all.Indice) = 0.0) loop
Modifier (V2, Temp1.all.Indice, Temp1.all.Valeur);
Temp1 := Temp1.all.Suivant;
end loop;
end if;
V1 := Temp1;
V2 := Temp2;
end Additionner;
function Norme2 (V : in T_Vecteur_Creux) return Float is
begin
return 0.0; -- TODO : à changer
end Norme2;
Function Produit_Scalaire (V1, V2: in T_Vecteur_Creux) return Float is
begin
return 0.0; -- TODO : à changer
end Produit_Scalaire;
procedure Afficher (V : T_Vecteur_Creux) is
begin
if V = Null then
Put_Line ("--E");
else
Put ("-->[ ");
Put (V.all.Indice, 0);
Put (" | ");
Put (V.all.Valeur, Fore => 0, Aft => 1, Exp => 0);
Put (" ]");
Afficher (V.all.Suivant);
end if;
end Afficher;
function Nombre_Composantes_Non_Nulles (V: in T_Vecteur_Creux) return Integer is
begin
if V = Null then
return 0;
else
return 1 + Nombre_Composantes_Non_Nulles (V.all.Suivant);
end if;
end Nombre_Composantes_Non_Nulles;
end Vecteurs_Creux;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--*
-- OBJECTIVE:
-- CHECK THAT SOME DIFFERENCES BETWEEN THE FORMAL AND THE
-- ACTUAL SUBPROGRAMS DO NOT INVALIDATE A MATCH.
-- 1) CHECK DIFFERENT PARAMETER NAMES.
-- 2) CHECK DIFFERENT PARAMETER CONSTRAINTS.
-- 3) CHECK ONE PARAMETER CONSTRAINED AND THE OTHER
-- UNCONSTRAINED (WITH ARRAY, RECORD, ACCESS, AND
-- PRIVATE TYPES).
-- 4) CHECK PRESENCE OR ABSENCE OF AN EXPLICIT "IN" MODE
-- INDICATOR.
-- 5) DIFFERENT TYPE MARKS USED TO SPECIFY THE TYPE OF
-- PARAMETERS.
-- HISTORY:
-- LDC 10/04/88 CREATED ORIGINAL TEST.
PACKAGE CC3605A_PACK IS
SUBTYPE INT IS INTEGER RANGE -100 .. 100;
TYPE PRI_TYPE (SIZE : INT) IS PRIVATE;
SUBTYPE PRI_CONST IS PRI_TYPE (2);
PRIVATE
TYPE ARR_TYPE IS ARRAY (INTEGER RANGE <>) OF BOOLEAN;
TYPE PRI_TYPE (SIZE : INT) IS
RECORD
SUB_A : ARR_TYPE (1 .. SIZE);
END RECORD;
END CC3605A_PACK;
WITH REPORT;
USE REPORT;
WITH CC3605A_PACK;
USE CC3605A_PACK;
PROCEDURE CC3605A IS
SUBTYPE ZERO_TO_TEN IS INTEGER
RANGE IDENT_INT (0) .. IDENT_INT (10);
SUBTYPE ONE_TO_FIVE IS INTEGER
RANGE IDENT_INT (1) .. IDENT_INT (5);
SUBPRG_ACT : BOOLEAN := FALSE;
BEGIN
TEST
("CC3605A", "CHECK THAT SOME DIFFERENCES BETWEEN THE " &
"FORMAL AND THE ACTUAL PARAMETERS DO NOT " &
"INVALIDATE A MATCH");
----------------------------------------------------------------------
-- DIFFERENT PARAMETER NAMES
----------------------------------------------------------------------
DECLARE
PROCEDURE ACT_PROC (DIFF_NAME_PARM : ONE_TO_FIVE) IS
BEGIN
SUBPRG_ACT := TRUE;
END ACT_PROC;
GENERIC
WITH PROCEDURE PASSED_PROC (PARM : ONE_TO_FIVE);
PROCEDURE GEN_PROC;
PROCEDURE GEN_PROC IS
BEGIN
PASSED_PROC (ONE_TO_FIVE'FIRST);
END GEN_PROC;
PROCEDURE INST_PROC IS NEW GEN_PROC (ACT_PROC);
BEGIN
INST_PROC;
IF NOT SUBPRG_ACT THEN
FAILED
("DIFFERENT PARAMETER NAMES MADE MATCH INVALID");
END IF;
END;
----------------------------------------------------------------------
-- DIFFERENT PARAMETER CONSTRAINTS
----------------------------------------------------------------------
DECLARE
PROCEDURE ACT_PROC (PARM : ONE_TO_FIVE) IS
BEGIN
SUBPRG_ACT := TRUE;
END ACT_PROC;
GENERIC
WITH PROCEDURE PASSED_PROC (PARM : ZERO_TO_TEN);
PROCEDURE GEN_PROC;
PROCEDURE GEN_PROC IS
BEGIN
PASSED_PROC (ONE_TO_FIVE'FIRST);
END GEN_PROC;
PROCEDURE INST_PROC IS NEW GEN_PROC (ACT_PROC);
BEGIN
SUBPRG_ACT := FALSE;
INST_PROC;
IF NOT SUBPRG_ACT THEN
FAILED
("DIFFERENT PARAMETER CONSTRAINTS MADE MATCH " &
"INVALID");
END IF;
END;
----------------------------------------------------------------------
-- ONE PARAMETER CONSTRAINED (ARRAY)
----------------------------------------------------------------------
DECLARE
TYPE ARR_TYPE IS ARRAY (INTEGER RANGE <>) OF BOOLEAN;
SUBTYPE ARR_CONST IS ARR_TYPE (ONE_TO_FIVE'FIRST ..
ONE_TO_FIVE'LAST);
PASSED_PARM : ARR_CONST := (OTHERS => TRUE);
PROCEDURE ACT_PROC (PARM : ARR_CONST) IS
BEGIN
SUBPRG_ACT := TRUE;
END ACT_PROC;
GENERIC
WITH PROCEDURE PASSED_PROC (PARM : ARR_TYPE);
PROCEDURE GEN_PROC;
PROCEDURE GEN_PROC IS
BEGIN
PASSED_PROC (PASSED_PARM);
END GEN_PROC;
PROCEDURE INST_PROC IS NEW GEN_PROC (ACT_PROC);
BEGIN
SUBPRG_ACT := FALSE;
INST_PROC;
IF NOT SUBPRG_ACT THEN
FAILED
("ONE ARRAY PARAMETER CONSTRAINED MADE MATCH " &
"INVALID");
END IF;
END;
----------------------------------------------------------------------
-- ONE PARAMETER CONSTRAINED (RECORDS)
----------------------------------------------------------------------
DECLARE
TYPE REC_TYPE (BOL : BOOLEAN) IS
RECORD
SUB_A : INTEGER;
CASE BOL IS
WHEN TRUE =>
DSCR_A : INTEGER;
WHEN FALSE =>
DSCR_B : BOOLEAN;
END CASE;
END RECORD;
SUBTYPE REC_CONST IS REC_TYPE (TRUE);
PASSED_PARM : REC_CONST := (TRUE, 1, 2);
PROCEDURE ACT_PROC (PARM : REC_CONST) IS
BEGIN
SUBPRG_ACT := TRUE;
END ACT_PROC;
GENERIC
WITH PROCEDURE PASSED_PROC (PARM : REC_TYPE);
PROCEDURE GEN_PROC;
PROCEDURE GEN_PROC IS
BEGIN
PASSED_PROC (PASSED_PARM);
END GEN_PROC;
PROCEDURE INST_PROC IS NEW GEN_PROC (ACT_PROC);
BEGIN
SUBPRG_ACT := FALSE;
INST_PROC;
IF NOT SUBPRG_ACT THEN
FAILED
("ONE RECORD PARAMETER CONSTRAINED MADE MATCH " &
"INVALID");
END IF;
END;
----------------------------------------------------------------------
-- ONE PARAMETER CONSTRAINED (ACCESS)
----------------------------------------------------------------------
DECLARE
TYPE ARR_TYPE IS ARRAY (INTEGER RANGE <>) OF BOOLEAN;
SUBTYPE ARR_CONST IS ARR_TYPE (ONE_TO_FIVE'FIRST ..
ONE_TO_FIVE'LAST);
TYPE ARR_ACC_TYPE IS ACCESS ARR_TYPE;
SUBTYPE ARR_ACC_CONST IS ARR_ACC_TYPE (1 .. 3);
PASSED_PARM : ARR_ACC_TYPE := NULL;
PROCEDURE ACT_PROC (PARM : ARR_ACC_CONST) IS
BEGIN
SUBPRG_ACT := TRUE;
END ACT_PROC;
GENERIC
WITH PROCEDURE PASSED_PROC (PARM : ARR_ACC_TYPE);
PROCEDURE GEN_PROC;
PROCEDURE GEN_PROC IS
BEGIN
PASSED_PROC (PASSED_PARM);
END GEN_PROC;
PROCEDURE INST_PROC IS NEW GEN_PROC (ACT_PROC);
BEGIN
SUBPRG_ACT := FALSE;
INST_PROC;
IF NOT SUBPRG_ACT THEN
FAILED
("ONE ACCESS PARAMETER CONSTRAINED MADE MATCH " &
"INVALID");
END IF;
END;
----------------------------------------------------------------------
-- ONE PARAMETER CONSTRAINED (PRIVATE)
----------------------------------------------------------------------
DECLARE
PASSED_PARM : PRI_CONST;
PROCEDURE ACT_PROC (PARM : PRI_CONST) IS
BEGIN
SUBPRG_ACT := TRUE;
END ACT_PROC;
GENERIC
WITH PROCEDURE PASSED_PROC (PARM : PRI_TYPE);
PROCEDURE GEN_PROC;
PROCEDURE GEN_PROC IS
BEGIN
PASSED_PROC (PASSED_PARM);
END GEN_PROC;
PROCEDURE INST_PROC IS NEW GEN_PROC (ACT_PROC);
BEGIN
SUBPRG_ACT := FALSE;
INST_PROC;
IF NOT SUBPRG_ACT THEN
FAILED
("ONE PRIVATE PARAMETER CONSTRAINED MADE MATCH " &
"INVALID");
END IF;
END;
----------------------------------------------------------------------
-- PRESENCE (OR ABSENCE) OF AN EXPLICIT "IN" MODE
----------------------------------------------------------------------
DECLARE
PROCEDURE ACT_PROC (PARM : INTEGER) IS
BEGIN
SUBPRG_ACT := TRUE;
END ACT_PROC;
GENERIC
WITH PROCEDURE PASSED_PROC (PARM : IN INTEGER);
PROCEDURE GEN_PROC;
PROCEDURE GEN_PROC IS
BEGIN
PASSED_PROC (1);
END GEN_PROC;
PROCEDURE INST_PROC IS NEW GEN_PROC (ACT_PROC);
BEGIN
SUBPRG_ACT := FALSE;
INST_PROC;
IF NOT SUBPRG_ACT THEN
FAILED
("PRESENCE OF AN EXPLICIT 'IN' MODE MADE MATCH " &
"INVALID");
END IF;
END;
----------------------------------------------------------------------
-- DIFFERENT TYPE MARKS
----------------------------------------------------------------------
DECLARE
SUBTYPE MARK_1_TYPE IS INTEGER;
SUBTYPE MARK_2_TYPE IS INTEGER;
PROCEDURE ACT_PROC (PARM1 : IN MARK_1_TYPE) IS
BEGIN
SUBPRG_ACT := TRUE;
END ACT_PROC;
GENERIC
WITH PROCEDURE PASSED_PROC (PARM2 : MARK_2_TYPE);
PROCEDURE GEN_PROC;
PROCEDURE GEN_PROC IS
BEGIN
PASSED_PROC (1);
END GEN_PROC;
PROCEDURE INST_PROC IS NEW GEN_PROC (ACT_PROC);
BEGIN
SUBPRG_ACT := FALSE;
INST_PROC;
IF NOT SUBPRG_ACT THEN
FAILED ("DIFFERENT TYPE MARKS MADE MATCH INVALID");
END IF;
END;
RESULT;
END CC3605A;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--
--
with ewok.tasks; use ewok.tasks;
with ewok.sanitize;
with ewok.debug;
package body ewok.syscalls.log
with spark_mode => off
is
procedure svc_log
(caller_id : in ewok.tasks_shared.t_task_id;
params : in out t_parameters;
mode : in ewok.tasks_shared.t_task_mode)
is
-- Message size
size : positive
with address => params(1)'address;
-- Message address
msg_address : constant system_address := params(2);
begin
if size >= 512 then
goto ret_inval;
end if;
-- Does &msg is in the caller address space ?
if not ewok.sanitize.is_range_in_data_slot
(msg_address,
unsigned_32 (size),
caller_id,
mode)
then
goto ret_inval;
end if;
declare
msg : string (1 .. size)
with address => to_address (msg_address);
begin
pragma DEBUG (debug.log
(ewok.tasks.tasks_list(caller_id).name & " " & msg & ASCII.CR,
false));
end;
set_return_value (caller_id, mode, SYS_E_DONE);
ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE);
return;
<<ret_inval>>
set_return_value (caller_id, mode, SYS_E_INVAL);
ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE);
end svc_log;
end ewok.syscalls.log;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-------------------------------------------------------------
package body Program.Units is
-----------------
-- Compilation --
-----------------
overriding function Compilation
(Self : access Unit)
return Program.Compilations.Compilation_Access is
begin
return Self.Compilation;
end Compilation;
-----------------------------
-- Context_Clause_Elements --
-----------------------------
overriding function Context_Clause_Elements
(Self : access Unit)
return Program.Element_Vectors.Element_Vector_Access is
begin
return Self.Context_Clause;
end Context_Clause_Elements;
---------------
-- Full_Name --
---------------
overriding function Full_Name (Self : access Unit) return Text is
begin
return Ada.Strings.Wide_Wide_Unbounded.To_Wide_Wide_String
(Self.Full_Name);
end Full_Name;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : in out Unit'Class;
Compilation : Program.Compilations.Compilation_Access;
Full_Name : Text;
Context_Clause : Program.Element_Vectors.Element_Vector_Access;
Unit_Declaration : not null Program.Elements.Element_Access) is
begin
Self.Compilation := Compilation;
Self.Full_Name :=
Ada.Strings.Wide_Wide_Unbounded.To_Unbounded_Wide_Wide_String
(Full_Name);
Self.Context_Clause := Context_Clause;
Self.Unit_Declaration := Unit_Declaration;
end Initialize;
----------------------
-- Unit_Declaration --
----------------------
overriding function Unit_Declaration
(Self : access Unit)
return not null Program.Elements.Element_Access is
begin
return Self.Unit_Declaration;
end Unit_Declaration;
-------------------------------
-- Is_Library_Unit_Body_Unit --
-------------------------------
overriding function Is_Library_Unit_Body_Unit
(Self : Unit) return Boolean
is
pragma Unreferenced (Self);
begin
return False;
end Is_Library_Unit_Body_Unit;
--------------------------
-- Is_Library_Item_Unit --
--------------------------
overriding function Is_Library_Item_Unit (Self : Unit) return Boolean is
pragma Unreferenced (Self);
begin
return False;
end Is_Library_Item_Unit;
--------------------------------------
-- Is_Library_Unit_Declaration_Unit --
--------------------------------------
overriding function Is_Library_Unit_Declaration_Unit
(Self : Unit) return Boolean
is
pragma Unreferenced (Self);
begin
return False;
end Is_Library_Unit_Declaration_Unit;
---------------------
-- Is_Subunit_Unit --
---------------------
overriding function Is_Subunit_Unit (Self : Unit) return Boolean is
pragma Unreferenced (Self);
begin
return False;
end Is_Subunit_Unit;
end Program.Units;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- All data returned by the network data base library are supplied in
-- host order and returned in network order (suitable for use in
-- system calls).
-- This is necessary to make this include file properly replace the
-- Sun version.
-- Absolute file name for network data base files.
-- Error status for non-reentrant lookup functions.
-- We use a macro to access always the thread-specific `h_errno' variable.
-- Function to get address of global `h_errno' variable.
-- skipped func __h_errno_location
-- Possible values left in `h_errno'.
-- Highest reserved Internet port number.
-- Scope delimiter for getaddrinfo(), getnameinfo().
-- Print error indicated by `h_errno' variable on standard error. STR
-- if non-null is printed before the error string.
procedure herror (uu_str : Interfaces.C.Strings.chars_ptr); -- netdb.h:92
pragma Import (C, herror, "herror");
-- Return string associated with error ERR_NUM.
function hstrerror (uu_err_num : int) return Interfaces.C.Strings.chars_ptr; -- netdb.h:95
pragma Import (C, hstrerror, "hstrerror");
-- Description of data base entry for a single host.
-- Official name of host.
type hostent is record
h_name : Interfaces.C.Strings.chars_ptr; -- netdb.h:102
h_aliases : System.Address; -- netdb.h:103
h_addrtype : aliased int; -- netdb.h:104
h_length : aliased int; -- netdb.h:105
h_addr_list : System.Address; -- netdb.h:106
end record;
pragma Convention (C_Pass_By_Copy, hostent); -- netdb.h:100
-- Alias list.
-- Host address type.
-- Length of address.
-- List of addresses from name server.
-- Open host data base files and mark them as staying open even after
-- a later search if STAY_OPEN is non-zero.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
procedure sethostent (uu_stay_open : int); -- netdb.h:117
pragma Import (C, sethostent, "sethostent");
-- Close host data base files and clear `stay open' flag.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
procedure endhostent; -- netdb.h:123
pragma Import (C, endhostent, "endhostent");
-- Get next entry from host data base file. Open data base if
-- necessary.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
function gethostent return access hostent; -- netdb.h:130
pragma Import (C, gethostent, "gethostent");
-- Return entry from host data base which address match ADDR with
-- length LEN and type TYPE.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
function gethostbyaddr
(uu_addr : System.Address;
uu_len : CUPS.bits_types_h.uu_socklen_t;
uu_type : int) return access hostent; -- netdb.h:137
pragma Import (C, gethostbyaddr, "gethostbyaddr");
-- Return entry from host data base for host with NAME.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
function gethostbyname (uu_name : Interfaces.C.Strings.chars_ptr) return access hostent; -- netdb.h:144
pragma Import (C, gethostbyname, "gethostbyname");
-- Return entry from host data base for host with NAME. AF must be
-- set to the address type which is `AF_INET' for IPv4 or `AF_INET6'
-- for IPv6.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
function gethostbyname2 (uu_name : Interfaces.C.Strings.chars_ptr; uu_af : int) return access hostent; -- netdb.h:155
pragma Import (C, gethostbyname2, "gethostbyname2");
-- Reentrant versions of the functions above. The additional
-- arguments specify a buffer of BUFLEN starting at BUF. The last
-- argument is a pointer to a variable which gets the value which
-- would be stored in the global variable `herrno' by the
-- non-reentrant functions.
-- These functions are not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation they are cancellation points and
-- therefore not marked with __THROW.
function gethostent_r
(uu_result_buf : access hostent;
uu_buf : Interfaces.C.Strings.chars_ptr;
uu_buflen : size_t;
uu_result : System.Address;
uu_h_errnop : access int) return int; -- netdb.h:167
pragma Import (C, gethostent_r, "gethostent_r");
function gethostbyaddr_r
(uu_addr : System.Address;
uu_len : CUPS.bits_types_h.uu_socklen_t;
uu_type : int;
uu_result_buf : access hostent;
uu_buf : Interfaces.C.Strings.chars_ptr;
uu_buflen : size_t;
uu_result : System.Address;
uu_h_errnop : access int) return int; -- netdb.h:172
pragma Import (C, gethostbyaddr_r, "gethostbyaddr_r");
function gethostbyname_r
(uu_name : Interfaces.C.Strings.chars_ptr;
uu_result_buf : access hostent;
uu_buf : Interfaces.C.Strings.chars_ptr;
uu_buflen : size_t;
uu_result : System.Address;
uu_h_errnop : access int) return int; -- netdb.h:179
pragma Import (C, gethostbyname_r, "gethostbyname_r");
function gethostbyname2_r
(uu_name : Interfaces.C.Strings.chars_ptr;
uu_af : int;
uu_result_buf : access hostent;
uu_buf : Interfaces.C.Strings.chars_ptr;
uu_buflen : size_t;
uu_result : System.Address;
uu_h_errnop : access int) return int; -- netdb.h:185
pragma Import (C, gethostbyname2_r, "gethostbyname2_r");
-- Open network data base files and mark them as staying open even
-- after a later search if STAY_OPEN is non-zero.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
procedure setnetent (uu_stay_open : int); -- netdb.h:198
pragma Import (C, setnetent, "setnetent");
-- Close network data base files and clear `stay open' flag.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
procedure endnetent; -- netdb.h:204
pragma Import (C, endnetent, "endnetent");
-- Get next entry from network data base file. Open data base if
-- necessary.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
function getnetent return access CUPS.bits_netdb_h.netent; -- netdb.h:211
pragma Import (C, getnetent, "getnetent");
-- Return entry from network data base which address match NET and
-- type TYPE.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
function getnetbyaddr (uu_net : CUPS.stdint_h.uint32_t; uu_type : int) return access CUPS.bits_netdb_h.netent; -- netdb.h:218
pragma Import (C, getnetbyaddr, "getnetbyaddr");
-- Return entry from network data base for network with NAME.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
function getnetbyname (uu_name : Interfaces.C.Strings.chars_ptr) return access CUPS.bits_netdb_h.netent; -- netdb.h:224
pragma Import (C, getnetbyname, "getnetbyname");
-- Reentrant versions of the functions above. The additional
-- arguments specify a buffer of BUFLEN starting at BUF. The last
-- argument is a pointer to a variable which gets the value which
-- would be stored in the global variable `herrno' by the
-- non-reentrant functions.
-- These functions are not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation they are cancellation points and
-- therefore not marked with __THROW.
function getnetent_r
(uu_result_buf : access CUPS.bits_netdb_h.netent;
uu_buf : Interfaces.C.Strings.chars_ptr;
uu_buflen : size_t;
uu_result : System.Address;
uu_h_errnop : access int) return int; -- netdb.h:237
pragma Import (C, getnetent_r, "getnetent_r");
function getnetbyaddr_r
(uu_net : CUPS.stdint_h.uint32_t;
uu_type : int;
uu_result_buf : access CUPS.bits_netdb_h.netent;
uu_buf : Interfaces.C.Strings.chars_ptr;
uu_buflen : size_t;
uu_result : System.Address;
uu_h_errnop : access int) return int; -- netdb.h:242
pragma Import (C, getnetbyaddr_r, "getnetbyaddr_r");
function getnetbyname_r
(uu_name : Interfaces.C.Strings.chars_ptr;
uu_result_buf : access CUPS.bits_netdb_h.netent;
uu_buf : Interfaces.C.Strings.chars_ptr;
uu_buflen : size_t;
uu_result : System.Address;
uu_h_errnop : access int) return int; -- netdb.h:248
pragma Import (C, getnetbyname_r, "getnetbyname_r");
-- Description of data base entry for a single service.
-- Official service name.
type servent is record
s_name : Interfaces.C.Strings.chars_ptr; -- netdb.h:259
s_aliases : System.Address; -- netdb.h:260
s_port : aliased int; -- netdb.h:261
s_proto : Interfaces.C.Strings.chars_ptr; -- netdb.h:262
end record;
pragma Convention (C_Pass_By_Copy, servent); -- netdb.h:257
-- Alias list.
-- Port number.
-- Protocol to use.
-- Open service data base files and mark them as staying open even
-- after a later search if STAY_OPEN is non-zero.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
procedure setservent (uu_stay_open : int); -- netdb.h:270
pragma Import (C, setservent, "setservent");
-- Close service data base files and clear `stay open' flag.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
procedure endservent; -- netdb.h:276
pragma Import (C, endservent, "endservent");
-- Get next entry from service data base file. Open data base if
-- necessary.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
function getservent return access servent; -- netdb.h:283
pragma Import (C, getservent, "getservent");
-- Return entry from network data base for network with NAME and
-- protocol PROTO.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
function getservbyname (uu_name : Interfaces.C.Strings.chars_ptr; uu_proto : Interfaces.C.Strings.chars_ptr) return access servent; -- netdb.h:290
pragma Import (C, getservbyname, "getservbyname");
-- Return entry from service data base which matches port PORT and
-- protocol PROTO.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
function getservbyport (uu_port : int; uu_proto : Interfaces.C.Strings.chars_ptr) return access servent; -- netdb.h:297
pragma Import (C, getservbyport, "getservbyport");
-- Reentrant versions of the functions above. The additional
-- arguments specify a buffer of BUFLEN starting at BUF.
-- These functions are not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation they are cancellation points and
-- therefore not marked with __THROW.
function getservent_r
(uu_result_buf : access servent;
uu_buf : Interfaces.C.Strings.chars_ptr;
uu_buflen : size_t;
uu_result : System.Address) return int; -- netdb.h:308
pragma Import (C, getservent_r, "getservent_r");
function getservbyname_r
(uu_name : Interfaces.C.Strings.chars_ptr;
uu_proto : Interfaces.C.Strings.chars_ptr;
uu_result_buf : access servent;
uu_buf : Interfaces.C.Strings.chars_ptr;
uu_buflen : size_t;
uu_result : System.Address) return int; -- netdb.h:312
pragma Import (C, getservbyname_r, "getservbyname_r");
function getservbyport_r
(uu_port : int;
uu_proto : Interfaces.C.Strings.chars_ptr;
uu_result_buf : access servent;
uu_buf : Interfaces.C.Strings.chars_ptr;
uu_buflen : size_t;
uu_result : System.Address) return int; -- netdb.h:318
pragma Import (C, getservbyport_r, "getservbyport_r");
-- Description of data base entry for a single service.
-- Official protocol name.
type protoent is record
p_name : Interfaces.C.Strings.chars_ptr; -- netdb.h:328
p_aliases : System.Address; -- netdb.h:329
p_proto : aliased int; -- netdb.h:330
end record;
pragma Convention (C_Pass_By_Copy, protoent); -- netdb.h:326
-- Alias list.
-- Protocol number.
-- Open protocol data base files and mark them as staying open even
-- after a later search if STAY_OPEN is non-zero.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
procedure setprotoent (uu_stay_open : int); -- netdb.h:338
pragma Import (C, setprotoent, "setprotoent");
-- Close protocol data base files and clear `stay open' flag.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
procedure endprotoent; -- netdb.h:344
pragma Import (C, endprotoent, "endprotoent");
-- Get next entry from protocol data base file. Open data base if
-- necessary.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
function getprotoent return access protoent; -- netdb.h:351
pragma Import (C, getprotoent, "getprotoent");
-- Return entry from protocol data base for network with NAME.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
function getprotobyname (uu_name : Interfaces.C.Strings.chars_ptr) return access protoent; -- netdb.h:357
pragma Import (C, getprotobyname, "getprotobyname");
-- Return entry from protocol data base which number is PROTO.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
function getprotobynumber (uu_proto : int) return access protoent; -- netdb.h:363
pragma Import (C, getprotobynumber, "getprotobynumber");
-- Reentrant versions of the functions above. The additional
-- arguments specify a buffer of BUFLEN starting at BUF.
-- These functions are not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation they are cancellation points and
-- therefore not marked with __THROW.
function getprotoent_r
(uu_result_buf : access protoent;
uu_buf : Interfaces.C.Strings.chars_ptr;
uu_buflen : size_t;
uu_result : System.Address) return int; -- netdb.h:374
pragma Import (C, getprotoent_r, "getprotoent_r");
function getprotobyname_r
(uu_name : Interfaces.C.Strings.chars_ptr;
uu_result_buf : access protoent;
uu_buf : Interfaces.C.Strings.chars_ptr;
uu_buflen : size_t;
uu_result : System.Address) return int; -- netdb.h:378
pragma Import (C, getprotobyname_r, "getprotobyname_r");
function getprotobynumber_r
(uu_proto : int;
uu_result_buf : access protoent;
uu_buf : Interfaces.C.Strings.chars_ptr;
uu_buflen : size_t;
uu_result : System.Address) return int; -- netdb.h:383
pragma Import (C, getprotobynumber_r, "getprotobynumber_r");
-- Establish network group NETGROUP for enumeration.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
function setnetgrent (uu_netgroup : Interfaces.C.Strings.chars_ptr) return int; -- netdb.h:395
pragma Import (C, setnetgrent, "setnetgrent");
-- Free all space allocated by previous `setnetgrent' call.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
procedure endnetgrent; -- netdb.h:403
pragma Import (C, endnetgrent, "endnetgrent");
-- Get next member of netgroup established by last `setnetgrent' call
-- and return pointers to elements in HOSTP, USERP, and DOMAINP.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
function getnetgrent
(uu_hostp : System.Address;
uu_userp : System.Address;
uu_domainp : System.Address) return int; -- netdb.h:412
pragma Import (C, getnetgrent, "getnetgrent");
-- Test whether NETGROUP contains the triple (HOST,USER,DOMAIN).
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
function innetgr
(uu_netgroup : Interfaces.C.Strings.chars_ptr;
uu_host : Interfaces.C.Strings.chars_ptr;
uu_user : Interfaces.C.Strings.chars_ptr;
uu_domain : Interfaces.C.Strings.chars_ptr) return int; -- netdb.h:423
pragma Import (C, innetgr, "innetgr");
-- Reentrant version of `getnetgrent' where result is placed in BUFFER.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
function getnetgrent_r
(uu_hostp : System.Address;
uu_userp : System.Address;
uu_domainp : System.Address;
uu_buffer : Interfaces.C.Strings.chars_ptr;
uu_buflen : size_t) return int; -- netdb.h:432
pragma Import (C, getnetgrent_r, "getnetgrent_r");
-- Call `rshd' at port RPORT on remote machine *AHOST to execute CMD.
-- The local user is LOCUSER, on the remote machine the command is
-- executed as REMUSER. In *FD2P the descriptor to the socket for the
-- connection is returned. The caller must have the right to use a
-- reserved port. When the function returns *AHOST contains the
-- official host name.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
function rcmd
(uu_ahost : System.Address;
uu_rport : unsigned_short;
uu_locuser : Interfaces.C.Strings.chars_ptr;
uu_remuser : Interfaces.C.Strings.chars_ptr;
uu_cmd : Interfaces.C.Strings.chars_ptr;
uu_fd2p : access int) return int; -- netdb.h:451
pragma Import (C, rcmd, "rcmd");
-- This is the equivalent function where the protocol can be selected
-- and which therefore can be used for IPv6.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
function rcmd_af
(uu_ahost : System.Address;
uu_rport : unsigned_short;
uu_locuser : Interfaces.C.Strings.chars_ptr;
uu_remuser : Interfaces.C.Strings.chars_ptr;
uu_cmd : Interfaces.C.Strings.chars_ptr;
uu_fd2p : access int;
uu_af : CUPS.bits_sockaddr_h.sa_family_t) return int; -- netdb.h:463
pragma Import (C, rcmd_af, "rcmd_af");
-- Call `rexecd' at port RPORT on remote machine *AHOST to execute
-- CMD. The process runs at the remote machine using the ID of user
-- NAME whose cleartext password is <PASSWORD>. In *FD2P the descriptor
-- to the socket for the connection is returned. When the function
-- returns *AHOST contains the official host name.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
function rexec
(uu_ahost : System.Address;
uu_rport : int;
uu_name : Interfaces.C.Strings.chars_ptr;
uu_pass : Interfaces.C.Strings.chars_ptr;
uu_cmd : Interfaces.C.Strings.chars_ptr;
uu_fd2p : access int) return int; -- netdb.h:479
pragma Import (C, rexec, "rexec");
-- This is the equivalent function where the protocol can be selected
-- and which therefore can be used for IPv6.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
function rexec_af
(uu_ahost : System.Address;
uu_rport : int;
uu_name : Interfaces.C.Strings.chars_ptr;
uu_pass : Interfaces.C.Strings.chars_ptr;
uu_cmd : Interfaces.C.Strings.chars_ptr;
uu_fd2p : access int;
uu_af : CUPS.bits_sockaddr_h.sa_family_t) return int; -- netdb.h:491
pragma Import (C, rexec_af, "rexec_af");
-- Check whether user REMUSER on system RHOST is allowed to login as LOCUSER.
-- If SUSER is not zero the user tries to become superuser. Return 0 if
-- it is possible.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
function ruserok
(uu_rhost : Interfaces.C.Strings.chars_ptr;
uu_suser : int;
uu_remuser : Interfaces.C.Strings.chars_ptr;
uu_locuser : Interfaces.C.Strings.chars_ptr) return int; -- netdb.h:505
pragma Import (C, ruserok, "ruserok");
-- This is the equivalent function where the protocol can be selected
-- and which therefore can be used for IPv6.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
function ruserok_af
(uu_rhost : Interfaces.C.Strings.chars_ptr;
uu_suser : int;
uu_remuser : Interfaces.C.Strings.chars_ptr;
uu_locuser : Interfaces.C.Strings.chars_ptr;
uu_af : CUPS.bits_sockaddr_h.sa_family_t) return int; -- netdb.h:515
pragma Import (C, ruserok_af, "ruserok_af");
-- Check whether user REMUSER on system indicated by IPv4 address
-- RADDR is allowed to login as LOCUSER. Non-IPv4 (e.g., IPv6) are
-- not supported. If SUSER is not zero the user tries to become
-- superuser. Return 0 if it is possible.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
function iruserok
(uu_raddr : CUPS.stdint_h.uint32_t;
uu_suser : int;
uu_remuser : Interfaces.C.Strings.chars_ptr;
uu_locuser : Interfaces.C.Strings.chars_ptr) return int; -- netdb.h:528
pragma Import (C, iruserok, "iruserok");
-- This is the equivalent function where the pfamiliy if the address
-- pointed to by RADDR is determined by the value of AF. It therefore
-- can be used for IPv6
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
function iruserok_af
(uu_raddr : System.Address;
uu_suser : int;
uu_remuser : Interfaces.C.Strings.chars_ptr;
uu_locuser : Interfaces.C.Strings.chars_ptr;
uu_af : CUPS.bits_sockaddr_h.sa_family_t) return int; -- netdb.h:539
pragma Import (C, iruserok_af, "iruserok_af");
-- Try to allocate reserved port, returning a descriptor for a socket opened
-- at this port or -1 if unsuccessful. The search for an available port
-- will start at ALPORT and continues with lower numbers.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
function rresvport (uu_alport : access int) return int; -- netdb.h:551
pragma Import (C, rresvport, "rresvport");
-- This is the equivalent function where the protocol can be selected
-- and which therefore can be used for IPv6.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
function rresvport_af (uu_alport : access int; uu_af : CUPS.bits_sockaddr_h.sa_family_t) return int; -- netdb.h:560
pragma Import (C, rresvport_af, "rresvport_af");
-- Extension from POSIX.1:2001.
-- Structure to contain information about address of a service provider.
-- Input flags.
type addrinfo is record
ai_flags : aliased int; -- netdb.h:569
ai_family : aliased int; -- netdb.h:570
ai_socktype : aliased int; -- netdb.h:571
ai_protocol : aliased int; -- netdb.h:572
ai_addrlen : aliased CUPS.unistd_h.socklen_t; -- netdb.h:573
ai_addr : access CUPS.bits_socket_h.sockaddr; -- netdb.h:574
ai_canonname : Interfaces.C.Strings.chars_ptr; -- netdb.h:575
ai_next : access addrinfo; -- netdb.h:576
end record;
pragma Convention (C_Pass_By_Copy, addrinfo); -- netdb.h:567
-- Protocol family for socket.
-- Socket type.
-- Protocol for socket.
-- Length of socket address.
-- Socket address for socket.
-- Canonical name for service location.
-- Pointer to next in list.
-- Structure used as control block for asynchronous lookup.
-- Name to look up.
type gaicb_uu_glibc_reserved_array is array (0 .. 4) of aliased int;
type gaicb is record
ar_name : Interfaces.C.Strings.chars_ptr; -- netdb.h:583
ar_service : Interfaces.C.Strings.chars_ptr; -- netdb.h:584
ar_request : access constant addrinfo; -- netdb.h:585
ar_result : access addrinfo; -- netdb.h:586
uu_return : aliased int; -- netdb.h:588
uu_glibc_reserved : aliased gaicb_uu_glibc_reserved_array; -- netdb.h:589
end record;
pragma Convention (C_Pass_By_Copy, gaicb); -- netdb.h:581
-- Service name.
-- Additional request specification.
-- Pointer to result.
-- The following are internal elements.
-- Lookup mode.
-- Possible values for `ai_flags' field in `addrinfo' structure.
-- Error values for `getaddrinfo' function.
-- Translate name of a service location and/or a service name to set of
-- socket addresses.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
function getaddrinfo
(uu_name : Interfaces.C.Strings.chars_ptr;
uu_service : Interfaces.C.Strings.chars_ptr;
uu_req : access constant addrinfo;
uu_pai : System.Address) return int; -- netdb.h:662
pragma Import (C, getaddrinfo, "getaddrinfo");
-- Free `addrinfo' structure AI including associated storage.
procedure freeaddrinfo (uu_ai : access addrinfo); -- netdb.h:668
pragma Import (C, freeaddrinfo, "freeaddrinfo");
-- Convert error return from getaddrinfo() to a string.
function gai_strerror (uu_ecode : int) return Interfaces.C.Strings.chars_ptr; -- netdb.h:671
pragma Import (C, gai_strerror, "gai_strerror");
-- Translate a socket address to a location and service name.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
function getnameinfo
(uu_sa : access constant CUPS.bits_socket_h.sockaddr;
uu_salen : CUPS.unistd_h.socklen_t;
uu_host : Interfaces.C.Strings.chars_ptr;
uu_hostlen : CUPS.unistd_h.socklen_t;
uu_serv : Interfaces.C.Strings.chars_ptr;
uu_servlen : CUPS.unistd_h.socklen_t;
uu_flags : int) return int; -- netdb.h:677
pragma Import (C, getnameinfo, "getnameinfo");
-- Enqueue ENT requests from the LIST. If MODE is GAI_WAIT wait until all
-- requests are handled. If WAIT is GAI_NOWAIT return immediately after
-- queueing the requests and signal completion according to SIG.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
function getaddrinfo_a
(uu_mode : int;
uu_list : System.Address;
uu_ent : int;
uu_sig : access CUPS.bits_siginfo_h.sigevent) return int; -- netdb.h:692
pragma Import (C, getaddrinfo_a, "getaddrinfo_a");
-- Suspend execution of the thread until at least one of the ENT requests
-- in LIST is handled. If TIMEOUT is not a null pointer it specifies the
-- longest time the function keeps waiting before returning with an error.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
function gai_suspend
(uu_list : System.Address;
uu_ent : int;
uu_timeout : access constant CUPS.time_h.timespec) return int; -- netdb.h:703
pragma Import (C, gai_suspend, "gai_suspend");
-- Get the error status of the request REQ.
function gai_error (uu_req : access gaicb) return int; -- netdb.h:707
pragma Import (C, gai_error, "gai_error");
-- Cancel the requests associated with GAICBP.
function gai_cancel (uu_gaicbp : access gaicb) return int; -- netdb.h:710
pragma Import (C, gai_cancel, "gai_cancel");
end CUPS.netdb_h;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Tridiagonal_LU;
With Text_IO; use Text_IO;
procedure tridiag_tst_1 is
type Real is digits 15;
package rio is new Text_IO.Float_IO(Real);
use rio;
Type Index is range 1..40;
Package Tri is new Tridiagonal_LU (Real, Index);
use Tri;
SolutionVector : Column;
D : Matrix := (others => (others => 0.0));
A : Matrix;
UnitVector : Column;
ZeroVector : constant Column := (others => 0.0);
Index_First : Index := Index'First;
Index_Last : Index := Index'Last;
RealMaxIndex : Real;
Test : Real;
begin
Put("Input First Index Of Matrix To Invert. (e.g. 2)"); New_Line;
get(RealMaxIndex);
Index_First := Index (RealMaxIndex);
Put("Input Last Index Of Matrix To Invert. (e.g. 8)"); New_Line;
get(RealMaxIndex);
Index_Last := Index (RealMaxIndex);
-- if Banded_Matrix_Desired then
-- Construct a banded matrix:
for I in Index loop
D(0)(I) := 0.3;
end loop;
for Row in Index'First..Index'Last loop
D(1)(Row) := 0.9;
end loop;
for Row in Index'First..Index'Last loop
D(-1)(Row) := 0.5;
end loop;
A := D;
LU_Decompose (A, Index_First, Index_Last);
-- Get Nth column of the inverse matrix
-- Col := N;
Put("Output should be the Identity matrix."); new_Line;
for Col in Index range Index_First..Index_Last loop
UnitVector := ZeroVector;
UnitVector(Col) := 1.0;
Solve (SolutionVector, A, UnitVector, Index_First, Index_Last);
New_Line;
-- Multiply SolutionVector times tridiagonal D:
for Row in Index_First..Index_Last loop
Test := 0.0;
if Row > Index_First then
Test := Test + D(-1)(Row) * SolutionVector(Row-1);
end if;
Test := Test + D(0)(Row) * SolutionVector(Row);
if Row < Index_Last then
Test := Test + D(1)(Row) * SolutionVector(Row+1);
end if;
Put (Test, 2, 3, 3); Put (" ");
end loop;
end loop;
end;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with RASCAL.ToolboxQuit; use RASCAL.ToolboxQuit;
with RASCAL.Toolbox; use RASCAL.Toolbox;
with RASCAL.OS; use RASCAL.OS;
package Controller_MainWindow is
type TEL_OpenWindow_Type is new Toolbox_UserEventListener(16#14#,-1,-1) with null record;
type TEL_OKButtonPressed_Type is new Toolbox_UserEventListener(16#30#,-1,-1) with null record;
type TEL_EscapeButtonPressed_Type is new Toolbox_UserEventListener(16#31#,-1,-1) with null record;
type TEL_RenewSelected_Type is new Toolbox_UserEventListener(16#33#,-1,-1) with null record;
--
--
--
procedure Handle (The : in TEL_OKButtonPressed_Type);
--
--
--
procedure Handle (The : in TEL_EscapeButtonPressed_Type);
--
--
--
procedure Handle (The : in TEL_RenewSelected_Type);
--
-- The user has clicked on the iconbar icon - open the amin window.
--
procedure Handle (The : in TEL_OpenWindow_Type);
end Controller_MainWindow;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
package GL.Objects.Vertex_Arrays is
pragma Preelaborate;
type Vertex_Array_Object is new GL_Object with private;
-- A single VAO is manually created and binded after the context
-- is made current.
procedure Create (Object : in out Vertex_Array_Object);
procedure Delete (Object : in out Vertex_Array_Object);
overriding
procedure Initialize_Id (Object : in out Vertex_Array_Object) is null;
-- Null because VAO is created manually
overriding
procedure Delete_Id (Object : in out Vertex_Array_Object) is null;
-- Null because VAO is deleted manually
overriding
function Identifier (Object : Vertex_Array_Object) return Types.Debug.Identifier is
(Types.Debug.Vertex_Array);
private
type Vertex_Array_Object is new GL_Object with null record;
end GL.Objects.Vertex_Arrays;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Strings;
with Tcl.Lists; use Tcl.Lists;
package body Tk.TtkWidget is
procedure Option_Image
(Name: String; Value: Compound_Type;
Options_String: in out Unbounded_String) is
begin
if Value /= EMPTY then
Append
(Source => Options_String,
New_Item =>
" -" & Name & " " &
To_Lower(Item => Compound_Type'Image(Value)));
end if;
end Option_Image;
procedure Option_Image
(Name: String; Value: Disabled_State_Type;
Options_String: in out Unbounded_String) is
begin
if Value /= NONE then
Append
(Source => Options_String,
New_Item =>
" -" & Name & " " &
To_Lower(Item => Disabled_State_Type'Image(Value)));
end if;
end Option_Image;
procedure Option_Image
(Name: String; Value: Ttk_Image_Option;
Options_String: in out Unbounded_String) is
begin
if Value = Default_Ttk_Image_Option then
return;
end if;
Append
(Source => Options_String,
New_Item => " -" & Name & " {" & To_String(Source => Value.Default));
if Value.Active /= Tcl_String(Null_Unbounded_String) then
Append
(Source => Options_String,
New_Item => " active " & To_String(Source => Value.Active));
end if;
if Value.Disabled /= Tcl_String(Null_Unbounded_String) then
Append
(Source => Options_String,
New_Item => " disabled " & To_String(Source => Value.Disabled));
end if;
if Value.Focus /= Tcl_String(Null_Unbounded_String) then
Append
(Source => Options_String,
New_Item => " focus " & To_String(Source => Value.Focus));
end if;
if Value.Pressed /= Tcl_String(Null_Unbounded_String) then
Append
(Source => Options_String,
New_Item => " pressed " & To_String(Source => Value.Pressed));
end if;
if Value.Selected /= Tcl_String(Null_Unbounded_String) then
Append
(Source => Options_String,
New_Item => " selected " & To_String(Source => Value.Selected));
end if;
if Value.Background /= Tcl_String(Null_Unbounded_String) then
Append
(Source => Options_String,
New_Item =>
" background " & To_String(Source => Value.Background));
end if;
if Value.Readonly /= Tcl_String(Null_Unbounded_String) then
Append
(Source => Options_String,
New_Item => " readonly " & To_String(Source => Value.Readonly));
end if;
if Value.Alternate /= Tcl_String(Null_Unbounded_String) then
Append
(Source => Options_String,
New_Item => " alternate " & To_String(Source => Value.Alternate));
end if;
if Value.Invalid /= Tcl_String(Null_Unbounded_String) then
Append
(Source => Options_String,
New_Item => " invalid " & To_String(Source => Value.Invalid));
end if;
if Value.Hover /= Tcl_String(Null_Unbounded_String) then
Append
(Source => Options_String,
New_Item => " hover " & To_String(Source => Value.Hover));
end if;
Append(Source => Options_String, New_Item => "}");
end Option_Image;
procedure Option_Image
(Name: String; Value: Padding_Data;
Options_String: in out Unbounded_String) is
use Ada.Strings;
First: Boolean := True;
procedure Append_Value
(New_Value: Pixel_Data; Is_First: in out Boolean) is
begin
if New_Value.Value > -1.0 then
if Is_First then
Append
(Source => Options_String, New_Item => " -" & Name & " {");
Is_First := False;
end if;
Append
(Source => Options_String,
New_Item => Pixel_Data_Image(Value => New_Value) & " ");
end if;
end Append_Value;
begin
Append_Value(New_Value => Value.Left, Is_First => First);
Append_Value(New_Value => Value.Top, Is_First => First);
Append_Value(New_Value => Value.Right, Is_First => First);
Append_Value(New_Value => Value.Bottom, Is_First => First);
if not First then
Trim(Source => Options_String, Side => Right);
Append(Source => Options_String, New_Item => "}");
end if;
end Option_Image;
function Option_Value
(Ttk_Widgt: Ttk_Widget; Name: String) return Compound_Type is
Result: constant String :=
Execute_Widget_Command
(Widgt => Ttk_Widgt, Command_Name => "cget", Options => "-" & Name)
.Result;
begin
if Result'Length = 0 then
return EMPTY;
end if;
return Compound_Type'Value(Result);
end Option_Value;
function Option_Value
(Ttk_Widgt: Ttk_Widget; Name: String) return Disabled_State_Type is
begin
return
Disabled_State_Type'Value
(Execute_Widget_Command
(Widgt => Ttk_Widgt, Command_Name => "cget",
Options => "-" & Name)
.Result);
end Option_Value;
function Option_Value
(Ttk_Widgt: Ttk_Widget; Name: String) return Ttk_Image_Option is
Options: Ttk_Image_Option := Default_Ttk_Image_Option;
Options_Array: constant Array_List :=
Split_List
(List =>
Execute_Widget_Command
(Widgt => Ttk_Widgt, Command_Name => "cget",
Options => "-" & Name)
.Result,
Interpreter => Tk_Interp(Widgt => Ttk_Widgt));
Index: Positive := 2;
begin
if Options_Array'Length < 1 then
return Options;
end if;
Options.Default :=
To_Tcl_String(Source => To_String(Source => Options_Array(1)));
Set_Options_Loop :
while Index <= Options_Array'Length loop
if Options_Array(Index) = To_Tcl_String(Source => "active") then
Options.Active := Options_Array(Index + 1);
elsif Options_Array(Index) = To_Tcl_String(Source => "disabled") then
Options.Disabled := Options_Array(Index + 1);
elsif Options_Array(Index) = To_Tcl_String(Source => "focus") then
Options.Focus := Options_Array(Index + 1);
elsif Options_Array(Index) = To_Tcl_String(Source => "pressed") then
Options.Pressed := Options_Array(Index + 1);
elsif Options_Array(Index) = To_Tcl_String(Source => "selected") then
Options.Selected := Options_Array(Index + 1);
elsif Options_Array(Index) =
To_Tcl_String(Source => "background") then
Options.Background := Options_Array(Index + 1);
elsif Options_Array(Index) = To_Tcl_String(Source => "readonly") then
Options.Readonly := Options_Array(Index + 1);
elsif Options_Array(Index) = To_Tcl_String(Source => "alternate") then
Options.Alternate := Options_Array(Index + 1);
elsif Options_Array(Index) = To_Tcl_String(Source => "invalid") then
Options.Invalid := Options_Array(Index + 1);
elsif Options_Array(Index) = To_Tcl_String(Source => "hover") then
Options.Hover := Options_Array(Index + 1);
end if;
Index := Index + 2;
end loop Set_Options_Loop;
return Options;
end Option_Value;
function Option_Value
(Ttk_Widgt: Ttk_Widget; Name: String) return Padding_Data is
Result_List: constant Array_List :=
Split_List
(List =>
Execute_Widget_Command
(Widgt => Ttk_Widgt, Command_Name => "cget",
Options => "-" & Name)
.Result,
Interpreter => Tk_Interp(Widgt => Ttk_Widgt));
begin
if Result_List'Length = 0 then
return Empty_Padding_Data;
end if;
return Padding: Padding_Data := Empty_Padding_Data do
Padding.Left :=
Pixel_Data_Value(Value => To_Ada_String(Source => Result_List(1)));
if Result_List'Length > 1 then
Padding.Top :=
Pixel_Data_Value
(Value => To_Ada_String(Source => Result_List(2)));
end if;
if Result_List'Length > 2 then
Padding.Right :=
Pixel_Data_Value
(Value => To_Ada_String(Source => Result_List(3)));
end if;
if Result_List'Length = 4 then
Padding.Bottom :=
Pixel_Data_Value
(Value => To_Ada_String(Source => Result_List(4)));
end if;
end return;
end Option_Value;
function In_State
(Ttk_Widgt: Ttk_Widget; State_Ttk: Ttk_State_Type) return Boolean is
begin
Execute_Widget_Command
(Widgt => Ttk_Widgt, Command_Name => "instate",
Options => To_Lower(Item => Ttk_State_Type'Image(State_Ttk)));
if Tcl_Get_Result(Interpreter => Tk_Interp(Widgt => Ttk_Widgt)) = 1 then
return True;
end if;
return False;
end In_State;
procedure In_State
(Ttk_Widgt: Ttk_Widget; State_Type: Ttk_State_Type;
Tcl_Script: Tcl_String) is
begin
Execute_Widget_Command
(Widgt => Ttk_Widgt, Command_Name => "instate",
Options =>
To_Lower(Item => Ttk_State_Type'Image(State_Type)) & " " &
To_String(Source => Tcl_Script));
end In_State;
procedure Set_State
(Ttk_Widgt: Ttk_Widget; Widget_State: Ttk_State_Type;
Disable: Boolean := False) is
begin
if Disable then
Execute_Widget_Command
(Widgt => Ttk_Widgt, Command_Name => "state",
Options =>
"!" & To_Lower(Item => Ttk_State_Type'Image(Widget_State)));
else
Execute_Widget_Command
(Widgt => Ttk_Widgt, Command_Name => "state",
Options => To_Lower(Item => Ttk_State_Type'Image(Widget_State)));
end if;
end Set_State;
function Get_States(Ttk_Widgt: Ttk_Widget) return Ttk_State_Array is
Result_List: constant Array_List :=
Split_List
(List =>
Execute_Widget_Command
(Widgt => Ttk_Widgt, Command_Name => "state")
.Result,
Interpreter => Tk_Interp(Widgt => Ttk_Widgt));
begin
return
States: Ttk_State_Array(1 .. Result_List'Last) :=
(others => Default_Ttk_State) do
Fill_Return_Value_Loop :
for I in 1 .. Result_List'Last loop
States(I) :=
Ttk_State_Type'Value(To_Ada_String(Source => Result_List(I)));
end loop Fill_Return_Value_Loop;
end return;
end Get_States;
end Tk.TtkWidget;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-------------------------------------------------------------
package body Program.Nodes.Object_Declarations is
function Create
(Names : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Vector_Access;
Colon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Aliased_Token : Program.Lexical_Elements
.Lexical_Element_Access;
Constant_Token : Program.Lexical_Elements
.Lexical_Element_Access;
Object_Subtype : not null Program.Elements.Definitions
.Definition_Access;
Assignment_Token : Program.Lexical_Elements
.Lexical_Element_Access;
Initialization_Expression : Program.Elements.Expressions
.Expression_Access;
With_Token : Program.Lexical_Elements
.Lexical_Element_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access)
return Object_Declaration is
begin
return Result : Object_Declaration :=
(Names => Names, Colon_Token => Colon_Token,
Aliased_Token => Aliased_Token, Constant_Token => Constant_Token,
Object_Subtype => Object_Subtype,
Assignment_Token => Assignment_Token,
Initialization_Expression => Initialization_Expression,
With_Token => With_Token, Aspects => Aspects,
Semicolon_Token => Semicolon_Token, Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
function Create
(Names : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Vector_Access;
Object_Subtype : not null Program.Elements.Definitions
.Definition_Access;
Initialization_Expression : Program.Elements.Expressions
.Expression_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Aliased : Boolean := False;
Has_Constant : Boolean := False)
return Implicit_Object_Declaration is
begin
return Result : Implicit_Object_Declaration :=
(Names => Names, Object_Subtype => Object_Subtype,
Initialization_Expression => Initialization_Expression,
Aspects => Aspects, Is_Part_Of_Implicit => Is_Part_Of_Implicit,
Is_Part_Of_Inherited => Is_Part_Of_Inherited,
Is_Part_Of_Instance => Is_Part_Of_Instance,
Has_Aliased => Has_Aliased, Has_Constant => Has_Constant,
Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
overriding function Names
(Self : Base_Object_Declaration)
return not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Vector_Access is
begin
return Self.Names;
end Names;
overriding function Object_Subtype
(Self : Base_Object_Declaration)
return not null Program.Elements.Definitions.Definition_Access is
begin
return Self.Object_Subtype;
end Object_Subtype;
overriding function Initialization_Expression
(Self : Base_Object_Declaration)
return Program.Elements.Expressions.Expression_Access is
begin
return Self.Initialization_Expression;
end Initialization_Expression;
overriding function Aspects
(Self : Base_Object_Declaration)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access is
begin
return Self.Aspects;
end Aspects;
overriding function Colon_Token
(Self : Object_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Colon_Token;
end Colon_Token;
overriding function Aliased_Token
(Self : Object_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Aliased_Token;
end Aliased_Token;
overriding function Constant_Token
(Self : Object_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Constant_Token;
end Constant_Token;
overriding function Assignment_Token
(Self : Object_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Assignment_Token;
end Assignment_Token;
overriding function With_Token
(Self : Object_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.With_Token;
end With_Token;
overriding function Semicolon_Token
(Self : Object_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Semicolon_Token;
end Semicolon_Token;
overriding function Has_Aliased
(Self : Object_Declaration)
return Boolean is
begin
return Self.Aliased_Token.Assigned;
end Has_Aliased;
overriding function Has_Constant
(Self : Object_Declaration)
return Boolean is
begin
return Self.Constant_Token.Assigned;
end Has_Constant;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Object_Declaration)
return Boolean is
begin
return Self.Is_Part_Of_Implicit;
end Is_Part_Of_Implicit;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Object_Declaration)
return Boolean is
begin
return Self.Is_Part_Of_Inherited;
end Is_Part_Of_Inherited;
overriding function Is_Part_Of_Instance
(Self : Implicit_Object_Declaration)
return Boolean is
begin
return Self.Is_Part_Of_Instance;
end Is_Part_Of_Instance;
overriding function Has_Aliased
(Self : Implicit_Object_Declaration)
return Boolean is
begin
return Self.Has_Aliased;
end Has_Aliased;
overriding function Has_Constant
(Self : Implicit_Object_Declaration)
return Boolean is
begin
return Self.Has_Constant;
end Has_Constant;
procedure Initialize (Self : in out Base_Object_Declaration'Class) is
begin
for Item in Self.Names.Each_Element loop
Set_Enclosing_Element (Item.Element, Self'Unchecked_Access);
end loop;
Set_Enclosing_Element (Self.Object_Subtype, Self'Unchecked_Access);
if Self.Initialization_Expression.Assigned then
Set_Enclosing_Element
(Self.Initialization_Expression, Self'Unchecked_Access);
end if;
for Item in Self.Aspects.Each_Element loop
Set_Enclosing_Element (Item.Element, Self'Unchecked_Access);
end loop;
null;
end Initialize;
overriding function Is_Object_Declaration
(Self : Base_Object_Declaration)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Object_Declaration;
overriding function Is_Declaration
(Self : Base_Object_Declaration)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Declaration;
overriding procedure Visit
(Self : not null access Base_Object_Declaration;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is
begin
Visitor.Object_Declaration (Self);
end Visit;
overriding function To_Object_Declaration_Text
(Self : in out Object_Declaration)
return Program.Elements.Object_Declarations
.Object_Declaration_Text_Access is
begin
return Self'Unchecked_Access;
end To_Object_Declaration_Text;
overriding function To_Object_Declaration_Text
(Self : in out Implicit_Object_Declaration)
return Program.Elements.Object_Declarations
.Object_Declaration_Text_Access is
pragma Unreferenced (Self);
begin
return null;
end To_Object_Declaration_Text;
end Program.Nodes.Object_Declarations;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with
GL,
GL.Binding,
openGL.Tasks,
interfaces.C;
package body openGL.Renderer
is
use GL,
interfaces.C;
procedure Background_is (Self : in out Item; Now : in openGL.Color;
Opacity : in Opaqueness := 1.0)
is
begin
Self.Background.Primary := +Now;
Self.Background.Alpha := to_color_Value (Primary (Opacity));
end Background_is;
procedure Background_is (Self : in out Item; Now : in openGL.lucid_Color)
is
begin
Self.Background := +Now;
end Background_is;
procedure clear_Frame (Self : in Item)
is
use GL.Binding;
check_is_OK : constant Boolean := openGL.Tasks.Check with Unreferenced;
begin
glClearColor (GLfloat (to_Primary (Self.Background.Primary.Red)),
GLfloat (to_Primary (Self.Background.Primary.Green)),
GLfloat (to_Primary (Self.Background.Primary.Blue)),
GLfloat (to_Primary (Self.Background.Alpha)));
glClear ( GL_COLOR_BUFFER_BIT
or GL_DEPTH_BUFFER_BIT);
glCullFace (GL_BACK);
glEnable (GL_CULL_FACE);
end clear_Frame;
end openGL.Renderer;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-------------------------------------------------------------
package body Program.Nodes.Loop_Parameter_Specifications is
function Create
(Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
In_Token : not null Program.Lexical_Elements.Lexical_Element_Access;
Reverse_Token : Program.Lexical_Elements.Lexical_Element_Access;
Definition : not null Program.Elements.Discrete_Ranges
.Discrete_Range_Access)
return Loop_Parameter_Specification is
begin
return Result : Loop_Parameter_Specification :=
(Name => Name, In_Token => In_Token, Reverse_Token => Reverse_Token,
Definition => Definition, Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
function Create
(Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
Definition : not null Program.Elements.Discrete_Ranges
.Discrete_Range_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Reverse : Boolean := False)
return Implicit_Loop_Parameter_Specification is
begin
return Result : Implicit_Loop_Parameter_Specification :=
(Name => Name, Definition => Definition,
Is_Part_Of_Implicit => Is_Part_Of_Implicit,
Is_Part_Of_Inherited => Is_Part_Of_Inherited,
Is_Part_Of_Instance => Is_Part_Of_Instance,
Has_Reverse => Has_Reverse, Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
overriding function Name
(Self : Base_Loop_Parameter_Specification)
return not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access is
begin
return Self.Name;
end Name;
overriding function Definition
(Self : Base_Loop_Parameter_Specification)
return not null Program.Elements.Discrete_Ranges.Discrete_Range_Access is
begin
return Self.Definition;
end Definition;
overriding function In_Token
(Self : Loop_Parameter_Specification)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.In_Token;
end In_Token;
overriding function Reverse_Token
(Self : Loop_Parameter_Specification)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Reverse_Token;
end Reverse_Token;
overriding function Has_Reverse
(Self : Loop_Parameter_Specification)
return Boolean is
begin
return Self.Reverse_Token.Assigned;
end Has_Reverse;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Loop_Parameter_Specification)
return Boolean is
begin
return Self.Is_Part_Of_Implicit;
end Is_Part_Of_Implicit;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Loop_Parameter_Specification)
return Boolean is
begin
return Self.Is_Part_Of_Inherited;
end Is_Part_Of_Inherited;
overriding function Is_Part_Of_Instance
(Self : Implicit_Loop_Parameter_Specification)
return Boolean is
begin
return Self.Is_Part_Of_Instance;
end Is_Part_Of_Instance;
overriding function Has_Reverse
(Self : Implicit_Loop_Parameter_Specification)
return Boolean is
begin
return Self.Has_Reverse;
end Has_Reverse;
procedure Initialize
(Self : aliased in out Base_Loop_Parameter_Specification'Class) is
begin
Set_Enclosing_Element (Self.Name, Self'Unchecked_Access);
Set_Enclosing_Element (Self.Definition, Self'Unchecked_Access);
null;
end Initialize;
overriding function Is_Loop_Parameter_Specification_Element
(Self : Base_Loop_Parameter_Specification)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Loop_Parameter_Specification_Element;
overriding function Is_Declaration_Element
(Self : Base_Loop_Parameter_Specification)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Declaration_Element;
overriding procedure Visit
(Self : not null access Base_Loop_Parameter_Specification;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is
begin
Visitor.Loop_Parameter_Specification (Self);
end Visit;
overriding function To_Loop_Parameter_Specification_Text
(Self : aliased in out Loop_Parameter_Specification)
return Program.Elements.Loop_Parameter_Specifications
.Loop_Parameter_Specification_Text_Access is
begin
return Self'Unchecked_Access;
end To_Loop_Parameter_Specification_Text;
overriding function To_Loop_Parameter_Specification_Text
(Self : aliased in out Implicit_Loop_Parameter_Specification)
return Program.Elements.Loop_Parameter_Specifications
.Loop_Parameter_Specification_Text_Access is
pragma Unreferenced (Self);
begin
return null;
end To_Loop_Parameter_Specification_Text;
end Program.Nodes.Loop_Parameter_Specifications;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
with Interfaces;
package body Util.Streams is
use Ada.Streams;
subtype Offset is Ada.Streams.Stream_Element_Offset;
-- ------------------------------
-- Copy the input stream to the output stream until the end of the input stream
-- is reached.
-- ------------------------------
procedure Copy (From : in out Input_Stream'Class;
Into : in out Output_Stream'Class) is
Buffer : Stream_Element_Array (0 .. 4_096);
Last : Stream_Element_Offset;
begin
loop
From.Read (Buffer, Last);
if Last > Buffer'First then
Into.Write (Buffer (Buffer'First .. Last));
end if;
exit when Last < Buffer'Last;
end loop;
end Copy;
-- ------------------------------
-- Copy the stream array to the string.
-- The string must be large enough to hold the stream array
-- or a Constraint_Error exception is raised.
-- ------------------------------
procedure Copy (From : in Ada.Streams.Stream_Element_Array;
Into : in out String) is
Pos : Positive := Into'First;
begin
for I in From'Range loop
Into (Pos) := Character'Val (From (I));
Pos := Pos + 1;
end loop;
end Copy;
-- ------------------------------
-- Copy the string to the stream array.
-- The stream array must be large enough to hold the string
-- or a Constraint_Error exception is raised.
-- ------------------------------
procedure Copy (From : in String;
Into : in out Ada.Streams.Stream_Element_Array) is
Pos : Ada.Streams.Stream_Element_Offset := Into'First;
begin
for I in From'Range loop
Into (Pos) := Character'Pos (From (I));
Pos := Pos + 1;
end loop;
end Copy;
-- ------------------------------
-- Write a raw character on the stream.
-- ------------------------------
procedure Write (Stream : in out Output_Stream'Class;
Item : in Character) is
Buf : constant Ada.Streams.Stream_Element_Array (1 .. 1)
:= (1 => Ada.Streams.Stream_Element (Character'Pos (Item)));
begin
Stream.Write (Buf);
end Write;
-- ------------------------------
-- Write a wide character on the stream doing some conversion if necessary.
-- The default implementation translates the wide character to a UTF-8 sequence.
-- ------------------------------
procedure Write_Wide (Stream : in out Output_Stream'Class;
Item : in Wide_Wide_Character) is
use Interfaces;
Val : Unsigned_32;
Buf : Ada.Streams.Stream_Element_Array (1 .. 4);
begin
-- UTF-8 conversion
-- 7 U+0000 U+007F 1 0xxxxxxx
-- 11 U+0080 U+07FF 2 110xxxxx 10xxxxxx
-- 16 U+0800 U+FFFF 3 1110xxxx 10xxxxxx 10xxxxxx
-- 21 U+10000 U+1FFFFF 4 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
Val := Wide_Wide_Character'Pos (Item);
if Val <= 16#7f# then
Buf (1) := Ada.Streams.Stream_Element (Val);
Stream.Write (Buf (1 .. 1));
elsif Val <= 16#07FF# then
Buf (1) := Stream_Element (16#C0# or Shift_Right (Val, 6));
Buf (2) := Stream_Element (16#80# or (Val and 16#03F#));
Stream.Write (Buf (1 .. 2));
elsif Val <= 16#0FFFF# then
Buf (1) := Stream_Element (16#E0# or Shift_Right (Val, 12));
Val := Val and 16#0FFF#;
Buf (2) := Stream_Element (16#80# or Shift_Right (Val, 6));
Buf (3) := Stream_Element (16#80# or (Val and 16#03F#));
Stream.Write (Buf (1 .. 3));
else
Val := Val and 16#1FFFFF#;
Buf (1) := Stream_Element (16#F0# or Shift_Right (Val, 18));
Val := Val and 16#3FFFF#;
Buf (2) := Stream_Element (16#80# or Shift_Right (Val, 12));
Val := Val and 16#0FFF#;
Buf (3) := Stream_Element (16#80# or Shift_Right (Val, 6));
Buf (4) := Stream_Element (16#80# or (Val and 16#03F#));
Stream.Write (Buf (1 .. 4));
end if;
end Write_Wide;
procedure Write_Wide (Stream : in out Output_Stream'Class;
Item : in Wide_Wide_String) is
begin
for C of Item loop
Stream.Write_Wide (C);
end loop;
end Write_Wide;
-- ------------------------------
-- Write a raw string on the stream.
-- ------------------------------
procedure Write (Stream : in out Output_Stream'Class;
Item : in String) is
Buf : Ada.Streams.Stream_Element_Array (Offset (Item'First) .. Offset (Item'Last));
for Buf'Address use Item'Address;
begin
Stream.Write (Buf);
end Write;
end Util.Streams;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Approximation, Ada.Numerics.Elementary_Functions;
procedure Test_Approximations is
package A is new Approximation(Float,
Ada.Numerics.Elementary_Functions.Sqrt,
Ada.Numerics.Elementary_Functions."**");
use type A.Number;
X1: A.Number := A.Approx(100.0, 1.1);
Y1: A.Number := A.Approx( 50.0, 1.2);
X2: A.Number := A.Approx(200.0, 2.2);
Y2: A.Number := A.Approx(100.0, 2.3);
begin
A.Put_Line("Distance:",
((X1-X2)**2 + (Y1 - Y2)**2)**0.5,
Sigma_Fore => 1);
end Test_Approximations;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Tkmrpc.Types;
package Tkmrpc.Contexts.cc
is
type cc_State_Type is
(clean,
-- Initial clean state.
invalid,
-- Error state.
stale,
-- CC context is stale.
linked,
-- CC is linked.
checked
-- CC has been checked and verified.
);
function Get_State
(Id : Types.cc_id_type)
return cc_State_Type
with
Pre => Is_Valid (Id);
function Is_Valid (Id : Types.cc_id_type) return Boolean;
-- Returns True if the given id has a valid value.
function Has_authag_id
(Id : Types.cc_id_type;
authag_id : Types.authag_id_type)
return Boolean
with
Pre => Is_Valid (Id);
-- Returns True if the context specified by id has the given
-- authag_id value.
function Has_ca_id
(Id : Types.cc_id_type;
ca_id : Types.ca_id_type)
return Boolean
with
Pre => Is_Valid (Id);
-- Returns True if the context specified by id has the given
-- ca_id value.
function Has_certificate
(Id : Types.cc_id_type;
certificate : Types.certificate_type)
return Boolean
with
Pre => Is_Valid (Id);
-- Returns True if the context specified by id has the given
-- certificate value.
function Has_last_cert
(Id : Types.cc_id_type;
last_cert : Types.certificate_type)
return Boolean
with
Pre => Is_Valid (Id);
-- Returns True if the context specified by id has the given
-- last_cert value.
function Has_not_after
(Id : Types.cc_id_type;
not_after : Types.abs_time_type)
return Boolean
with
Pre => Is_Valid (Id);
-- Returns True if the context specified by id has the given
-- not_after value.
function Has_not_before
(Id : Types.cc_id_type;
not_before : Types.abs_time_type)
return Boolean
with
Pre => Is_Valid (Id);
-- Returns True if the context specified by id has the given
-- not_before value.
function Has_ri_id
(Id : Types.cc_id_type;
ri_id : Types.ri_id_type)
return Boolean
with
Pre => Is_Valid (Id);
-- Returns True if the context specified by id has the given
-- ri_id value.
function Has_State
(Id : Types.cc_id_type;
State : cc_State_Type)
return Boolean
with
Pre => Is_Valid (Id);
-- Returns True if the context specified by id has the given
-- State value.
procedure add_certificate
(Id : Types.cc_id_type;
certificate : Types.certificate_type;
not_before : Types.abs_time_type;
not_after : Types.abs_time_type)
with
Pre => Is_Valid (Id) and then
(Has_State (Id, linked)),
Post => Has_State (Id, Get_State (Id)'Old) and
Has_last_cert (Id, certificate) and
Has_not_before (Id, not_before) and
Has_not_after (Id, not_after);
procedure check
(Id : Types.cc_id_type;
ca_id : Types.ca_id_type)
with
Pre => Is_Valid (Id) and then
(Has_State (Id, linked)),
Post => Has_State (Id, checked) and
Has_ca_id (Id, ca_id);
procedure create
(Id : Types.cc_id_type;
authag_id : Types.authag_id_type;
ri_id : Types.ri_id_type;
certificate : Types.certificate_type;
last_cert : Types.certificate_type;
not_before : Types.abs_time_type;
not_after : Types.abs_time_type)
with
Pre => Is_Valid (Id) and then
(Has_State (Id, clean)),
Post => Has_State (Id, linked) and
Has_authag_id (Id, authag_id) and
Has_ri_id (Id, ri_id) and
Has_certificate (Id, certificate) and
Has_last_cert (Id, last_cert) and
Has_not_before (Id, not_before) and
Has_not_after (Id, not_after);
function get_certificate
(Id : Types.cc_id_type)
return Types.certificate_type
with
Pre => Is_Valid (Id) and then
(Has_State (Id, checked)),
Post => Has_certificate (Id, get_certificate'Result);
function get_last_cert
(Id : Types.cc_id_type)
return Types.certificate_type
with
Pre => Is_Valid (Id) and then
(Has_State (Id, linked)),
Post => Has_last_cert (Id, get_last_cert'Result);
function get_not_after
(Id : Types.cc_id_type)
return Types.abs_time_type
with
Pre => Is_Valid (Id) and then
(Has_State (Id, linked)),
Post => Has_not_after (Id, get_not_after'Result);
function get_not_before
(Id : Types.cc_id_type)
return Types.abs_time_type
with
Pre => Is_Valid (Id) and then
(Has_State (Id, linked)),
Post => Has_not_before (Id, get_not_before'Result);
function get_remote_id
(Id : Types.cc_id_type)
return Types.ri_id_type
with
Pre => Is_Valid (Id) and then
(Has_State (Id, checked)),
Post => Has_ri_id (Id, get_remote_id'Result);
procedure invalidate
(Id : Types.cc_id_type)
with
Pre => Is_Valid (Id),
Post => Has_State (Id, invalid);
procedure reset
(Id : Types.cc_id_type)
with
Pre => Is_Valid (Id),
Post => Has_State (Id, clean);
end Tkmrpc.Contexts.cc;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Orka.SIMD.SSE.Singles;
package Orka.SIMD.SSE4_1.Singles.Swizzle is
pragma Pure;
use Orka.SIMD.SSE.Singles;
function Blend (Left, Right : m128; Mask : Unsigned_32) return m128
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_blendps";
-- Select elements from two sources (Left and Right) using a constant mask
function Blend (Left, Right, Mask : m128) return m128
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_blendvps";
-- Select elements from two sources (Left and Right) using a variable mask
function Extract (Elements : m128; Mask : Unsigned_32) return Float_32
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vec_ext_v4sf";
function Insert (Left, Right : m128; Mask : Unsigned_32) return m128
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_insertps128";
-- Insert an element from Right into Left. Bits 6-7 of Mask
-- define the index of the source (Right), bits 4-5 define
-- the index of the destination (Left). Bits 0-3 define the
-- zero mask.
end Orka.SIMD.SSE4_1.Singles.Swizzle;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- Based on libgasandbox.draw.h
with GL.Objects.Programs;
with C3GA;
with Multivector_Analyze;
with Palet;
package GA_Draw is
type Method_Type is (Draw_Method_Undefined, Draw_Bivector_Circle,
Draw_Bivector_Parallelogram,
Draw_Bivector_Parallelogram_No_Vectors,
Draw_Bivector_Cross, Draw_Bivector_Curly_Tail,
Draw_Bivector_Swirl, Draw_Bivector_Circle_Outline,
Draw_TV_Sphere, Draw_TV_Cross, Draw_TV_Curly_Tail,
Draw_TV_Parellelepiped,
Draw_TV_Parellelepiped_No_Vectors);
procedure Draw_Bivector (Render_Program : GL.Objects.Programs.Program;
Base, Normal, Ortho_1, Ortho_2 : C3GA.Vector_E3;
Palet_Type : Palet.Colour_Palet;
Scale : float := 1.0;
Method : Method_Type := Draw_Bivector_Circle);
procedure Draw_Line (Render_Program : GL.Objects.Programs.Program;
Direction : C3GA.Vector_E3; Weight : Float := 1.0);
procedure Draw_Trivector (Render_Program : GL.Objects.Programs.Program;
Base : C3GA.Vector_E3; Scale : float := 1.0;
Palet_Type : Palet.Colour_Palet;
Method : Method_Type := Draw_TV_Sphere);
procedure Draw_Trivector (Render_Program : GL.Objects.Programs.Program;
Base : C3GA.Vector_E3; Scale : float := 1.0;
V : Multivector_Analyze.E3_Vector_Array;
-- Palet_Type : Palet.Colour_Palet;
Method : Method_Type := Draw_TV_Sphere);
procedure Draw_Vector (Render_Program : GL.Objects.Programs.Program;
Tail, Direction : C3GA.Vector_E3;
Scale : float := 1.0);
end GA_Draw;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
TYPE ACC6 IS ACCESS REC;
SUBTYPE ACC6S IS ACC6 (IDENT_INT (6));
FUNCTION F RETURN ACC6;
PRIVATE
TYPE REC (D : INTEGER) IS
RECORD
NULL;
END RECORD;
END PKG1;
PACKAGE BODY PKG1 IS
FUNCTION F RETURN ACC6 IS
BEGIN
RETURN NEW REC'(D => IDENT_INT (5));
END F;
END PKG1;
PACKAGE PKG2 IS END PKG2;
PACKAGE BODY PKG2 IS
USE PKG1;
A : ACC6;
BEGIN
A := ACC6S'(F);
IF A = NULL THEN
FAILED ( "NO EXCEPTION RAISED FOR INDEX BOUNDS " &
"DIFFERENT FROM THOSE OF TYPE ACC6 - 1" );
ELSE
FAILED ( "NO EXCEPTION RAISED FOR INDEX BOUNDS " &
"DIFFERENT FROM THOSE OF TYPE ACC6 - 2" );
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED FOR DISC " &
"VALUES DIFFERENT FROM THOSE OF TYPE " &
"ACC6" );
END PKG2;
BEGIN
NULL;
END;
RESULT;
END C47009A;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Real_Time;
use Ada.Real_Time;
with Ada.Numerics.Discrete_Random;
with semaphores;
use semaphores;
procedure ProducerConsumer is
X : Integer; -- Shared Variable
N : constant Integer := 40; -- Number of produced and comsumed variables
pragma Volatile(X); -- For a volatile object all reads and updates of
-- the object as a whole are performed directly
-- to memory (Ada Reference Manual, C.6)
-- Random Delays
subtype Delay_Interval is Integer range 50..250;
package Random_Delay is new Ada.Numerics.Discrete_Random (Delay_Interval);
use Random_Delay;
G : Generator;
SemWrite : CountingSemaphore(1, 1); --semaphore for producer
SemRead: CountingSemaphore(1, 0); --semaphore for consumer
task Producer;
task Consumer;
task body Producer is
Next : Time;
begin
Next := Clock;
for I in 1..N loop
-- Write to X
SemWrite.Wait; --SemPend()
X := I;
-- Next 'Release' in 50..250ms
Next := Next + Milliseconds(Random(G));
SemRead.Signal; --SemPost()
delay until Next;
end loop;
end;
task body Consumer is
begin
for I in 1..N loop
-- Read from X
SemRead.Wait; --SemPend()
Put_Line(Integer'Image(X));
SemWrite.Signal; --SemPost()
end loop;
end;
begin -- main task
null;
end ProducerConsumer;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Exceptions;
with Ada.Calendar.Time_Zones;
with Ada.Unchecked_Conversion;
package body AdaBase.Statement.Base.MySQL is
package EX renames Ada.Exceptions;
package CTZ renames Ada.Calendar.Time_Zones;
--------------------
-- discard_rest --
--------------------
overriding
procedure discard_rest (Stmt : out MySQL_statement)
is
use type ABM.MYSQL_RES_Access;
use type ABM.MYSQL_STMT_Access;
begin
case Stmt.type_of_statement is
when direct_statement =>
if Stmt.result_handle /= null then
Stmt.rows_leftover := True;
Stmt.mysql_conn.free_result (Stmt.result_handle);
Stmt.clear_column_information;
end if;
when prepared_statement =>
if Stmt.stmt_handle /= null then
Stmt.rows_leftover := True;
Stmt.mysql_conn.prep_free_result (Stmt.stmt_handle);
end if;
end case;
Stmt.delivery := completed;
end discard_rest;
--------------------
-- column_count --
--------------------
overriding
function column_count (Stmt : MySQL_statement) return Natural is
begin
return Stmt.num_columns;
end column_count;
---------------------------
-- last_driver_message --
---------------------------
overriding
function last_driver_message (Stmt : MySQL_statement) return String is
begin
case Stmt.type_of_statement is
when direct_statement =>
return Stmt.mysql_conn.driverMessage;
when prepared_statement =>
return Stmt.mysql_conn.prep_DriverMessage
(Stmt.stmt_handle);
end case;
end last_driver_message;
----------------------
-- last_insert_id --
----------------------
overriding
function last_insert_id (Stmt : MySQL_statement) return Trax_ID is
begin
case Stmt.type_of_statement is
when direct_statement =>
return Stmt.mysql_conn.lastInsertID;
when prepared_statement =>
return Stmt.mysql_conn.prep_LastInsertID
(Stmt.stmt_handle);
end case;
end last_insert_id;
----------------------
-- last_sql_state --
----------------------
overriding
function last_sql_state (Stmt : MySQL_statement) return SQL_State is
begin
case Stmt.type_of_statement is
when direct_statement =>
return Stmt.mysql_conn.SqlState;
when prepared_statement =>
return Stmt.mysql_conn.prep_SqlState
(Stmt.stmt_handle);
end case;
end last_sql_state;
------------------------
-- last_driver_code --
------------------------
overriding
function last_driver_code (Stmt : MySQL_statement) return Driver_Codes is
begin
case Stmt.type_of_statement is
when direct_statement =>
return Stmt.mysql_conn.driverCode;
when prepared_statement =>
return Stmt.mysql_conn.prep_DriverCode
(Stmt.stmt_handle);
end case;
end last_driver_code;
----------------------------
-- execute (version 1) --
----------------------------
overriding
function execute (Stmt : out MySQL_statement) return Boolean
is
num_markers : constant Natural := Natural (Stmt.realmccoy.Length);
status_successful : Boolean := True;
begin
if Stmt.type_of_statement = direct_statement then
raise INVALID_FOR_DIRECT_QUERY
with "The execute command is for prepared statements only";
end if;
Stmt.successful_execution := False;
Stmt.rows_leftover := False;
if num_markers > 0 then
-- Check to make sure all prepared markers are bound
for sx in Natural range 1 .. num_markers loop
if not Stmt.realmccoy.Element (sx).bound then
raise STMT_PREPARATION
with "Prep Stmt column" & sx'Img & " unbound";
end if;
end loop;
declare
slots : ABM.MYSQL_BIND_Array (1 .. num_markers);
vault : mysql_canvases (1 .. num_markers);
begin
for sx in slots'Range loop
Stmt.construct_bind_slot (struct => slots (sx),
canvas => vault (sx),
marker => sx);
end loop;
if not Stmt.mysql_conn.prep_bind_parameters
(Stmt.stmt_handle, slots)
then
Stmt.log_problem (category => statement_preparation,
message => "failed to bind parameters",
pull_codes => True);
status_successful := False;
end if;
if status_successful then
Stmt.log_nominal (category => statement_execution,
message => "Exec with" & num_markers'Img &
" bound parameters");
if Stmt.mysql_conn.prep_execute (Stmt.stmt_handle) then
Stmt.successful_execution := True;
else
Stmt.log_problem (category => statement_execution,
message => "failed to exec prep stmt",
pull_codes => True);
status_successful := False;
end if;
end if;
-- Recover dynamically allocated data
for sx in slots'Range loop
free_binary (vault (sx).buffer_binary);
end loop;
end;
else
-- No binding required, just execute the prepared statement
Stmt.log_nominal (category => statement_execution,
message => "Exec without bound parameters");
if Stmt.mysql_conn.prep_execute (Stmt.stmt_handle) then
Stmt.successful_execution := True;
else
Stmt.log_problem (category => statement_execution,
message => "failed to exec prep stmt",
pull_codes => True);
status_successful := False;
end if;
end if;
Stmt.internal_post_prep_stmt;
return status_successful;
end execute;
----------------------------
-- execute (version 2) --
----------------------------
overriding
function execute (Stmt : out MySQL_statement; parameters : String;
delimiter : Character := '|') return Boolean
is
function parameters_given return Natural;
num_markers : constant Natural := Natural (Stmt.realmccoy.Length);
function parameters_given return Natural
is
result : Natural := 1;
begin
for x in parameters'Range loop
if parameters (x) = delimiter then
result := result + 1;
end if;
end loop;
return result;
end parameters_given;
begin
if Stmt.type_of_statement = direct_statement then
raise INVALID_FOR_DIRECT_QUERY
with "The execute command is for prepared statements only";
end if;
if num_markers /= parameters_given then
raise STMT_PREPARATION
with "Parameter number mismatch, " & num_markers'Img &
" expected, but" & parameters_given'Img & " provided.";
end if;
declare
index : Natural := 1;
arrow : Natural := parameters'First;
scans : Boolean := False;
start : Natural := 1;
stop : Natural := 0;
begin
for x in parameters'Range loop
if parameters (x) = delimiter then
if not scans then
Stmt.auto_assign (index, "");
else
Stmt.auto_assign (index, parameters (start .. stop));
scans := False;
end if;
index := index + 1;
else
stop := x;
if not scans then
start := x;
scans := True;
end if;
end if;
end loop;
if not scans then
Stmt.auto_assign (index, "");
else
Stmt.auto_assign (index, parameters (start .. stop));
end if;
end;
return Stmt.execute;
end execute;
------------------
-- initialize --
------------------
overriding
procedure initialize (Object : in out MySQL_statement)
is
use type ACM.MySQL_Connection_Access;
begin
if Object.mysql_conn = null then
return;
end if;
logger_access := Object.log_handler;
Object.dialect := driver_mysql;
Object.connection := ACB.Base_Connection_Access (Object.mysql_conn);
case Object.type_of_statement is
when direct_statement =>
Object.sql_final := new String'(CT.trim_sql
(Object.initial_sql.all));
Object.internal_direct_post_exec;
when prepared_statement =>
declare
use type ABM.MYSQL_RES_Access;
begin
Object.sql_final := new String'(Object.transform_sql
(Object.initial_sql.all));
Object.mysql_conn.initialize_and_prepare_statement
(stmt => Object.stmt_handle, sql => Object.sql_final.all);
declare
params : Natural := Object.mysql_conn.prep_markers_found
(stmt => Object.stmt_handle);
errmsg : String := "marker mismatch," &
Object.realmccoy.Length'Img & " expected but" &
params'Img & " found by MySQL";
begin
if params /= Natural (Object.realmccoy.Length) then
raise ILLEGAL_BIND_SQL with errmsg;
end if;
Object.log_nominal (category => statement_preparation,
message => Object.sql_final.all);
end;
Object.result_handle := Object.mysql_conn.prep_result_metadata
(Object.stmt_handle);
-- Direct statements always produce result sets, but prepared
-- statements very well may not. The next procedure ends early
-- after clearing column data if there is results.
Object.scan_column_information;
if Object.result_handle /= null then
Object.mysql_conn.free_result (Object.result_handle);
end if;
exception
when HELL : others =>
Object.log_problem (category => statement_preparation,
message => EX.Exception_Message (HELL));
raise;
end;
end case;
end initialize;
--------------
-- Adjust --
--------------
overriding
procedure Adjust (Object : in out MySQL_statement) is
begin
-- The stmt object goes through this evolution:
-- A) created in private_prepare()
-- B) copied to new object in prepare(), A) destroyed
-- C) copied to new object in program, B) destroyed
-- We don't want to take any action until C) is destroyed, so add a
-- reference counter upon each assignment. When finalize sees a
-- value of "2", it knows it is the program-level statement and then
-- it can release memory releases, but not before!
Object.assign_counter := Object.assign_counter + 1;
-- Since the finalization is looking for a specific reference
-- counter, any further assignments would fail finalization, so
-- just prohibit them outright.
if Object.assign_counter > 2 then
raise STMT_PREPARATION
with "Statement objects cannot be re-assigned.";
end if;
end Adjust;
----------------
-- finalize --
----------------
overriding
procedure finalize (Object : in out MySQL_statement) is
begin
if Object.assign_counter /= 2 then
return;
end if;
if Object.type_of_statement = prepared_statement then
if not Object.mysql_conn.prep_close_statement (Object.stmt_handle)
then
Object.log_problem (category => statement_preparation,
message => "Deallocating statement memory",
pull_codes => True);
end if;
end if;
free_sql (Object.sql_final);
Object.reclaim_canvas;
end finalize;
---------------------
-- direct_result --
---------------------
procedure process_direct_result (Stmt : out MySQL_statement)
is
use type ABM.MYSQL_RES_Access;
begin
case Stmt.con_buffered is
when True => Stmt.mysql_conn.store_result
(result_handle => Stmt.result_handle);
when False => Stmt.mysql_conn.use_result
(result_handle => Stmt.result_handle);
end case;
Stmt.result_present := (Stmt.result_handle /= null);
end process_direct_result;
---------------------
-- rows_returned --
---------------------
overriding
function rows_returned (Stmt : MySQL_statement) return Affected_Rows is
begin
if not Stmt.successful_execution then
raise PRIOR_EXECUTION_FAILED
with "Has query been executed yet?";
end if;
if Stmt.result_present then
if Stmt.con_buffered then
return Stmt.size_of_rowset;
else
raise INVALID_FOR_RESULT_SET
with "Row set size is not known (Use query buffers to fix)";
end if;
else
raise INVALID_FOR_RESULT_SET
with "Result set not found; use rows_affected";
end if;
end rows_returned;
----------------------
-- reclaim_canvas --
----------------------
procedure reclaim_canvas (Stmt : out MySQL_statement)
is
use type ABM.ICS.char_array_access;
begin
if Stmt.bind_canvas /= null then
for sx in Stmt.bind_canvas.all'Range loop
if Stmt.bind_canvas (sx).buffer_binary /= null then
free_binary (Stmt.bind_canvas (sx).buffer_binary);
end if;
end loop;
free_canvas (Stmt.bind_canvas);
end if;
end reclaim_canvas;
--------------------------------
-- clear_column_information --
--------------------------------
procedure clear_column_information (Stmt : out MySQL_statement) is
begin
Stmt.num_columns := 0;
Stmt.column_info.Clear;
Stmt.crate.Clear;
Stmt.headings_map.Clear;
Stmt.reclaim_canvas;
end clear_column_information;
-------------------------------
-- scan_column_information --
-------------------------------
procedure scan_column_information (Stmt : out MySQL_statement)
is
use type ABM.MYSQL_FIELD_Access;
use type ABM.MYSQL_RES_Access;
field : ABM.MYSQL_FIELD_Access;
function fn (raw : String) return CT.Text;
function sn (raw : String) return String;
function fn (raw : String) return CT.Text is
begin
case Stmt.con_case_mode is
when upper_case =>
return CT.SUS (ACH.To_Upper (raw));
when lower_case =>
return CT.SUS (ACH.To_Lower (raw));
when natural_case =>
return CT.SUS (raw);
end case;
end fn;
function sn (raw : String) return String is
begin
case Stmt.con_case_mode is
when upper_case =>
return ACH.To_Upper (raw);
when lower_case =>
return ACH.To_Lower (raw);
when natural_case =>
return raw;
end case;
end sn;
begin
Stmt.clear_column_information;
if Stmt.result_handle = null then
return;
end if;
Stmt.num_columns := Stmt.mysql_conn.fields_in_result
(Stmt.result_handle);
loop
field := Stmt.mysql_conn.fetch_field
(result_handle => Stmt.result_handle);
exit when field = null;
declare
info : column_info;
brec : bindrec;
begin
brec.v00 := False; -- placeholder
info.field_name := fn (Stmt.mysql_conn.field_name_field (field));
info.table := fn (Stmt.mysql_conn.field_name_table (field));
info.mysql_type := field.field_type;
info.null_possible := Stmt.mysql_conn.field_allows_null (field);
Stmt.mysql_conn.field_data_type (field => field,
std_type => info.field_type,
size => info.field_size);
if info.field_size > Stmt.con_max_blob then
info.field_size := Stmt.con_max_blob;
end if;
Stmt.column_info.Append (New_Item => info);
-- The following pre-populates for bind support
Stmt.crate.Append (New_Item => brec);
Stmt.headings_map.Insert
(Key => sn (Stmt.mysql_conn.field_name_field (field)),
New_Item => Stmt.crate.Last_Index);
end;
end loop;
end scan_column_information;
-------------------
-- column_name --
-------------------
overriding
function column_name (Stmt : MySQL_statement; index : Positive)
return String
is
maxlen : constant Natural := Natural (Stmt.column_info.Length);
begin
if index > maxlen then
raise INVALID_COLUMN_INDEX with "Max index is" & maxlen'Img &
" but" & index'Img & " attempted";
end if;
return CT.USS (Stmt.column_info.Element (Index => index).field_name);
end column_name;
--------------------
-- column_table --
--------------------
overriding
function column_table (Stmt : MySQL_statement; index : Positive)
return String
is
maxlen : constant Natural := Natural (Stmt.column_info.Length);
begin
if index > maxlen then
raise INVALID_COLUMN_INDEX with "Max index is" & maxlen'Img &
" but" & index'Img & " attempted";
end if;
return CT.USS (Stmt.column_info.Element (Index => index).table);
end column_table;
--------------------------
-- column_native_type --
--------------------------
overriding
function column_native_type (Stmt : MySQL_statement; index : Positive)
return field_types
is
maxlen : constant Natural := Natural (Stmt.column_info.Length);
begin
if index > maxlen then
raise INVALID_COLUMN_INDEX with "Max index is" & maxlen'Img &
" but" & index'Img & " attempted";
end if;
return Stmt.column_info.Element (Index => index).field_type;
end column_native_type;
------------------
-- fetch_next --
------------------
overriding
function fetch_next (Stmt : out MySQL_statement) return ARS.Datarow is
begin
if Stmt.delivery = completed then
return ARS.Empty_Datarow;
end if;
case Stmt.type_of_statement is
when prepared_statement =>
return Stmt.internal_ps_fetch_row;
when direct_statement =>
return Stmt.internal_fetch_row;
end case;
end fetch_next;
-------------------
-- fetch_bound --
-------------------
overriding
function fetch_bound (Stmt : out MySQL_statement) return Boolean is
begin
if Stmt.delivery = completed then
return False;
end if;
case Stmt.type_of_statement is
when prepared_statement =>
return Stmt.internal_ps_fetch_bound;
when direct_statement =>
return Stmt.internal_fetch_bound;
end case;
end fetch_bound;
-----------------
-- fetch_all --
-----------------
overriding
function fetch_all (Stmt : out MySQL_statement) return ARS.Datarow_Set
is
maxrows : Natural := Natural (Stmt.rows_returned);
tmpset : ARS.Datarow_Set (1 .. maxrows + 1);
nullset : ARS.Datarow_Set (1 .. 0);
index : Natural := 1;
row : ARS.Datarow;
begin
if (Stmt.delivery = completed) or else (maxrows = 0) then
return nullset;
end if;
-- It is possible that one or more rows was individually fetched
-- before the entire set was fetched. Let's consider this legal so
-- use a repeat loop to check each row and return a partial set
-- if necessary.
loop
tmpset (index) := Stmt.fetch_next;
exit when tmpset (index).data_exhausted;
index := index + 1;
exit when index > maxrows + 1; -- should never happen
end loop;
if index = 1 then
return nullset; -- nothing was fetched
end if;
return tmpset (1 .. index - 1);
end fetch_all;
----------------------
-- fetch_next_set --
----------------------
overriding
procedure fetch_next_set (Stmt : out MySQL_statement;
data_present : out Boolean;
data_fetched : out Boolean)
is
use type ABM.MYSQL_RES_Access;
begin
data_fetched := False;
if Stmt.result_handle /= null then
Stmt.mysql_conn.free_result (Stmt.result_handle);
end if;
data_present := Stmt.mysql_conn.fetch_next_set;
if not data_present then
return;
end if;
declare
begin
Stmt.process_direct_result;
exception
when others =>
Stmt.log_nominal (category => statement_execution,
message => "Result set missing from: "
& Stmt.sql_final.all);
return;
end;
Stmt.internal_direct_post_exec (newset => True);
data_fetched := True;
end fetch_next_set;
--------------------------
-- internal_fetch_row --
--------------------------
function internal_fetch_row (Stmt : out MySQL_statement)
return ARS.Datarow
is
use type ABM.ICS.chars_ptr;
use type ABM.MYSQL_ROW_access;
rptr : ABM.MYSQL_ROW_access :=
Stmt.mysql_conn.fetch_row (Stmt.result_handle);
begin
if rptr = null then
Stmt.delivery := completed;
Stmt.mysql_conn.free_result (Stmt.result_handle);
Stmt.clear_column_information;
return ARS.Empty_Datarow;
end if;
Stmt.delivery := progressing;
declare
maxlen : constant Natural := Natural (Stmt.column_info.Length);
bufmax : constant ABM.IC.size_t := ABM.IC.size_t (Stmt.con_max_blob);
subtype data_buffer is ABM.IC.char_array (1 .. bufmax);
type db_access is access all data_buffer;
type rowtype is array (1 .. maxlen) of db_access;
type rowtype_access is access all rowtype;
row : rowtype_access;
result : ARS.Datarow;
field_lengths : constant ACM.fldlen := Stmt.mysql_conn.fetch_lengths
(result_handle => Stmt.result_handle,
num_columns => maxlen);
function convert is new Ada.Unchecked_Conversion
(Source => ABM.MYSQL_ROW_access, Target => rowtype_access);
function db_convert (dba : db_access; size : Natural) return String;
function db_convert (dba : db_access; size : Natural) return String
is
max : Natural := size;
begin
if max > Stmt.con_max_blob then
max := Stmt.con_max_blob;
end if;
declare
result : String (1 .. max);
begin
for x in result'Range loop
result (x) := Character (dba.all (ABM.IC.size_t (x)));
end loop;
return result;
end;
end db_convert;
begin
row := convert (rptr);
for F in 1 .. maxlen loop
declare
colinfo : column_info renames Stmt.column_info.Element (F);
field : ARF.Std_Field;
last_one : constant Boolean := (F = maxlen);
heading : constant String := CT.USS (colinfo.field_name);
isnull : constant Boolean := (row (F) = null);
sz : constant Natural := field_lengths (F);
ST : constant String := db_convert (row (F), sz);
dvariant : ARF.Variant;
begin
if isnull then
field := ARF.spawn_null_field (colinfo.field_type);
else
case colinfo.field_type is
when ft_nbyte0 =>
dvariant := (datatype => ft_nbyte0, v00 => ST = "1");
when ft_nbyte1 =>
dvariant := (datatype => ft_nbyte1, v01 => convert (ST));
when ft_nbyte2 =>
dvariant := (datatype => ft_nbyte2, v02 => convert (ST));
when ft_nbyte3 =>
dvariant := (datatype => ft_nbyte3, v03 => convert (ST));
when ft_nbyte4 =>
dvariant := (datatype => ft_nbyte4, v04 => convert (ST));
when ft_nbyte8 =>
dvariant := (datatype => ft_nbyte8, v05 => convert (ST));
when ft_byte1 =>
dvariant := (datatype => ft_byte1, v06 => convert (ST));
when ft_byte2 =>
dvariant := (datatype => ft_byte2, v07 => convert (ST));
when ft_byte3 =>
dvariant := (datatype => ft_byte3, v08 => convert (ST));
when ft_byte4 =>
dvariant := (datatype => ft_byte4, v09 => convert (ST));
when ft_byte8 =>
dvariant := (datatype => ft_byte8, v10 => convert (ST));
when ft_real9 =>
dvariant := (datatype => ft_real9, v11 => convert (ST));
when ft_real18 =>
dvariant := (datatype => ft_real18, v12 => convert (ST));
when ft_textual =>
dvariant := (datatype => ft_textual, v13 => CT.SUS (ST));
when ft_widetext =>
dvariant := (datatype => ft_widetext,
v14 => convert (ST));
when ft_supertext =>
dvariant := (datatype => ft_supertext,
v15 => convert (ST));
when ft_utf8 =>
dvariant := (datatype => ft_utf8, v21 => CT.SUS (ST));
when ft_geometry =>
-- MySQL internal geometry format is SRID + WKB
-- Remove the first 4 bytes and save only the WKB
dvariant :=
(datatype => ft_geometry,
v22 => CT.SUS (ST (ST'First + 4 .. ST'Last)));
when ft_timestamp =>
begin
dvariant := (datatype => ft_timestamp,
v16 => ARC.convert (ST));
exception
when AR.CONVERSION_FAILED =>
dvariant := (datatype => ft_textual,
v13 => CT.SUS (ST));
end;
when ft_enumtype =>
dvariant := (datatype => ft_enumtype,
v18 => ARC.convert (CT.SUS (ST)));
when ft_chain => null;
when ft_settype => null;
when ft_bits => null;
end case;
case colinfo.field_type is
when ft_chain =>
field := ARF.spawn_field (binob => ARC.convert (ST));
when ft_bits =>
field := ARF.spawn_bits_field
(convert_to_bitstring (ST, colinfo.field_size * 8));
when ft_settype =>
field := ARF.spawn_field (enumset => ST);
when others =>
field := ARF.spawn_field (data => dvariant,
null_data => isnull);
end case;
end if;
result.push (heading => heading,
field => field,
last_field => last_one);
end;
end loop;
return result;
end;
end internal_fetch_row;
------------------
-- bincopy #1 --
------------------
function bincopy (data : ABM.ICS.char_array_access;
datalen, max_size : Natural) return String
is
reslen : Natural := datalen;
begin
if reslen > max_size then
reslen := max_size;
end if;
declare
result : String (1 .. reslen) := (others => '_');
begin
for x in result'Range loop
result (x) := Character (data.all (ABM.IC.size_t (x)));
end loop;
return result;
end;
end bincopy;
------------------
-- bincopy #2 --
------------------
function bincopy (data : ABM.ICS.char_array_access;
datalen, max_size : Natural;
hard_limit : Natural := 0) return AR.Chain
is
reslen : Natural := datalen;
chainlen : Natural := data.all'Length;
begin
if reslen > max_size then
reslen := max_size;
end if;
if hard_limit > 0 then
chainlen := hard_limit;
else
chainlen := reslen;
end if;
declare
result : AR.Chain (1 .. chainlen) := (others => 0);
jimmy : Character;
begin
for x in Natural range 1 .. reslen loop
jimmy := Character (data.all (ABM.IC.size_t (x)));
result (x) := AR.NByte1 (Character'Pos (jimmy));
end loop;
return result;
end;
end bincopy;
-----------------------------
-- internal_ps_fetch_row --
-----------------------------
function internal_ps_fetch_row (Stmt : out MySQL_statement)
return ARS.Datarow
is
use type ABM.ICS.chars_ptr;
use type ABM.MYSQL_ROW_access;
use type ACM.fetch_status;
status : ACM.fetch_status;
begin
status := Stmt.mysql_conn.prep_fetch_bound (Stmt.stmt_handle);
if status = ACM.spent then
Stmt.delivery := completed;
Stmt.clear_column_information;
elsif status = ACM.truncated then
Stmt.log_nominal (category => statement_execution,
message => "data truncated");
Stmt.delivery := progressing;
elsif status = ACM.error then
Stmt.log_problem (category => statement_execution,
message => "prep statement fetch error",
pull_codes => True);
Stmt.delivery := completed;
else
Stmt.delivery := progressing;
end if;
if Stmt.delivery = completed then
return ARS.Empty_Datarow;
end if;
declare
maxlen : constant Natural := Stmt.num_columns;
result : ARS.Datarow;
begin
for F in 1 .. maxlen loop
declare
use type ABM.enum_field_types;
function binary_string return String;
cv : mysql_canvas renames Stmt.bind_canvas (F);
colinfo : column_info renames Stmt.column_info.Element (F);
dvariant : ARF.Variant;
field : ARF.Std_Field;
last_one : constant Boolean := (F = maxlen);
datalen : constant Natural := Natural (cv.length);
heading : constant String := CT.USS (colinfo.field_name);
isnull : constant Boolean := (Natural (cv.is_null) = 1);
mtype : ABM.enum_field_types := colinfo.mysql_type;
function binary_string return String is
begin
return bincopy (data => cv.buffer_binary,
datalen => datalen,
max_size => Stmt.con_max_blob);
end binary_string;
begin
if isnull then
field := ARF.spawn_null_field (colinfo.field_type);
else
case colinfo.field_type is
when ft_nbyte0 =>
dvariant := (datatype => ft_nbyte0,
v00 => Natural (cv.buffer_uint8) = 1);
when ft_nbyte1 =>
dvariant := (datatype => ft_nbyte1,
v01 => AR.NByte1 (cv.buffer_uint8));
when ft_nbyte2 =>
dvariant := (datatype => ft_nbyte2,
v02 => AR.NByte2 (cv.buffer_uint16));
when ft_nbyte3 =>
dvariant := (datatype => ft_nbyte3,
v03 => AR.NByte3 (cv.buffer_uint32));
when ft_nbyte4 =>
dvariant := (datatype => ft_nbyte4,
v04 => AR.NByte4 (cv.buffer_uint32));
when ft_nbyte8 =>
dvariant := (datatype => ft_nbyte8,
v05 => AR.NByte8 (cv.buffer_uint64));
when ft_byte1 =>
dvariant := (datatype => ft_byte1,
v06 => AR.Byte1 (cv.buffer_int8));
when ft_byte2 =>
dvariant := (datatype => ft_byte2,
v07 => AR.Byte2 (cv.buffer_int16));
when ft_byte3 =>
dvariant := (datatype => ft_byte3,
v08 => AR.Byte3 (cv.buffer_int32));
when ft_byte4 =>
dvariant := (datatype => ft_byte4,
v09 => AR.Byte4 (cv.buffer_int32));
when ft_byte8 =>
dvariant := (datatype => ft_byte8,
v10 => AR.Byte8 (cv.buffer_int64));
when ft_real9 =>
if mtype = ABM.MYSQL_TYPE_NEWDECIMAL or else
mtype = ABM.MYSQL_TYPE_DECIMAL
then
dvariant := (datatype => ft_real9,
v11 => convert (binary_string));
else
dvariant := (datatype => ft_real9,
v11 => AR.Real9 (cv.buffer_float));
end if;
when ft_real18 =>
if mtype = ABM.MYSQL_TYPE_NEWDECIMAL or else
mtype = ABM.MYSQL_TYPE_DECIMAL
then
dvariant := (datatype => ft_real18,
v12 => convert (binary_string));
else
dvariant := (datatype => ft_real18,
v12 => AR.Real18 (cv.buffer_double));
end if;
when ft_textual =>
dvariant := (datatype => ft_textual,
v13 => CT.SUS (binary_string));
when ft_widetext =>
dvariant := (datatype => ft_widetext,
v14 => convert (binary_string));
when ft_supertext =>
dvariant := (datatype => ft_supertext,
v15 => convert (binary_string));
when ft_utf8 =>
dvariant := (datatype => ft_utf8,
v21 => CT.SUS (binary_string));
when ft_geometry =>
-- MySQL internal geometry format is SRID + WKB
-- Remove the first 4 bytes and save only the WKB
declare
ST : String := binary_string;
wkbstring : String := ST (ST'First + 4 .. ST'Last);
begin
dvariant := (datatype => ft_geometry,
v22 => CT.SUS (wkbstring));
end;
when ft_timestamp =>
declare
year : Natural := Natural (cv.buffer_time.year);
month : Natural := Natural (cv.buffer_time.month);
day : Natural := Natural (cv.buffer_time.day);
begin
if year < CAL.Year_Number'First or else
year > CAL.Year_Number'Last
then
year := CAL.Year_Number'First;
end if;
if month < CAL.Month_Number'First or else
month > CAL.Month_Number'Last
then
month := CAL.Month_Number'First;
end if;
if day < CAL.Day_Number'First or else
day > CAL.Day_Number'Last
then
day := CAL.Day_Number'First;
end if;
dvariant :=
(datatype => ft_timestamp,
v16 => CFM.Time_Of
(Year => year,
Month => month,
Day => day,
Hour => Natural (cv.buffer_time.hour),
Minute => Natural (cv.buffer_time.minute),
Second => Natural (cv.buffer_time.second),
Sub_Second => CFM.Second_Duration (Natural
(cv.buffer_time.second_part) / 1000000))
);
end;
when ft_enumtype =>
dvariant := (datatype => ft_enumtype,
v18 => ARC.convert (binary_string));
when ft_settype => null;
when ft_chain => null;
when ft_bits => null;
end case;
case colinfo.field_type is
when ft_chain =>
field := ARF.spawn_field
(binob => bincopy (cv.buffer_binary, datalen,
Stmt.con_max_blob));
when ft_bits =>
field := ARF.spawn_bits_field
(convert_to_bitstring
(binary_string, datalen * 8));
when ft_settype =>
field := ARF.spawn_field
(enumset => binary_string);
when others =>
field := ARF.spawn_field
(data => dvariant, null_data => isnull);
end case;
end if;
result.push (heading => heading,
field => field,
last_field => last_one);
end;
end loop;
return result;
end;
end internal_ps_fetch_row;
-------------------------------
-- internal_ps_fetch_bound --
-------------------------------
function internal_ps_fetch_bound (Stmt : out MySQL_statement)
return Boolean
is
use type ABM.ICS.chars_ptr;
use type ACM.fetch_status;
status : ACM.fetch_status;
begin
status := Stmt.mysql_conn.prep_fetch_bound (Stmt.stmt_handle);
if status = ACM.spent then
Stmt.delivery := completed;
Stmt.clear_column_information;
elsif status = ACM.truncated then
Stmt.log_nominal (category => statement_execution,
message => "data truncated");
Stmt.delivery := progressing;
elsif status = ACM.error then
Stmt.log_problem (category => statement_execution,
message => "prep statement fetch error",
pull_codes => True);
Stmt.delivery := completed;
else
Stmt.delivery := progressing;
end if;
if Stmt.delivery = completed then
return False;
end if;
declare
maxlen : constant Natural := Stmt.num_columns;
begin
for F in 1 .. maxlen loop
if not Stmt.crate.Element (Index => F).bound then
goto continue;
end if;
declare
use type ABM.enum_field_types;
function binary_string return String;
cv : mysql_canvas renames Stmt.bind_canvas (F);
colinfo : column_info renames Stmt.column_info.Element (F);
param : bindrec renames Stmt.crate.Element (F);
datalen : constant Natural := Natural (cv.length);
Tout : constant field_types := param.output_type;
Tnative : constant field_types := colinfo.field_type;
mtype : ABM.enum_field_types := colinfo.mysql_type;
errmsg : constant String := "native type : " &
field_types'Image (Tnative) & " binding type : " &
field_types'Image (Tout);
function binary_string return String is
begin
return bincopy (data => cv.buffer_binary,
datalen => datalen,
max_size => Stmt.con_max_blob);
end binary_string;
begin
-- Derivation of implementation taken from PostgreSQL
-- Only guaranteed successful converstions allowed though
case Tout is
when ft_nbyte2 =>
case Tnative is
when ft_nbyte1 | ft_nbyte2 =>
null;
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when ft_nbyte3 =>
case Tnative is
when ft_nbyte1 | ft_nbyte2 | ft_nbyte3 =>
null;
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when ft_nbyte4 =>
case Tnative is
when ft_nbyte1 | ft_nbyte2 | ft_nbyte3 | ft_nbyte4 =>
null;
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when ft_nbyte8 =>
case Tnative is
when ft_nbyte1 | ft_nbyte2 | ft_nbyte3 | ft_nbyte4 |
ft_nbyte8 =>
null;
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when ft_byte2 =>
case Tnative is
when ft_byte1 | ft_byte2 =>
null;
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when ft_byte3 =>
case Tnative is
when ft_byte1 | ft_byte2 | ft_byte3 =>
null;
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when ft_byte4 =>
case Tnative is
when ft_byte1 | ft_byte2 | ft_byte3 | ft_byte4 =>
null;
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when ft_byte8 =>
case Tnative is
when ft_byte1 | ft_byte2 | ft_byte3 | ft_byte4 |
ft_byte8 =>
null;
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when ft_real18 =>
case Tnative is
when ft_real9 | ft_real18 =>
null; -- guaranteed to convert without loss
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when ft_textual =>
case Tnative is
when ft_textual | ft_utf8 =>
null;
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when others =>
if Tnative /= Tout then
raise BINDING_TYPE_MISMATCH with errmsg;
end if;
end case;
case Tout is
when ft_nbyte0 => param.a00.all := (Natural (cv.buffer_uint8) = 1);
when ft_nbyte1 => param.a01.all := AR.NByte1 (cv.buffer_uint8);
when ft_nbyte2 => param.a02.all := AR.NByte2 (cv.buffer_uint16);
when ft_nbyte3 => param.a03.all := AR.NByte3 (cv.buffer_uint32);
when ft_nbyte4 => param.a04.all := AR.NByte4 (cv.buffer_uint32);
when ft_nbyte8 => param.a05.all := AR.NByte8 (cv.buffer_uint64);
when ft_byte1 => param.a06.all := AR.Byte1 (cv.buffer_int8);
when ft_byte2 => param.a07.all := AR.Byte2 (cv.buffer_int16);
when ft_byte3 => param.a08.all := AR.Byte3 (cv.buffer_int32);
when ft_byte4 => param.a09.all := AR.Byte4 (cv.buffer_int32);
when ft_byte8 => param.a10.all := AR.Byte8 (cv.buffer_int64);
when ft_real9 =>
if mtype = ABM.MYSQL_TYPE_NEWDECIMAL or else
mtype = ABM.MYSQL_TYPE_DECIMAL
then
param.a11.all := convert (binary_string);
else
param.a11.all := AR.Real9 (cv.buffer_float);
end if;
when ft_real18 =>
if mtype = ABM.MYSQL_TYPE_NEWDECIMAL or else
mtype = ABM.MYSQL_TYPE_DECIMAL
then
param.a12.all := convert (binary_string);
else
param.a12.all := AR.Real18 (cv.buffer_double);
end if;
when ft_textual => param.a13.all := CT.SUS (binary_string);
when ft_widetext => param.a14.all := convert (binary_string);
when ft_supertext => param.a15.all :=
convert (binary_string);
when ft_utf8 => param.a21.all := binary_string;
when ft_geometry =>
-- MySQL internal geometry format is SRID + WKB
-- Remove the first 4 bytes and translate WKB
declare
ST : String := binary_string;
wkbstring : String := ST (ST'First + 4 .. ST'Last);
begin
param.a22.all := WKB.Translate_WKB (wkbstring);
end;
when ft_timestamp =>
declare
year : Natural := Natural (cv.buffer_time.year);
month : Natural := Natural (cv.buffer_time.month);
day : Natural := Natural (cv.buffer_time.day);
begin
if year < CAL.Year_Number'First or else
year > CAL.Year_Number'Last
then
year := CAL.Year_Number'First;
end if;
if month < CAL.Month_Number'First or else
month > CAL.Month_Number'Last
then
month := CAL.Month_Number'First;
end if;
if day < CAL.Day_Number'First or else
day > CAL.Day_Number'Last
then
day := CAL.Day_Number'First;
end if;
param.a16.all := CFM.Time_Of
(Year => year,
Month => month,
Day => day,
Hour => Natural (cv.buffer_time.hour),
Minute => Natural (cv.buffer_time.minute),
Second => Natural (cv.buffer_time.second),
Sub_Second => CFM.Second_Duration (Natural
(cv.buffer_time.second_part) / 1000000));
end;
when ft_chain =>
if param.a17.all'Length < datalen then
raise BINDING_SIZE_MISMATCH with "native size : " &
param.a17.all'Length'Img &
" less than binding size : " & datalen'Img;
end if;
param.a17.all := bincopy
(cv.buffer_binary, datalen, Stmt.con_max_blob,
param.a17.all'Length);
when ft_bits =>
declare
strval : String := bincopy (cv.buffer_binary, datalen,
Stmt.con_max_blob);
FL : Natural := param.a20.all'Length;
DVLEN : Natural := strval'Length * 8;
begin
if FL < DVLEN then
raise BINDING_SIZE_MISMATCH with "native size : " &
FL'Img & " less than binding size : " & DVLEN'Img;
end if;
param.a20.all :=
ARC.convert (convert_to_bitstring (strval, FL));
end;
when ft_enumtype =>
param.a18.all :=
ARC.convert (CT.SUS (binary_string));
when ft_settype =>
declare
setstr : constant String := binary_string;
num_items : constant Natural := num_set_items (setstr);
begin
if param.a19.all'Length < num_items
then
raise BINDING_SIZE_MISMATCH with "native size : " &
param.a19.all'Length'Img &
" less than binding size : " & num_items'Img;
end if;
param.a19.all := ARC.convert (setstr,
param.a19.all'Length);
end;
end case;
end;
<<continue>>
null;
end loop;
return True;
end;
end internal_ps_fetch_bound;
-----------------------------------
-- internal_fetch_bound_direct --
-----------------------------------
function internal_fetch_bound (Stmt : out MySQL_statement) return Boolean
is
use type ABM.ICS.chars_ptr;
use type ABM.MYSQL_ROW_access;
rptr : ABM.MYSQL_ROW_access :=
Stmt.mysql_conn.fetch_row (Stmt.result_handle);
begin
if rptr = null then
Stmt.delivery := completed;
Stmt.mysql_conn.free_result (Stmt.result_handle);
Stmt.clear_column_information;
return False;
end if;
Stmt.delivery := progressing;
declare
maxlen : constant Natural := Natural (Stmt.column_info.Length);
bufmax : constant ABM.IC.size_t := ABM.IC.size_t (Stmt.con_max_blob);
subtype data_buffer is ABM.IC.char_array (1 .. bufmax);
type db_access is access all data_buffer;
type rowtype is array (1 .. maxlen) of db_access;
type rowtype_access is access all rowtype;
row : rowtype_access;
field_lengths : constant ACM.fldlen := Stmt.mysql_conn.fetch_lengths
(result_handle => Stmt.result_handle,
num_columns => maxlen);
function Convert is new Ada.Unchecked_Conversion
(Source => ABM.MYSQL_ROW_access, Target => rowtype_access);
function db_convert (dba : db_access; size : Natural) return String;
function db_convert (dba : db_access; size : Natural) return String
is
max : Natural := size;
begin
if max > Stmt.con_max_blob then
max := Stmt.con_max_blob;
end if;
declare
result : String (1 .. max);
begin
for x in result'Range loop
result (x) := Character (dba.all (ABM.IC.size_t (x)));
end loop;
return result;
end;
end db_convert;
begin
row := Convert (rptr);
for F in 1 .. maxlen loop
declare
use type ABM.enum_field_types;
dossier : bindrec renames Stmt.crate.Element (F);
colinfo : column_info renames Stmt.column_info.Element (F);
mtype : ABM.enum_field_types := colinfo.mysql_type;
isnull : constant Boolean := (row (F) = null);
sz : constant Natural := field_lengths (F);
ST : constant String := db_convert (row (F), sz);
Tout : constant field_types := dossier.output_type;
Tnative : constant field_types := colinfo.field_type;
errmsg : constant String := "native type : " &
field_types'Image (Tnative) & " binding type : " &
field_types'Image (Tout);
begin
if not dossier.bound then
goto continue;
end if;
if isnull or else CT.IsBlank (ST) then
set_as_null (dossier);
goto continue;
end if;
-- Derivation of implementation taken from PostgreSQL
-- Only guaranteed successful converstions allowed though
case Tout is
when ft_nbyte2 =>
case Tnative is
when ft_nbyte1 | ft_nbyte2 =>
null;
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when ft_nbyte3 =>
case Tnative is
when ft_nbyte1 | ft_nbyte2 | ft_nbyte3 =>
null;
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when ft_nbyte4 =>
case Tnative is
when ft_nbyte1 | ft_nbyte2 | ft_nbyte3 | ft_nbyte4 =>
null;
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when ft_nbyte8 =>
case Tnative is
when ft_nbyte1 | ft_nbyte2 | ft_nbyte3 | ft_nbyte4 |
ft_nbyte8 =>
null;
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when ft_byte2 =>
case Tnative is
when ft_byte1 | ft_byte2 =>
null;
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when ft_byte3 =>
case Tnative is
when ft_byte1 | ft_byte2 | ft_byte3 =>
null;
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when ft_byte4 =>
case Tnative is
when ft_byte1 | ft_byte2 | ft_byte3 | ft_byte4 =>
null;
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when ft_byte8 =>
case Tnative is
when ft_byte1 | ft_byte2 | ft_byte3 | ft_byte4 |
ft_byte8 =>
null;
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when ft_real18 =>
case Tnative is
when ft_real9 | ft_real18 =>
null; -- guaranteed to convert without loss
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when ft_textual =>
case Tnative is
when ft_textual | ft_utf8 =>
null;
when others =>
raise BINDING_TYPE_MISMATCH with errmsg;
end case;
when others =>
if Tnative /= Tout then
raise BINDING_TYPE_MISMATCH with errmsg;
end if;
end case;
case Tout is
when ft_nbyte0 => dossier.a00.all := (ST = "1");
when ft_nbyte1 => dossier.a01.all := convert (ST);
when ft_nbyte2 => dossier.a02.all := convert (ST);
when ft_nbyte3 => dossier.a03.all := convert (ST);
when ft_nbyte4 => dossier.a04.all := convert (ST);
when ft_nbyte8 => dossier.a05.all := convert (ST);
when ft_byte1 => dossier.a06.all := convert (ST);
when ft_byte2 => dossier.a07.all := convert (ST);
when ft_byte3 => dossier.a08.all := convert (ST);
when ft_byte4 => dossier.a09.all := convert (ST);
when ft_byte8 => dossier.a10.all := convert (ST);
when ft_real9 => dossier.a11.all := convert (ST);
when ft_real18 => dossier.a12.all := convert (ST);
when ft_widetext => dossier.a14.all := convert (ST);
when ft_supertext => dossier.a15.all := convert (ST);
when ft_enumtype => dossier.a18.all := ARC.convert (ST);
when ft_textual => dossier.a13.all := CT.SUS (ST);
when ft_utf8 => dossier.a21.all := ST;
when ft_geometry =>
-- MySQL internal geometry format is SRID + WKB
-- Remove the first 4 bytes and translate WKB
declare
wkbstring : String := ST (ST'First + 4 .. ST'Last);
begin
dossier.a22.all := WKB.Translate_WKB (wkbstring);
end;
when ft_timestamp =>
begin
dossier.a16.all := ARC.convert (ST);
exception
when AR.CONVERSION_FAILED =>
dossier.a16.all := AR.PARAM_IS_TIMESTAMP;
end;
when ft_chain =>
declare
FL : Natural := dossier.a17.all'Length;
DVLEN : Natural := ST'Length;
begin
if DVLEN > FL then
raise BINDING_SIZE_MISMATCH with "native size : " &
DVLEN'Img & " greater than binding size : " &
FL'Img;
end if;
dossier.a17.all := ARC.convert (ST, FL);
end;
when ft_bits =>
declare
FL : Natural := dossier.a20.all'Length;
DVLEN : Natural := ST'Length * 8;
begin
if DVLEN > FL then
raise BINDING_SIZE_MISMATCH with "native size : " &
DVLEN'Img & " greater than binding size : " &
FL'Img;
end if;
dossier.a20.all :=
ARC.convert (convert_to_bitstring (ST, FL));
end;
when ft_settype =>
declare
FL : Natural := dossier.a19.all'Length;
items : constant Natural := CT.num_set_items (ST);
begin
if items > FL then
raise BINDING_SIZE_MISMATCH with
"native size : " & items'Img &
" greater than binding size : " & FL'Img;
end if;
dossier.a19.all := ARC.convert (ST, FL);
end;
end case;
end;
<<continue>>
end loop;
return True;
end;
end internal_fetch_bound;
----------------------------------
-- internal_direct_post_exec --
----------------------------------
procedure internal_direct_post_exec (Stmt : out MySQL_statement;
newset : Boolean := False) is
begin
Stmt.successful_execution := False;
Stmt.size_of_rowset := 0;
if newset then
Stmt.log_nominal (category => statement_execution,
message => "Fetch next rowset from: "
& Stmt.sql_final.all);
else
Stmt.connection.execute (sql => Stmt.sql_final.all);
Stmt.log_nominal (category => statement_execution,
message => Stmt.sql_final.all);
Stmt.process_direct_result;
end if;
Stmt.successful_execution := True;
if Stmt.result_present then
Stmt.scan_column_information;
if Stmt.con_buffered then
Stmt.size_of_rowset := Stmt.mysql_conn.rows_in_result
(Stmt.result_handle);
end if;
Stmt.delivery := pending;
else
declare
returned_cols : Natural;
begin
returned_cols := Stmt.mysql_conn.field_count;
if returned_cols = 0 then
Stmt.impacted := Stmt.mysql_conn.rows_affected_by_execution;
else
raise ACM.RESULT_FAIL with "Columns returned without result";
end if;
end;
Stmt.delivery := completed;
end if;
exception
when ACM.QUERY_FAIL =>
Stmt.log_problem (category => statement_execution,
message => Stmt.sql_final.all,
pull_codes => True);
when RES : ACM.RESULT_FAIL =>
Stmt.log_problem (category => statement_execution,
message => EX.Exception_Message (X => RES),
pull_codes => True);
end internal_direct_post_exec;
-------------------------------
-- internal_post_prep_stmt --
-------------------------------
procedure internal_post_prep_stmt (Stmt : out MySQL_statement)
is
use type mysql_canvases_Access;
begin
Stmt.delivery := completed; -- default for early returns
if Stmt.num_columns = 0 then
Stmt.result_present := False;
Stmt.impacted := Stmt.mysql_conn.prep_rows_affected_by_execution
(Stmt.stmt_handle);
return;
end if;
Stmt.result_present := True;
if Stmt.bind_canvas /= null then
raise STMT_PREPARATION with
"Previous bind canvas present (expected to be null)";
end if;
Stmt.bind_canvas := new mysql_canvases (1 .. Stmt.num_columns);
declare
slots : ABM.MYSQL_BIND_Array (1 .. Stmt.num_columns);
ft : field_types;
fsize : Natural;
begin
for sx in slots'Range loop
slots (sx).is_null := Stmt.bind_canvas (sx).is_null'Access;
slots (sx).length := Stmt.bind_canvas (sx).length'Access;
slots (sx).error := Stmt.bind_canvas (sx).error'Access;
slots (sx).buffer_type := Stmt.column_info.Element (sx).mysql_type;
ft := Stmt.column_info.Element (sx).field_type;
case slots (sx).buffer_type is
when ABM.MYSQL_TYPE_DOUBLE =>
slots (sx).buffer :=
Stmt.bind_canvas (sx).buffer_double'Address;
when ABM.MYSQL_TYPE_FLOAT =>
slots (sx).buffer :=
Stmt.bind_canvas (sx).buffer_float'Address;
when ABM.MYSQL_TYPE_NEWDECIMAL | ABM.MYSQL_TYPE_DECIMAL =>
-- Don't set buffer_type to FLOAT or DOUBLE. MySQL will
-- automatically convert it, but precision will be lost.
-- Ask for a string and let's convert that ourselves.
slots (sx).buffer_type := ABM.MYSQL_TYPE_NEWDECIMAL;
fsize := Stmt.column_info.Element (sx).field_size;
slots (sx).buffer_length := ABM.IC.unsigned_long (fsize);
Stmt.bind_canvas (sx).buffer_binary := new ABM.IC.char_array
(1 .. ABM.IC.size_t (fsize));
slots (sx).buffer :=
Stmt.bind_canvas (sx).buffer_binary.all'Address;
when ABM.MYSQL_TYPE_TINY =>
if ft = ft_nbyte0 or else ft = ft_nbyte1 then
slots (sx).is_unsigned := 1;
slots (sx).buffer :=
Stmt.bind_canvas (sx).buffer_uint8'Address;
else
slots (sx).buffer :=
Stmt.bind_canvas (sx).buffer_int8'Address;
end if;
when ABM.MYSQL_TYPE_SHORT | ABM.MYSQL_TYPE_YEAR =>
if ft = ft_nbyte2 then
slots (sx).is_unsigned := 1;
slots (sx).buffer :=
Stmt.bind_canvas (sx).buffer_uint16'Address;
else
slots (sx).buffer :=
Stmt.bind_canvas (sx).buffer_int16'Address;
end if;
when ABM.MYSQL_TYPE_INT24 | ABM.MYSQL_TYPE_LONG =>
if ft = ft_nbyte3 or else ft = ft_nbyte4 then
slots (sx).is_unsigned := 1;
slots (sx).buffer :=
Stmt.bind_canvas (sx).buffer_uint32'Address;
else
slots (sx).buffer :=
Stmt.bind_canvas (sx).buffer_int32'Address;
end if;
when ABM.MYSQL_TYPE_LONGLONG =>
if ft = ft_nbyte8 then
slots (sx).is_unsigned := 1;
slots (sx).buffer :=
Stmt.bind_canvas (sx).buffer_uint64'Address;
else
slots (sx).buffer :=
Stmt.bind_canvas (sx).buffer_int64'Address;
end if;
when ABM.MYSQL_TYPE_DATE | ABM.MYSQL_TYPE_TIMESTAMP |
ABM.MYSQL_TYPE_TIME | ABM.MYSQL_TYPE_DATETIME =>
slots (sx).buffer :=
Stmt.bind_canvas (sx).buffer_time'Address;
when ABM.MYSQL_TYPE_BIT | ABM.MYSQL_TYPE_TINY_BLOB |
ABM.MYSQL_TYPE_MEDIUM_BLOB | ABM.MYSQL_TYPE_LONG_BLOB |
ABM.MYSQL_TYPE_BLOB | ABM.MYSQL_TYPE_STRING |
ABM.MYSQL_TYPE_VAR_STRING =>
fsize := Stmt.column_info.Element (sx).field_size;
slots (sx).buffer_length := ABM.IC.unsigned_long (fsize);
Stmt.bind_canvas (sx).buffer_binary := new ABM.IC.char_array
(1 .. ABM.IC.size_t (fsize));
slots (sx).buffer :=
Stmt.bind_canvas (sx).buffer_binary.all'Address;
when ABM.MYSQL_TYPE_NULL | ABM.MYSQL_TYPE_NEWDATE |
ABM.MYSQL_TYPE_VARCHAR | ABM.MYSQL_TYPE_GEOMETRY |
ABM.MYSQL_TYPE_ENUM | ABM.MYSQL_TYPE_SET =>
raise STMT_PREPARATION with
"Unsupported MySQL type for result binding attempted";
end case;
end loop;
if not Stmt.mysql_conn.prep_bind_result (Stmt.stmt_handle, slots)
then
Stmt.log_problem (category => statement_preparation,
message => "failed to bind result structures",
pull_codes => True);
return;
end if;
end;
if Stmt.con_buffered then
Stmt.mysql_conn.prep_store_result (Stmt.stmt_handle);
Stmt.size_of_rowset := Stmt.mysql_conn.prep_rows_in_result
(Stmt.stmt_handle);
end if;
Stmt.delivery := pending;
end internal_post_prep_stmt;
---------------------------
-- construct_bind_slot --
---------------------------
procedure construct_bind_slot (Stmt : MySQL_statement;
struct : out ABM.MYSQL_BIND;
canvas : out mysql_canvas;
marker : Positive)
is
procedure set_binary_buffer (Str : String);
zone : bindrec renames Stmt.realmccoy.Element (marker);
vartype : constant field_types := zone.output_type;
use type AR.NByte0_Access;
use type AR.NByte1_Access;
use type AR.NByte2_Access;
use type AR.NByte3_Access;
use type AR.NByte4_Access;
use type AR.NByte8_Access;
use type AR.Byte1_Access;
use type AR.Byte2_Access;
use type AR.Byte3_Access;
use type AR.Byte4_Access;
use type AR.Byte8_Access;
use type AR.Real9_Access;
use type AR.Real18_Access;
use type AR.Str1_Access;
use type AR.Str2_Access;
use type AR.Str4_Access;
use type AR.Time_Access;
use type AR.Enum_Access;
use type AR.Chain_Access;
use type AR.Settype_Access;
use type AR.Bits_Access;
use type AR.S_UTF8_Access;
use type AR.Geometry_Access;
procedure set_binary_buffer (Str : String)
is
len : constant ABM.IC.size_t := ABM.IC.size_t (Str'Length);
begin
canvas.buffer_binary := new ABM.IC.char_array (1 .. len);
canvas.buffer_binary.all := ABM.IC.To_C (Str, False);
canvas.length := ABM.IC.unsigned_long (len);
struct.buffer := canvas.buffer_binary.all'Address;
struct.buffer_length := ABM.IC.unsigned_long (len);
struct.length := canvas.length'Unchecked_Access;
struct.is_null := canvas.is_null'Unchecked_Access;
end set_binary_buffer;
begin
case vartype is
when ft_nbyte0 | ft_nbyte1 | ft_nbyte2 | ft_nbyte3 | ft_nbyte4 |
ft_nbyte8 => struct.is_unsigned := 1;
when others => null;
end case;
case vartype is
when ft_nbyte0 => struct.buffer_type := ABM.MYSQL_TYPE_TINY;
when ft_nbyte1 => struct.buffer_type := ABM.MYSQL_TYPE_TINY;
when ft_nbyte2 => struct.buffer_type := ABM.MYSQL_TYPE_SHORT;
when ft_nbyte3 => struct.buffer_type := ABM.MYSQL_TYPE_LONG;
when ft_nbyte4 => struct.buffer_type := ABM.MYSQL_TYPE_LONG;
when ft_nbyte8 => struct.buffer_type := ABM.MYSQL_TYPE_LONGLONG;
when ft_byte1 => struct.buffer_type := ABM.MYSQL_TYPE_TINY;
when ft_byte2 => struct.buffer_type := ABM.MYSQL_TYPE_SHORT;
when ft_byte3 => struct.buffer_type := ABM.MYSQL_TYPE_LONG;
when ft_byte4 => struct.buffer_type := ABM.MYSQL_TYPE_LONG;
when ft_byte8 => struct.buffer_type := ABM.MYSQL_TYPE_LONGLONG;
when ft_real9 => struct.buffer_type := ABM.MYSQL_TYPE_FLOAT;
when ft_real18 => struct.buffer_type := ABM.MYSQL_TYPE_DOUBLE;
when ft_textual => struct.buffer_type := ABM.MYSQL_TYPE_STRING;
when ft_widetext => struct.buffer_type := ABM.MYSQL_TYPE_STRING;
when ft_supertext => struct.buffer_type := ABM.MYSQL_TYPE_STRING;
when ft_timestamp => struct.buffer_type := ABM.MYSQL_TYPE_DATETIME;
when ft_chain => struct.buffer_type := ABM.MYSQL_TYPE_BLOB;
when ft_enumtype => struct.buffer_type := ABM.MYSQL_TYPE_STRING;
when ft_settype => struct.buffer_type := ABM.MYSQL_TYPE_STRING;
when ft_bits => struct.buffer_type := ABM.MYSQL_TYPE_STRING;
when ft_utf8 => struct.buffer_type := ABM.MYSQL_TYPE_STRING;
when ft_geometry => struct.buffer_type := ABM.MYSQL_TYPE_STRING;
end case;
if zone.null_data then
canvas.is_null := 1;
struct.buffer_type := ABM.MYSQL_TYPE_NULL;
else
case vartype is
when ft_nbyte0 =>
struct.buffer := canvas.buffer_uint8'Address;
if zone.a00 = null then
if zone.v00 then
canvas.buffer_uint8 := 1;
end if;
else
if zone.a00.all then
canvas.buffer_uint8 := 1;
end if;
end if;
when ft_nbyte1 =>
struct.buffer := canvas.buffer_uint8'Address;
if zone.a01 = null then
canvas.buffer_uint8 := ABM.IC.unsigned_char (zone.v01);
else
canvas.buffer_uint8 := ABM.IC.unsigned_char (zone.a01.all);
end if;
when ft_nbyte2 =>
struct.buffer := canvas.buffer_uint16'Address;
if zone.a02 = null then
canvas.buffer_uint16 := ABM.IC.unsigned_short (zone.v02);
else
canvas.buffer_uint16 := ABM.IC.unsigned_short (zone.a02.all);
end if;
when ft_nbyte3 =>
struct.buffer := canvas.buffer_uint32'Address;
-- ABM.MYSQL_TYPE_INT24 not for input, use next biggest
if zone.a03 = null then
canvas.buffer_uint32 := ABM.IC.unsigned (zone.v03);
else
canvas.buffer_uint32 := ABM.IC.unsigned (zone.a03.all);
end if;
when ft_nbyte4 =>
struct.buffer := canvas.buffer_uint32'Address;
if zone.a04 = null then
canvas.buffer_uint32 := ABM.IC.unsigned (zone.v04);
else
canvas.buffer_uint32 := ABM.IC.unsigned (zone.a04.all);
end if;
when ft_nbyte8 =>
struct.buffer := canvas.buffer_uint64'Address;
if zone.a05 = null then
canvas.buffer_uint64 := ABM.IC.unsigned_long (zone.v05);
else
canvas.buffer_uint64 := ABM.IC.unsigned_long (zone.a05.all);
end if;
when ft_byte1 =>
struct.buffer := canvas.buffer_int8'Address;
if zone.a06 = null then
canvas.buffer_int8 := ABM.IC.signed_char (zone.v06);
else
canvas.buffer_int8 := ABM.IC.signed_char (zone.a06.all);
end if;
when ft_byte2 =>
struct.buffer := canvas.buffer_int16'Address;
if zone.a07 = null then
canvas.buffer_int16 := ABM.IC.short (zone.v07);
else
canvas.buffer_int16 := ABM.IC.short (zone.a07.all);
end if;
when ft_byte3 =>
struct.buffer := canvas.buffer_int32'Address;
-- ABM.MYSQL_TYPE_INT24 not for input, use next biggest
if zone.a08 = null then
canvas.buffer_int32 := ABM.IC.int (zone.v08);
else
canvas.buffer_int32 := ABM.IC.int (zone.a08.all);
end if;
when ft_byte4 =>
struct.buffer := canvas.buffer_int32'Address;
if zone.a09 = null then
canvas.buffer_int32 := ABM.IC.int (zone.v09);
else
canvas.buffer_int32 := ABM.IC.int (zone.a09.all);
end if;
when ft_byte8 =>
struct.buffer := canvas.buffer_int64'Address;
if zone.a10 = null then
canvas.buffer_int64 := ABM.IC.long (zone.v10);
else
canvas.buffer_int64 := ABM.IC.long (zone.a10.all);
end if;
when ft_real9 =>
struct.buffer := canvas.buffer_float'Address;
if zone.a11 = null then
canvas.buffer_float := ABM.IC.C_float (zone.v11);
else
canvas.buffer_float := ABM.IC.C_float (zone.a11.all);
end if;
when ft_real18 =>
struct.buffer := canvas.buffer_double'Address;
if zone.a12 = null then
canvas.buffer_double := ABM.IC.double (zone.v12);
else
canvas.buffer_double := ABM.IC.double (zone.a12.all);
end if;
when ft_textual =>
if zone.a13 = null then
set_binary_buffer (ARC.convert (zone.v13));
else
set_binary_buffer (ARC.convert (zone.a13.all));
end if;
when ft_widetext =>
if zone.a14 = null then
set_binary_buffer (ARC.convert (zone.v14));
else
set_binary_buffer (ARC.convert (zone.a14.all));
end if;
when ft_supertext =>
if zone.a15 = null then
set_binary_buffer (ARC.convert (zone.v15));
else
set_binary_buffer (ARC.convert (zone.a15.all));
end if;
when ft_utf8 =>
if zone.a21 = null then
set_binary_buffer (ARC.convert (zone.v21));
else
set_binary_buffer (zone.a21.all);
end if;
when ft_geometry =>
if zone.a22 = null then
set_binary_buffer (WKB.produce_WKT (zone.v22));
else
set_binary_buffer (Spatial_Data.Well_Known_Text (zone.a22.all));
end if;
when ft_timestamp =>
struct.buffer := canvas.buffer_time'Address;
declare
hack : CAL.Time;
begin
if zone.a16 = null then
hack := zone.v16;
else
hack := zone.a16.all;
end if;
-- Negative time not supported
canvas.buffer_time.year := ABM.IC.unsigned (CFM.Year (hack));
canvas.buffer_time.month := ABM.IC.unsigned (CFM.Month (hack));
canvas.buffer_time.day := ABM.IC.unsigned (CFM.Day (hack));
canvas.buffer_time.hour := ABM.IC.unsigned (CFM.Hour (hack));
canvas.buffer_time.minute := ABM.IC.unsigned
(CFM.Minute (hack));
canvas.buffer_time.second := ABM.IC.unsigned
(CFM.Second (hack));
canvas.buffer_time.second_part :=
ABM.IC.unsigned_long (CFM.Sub_Second (hack) * 1000000);
end;
when ft_chain =>
if zone.a17 = null then
set_binary_buffer (CT.USS (zone.v17));
else
set_binary_buffer (ARC.convert (zone.a17.all));
end if;
when ft_enumtype =>
if zone.a18 = null then
set_binary_buffer (ARC.convert (zone.v18.enumeration));
else
set_binary_buffer (ARC.convert (zone.a18.all.enumeration));
end if;
when ft_settype =>
if zone.a19 = null then
set_binary_buffer (CT.USS (zone.v19));
else
set_binary_buffer (ARC.convert (zone.a19.all));
end if;
when ft_bits =>
if zone.a20 = null then
set_binary_buffer (CT.USS (zone.v20));
else
set_binary_buffer (ARC.convert (zone.a20.all));
end if;
end case;
end if;
end construct_bind_slot;
-------------------
-- log_problem --
-------------------
procedure log_problem
(statement : MySQL_statement;
category : Log_Category;
message : String;
pull_codes : Boolean := False;
break : Boolean := False)
is
error_msg : CT.Text := CT.blank;
error_code : Driver_Codes := 0;
sqlstate : SQL_State := stateless;
begin
if pull_codes then
error_msg := CT.SUS (statement.last_driver_message);
error_code := statement.last_driver_code;
sqlstate := statement.last_sql_state;
end if;
logger_access.all.log_problem
(driver => statement.dialect,
category => category,
message => CT.SUS (message),
error_msg => error_msg,
error_code => error_code,
sqlstate => sqlstate,
break => break);
end log_problem;
---------------------
-- num_set_items --
---------------------
function num_set_items (nv : String) return Natural
is
result : Natural := 0;
begin
if not CT.IsBlank (nv) then
result := 1;
for x in nv'Range loop
if nv (x) = ',' then
result := result + 1;
end if;
end loop;
end if;
return result;
end num_set_items;
----------------------------
-- convert_to_bitstring --
----------------------------
function convert_to_bitstring (nv : String; width : Natural) return String
is
use type AR.NByte1;
result : String (1 .. width) := (others => '0');
marker : Natural;
lode : AR.NByte1;
mask : constant array (0 .. 7) of AR.NByte1 := (2 ** 0, 2 ** 1,
2 ** 2, 2 ** 3,
2 ** 4, 2 ** 5,
2 ** 6, 2 ** 7);
begin
-- We can't seem to get the true size, e.g 12 bits shows as 2,
-- for two bytes, which could represent up to 16 bits. Thus, we
-- return a variable width in multiples of 8. MySQL doesn't mind
-- leading zeros.
marker := result'Last;
for x in reverse nv'Range loop
lode := AR.NByte1 (Character'Pos (nv (x)));
for position in mask'Range loop
if (lode and mask (position)) > 0 then
result (marker) := '1';
end if;
exit when marker = result'First;
marker := marker - 1;
end loop;
end loop;
return result;
end convert_to_bitstring;
end AdaBase.Statement.Base.MySQL;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
with Ada.IO_Exceptions;
with AWS.Config.Set;
with Servlet.Server.Web;
with Util.Strings;
with Util.Log.Loggers;
with Util.Properties;
with Util.Properties.Basic;
with Wi2wic.Rest;
with Wi2wic.Applications;
procedure Wi2wic.Server is
procedure Configure (Config : in out AWS.Config.Object);
use Util.Properties.Basic;
CONFIG_PATH : constant String := "wi2wic.properties";
Port : Natural := 8080;
procedure Configure (Config : in out AWS.Config.Object) is
begin
AWS.Config.Set.Server_Port (Config, Port);
AWS.Config.Set.Max_Connection (Config, 8);
AWS.Config.Set.Accept_Queue_Size (Config, 512);
end Configure;
App : aliased Wi2wic.Applications.Application_Type;
WS : Servlet.Server.Web.AWS_Container;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Wi2wic.Server");
Props : Util.Properties.Manager;
begin
Props.Load_Properties (CONFIG_PATH);
Util.Log.Loggers.Initialize (Props);
Port := Integer_Property.Get (Props, "wi2wic.port", Port);
App.Configure (Props);
Wi2wic.Rest.Register (App);
WS.Configure (Configure'Access);
WS.Register_Application ("/wi2wic", App'Unchecked_Access);
App.Dump_Routes (Util.Log.INFO_LEVEL);
Log.Info ("Connect you browser to: http://localhost:{0}/wi2wic/index.html",
Util.Strings.Image (Port));
WS.Start;
loop
delay 6000.0;
end loop;
exception
when Ada.IO_Exceptions.Name_Error =>
Log.Error ("Cannot read application configuration file {0}", CONFIG_PATH);
end Wi2wic.Server;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--*
-- CHECK THAT WHEN A FUNCTION IS READY TO RETURN CONTROL TO ITS INVOKER
-- THE CONSTRAINTS ON THE RETURN VALUES ARE CHECKED, AND THAT
-- CONSTRAINT ERROR IS THEN RAISED IF AND ONLY IF THE CONSTRAINTS
-- ARE NOT SATISFIED.
-- THIS TEST CHECKS THAT THE EXCEPTION IS RAISED UNDER THE APPROPRIATE
-- CONDITIONS; IT ALSO CHECKS THE IDENTITY OF THE EXCEPTION. THE
-- PRECISE MOMENT AND PLACE THE EXCEPTION IS RAISED IS TESTED
-- ELSEWHERE.
-- RM 05/14/81
-- SPS 10/26/82
WITH REPORT;
PROCEDURE C58005A IS
USE REPORT ;
INTVAR : INTEGER ;
BEGIN
TEST( "C58005A" , "CHECK THAT EXCEPTIONS ARE RAISED BY A RETURN" &
" STATEMENT IF AND ONLY IF THE CONSTRAINTS ARE" &
" VIOLATED" );
DECLARE
SUBTYPE I1 IS INTEGER RANGE -10..90;
SUBTYPE I2 IS INTEGER RANGE 1..10;
FUNCTION FN1( X : I1 )
RETURN I2 IS
BEGIN
RETURN 0 ;
END FN1 ;
FUNCTION FN2( X : I1 )
RETURN I2 IS
BEGIN
RETURN X + IDENT_INT(0) ;
END FN2 ;
FUNCTION FN3( X : I1 )
RETURN I2 IS
HUNDRED : INTEGER RANGE -100..100 := IDENT_INT(100) ;
BEGIN
RETURN HUNDRED - 90 ;
END FN3 ;
BEGIN
INTVAR := 0 ;
BEGIN
INTVAR := FN1( 0 ) + INTVAR ; -- EXCEPTION.
FAILED( "EXCEPTION NOT RAISED - 1" );
EXCEPTION
WHEN CONSTRAINT_ERROR => INTVAR := INTVAR + 10 ;
WHEN OTHERS => FAILED( "WRONG EXCEPTION RAISED - 1" ) ;
END ;
BEGIN
INTVAR := FN2( 1 ) + INTVAR ; -- 10+1=11 -- NO EXCEPTION.
INTVAR := INTVAR + 100 ; -- 11+100=111
EXCEPTION
WHEN OTHERS => FAILED( "EXCEPTION RAISED - 2" ) ;
END ;
BEGIN
INTVAR := FN2(11 ) + INTVAR ; -- EXCEPTION.
FAILED( "EXCEPTION NOT RAISED - 3" );
EXCEPTION
WHEN CONSTRAINT_ERROR => INTVAR := INTVAR + 10 ; -- 121
WHEN OTHERS => FAILED( "WRONG EXCEPTION RAISED - 3" ) ;
END ;
BEGIN
INTVAR := FN3( 0 ) + INTVAR ;--121+10=131 --NO EXCEPTION.
INTVAR := INTVAR + 1000 ;-- 131+1000=1131
EXCEPTION
WHEN OTHERS => FAILED( "EXCEPTION RAISED - 4" ) ;
END ;
END ;
IF INTVAR /= 1131 THEN
FAILED("WRONG FLOW OF CONTROL" );
END IF;
RESULT ;
END C58005A;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
pragma Warnings (Off);
with ADO.Sessions;
with ADO.Objects;
with ADO.Statements;
with ADO.SQL;
with ADO.Schemas;
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded;
with Util.Beans.Objects;
with Util.Beans.Basic.Lists;
with Util.Beans.Methods;
pragma Warnings (On);
package AWA.Votes.Models is
pragma Style_Checks ("-mr");
type Rating_Ref is new ADO.Objects.Object_Ref with null record;
type Vote_Ref is new ADO.Objects.Object_Ref with null record;
-- Create an object key for Rating.
function Rating_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Rating from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Rating_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Rating : constant Rating_Ref;
function "=" (Left, Right : Rating_Ref'Class) return Boolean;
-- Set the rating identifier
procedure Set_Id (Object : in out Rating_Ref;
Value : in ADO.Identifier);
-- Get the rating identifier
function Get_Id (Object : in Rating_Ref)
return ADO.Identifier;
-- Set the rating taking into account all votes
procedure Set_Rating (Object : in out Rating_Ref;
Value : in Integer);
-- Get the rating taking into account all votes
function Get_Rating (Object : in Rating_Ref)
return Integer;
-- Set the number of votes
procedure Set_Vote_Count (Object : in out Rating_Ref;
Value : in Integer);
-- Get the number of votes
function Get_Vote_Count (Object : in Rating_Ref)
return Integer;
--
procedure Set_For_Entity_Id (Object : in out Rating_Ref;
Value : in ADO.Identifier);
--
function Get_For_Entity_Id (Object : in Rating_Ref)
return ADO.Identifier;
-- Set the entity type
procedure Set_For_Entity_Type (Object : in out Rating_Ref;
Value : in ADO.Entity_Type);
-- Get the entity type
function Get_For_Entity_Type (Object : in Rating_Ref)
return ADO.Entity_Type;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Rating_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Rating_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Rating_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Rating_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Rating_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Rating_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
RATING_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Rating_Ref);
-- Copy of the object.
procedure Copy (Object : in Rating_Ref;
Into : in out Rating_Ref);
-- --------------------
-- The vote table tracks a vote action by a user on a given database entity.
-- The primary key is made of the user, the entity id and entity type.
-- --------------------
-- Create an object key for Vote.
function Vote_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Vote from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Vote_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Vote : constant Vote_Ref;
function "=" (Left, Right : Vote_Ref'Class) return Boolean;
--
procedure Set_Rating (Object : in out Vote_Ref;
Value : in Integer);
--
function Get_Rating (Object : in Vote_Ref)
return Integer;
--
procedure Set_Entity (Object : in out Vote_Ref;
Value : in AWA.Votes.Models.Rating_Ref'Class);
--
function Get_Entity (Object : in Vote_Ref)
return AWA.Votes.Models.Rating_Ref'Class;
--
procedure Set_User_Id (Object : in out Vote_Ref;
Value : in ADO.Identifier);
--
function Get_User_Id (Object : in Vote_Ref)
return ADO.Identifier;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Vote_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Vote_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Vote_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Vote_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Vote_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Vote_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
VOTE_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Vote_Ref);
-- Copy of the object.
procedure Copy (Object : in Vote_Ref;
Into : in out Vote_Ref);
type Vote_Bean is abstract
new Util.Beans.Basic.Bean and Util.Beans.Methods.Method_Bean with record
-- the permission name to check if the user is allowed to vote
Permission : Ada.Strings.Unbounded.Unbounded_String;
-- the entity identifier
Entity_Id : ADO.Identifier;
-- the user rating
Rating : Integer;
-- the entity type
Entity_Type : Ada.Strings.Unbounded.Unbounded_String;
-- the total rating for the entity
Total : Integer;
end record;
-- This bean provides some methods that can be used in a Method_Expression.
overriding
function Get_Method_Bindings (From : in Vote_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access;
-- Get the bean attribute identified by the name.
overriding
function Get_Value (From : in Vote_Bean;
Name : in String) return Util.Beans.Objects.Object;
-- Set the bean attribute identified by the name.
overriding
procedure Set_Value (Item : in out Vote_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object);
procedure Vote_Up (Bean : in out Vote_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is abstract;
procedure Vote_Down (Bean : in out Vote_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is abstract;
procedure Vote (Bean : in out Vote_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is abstract;
private
RATING_NAME : aliased constant String := "awa_rating";
COL_0_1_NAME : aliased constant String := "id";
COL_1_1_NAME : aliased constant String := "rating";
COL_2_1_NAME : aliased constant String := "vote_count";
COL_3_1_NAME : aliased constant String := "for_entity_id";
COL_4_1_NAME : aliased constant String := "for_entity_type";
RATING_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 5,
Table => RATING_NAME'Access,
Members => (
1 => COL_0_1_NAME'Access,
2 => COL_1_1_NAME'Access,
3 => COL_2_1_NAME'Access,
4 => COL_3_1_NAME'Access,
5 => COL_4_1_NAME'Access)
);
RATING_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= RATING_DEF'Access;
Null_Rating : constant Rating_Ref
:= Rating_Ref'(ADO.Objects.Object_Ref with null record);
type Rating_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => RATING_DEF'Access)
with record
Rating : Integer;
Vote_Count : Integer;
For_Entity_Id : ADO.Identifier;
For_Entity_Type : ADO.Entity_Type;
end record;
type Rating_Access is access all Rating_Impl;
overriding
procedure Destroy (Object : access Rating_Impl);
overriding
procedure Find (Object : in out Rating_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Rating_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Rating_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Rating_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Rating_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Rating_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Rating_Ref'Class;
Impl : out Rating_Access);
VOTE_NAME : aliased constant String := "awa_vote";
COL_0_2_NAME : aliased constant String := "rating";
COL_1_2_NAME : aliased constant String := "entity_id";
COL_2_2_NAME : aliased constant String := "user_id";
VOTE_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 3,
Table => VOTE_NAME'Access,
Members => (
1 => COL_0_2_NAME'Access,
2 => COL_1_2_NAME'Access,
3 => COL_2_2_NAME'Access)
);
VOTE_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= VOTE_DEF'Access;
Null_Vote : constant Vote_Ref
:= Vote_Ref'(ADO.Objects.Object_Ref with null record);
type Vote_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => VOTE_DEF'Access)
with record
Rating : Integer;
Entity : AWA.Votes.Models.Rating_Ref;
end record;
type Vote_Access is access all Vote_Impl;
overriding
procedure Destroy (Object : access Vote_Impl);
overriding
procedure Find (Object : in out Vote_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Vote_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Vote_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Vote_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Vote_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Vote_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Vote_Ref'Class;
Impl : out Vote_Access);
end AWA.Votes.Models;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
package body Servlet.Filters.Cache_Control is
-- ------------------------------
-- The Do_Filter method of the Filter is called by the container each time
-- a request/response pair is passed through the chain due to a client request
-- for a resource at the end of the chain. The <b>Cache_Control</b> filter adds
-- a <tt>Cache-Control</tt>, <tt>Expires</tt>, <tt>Pragma</tt> and optionally a
-- <tt>Vary</tt> header in the HTTP response.
-- ------------------------------
overriding
procedure Do_Filter (F : in Cache_Control_Filter;
Request : in out Requests.Request'Class;
Response : in out Responses.Response'Class;
Chain : in out Servlet.Core.Filter_Chain) is
use Ada.Strings.Unbounded;
begin
if Length (F.Cache_Control_Header) > 0 then
Response.Add_Header ("Cache-Control", To_String (F.Cache_Control_Header));
end if;
if Length (F.Vary) > 0 then
Response.Add_Header ("Vary", To_String (F.Vary));
end if;
Servlet.Core.Do_Filter (Chain => Chain,
Request => Request,
Response => Response);
end Do_Filter;
-- ------------------------------
-- Called by the servlet container to indicate to a filter that the filter
-- instance is being placed into service.
-- ------------------------------
procedure Initialize (Server : in out Cache_Control_Filter;
Config : in Servlet.Core.Filter_Config) is
begin
Server.Vary := Core.Get_Init_Parameter (Config, VARY_HEADER_PARAM);
Server.Cache_Control_Header := Core.Get_Init_Parameter (Config, CACHE_CONTROL_PARAM);
end Initialize;
end Servlet.Filters.Cache_Control;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
private with Ada.Streams.Stream_IO;
private with Ada.Directories;
package Lexer.Source.File is
-- this provides streams which are backed by files on the file system.
type Instance is new Source.Instance with private;
type Instance_Access is access all Instance;
overriding procedure Read_Data (S : in out Instance; Buffer : out String;
Length : out Natural);
overriding procedure Finalize (Object : in out Instance);
function As_Source (File_Path : String) return Pointer;
private
type Instance is new Source.Instance with record
File : Ada.Streams.Stream_IO.File_Type;
Stream : Ada.Streams.Stream_IO.Stream_Access;
Input_At, Input_Length : Ada.Directories.File_Size;
end record;
end Lexer.Source.File;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--*< Length of the data member.
--*< Data interpreted in a protocol-specific manner.
-- xcb_out.c
--*
-- * @brief Forces any buffered output to be written to the server.
-- * @param c The connection to the X server.
-- * @return > @c 0 on success, <= @c 0 otherwise.
-- *
-- * Forces any buffered output to be written to the server. Blocks
-- * until the write is complete.
--
function xcb_flush (c : access xcb_connection_t) return int -- /usr/include/xcb/xcb.h:246
with Import => True,
Convention => C,
External_Name => "xcb_flush";
--*
-- * @brief Returns the maximum request length that this server accepts.
-- * @param c The connection to the X server.
-- * @return The maximum request length field.
-- *
-- * In the absence of the BIG-REQUESTS extension, returns the
-- * maximum request length field from the connection setup data, which
-- * may be as much as 65535. If the server supports BIG-REQUESTS, then
-- * the maximum request length field from the reply to the
-- * BigRequestsEnable request will be returned instead.
-- *
-- * Note that this length is measured in four-byte units, making the
-- * theoretical maximum lengths roughly 256kB without BIG-REQUESTS and
-- * 16GB with.
--
function xcb_get_maximum_request_length (c : access xcb_connection_t) return bits_stdint_uintn_h.uint32_t -- /usr/include/xcb/xcb.h:263
with Import => True,
Convention => C,
External_Name => "xcb_get_maximum_request_length";
--*
-- * @brief Prefetch the maximum request length without blocking.
-- * @param c The connection to the X server.
-- *
-- * Without blocking, does as much work as possible toward computing
-- * the maximum request length accepted by the X server.
-- *
-- * Invoking this function may cause a call to xcb_big_requests_enable,
-- * but will not block waiting for the reply.
-- * xcb_get_maximum_request_length will return the prefetched data
-- * after possibly blocking while the reply is retrieved.
-- *
-- * Note that in order for this function to be fully non-blocking, the
-- * application must previously have called
-- * xcb_prefetch_extension_data(c, &xcb_big_requests_id) and the reply
-- * must have already arrived.
--
procedure xcb_prefetch_maximum_request_length (c : access xcb_connection_t) -- /usr/include/xcb/xcb.h:282
with Import => True,
Convention => C,
External_Name => "xcb_prefetch_maximum_request_length";
-- xcb_in.c
--*
-- * @brief Returns the next event or error from the server.
-- * @param c The connection to the X server.
-- * @return The next event from the server.
-- *
-- * Returns the next event or error from the server, or returns null in
-- * the event of an I/O error. Blocks until either an event or error
-- * arrive, or an I/O error occurs.
--
function xcb_wait_for_event (c : access xcb_connection_t) return access xcb_generic_event_t -- /usr/include/xcb/xcb.h:296
with Import => True,
Convention => C,
External_Name => "xcb_wait_for_event";
--*
-- * @brief Returns the next event or error from the server.
-- * @param c The connection to the X server.
-- * @return The next event from the server.
-- *
-- * Returns the next event or error from the server, if one is
-- * available, or returns @c NULL otherwise. If no event is available, that
-- * might be because an I/O error like connection close occurred while
-- * attempting to read the next event, in which case the connection is
-- * shut down when this function returns.
--
function xcb_poll_for_event (c : access xcb_connection_t) return access xcb_generic_event_t -- /usr/include/xcb/xcb.h:309
with Import => True,
Convention => C,
External_Name => "xcb_poll_for_event";
--*
-- * @brief Returns the next event without reading from the connection.
-- * @param c The connection to the X server.
-- * @return The next already queued event from the server.
-- *
-- * This is a version of xcb_poll_for_event that only examines the
-- * event queue for new events. The function doesn't try to read new
-- * events from the connection if no queued events are found.
-- *
-- * This function is useful for callers that know in advance that all
-- * interesting events have already been read from the connection. For
-- * example, callers might use xcb_wait_for_reply and be interested
-- * only of events that preceded a specific reply.
--
function xcb_poll_for_queued_event (c : access xcb_connection_t) return access xcb_generic_event_t -- /usr/include/xcb/xcb.h:325
with Import => True,
Convention => C,
External_Name => "xcb_poll_for_queued_event";
type xcb_special_event is null record; -- incomplete struct
subtype xcb_special_event_t is xcb_special_event; -- /usr/include/xcb/xcb.h:327
--*
-- * @brief Returns the next event from a special queue
--
function xcb_poll_for_special_event (c : access xcb_connection_t; se : access xcb_special_event_t) return access xcb_generic_event_t -- /usr/include/xcb/xcb.h:332
with Import => True,
Convention => C,
External_Name => "xcb_poll_for_special_event";
--*
-- * @brief Returns the next event from a special queue, blocking until one arrives
--
function xcb_wait_for_special_event (c : access xcb_connection_t; se : access xcb_special_event_t) return access xcb_generic_event_t -- /usr/include/xcb/xcb.h:338
with Import => True,
Convention => C,
External_Name => "xcb_wait_for_special_event";
--*
-- * @typedef typedef struct xcb_extension_t xcb_extension_t
--
--*< Opaque structure used as key for xcb_get_extension_data_t.
type xcb_extension_t is null record; -- incomplete struct
--*
-- * @brief Listen for a special event
--
function xcb_register_for_special_xge
(c : access xcb_connection_t;
ext : access xcb_extension_t;
eid : bits_stdint_uintn_h.uint32_t;
stamp : access bits_stdint_uintn_h.uint32_t) return access xcb_special_event_t -- /usr/include/xcb/xcb.h:348
with Import => True,
Convention => C,
External_Name => "xcb_register_for_special_xge";
--*
-- * @brief Stop listening for a special event
--
procedure xcb_unregister_for_special_event (c : access xcb_connection_t; se : access xcb_special_event_t) -- /usr/include/xcb/xcb.h:356
with Import => True,
Convention => C,
External_Name => "xcb_unregister_for_special_event";
--*
-- * @brief Return the error for a request, or NULL if none can ever arrive.
-- * @param c The connection to the X server.
-- * @param cookie The request cookie.
-- * @return The error for the request, or NULL if none can ever arrive.
-- *
-- * The xcb_void_cookie_t cookie supplied to this function must have resulted
-- * from a call to xcb_[request_name]_checked(). This function will block
-- * until one of two conditions happens. If an error is received, it will be
-- * returned. If a reply to a subsequent request has already arrived, no error
-- * can arrive for this request, so this function will return NULL.
-- *
-- * Note that this function will perform a sync if needed to ensure that the
-- * sequence number will advance beyond that provided in cookie; this is a
-- * convenience to avoid races in determining whether the sync is needed.
--
function xcb_request_check (c : access xcb_connection_t; cookie : xcb_void_cookie_t) return access xcb_generic_error_t -- /usr/include/xcb/xcb.h:375
with Import => True,
Convention => C,
External_Name => "xcb_request_check";
--*
-- * @brief Discards the reply for a request.
-- * @param c The connection to the X server.
-- * @param sequence The request sequence number from a cookie.
-- *
-- * Discards the reply for a request. Additionally, any error generated
-- * by the request is also discarded (unless it was an _unchecked request
-- * and the error has already arrived).
-- *
-- * This function will not block even if the reply is not yet available.
-- *
-- * Note that the sequence really does have to come from an xcb cookie;
-- * this function is not designed to operate on socket-handoff replies.
--
procedure xcb_discard_reply (c : access xcb_connection_t; sequence : unsigned) -- /usr/include/xcb/xcb.h:391
with Import => True,
Convention => C,
External_Name => "xcb_discard_reply";
--*
-- * @brief Discards the reply for a request, given by a 64bit sequence number
-- * @param c The connection to the X server.
-- * @param sequence 64-bit sequence number as returned by xcb_send_request64().
-- *
-- * Discards the reply for a request. Additionally, any error generated
-- * by the request is also discarded (unless it was an _unchecked request
-- * and the error has already arrived).
-- *
-- * This function will not block even if the reply is not yet available.
-- *
-- * Note that the sequence really does have to come from xcb_send_request64();
-- * the cookie sequence number is defined as "unsigned" int and therefore
-- * not 64-bit on all platforms.
-- * This function is not designed to operate on socket-handoff replies.
-- *
-- * Unlike its xcb_discard_reply() counterpart, the given sequence number is not
-- * automatically "widened" to 64-bit.
--
procedure xcb_discard_reply64 (c : access xcb_connection_t; sequence : bits_stdint_uintn_h.uint64_t) -- /usr/include/xcb/xcb.h:412
with Import => True,
Convention => C,
External_Name => "xcb_discard_reply64";
-- xcb_ext.c
--*
-- * @brief Caches reply information from QueryExtension requests.
-- * @param c The connection.
-- * @param ext The extension data.
-- * @return A pointer to the xcb_query_extension_reply_t for the extension.
-- *
-- * This function is the primary interface to the "extension cache",
-- * which caches reply information from QueryExtension
-- * requests. Invoking this function may cause a call to
-- * xcb_query_extension to retrieve extension information from the
-- * server, and may block until extension data is received from the
-- * server.
-- *
-- * The result must not be freed. This storage is managed by the cache
-- * itself.
--
function xcb_get_extension_data (c : access xcb_connection_t; ext : access xcb_extension_t) return access constant xproto.xcb_query_extension_reply_t -- /usr/include/xcb/xcb.h:432
with Import => True,
Convention => C,
External_Name => "xcb_get_extension_data";
--*
-- * @brief Prefetch of extension data into the extension cache
-- * @param c The connection.
-- * @param ext The extension data.
-- *
-- * This function allows a "prefetch" of extension data into the
-- * extension cache. Invoking the function may cause a call to
-- * xcb_query_extension, but will not block waiting for the
-- * reply. xcb_get_extension_data will return the prefetched data after
-- * possibly blocking while it is retrieved.
--
procedure xcb_prefetch_extension_data (c : access xcb_connection_t; ext : access xcb_extension_t) -- /usr/include/xcb/xcb.h:445
with Import => True,
Convention => C,
External_Name => "xcb_prefetch_extension_data";
-- xcb_conn.c
--*
-- * @brief Access the data returned by the server.
-- * @param c The connection.
-- * @return A pointer to an xcb_setup_t structure.
-- *
-- * Accessor for the data returned by the server when the xcb_connection_t
-- * was initialized. This data includes
-- * - the server's required format for images,
-- * - a list of available visuals,
-- * - a list of available screens,
-- * - the server's maximum request length (in the absence of the
-- * BIG-REQUESTS extension),
-- * - and other assorted information.
-- *
-- * See the X protocol specification for more details.
-- *
-- * The result must not be freed.
--
function xcb_get_setup (c : access xcb_connection_t) return access constant xproto.xcb_setup_t -- /usr/include/xcb/xcb.h:468
with Import => True,
Convention => C,
External_Name => "xcb_get_setup";
--*
-- * @brief Access the file descriptor of the connection.
-- * @param c The connection.
-- * @return The file descriptor.
-- *
-- * Accessor for the file descriptor that was passed to the
-- * xcb_connect_to_fd call that returned @p c.
--
function xcb_get_file_descriptor (c : access xcb_connection_t) return int -- /usr/include/xcb/xcb.h:478
with Import => True,
Convention => C,
External_Name => "xcb_get_file_descriptor";
--*
-- * @brief Test whether the connection has shut down due to a fatal error.
-- * @param c The connection.
-- * @return > 0 if the connection is in an error state; 0 otherwise.
-- *
-- * Some errors that occur in the context of an xcb_connection_t
-- * are unrecoverable. When such an error occurs, the
-- * connection is shut down and further operations on the
-- * xcb_connection_t have no effect, but memory will not be freed until
-- * xcb_disconnect() is called on the xcb_connection_t.
-- *
-- * @return XCB_CONN_ERROR, because of socket errors, pipe errors or other stream errors.
-- * @return XCB_CONN_CLOSED_EXT_NOTSUPPORTED, when extension not supported.
-- * @return XCB_CONN_CLOSED_MEM_INSUFFICIENT, when memory not available.
-- * @return XCB_CONN_CLOSED_REQ_LEN_EXCEED, exceeding request length that server accepts.
-- * @return XCB_CONN_CLOSED_PARSE_ERR, error during parsing display string.
-- * @return XCB_CONN_CLOSED_INVALID_SCREEN, because the server does not have a screen matching the display.
--
function xcb_connection_has_error (c : access xcb_connection_t) return int -- /usr/include/xcb/xcb.h:498
with Import => True,
Convention => C,
External_Name => "xcb_connection_has_error";
--*
-- * @brief Connects to the X server.
-- * @param fd The file descriptor.
-- * @param auth_info Authentication data.
-- * @return A newly allocated xcb_connection_t structure.
-- *
-- * Connects to an X server, given the open socket @p fd and the
-- * xcb_auth_info_t @p auth_info. The file descriptor @p fd is
-- * bidirectionally connected to an X server. If the connection
-- * should be unauthenticated, @p auth_info must be @c
-- * NULL.
-- *
-- * Always returns a non-NULL pointer to a xcb_connection_t, even on failure.
-- * Callers need to use xcb_connection_has_error() to check for failure.
-- * When finished, use xcb_disconnect() to close the connection and free
-- * the structure.
--
function xcb_connect_to_fd (fd : int; auth_info : access xcb_auth_info_t) return access xcb_connection_t -- /usr/include/xcb/xcb.h:517
with Import => True,
Convention => C,
External_Name => "xcb_connect_to_fd";
--*
-- * @brief Closes the connection.
-- * @param c The connection.
-- *
-- * Closes the file descriptor and frees all memory associated with the
-- * connection @c c. If @p c is @c NULL, nothing is done.
--
procedure xcb_disconnect (c : access xcb_connection_t) -- /usr/include/xcb/xcb.h:526
with Import => True,
Convention => C,
External_Name => "xcb_disconnect";
-- xcb_util.c
--*
-- * @brief Parses a display string name in the form documented by X(7x).
-- * @param name The name of the display.
-- * @param host A pointer to a malloc'd copy of the hostname.
-- * @param display A pointer to the display number.
-- * @param screen A pointer to the screen number.
-- * @return 0 on failure, non 0 otherwise.
-- *
-- * Parses the display string name @p display_name in the form
-- * documented by X(7x). Has no side effects on failure. If
-- * @p displayname is @c NULL or empty, it uses the environment
-- * variable DISPLAY. @p hostp is a pointer to a newly allocated string
-- * that contain the host name. @p displayp is set to the display
-- * number and @p screenp to the preferred screen number. @p screenp
-- * can be @c NULL. If @p displayname does not contain a screen number,
-- * it is set to @c 0.
--
function xcb_parse_display
(name : Interfaces.C.Strings.chars_ptr;
host : System.Address;
display : access int;
screen : access int) return int -- /usr/include/xcb/xcb.h:548
with Import => True,
Convention => C,
External_Name => "xcb_parse_display";
--*
-- * @brief Connects to the X server.
-- * @param displayname The name of the display.
-- * @param screenp A pointer to a preferred screen number.
-- * @return A newly allocated xcb_connection_t structure.
-- *
-- * Connects to the X server specified by @p displayname. If @p
-- * displayname is @c NULL, uses the value of the DISPLAY environment
-- * variable. If a particular screen on that server is preferred, the
-- * int pointed to by @p screenp (if not @c NULL) will be set to that
-- * screen; otherwise the screen will be set to 0.
-- *
-- * Always returns a non-NULL pointer to a xcb_connection_t, even on failure.
-- * Callers need to use xcb_connection_has_error() to check for failure.
-- * When finished, use xcb_disconnect() to close the connection and free
-- * the structure.
--
function xcb_connect (displayname : Interfaces.C.Strings.chars_ptr; screenp : access int) return access xcb_connection_t -- /usr/include/xcb/xcb.h:567
with Import => True,
Convention => C,
External_Name => "xcb_connect";
--*
-- * @brief Connects to the X server, using an authorization information.
-- * @param display The name of the display.
-- * @param auth The authorization information.
-- * @param screen A pointer to a preferred screen number.
-- * @return A newly allocated xcb_connection_t structure.
-- *
-- * Connects to the X server specified by @p displayname, using the
-- * authorization @p auth. If a particular screen on that server is
-- * preferred, the int pointed to by @p screenp (if not @c NULL) will
-- * be set to that screen; otherwise @p screenp will be set to 0.
-- *
-- * Always returns a non-NULL pointer to a xcb_connection_t, even on failure.
-- * Callers need to use xcb_connection_has_error() to check for failure.
-- * When finished, use xcb_disconnect() to close the connection and free
-- * the structure.
--
function xcb_connect_to_display_with_auth_info
(display : Interfaces.C.Strings.chars_ptr;
auth : access xcb_auth_info_t;
screen : access int) return access xcb_connection_t -- /usr/include/xcb/xcb.h:586
with Import => True,
Convention => C,
External_Name => "xcb_connect_to_display_with_auth_info";
-- xcb_xid.c
--*
-- * @brief Allocates an XID for a new object.
-- * @param c The connection.
-- * @return A newly allocated XID.
-- *
-- * Allocates an XID for a new object. Typically used just prior to
-- * various object creation functions, such as xcb_create_window.
--
function xcb_generate_id (c : access xcb_connection_t) return bits_stdint_uintn_h.uint32_t -- /usr/include/xcb/xcb.h:599
with Import => True,
Convention => C,
External_Name => "xcb_generate_id";
--*
-- * @brief Obtain number of bytes read from the connection.
-- * @param c The connection
-- * @return Number of bytes read from the server.
-- *
-- * Returns cumulative number of bytes received from the connection.
-- *
-- * This retrieves the total number of bytes read from this connection,
-- * to be used for diagnostic/monitoring/informative purposes.
--
function xcb_total_read (c : access xcb_connection_t) return bits_stdint_uintn_h.uint64_t -- /usr/include/xcb/xcb.h:614
with Import => True,
Convention => C,
External_Name => "xcb_total_read";
--*
-- *
-- * @brief Obtain number of bytes written to the connection.
-- * @param c The connection
-- * @return Number of bytes written to the server.
-- *
-- * Returns cumulative number of bytes sent to the connection.
-- *
-- * This retrieves the total number of bytes written to this connection,
-- * to be used for diagnostic/monitoring/informative purposes.
--
function xcb_total_written (c : access xcb_connection_t) return bits_stdint_uintn_h.uint64_t -- /usr/include/xcb/xcb.h:629
with Import => True,
Convention => C,
External_Name => "xcb_total_written";
--*
-- * @}
--
end xcb;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--*
-- CHECK ARRAY CONVERSIONS WHEN THE TARGET TYPE IS A CONSTRAINED
-- ARRAY TYPE AND THE OPERAND TYPE HAS BOUNDS THAT DO NOT BELONG TO
-- THE BASE TYPE OF THE TARGET TYPE'S INDEX SUBTYPE.
-- R.WILLIAMS 9/8/86
WITH REPORT; USE REPORT;
PROCEDURE C46042A IS
TYPE INT IS RANGE -100 .. 100;
TYPE NEWINTEGER IS NEW INTEGER;
TYPE DAY IS (SUN, MON, TUE, WED, THU, FRI, SAT);
TYPE NDAY1 IS NEW DAY RANGE MON .. FRI;
TYPE NDAY2 IS NEW DAY RANGE MON .. FRI;
TYPE NNDAY1 IS NEW NDAY1;
FUNCTION IDENT (X : INT) RETURN INT IS
BEGIN
RETURN INT'VAL (IDENT_INT (INT'POS (X)));
END IDENT;
FUNCTION IDENT (X : NEWINTEGER) RETURN NEWINTEGER IS
BEGIN
RETURN NEWINTEGER'VAL (IDENT_INT (NEWINTEGER'POS (X)));
END IDENT;
FUNCTION IDENT (X : NDAY1) RETURN NDAY1 IS
BEGIN
RETURN NDAY1'VAL (IDENT_INT (NDAY1'POS (X)));
END IDENT;
FUNCTION IDENT (X : NDAY2) RETURN NDAY2 IS
BEGIN
RETURN NDAY2'VAL (IDENT_INT (NDAY2'POS (X)));
END IDENT;
FUNCTION IDENT (X : NNDAY1) RETURN NNDAY1 IS
BEGIN
RETURN NNDAY1'VAL (IDENT_INT (NNDAY1'POS (X)));
END IDENT;
BEGIN
TEST ( "C46042A", "CHECK ARRAY CONVERSIONS WHEN THE TARGET " &
"TYPE IS A CONSTRAINED ARRAY TYPE AND THE " &
"OPERAND TYPE HAS BOUNDS THAT DO NOT " &
"BELONG TO THE BASE TYPE OF THE TARGET " &
"TYPE'S INDEX SUBTYPE" );
DECLARE
TYPE UNARR1 IS ARRAY (INTEGER RANGE <>) OF INTEGER;
SUBTYPE CONARR1 IS UNARR1 (IDENT_INT (1) .. IDENT_INT (10));
TYPE UNARR2 IS ARRAY (INTEGER RANGE <>, NDAY1 RANGE <>)
OF INTEGER;
SUBTYPE CONARR2 IS UNARR2 (IDENT_INT (1) .. IDENT_INT (10),
IDENT (MON) .. IDENT (TUE));
TYPE ARR1 IS ARRAY (INT RANGE <>) OF INTEGER;
A1 : ARR1 (IDENT (11) .. IDENT (20)) :=
(IDENT (11) .. IDENT (20) => 0);
TYPE ARR2 IS ARRAY (INT RANGE <>, NDAY2 RANGE <>)
OF INTEGER;
A2 : ARR2 (IDENT (11) .. IDENT (20),
IDENT (WED) .. IDENT (THU)) :=
(IDENT (11) .. IDENT (20) =>
(IDENT (WED) .. IDENT (THU) => 0));
TYPE ARR3 IS ARRAY (NEWINTEGER RANGE <>, NNDAY1 RANGE <>)
OF INTEGER;
A3 : ARR3 (IDENT (11) .. IDENT (20),
IDENT (WED) .. IDENT (THU)) :=
(IDENT (11) .. IDENT (20) =>
(IDENT (WED) .. IDENT (THU) => 0));
PROCEDURE CHECK (A : UNARR1) IS
BEGIN
IF A'FIRST /= 1 OR A'LAST /= 10 THEN
FAILED ( "INCORRECT CONVERSION OF UNARR1 (A1)" );
END IF;
END CHECK;
PROCEDURE CHECK (A : UNARR2; STR : STRING) IS
BEGIN
IF A'FIRST (1) /= 1 OR A'LAST /= 10 OR
A'FIRST (2) /= MON OR A'LAST (2) /= TUE THEN
FAILED ( "INCORRECT CONVERSION OF UNARR2 (A" &
STR & ")" );
END IF;
END CHECK;
BEGIN
BEGIN
CHECK (CONARR1 (A1));
EXCEPTION
WHEN OTHERS =>
FAILED ( "EXCEPTION RAISED BY 'CONARR1 (A1)'" );
END;
BEGIN
CHECK (CONARR2 (A2), "2");
EXCEPTION
WHEN OTHERS =>
FAILED ( "EXCEPTION RAISED BY 'CONARR2 (A2)'" );
END;
BEGIN
CHECK (CONARR2 (A3), "3");
EXCEPTION
WHEN OTHERS =>
FAILED ( "EXCEPTION RAISED BY 'CONARR2 (A3)'" );
END;
END;
RESULT;
END C46042A;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Units; use Units;
-- @summary
-- Interface to use a buzzer/beeper.
package Buzzer_Manager with SPARK_Mode is
-- subtype T_Name is Character
-- with Static_Predicate => T_Name in 'a' .. 'g'; -- c,d,e,f,g,a,b
-- subtype T_Octave is Integer range 3 .. 8;
-- type Tone_Type is record
-- name : T_Name;
-- octave : T_Octave; -- 3=small octave
-- end record;
-- -- A4 = 440Hz
--
-- type Song_Type is array (Positive range <>) of Tone_Type;
procedure Initialize;
procedure Tick;
-- call this periodically to manage the buzzer
function Valid_Frequency (f : Frequency_Type) return Boolean is
(f > 0.0 * Hertz);
-- procedure Set_Tone (t : Tone_Type);
--
-- function Tone_To_Frequency (tone : Tone_Type) return Frequency_Type;
-- -- compute the frequency for the given tone name.
-- -- Examples:
-- -- a' => 400
procedure Beep
(f : in Frequency_Type;
Reps : Natural;
Period : Time_Type;
Length : in Time_Type);
-- beep given number of times. If reps = 0, then infinite.
private
procedure Reconfigure_Buzzer;
end Buzzer_Manager;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
package body ADO.Statements.Create is
-- ------------------------------
-- Create the query statement
-- ------------------------------
function Create_Statement (Proxy : Query_Statement_Access) return Query_Statement is
begin
return Result : Query_Statement do
Result.Query := Proxy.Get_Query;
Result.Proxy := Proxy;
Result.Proxy.Ref_Counter := 1;
end return;
end Create_Statement;
-- ------------------------------
-- Create the delete statement
-- ------------------------------
function Create_Statement (Proxy : Delete_Statement_Access) return Delete_Statement is
begin
return Result : Delete_Statement do
Result.Query := Proxy.Get_Query;
Result.Proxy := Proxy;
Result.Proxy.Ref_Counter := 1;
end return;
end Create_Statement;
-- ------------------------------
-- Create an update statement
-- ------------------------------
function Create_Statement (Proxy : Update_Statement_Access) return Update_Statement is
begin
return Result : Update_Statement do
Result.Update := Proxy.Get_Update_Query;
Result.Query := Result.Update.all'Access;
Result.Proxy := Proxy;
Result.Proxy.Ref_Counter := 1;
end return;
end Create_Statement;
-- ------------------------------
-- Create the insert statement.
-- ------------------------------
function Create_Statement (Proxy : Update_Statement_Access) return Insert_Statement is
begin
return Result : Insert_Statement do
Result.Update := Proxy.Get_Update_Query;
Result.Query := Result.Update.all'Access;
Result.Proxy := Proxy;
Result.Proxy.Ref_Counter := 1;
end return;
end Create_Statement;
end ADO.Statements.Create;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
------------------------------------------------------------------------------
-- philosophers.adb
--
-- Implementation of the philosophers.
------------------------------------------------------------------------------
with Randoms, Meals, Chopsticks, Host, Orders, Reporter, Waiters;
use Randoms, Meals, Chopsticks, Host, Orders, Reporter, Waiters;
with Ada.Strings.Unbounded;
use Ada.Strings.Unbounded;
with Ada.Text_IO;
package body Philosophers is
task body Philosopher is
My_Index : Philosopher_Name;
My_Name : Unbounded_String;
Wealth : Float := 30.00;
Left : Chopstick_Name;
Right : Chopstick_Name;
My_Order : Order;
Cooking : Boolean;
begin
accept Here_Is_Your_Name (Name: Philosopher_Name) do
My_Index := Name;
My_Name := To_Unbounded_String(Philosopher_Name'Image(Name));
end Here_Is_Your_Name;
Left := Chopstick_Name(Philosopher_Name'Pos(My_Index));
Right := (Chopstick_Name'Pos(Left) + 1) mod (Chopstick_Name'Last + 1);
while Wealth > 0.0 loop
Norman_Bates.Enter;
Report (My_Name & " enters the cafe");
Report (My_Name & " is thinking");
delay Duration(Random(1,3));
My_Order := (My_Index, Random_Meal);
Report (My_Name & " has decided to order " & My_Order.Food);
select
Waiter_Array(Waiter_Name'Val(Random(0,1))).Place_Order(My_Order, My_Index, Cooking);
or
delay 35.0;
Report (My_Name & " cancels order and complains about lousy service");
end select;
if Cooking then
accept Here_Is_Your_Food;
Chopstick_Array(Right).Pick_Up;
Chopstick_Array(Left).Pick_Up;
Report (My_Name & " is eating " & My_Order.Food);
delay (12.0);
Chopstick_Array(Right).Put_Down;
Chopstick_Array(Left).Put_Down;
Report (My_Name & " pays for the " & My_Order.Food);
Wealth := Wealth - Price(My_Order.Food);
else
Report (My_Name & " receives a coupon");
Wealth := Wealth + 5.00;
end if;
Report (My_Name & " leaves the restaurant");
Norman_Bates.Leave;
end loop;
Report (My_Name & " died a normal death from overeating");
Norman_Bates.Death_Announcement;
exception
when others => Report ("Error: " & My_Name & " dead unexpectedly");
end Philosopher;
end Philosophers;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--*
-- CHECK THAT IF THE RENDEZVOUS IS NOT IMMEDIATELY POSSIBLE BUT BECOMES
-- POSSIBLE BEFORE THE DELAY EXPIRES, THE TIMED ENTRY CALL IS ACCEPTED.
-- CASE A: SINGLE ENTRY; THE CALLED TASK IS EXECUTING AN ACCEPT
-- STATEMENT.
-- WRG 7/13/86
-- PWN 11/30/94 REMOVED PRAGMA PRIORITY INSTANCES FOR ADA 9X.
with Impdef;
WITH REPORT; USE REPORT;
WITH SYSTEM; USE SYSTEM;
PROCEDURE C97305C IS
RENDEZVOUS_OCCURRED : BOOLEAN := FALSE;
STATEMENTS_AFTER_CALL_EXECUTED : BOOLEAN := FALSE;
DELAY_IN_MINUTES : CONSTANT POSITIVE := 30;
BEGIN
TEST ("C97305C", "CHECK THAT IF THE RENDEZVOUS IS NOT " &
"IMMEDIATELY POSSIBLE BUT BECOMES POSSIBLE " &
"BEFORE THE DELAY EXPIRES, THE TIMED ENTRY " &
"CALL IS ACCEPTED");
DECLARE
TASK T IS
ENTRY E (B : IN OUT BOOLEAN);
END T;
TASK BODY T IS
BEGIN
DELAY 10.0 * Impdef.One_Long_Second;
ACCEPT E (B : IN OUT BOOLEAN) DO
B := IDENT_BOOL (TRUE);
END E;
END T;
BEGIN
SELECT
T.E (RENDEZVOUS_OCCURRED);
STATEMENTS_AFTER_CALL_EXECUTED := IDENT_BOOL (TRUE);
OR
DELAY DELAY_IN_MINUTES * 60.0 * Impdef.One_Long_Second;
FAILED ("TIMED ENTRY CALL NOT ACCEPTED AFTER" &
POSITIVE'IMAGE(DELAY_IN_MINUTES) &
" MINUTES ELAPSED");
END SELECT;
END;
IF NOT RENDEZVOUS_OCCURRED THEN
FAILED ("RENDEZVOUS DID NOT OCCUR");
END IF;
IF NOT STATEMENTS_AFTER_CALL_EXECUTED THEN
FAILED ("STATEMENTS AFTER ENTRY CALL NOT EXECUTED");
END IF;
RESULT;
END C97305C;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ahven.Framework;
with Unknown.Api;
package Test_Foreign.Read is
package Skill renames Unknown.Api;
use Unknown;
use Unknown.Api;
type Test is new Ahven.Framework.Test_Case with null record;
procedure Initialize (T : in out Test);
procedure Aircraft;
procedure Annotation_Test;
procedure Colored_Nodes;
procedure Constant_Maybe_Wrong;
procedure Container;
procedure Date_Example;
procedure Four_Colored_Nodes;
procedure Local_Base_Pool_Start_Index;
procedure Node;
procedure Null_Annotation;
procedure Two_Node_Blocks;
end Test_Foreign.Read;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--******************************************************************************
--
-- package STANDARD
--
--******************************************************************************
package STANDARD is
-- This is the Digital Equipment Corporation VAX/VMS version of the
-- Ada standard and system packages.
type BOOLEAN is (FALSE, TRUE);
-- The predefined relational operators for this type are as follows:
-- function "=" (LEFT, RIGHT : BOOLEAN) return BOOLEAN;
-- function "/=" (LEFT, RIGHT : BOOLEAN) return BOOLEAN;
-- function "<" (LEFT, RIGHT : BOOLEAN) return BOOLEAN;
-- function "<=" (LEFT, RIGHT : BOOLEAN) return BOOLEAN;
-- function ">" (LEFT, RIGHT : BOOLEAN) return BOOLEAN;
-- function ">=" (LEFT, RIGHT : BOOLEAN) return BO0LEAN;
-- The predefined logical operators and the predefined logical negation
-- operator are as follows:
-- function "and" (LEFT, RIGHT : BOOLEAN) return BOOLEAN;
-- function "or" (LEFT, RIGHT : BOOLEAN) return BOOLEAN;
-- function "xor" (LEFT, RIGHT : BOOLEAN) return BOOLEAN;
-- function "not" (LEFT, RIGHT : BOOLEAN) return BOOLEAN;
-- The universal type universal_integer is predefined.
type INTEGER is range -2147483648 .. 2147483647;
-- The predefined operators for this type are as follows:
-- function "=" (LEFT, RIGHT : INTEGER) return BOOLEAN;
-- function "/=" (LEFT, RIGHT : INTEGER) return BOOLEAN;
-- function "<" (LEFT, RIGHT : INTEGER) return BOOLEAN;
-- function "<=" (LEFT, RIGHT : INTEGER) return BOOLEAN;
-- function ">" (LEFT, RIGHT : INTEGER) return BOOLEAN;
-- function ">=" (LEFT, RIGHT : INTEGER) return BOOLEAN;
-- function "+" (RIGHT : INTEGER) return INTEGER;
-- function "-" (RIGHT : INTEGER) return INTEGER;
-- function "abs" (RIGHT : INTEGER) return INTEGER;
-- function "+" (LEFT, RIGHT : INTEGER) return INTEGER;
-- function "-" (LEFT, RIGHT : INTEGER) return INTEGER;
-- function "*" (LEFT, RIGHT : INTEGER) return INTEGER;
-- function "/" (LEFT, RIGHT : INTEGER) return INTEGER;
-- function "rem" (LEFT, RIGHT : INTEGER) return INTEGER;
-- function "mod" (LEFT, RIGHT : INTEGER) return INTEGER;
-- function "**" (LEFT, : INTEGER; RIGHT : INTEGER) return INTEGER;
-- An implementation may provide additional predefined integer types.
-- It is recommended that the names of such additional types end
-- with INTEGER as in SHORT_INTEGER or LONG_INTEGER. The specification
-- of each operator for the type universal_integer, or for
-- any additional predefined integer type, is obtained by replacing
-- INTEGER by the name of the type in the specification of the
-- corresponding operator of the type INTEGER, except for the right
-- operand of the exponentiating operator.
type SHORT_INTEGER is range -32768 .. 32767;
type SHORT_SHORT_INTEGER is range -128 .. 127;
type LONG_INTEGER is range -2147483648 .. 2147483647;
type LONG_LONG_INTEGER is range -2147483648 .. 2147483647;
-- The universal type universal_real is predefined.
type FLOAT is digits 6 range -1.70141E+38 .. 1.70141E+38;
-- The predefined operators for this type are as follows:
-- function "=" (LEFT, RIGHT : FLOAT) return BOOLEAN;
-- function "/=" (LEFT, RIGHT : FLOAT) return BOOLEAN;
-- function "<" (LEFT, RIGHT : FLOAT) return BOOLEAN;
-- function "<=" (LEFT, RIGHT : FLOAT) return BOOLEAN;
-- function ">" (LEFT, RIGHT : FLOAT) return BOOLEAN;
-- function ">=" (LEFT, RIGHT : FLOAT) return BOOLEAN;
-- function "+" (RIGHT : FLOAT) return FLOAT;
-- function "-" (RIGHT : FLOAT) return FLOAT;
-- function "abs" (RIGHT : FLOAT) return FLOAT;
-- function "+" (LEFT, RIGHT : FLOAT) return FLOAT;
-- function "-" (LEFT, RIGHT : FLOAT) return FLOAT;
-- function "*" (LEFT, RIGHT : FLOAT) return FLOAT;
-- function "/" (LEFT, RIGHT : FLOAT) return FLOAT;
-- function "**" (LEFT : FLOAT; RIGHT : INTEGER) return FLOAT;
-- An implementation may provide additional predefined floating point
-- types. It is recommended that the names of such additional types
-- end with FLOAT as in SHORT_FLOAT or LONG_FLOAT. The specification
-- of each operator for the type universal_real, or for any additional
-- predefined floating point type, is obtained by replacing FLOAT by
-- the name of the type in the specification of the corresponding
-- operator of the type FLOAT.
type SHORT_FLOAT is digits 14 range -1.7014118346047E+38 .. 1.7014118346047E38;
type LONG_FLOAT is digits 14 range -1.7014118346047E+38 .. 1.7014118346047E+38;
type LONG_LONG_FLOAT is digits 32 range -5.948657467861588254287966331400E+4931 ..
5.948657467861588254287966331400E+4931;
-- In addition, the following operators are predefined for universal types:
-- function "*" (LEFT : universal_integer;
-- RIGHT : universal_real) return universal_real;
-- function "*" (LEFT : universal_real;
-- RIGHT : universal_integer) return universal_real;
-- function "/" (LEFT : universal_real;
-- RIGHT : universal_integer) return universal_real;
-- The type universal_fixed is predefined. The only operators
-- declared for this type are
-- function "*" (LEFT : any_fixed_point_type;
-- RIGHT : any_fixed_point_type) return universal_fixed;
-- function "/" (LEFT : any_fixed_point_type;
-- RIGHT : any_fixed_point_type) return universal_fixed;
-- The following characters form the standard ASCII character set.
-- Character literals corresponding to control characters are not
-- identifiers; they are indicated in italics in this definition.
type CHARACTER is
(nul, soh, stx, etx, eot, enq, ack, bel,
bs, ht, lf, vt, ff, cr, so, si,
dle, dc1, dc2, dc3, dc4, nak, syn, etb,
can, em, sub, esc, fs, gs, rs, us,
' ', '!', '"', '#', '$', '%', '&', ''',
'(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', ':', ';', '<', '=', '>', '?',
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '[', '\', ']', '^', '_',
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', '{', '|', '}', '~', del);
for CHARACTER use -- 128 ASCII character set without holes
( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103,104,105,106,107,
108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,
126,127 );
-- The predefined operators for the type CHARACTER are the same
-- as for any enumeration type.
--***************************************************************************
--
-- package ASCII
--
--***************************************************************************
package ASCII is
-- Control characters:
NUL : constant CHARACTER := nul;
SOH : constant CHARACTER := soh;
STX : constant CHARACTER := stx;
ETX : constant CHARACTER := etx;
EOT : constant CHARACTER := eot;
ENQ : constant CHARACTER := enq;
ACK : constant CHARACTER := ack;
BEL : constant CHARACTER := bel;
BS : constant CHARACTER := bs;
HT : constant CHARACTER := ht;
LF : constant CHARACTER := lf;
VT : constant CHARACTER := vt;
FF : constant CHARACTER := ff;
CR : constant CHARACTER := cr;
SO : constant CHARACTER := so;
SI : constant CHARACTER := si;
DLE : constant CHARACTER := dle;
DC1 : constant CHARACTER := dc1;
DC2 : constant CHARACTER := dc2;
DC3 : constant CHARACTER := dc3;
DC4 : constant CHARACTER := dc4;
NAK : constant CHARACTER := nak;
SYN : constant CHARACTER := syn;
ETB : constant CHARACTER := etb;
CAN : constant CHARACTER := can;
EM : constant CHARACTER := em;
SUB : constant CHARACTER := sub;
ESC : constant CHARACTER := esc;
FS : constant CHARACTER := fs;
GS : constant CHARACTER := gs;
RS : constant CHARACTER := rs;
US : constant CHARACTER := us;
DEL : constant CHARACTER := del;
-- Other characters:
EXCLAM : constant CHARACTER := '!';
QUOTATION : constant CHARACTER := '"';
SHARP : constant CHARACTER := '#';
DOLLAR : constant CHARACTER := '$';
PERCENT : constant CHARACTER := '%';
AMPERSAND : constant CHARACTER := '&';
COLON : constant CHARACTER := ':';
SEMICOLON : constant CHARACTER := ';';
QUERY : constant CHARACTER := '?';
AT_SIGN : constant CHARACTER := '@';
L_BRACKET : constant CHARACTER := '[';
BACK_SLASH : constant CHARACTER := '\';
R_BRACKET : constant CHARACTER := ']';
CIRCUMFLEX : constant CHARACTER := '^';
UNDERLINE : constant CHARACTER := '_';
GRAVE : constant CHARACTER := '`';
L_BRACE : constant CHARACTER := '{';
BAR : constant CHARACTER := '|';
R_BRACE : constant CHARACTER := '}';
TILDE : constant CHARACTER := '~';
-- Lower case letters:
LC_A : constant CHARACTER := 'a';
LC_B : constant CHARACTER := 'b';
LC_C : constant CHARACTER := 'c';
LC_D : constant CHARACTER := 'd';
LC_E : constant CHARACTER := 'e';
LC_F : constant CHARACTER := 'f';
LC_G : constant CHARACTER := 'g';
LC_H : constant CHARACTER := 'h';
LC_I : constant CHARACTER := 'i';
LC_J : constant CHARACTER := 'j';
LC_K : constant CHARACTER := 'k';
LC_L : constant CHARACTER := 'l';
LC_M : constant CHARACTER := 'm';
LC_N : constant CHARACTER := 'n';
LC_O : constant CHARACTER := 'o';
LC_P : constant CHARACTER := 'p';
LC_Q : constant CHARACTER := 'q';
LC_R : constant CHARACTER := 'r';
LC_S : constant CHARACTER := 's';
LC_T : constant CHARACTER := 't';
LC_U : constant CHARACTER := 'u';
LC_V : constant CHARACTER := 'v';
LC_W : constant CHARACTER := 'w';
LC_X : constant CHARACTER := 'x';
LC_Y : Constant CHARACTER := 'y';
LC_Z : Constant CHARACTER := 'z';
end ASCII;
-- Predefined subtypes:
subtype NATURAL is INTEGER range 0 .. INTEGER'LAST;
subtype POSITIVE is INTEGER range 1 .. INTEGER'LAST;
-- Predefined string type:
type STRING is array(POSITIVE range<>) of CHARACTER;
pragma PACK(STRING);
-- The predefined operators for this type are as follows:
-- function "=" (LEFT, RIGHT : STRING) return BOOLEAN;
-- function "/" (LEFT, RIGHT : STRING) return BOOLEAN;
-- function "<" (LEFT, RIGHT : STRING) return BOOLEAN;
-- function "<=" (LEFT, RIGHT : STRING) return BOOLEAN;
-- function ">" (LEFT, RIGHT : STRING) return BOOLEAN;
-- function ">=" (LEFT, RIGHT : STRING) return BOOLEAN;
-- function "&" (LEFT : STRING;
-- RIGHT : STRING) return STRING;
-- function "&" (LEFT : CHARACTER;
-- RIGHT : STRING) return STRING;
-- function "&" (LEFT : STRING;
-- RIGHT : CHARACTER) return STRING;
-- function "&" (LEFT : CHARACTER;
-- RIGHT : CHARACTER) return STRING;
type DURATION is delta 1.00000E-04 range -131072.0000 .. 131071.9999;
-- The predefined operators for the type DURATION are the same as for
-- any fixed point type.
-- The predefined exceptions:
CONSTRAINT_ERROR : exception;
NUMERIC_ERROR : exception;
PROGRAM_ERROR : exception;
STORAGE_ERROR : exception;
TASKING_ERROR : exception;
end STANDARD;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with
AdaM.Entity;
private
with
ada.Streams;
package AdaM.Comment
is
type Item is new Entity.item with private;
type View is access all Item'Class;
-- Forge
--
function new_Comment return Comment.view;
procedure free (Self : in out Comment.view);
procedure destruct (Self : in out Item);
-- Attributes
--
overriding
function Id (Self : access Item) return AdaM.Id;
function Lines (Self : in Item) return text_Lines;
procedure Lines_are (Self : in out Item; Now : in text_Lines);
overriding
function to_Source (Self : in Item) return text_Vectors.Vector;
overriding
function Name (Self : in Item) return Identifier;
private
type Item is new Entity.item with
record
Lines : text_Lines;
end record;
-- Streams
--
procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : in View);
procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : out View);
for View'write use View_write;
for View'read use View_read;
end AdaM.Comment;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-------------------------------------------------------------
with League.Strings;
with Incr.Nodes.Tokens;
package body Incr.Parsers.Incremental is
---------
-- Run --
---------
procedure Run
(Self : Incremental_Parser;
Lexer : Incr.Lexers.Incremental.Incremental_Lexer_Access;
Provider : Parser_Data_Providers.Parser_Data_Provider_Access;
Factory : Parser_Data_Providers.Node_Factory_Access;
Document : Documents.Document_Access;
Reference : Version_Trees.Version)
is
pragma Unreferenced (Self);
use Parser_Data_Providers;
use type Nodes.Node_Kind;
Stack_Length : constant := 256;
type State_Array is array (1 .. Stack_Length) of Parser_State;
type Parser_Stack is record
Top : Natural;
State : State_Array;
Node : Nodes.Node_Array (1 .. Stack_Length);
end record;
procedure Clear (Self : out Parser_Stack);
procedure Push
(Self : in out Parser_Stack;
State : Parser_State;
Node : Nodes.Node_Access);
procedure Pop
(Self : in out Parser_Stack;
State : out Parser_State;
Node : out Nodes.Node_Access);
procedure On_Reduce (Parts : Production_Index);
procedure On_Shift
(State : in out Parser_State;
New_State : Parser_State;
Node : access Nodes.Node'Class);
procedure Do_Shift (Node : Nodes.Node_Access);
function Left_Breakdown
(Node : Nodes.Node_Access) return Nodes.Node_Access;
procedure Right_Breakdown;
procedure Recover (LA : out Nodes.Node_Access);
procedure Recover_2 (LA : out Nodes.Node_Access);
Stack : Parser_Stack;
State : Parser_State := 1;
Now : constant Version_Trees.Version := Document.History.Changing;
Previous : constant Version_Trees.Version :=
Document.History.Parent (Now);
Next_Action : constant Action_Table_Access := Provider.Actions;
Next_State : constant State_Table_Access := Provider.States;
Counts : constant Parts_Count_Table_Access := Provider.Part_Counts;
procedure Clear (Self : out Parser_Stack) is
begin
Self.Top := 0;
end Clear;
--------------
-- Do_Shift --
--------------
procedure Do_Shift (Node : Nodes.Node_Access) is
begin
if Node.Is_Token then
-- Next_Action should be shift
On_Shift (State, Next_Action (State, Node.Kind).State, Node);
else
On_Shift (State, Next_State (State, Node.Kind), Node);
end if;
end Do_Shift;
--------------------
-- Left_Breakdown --
--------------------
function Left_Breakdown
(Node : Nodes.Node_Access) return Nodes.Node_Access is
begin
if Node.Arity > 0 then
return Node.Child (1, Reference);
else
return Node.Next_Subtree (Reference);
end if;
end Left_Breakdown;
---------------
-- On_Reduce --
---------------
procedure On_Reduce (Parts : Production_Index) is
Count : constant Natural := Counts (Parts);
subtype First_Nodes is Nodes.Node_Array (1 .. Count);
Kind : Nodes.Node_Kind;
begin
Stack.Top := Stack.Top - Count + 1;
Factory.Create_Node
(Parts,
First_Nodes (Stack.Node (Stack.Top .. Stack.Top + Count - 1)),
Stack.Node (Stack.Top),
Kind);
if Count = 0 then
Stack.State (Stack.Top) := State;
end if;
State := Next_State (Stack.State (Stack.Top), Kind);
end On_Reduce;
--------------
-- On_Shift --
--------------
procedure On_Shift
(State : in out Parser_State;
New_State : Parser_State;
Node : access Nodes.Node'Class) is
begin
Push (Stack, State, Nodes.Node_Access (Node));
State := New_State;
end On_Shift;
---------
-- Pop --
---------
procedure Pop
(Self : in out Parser_Stack;
State : out Parser_State;
Node : out Nodes.Node_Access) is
begin
State := Self.State (Self.Top);
Node := Self.Node (Self.Top);
Self.Top := Self.Top - 1;
end Pop;
----------
-- Push --
----------
procedure Push
(Self : in out Parser_Stack;
State : Parser_State;
Node : Nodes.Node_Access) is
begin
Self.Top := Self.Top + 1;
Self.State (Self.Top) := State;
Self.Node (Self.Top) := Node;
Node.Set_Local_Errors (False);
end Push;
-------------
-- Recover --
-------------
procedure Recover (LA : out Nodes.Node_Access) is
begin
if Stack.Top > 1 then
-- Remove any default reductions from the parse stack
Right_Breakdown;
end if;
Recover_2 (LA);
end Recover;
---------------
-- Recover_2 --
---------------
procedure Recover_2 (LA : out Nodes.Node_Access) is
type Offset_Array is array (Positive range <>) of Natural;
function Is_Valid_Isolation
(Node : Nodes.Node_Access;
Offset : Natural;
State : Parser_State) return Boolean;
function Node_Offset
(Node : Nodes.Node_Access;
Time : Version_Trees.Version) return Natural;
-- Compute offset of Node in given Time
function Get_Cut
(Node : Nodes.Node_Access;
Offset : Offset_Array;
Top : Positive) return Natural;
-- Compute stack entry corresponding to leading edge of node’s
-- subtree in the previous version. Returns False if no entry is
-- so aligned. Top limits stack depth search.
procedure Isolate (Node : Nodes.Node_Access; Top : Positive);
-- Resets configuration so parsing can continue.
procedure Refine (Node : Nodes.Node_Access);
-- Isolate the argument and recursively recover the subtree that it
-- roots.
procedure Discard_Changes_And_Mark_Errors
(Node : access Nodes.Node'Class);
Jam_Offset : Natural;
-------------------------------------
-- Discard_Changes_And_Mark_Errors --
-------------------------------------
procedure Discard_Changes_And_Mark_Errors
(Node : access Nodes.Node'Class) is
begin
Node.Discard;
if Node.Local_Changes (Reference, Now) then
Node.Set_Local_Errors (True);
end if;
end Discard_Changes_And_Mark_Errors;
-------------
-- Get_Cut --
-------------
function Get_Cut
(Node : Nodes.Node_Access;
Offset : Offset_Array;
Top : Positive) return Natural
is
Old_Offset : constant Natural := Node_Offset (Node, Previous);
begin
for J in 1 .. Top loop
if Offset (J) > Old_Offset then
return 0;
elsif Offset (J) = Old_Offset then
for K in J + 1 .. Top loop
if Offset (K) /= Offset (J) then
return K - 1;
end if;
end loop;
return J;
end if;
end loop;
return 0;
end Get_Cut;
------------------------
-- Is_Valid_Isolation --
------------------------
function Is_Valid_Isolation
(Node : Nodes.Node_Access;
Offset : Natural;
State : Parser_State) return Boolean
is
Old_Offset : constant Natural := Node_Offset (Node, Previous);
begin
if Offset /= Old_Offset then
-- The starting offset of the subtree must be the same in both
-- the previous and current versions.
-- I have no idea how this could fail???
return False;
elsif Offset > Jam_Offset then
-- Cannot be to the right of the point where the error was
-- detected by the parser.
return False;
elsif Offset + Node.Span (Nodes.Text_Length, Previous) <=
Jam_Offset
then
-- The ending offset must meet or exceed the detection point.
return False;
elsif Node.Span (Nodes.Text_Length, Previous) /=
Node.Span (Nodes.Text_Length, Now)
then
-- The subtree span must the same in current and prev versions.
return False;
end if;
declare
Right : constant Nodes.Tokens.Token_Access :=
Node.Last_Token (Previous);
Next : constant Nodes.Tokens.Token_Access :=
Right.Next_Token (Previous);
begin
-- Check if lexical analysis cross right edge of Node
if Right.Get_Flag (Nodes.Need_Analysis) and
(Next not in null and then
Next.Get_Flag (Nodes.Need_Analysis))
then
return False;
end if;
end;
-- Now see if the parser is willing to accept this isolation, as
-- determined by the shiftability of its root symbol in the
-- given state.
return Next_Action (State, Node.Kind).Kind = Shift;
end Is_Valid_Isolation;
-------------
-- Isolate --
-------------
procedure Isolate (Node : Nodes.Node_Access; Top : Positive) is
begin
Refine (Node);
State := Stack.State (Top);
Stack.Top := Top - 1;
Do_Shift (Node);
LA := Node.Next_Subtree (Reference);
end Isolate;
-----------------
-- Node_Offset --
-----------------
function Node_Offset
(Node : Nodes.Node_Access;
Time : Version_Trees.Version) return Natural
is
use type Nodes.Node_Access;
Left : Nodes.Node_Access := Node.Previous_Subtree (Time);
Result : Natural := 0;
begin
while Left /= null loop
Result := Result + Left.Span (Nodes.Text_Length, Time);
Left := Left.Previous_Subtree (Time);
end loop;
return Result;
end Node_Offset;
------------
-- Refine --
------------
procedure Refine (Node : Nodes.Node_Access) is
procedure Pass_2 (Node : Nodes.Node_Access; Offset : Natural);
------------
-- Pass_2 --
------------
procedure Pass_2 (Node : Nodes.Node_Access; Offset : Natural) is
Prev : Natural := Offset;
Next : Natural;
Child : Nodes.Node_Access;
begin
for J in 1 .. Node.Arity loop
Child := Node.Child (J, Now);
-- I doubt getting span in current version will work due to
-- its caching in the node.
Next := Prev + Child.Span (Nodes.Text_Length, Now);
-- if Prev <= Jam_Offset and Jam_Offset < Next then
Discard_Changes_And_Mark_Errors (Child);
-- end if;
Pass_2 (Child, Next);
Prev := Next;
end loop;
end Pass_2;
Old_Offset : constant Natural := Node_Offset (Node, Previous);
begin
Node.Discard;
Node.Set_Local_Errors (False);
Pass_2 (Node, Old_Offset);
end Refine;
use type Nodes.Node_Access;
Ancestor : Nodes.Node_Access;
Node : Nodes.Node_Access;
Cut : Natural; -- Stack index or zero
Offset : Offset_Array (1 .. Stack.Top + 1) := (0, others => <>);
-- Computed offset of leftmost character not to the left of the
-- Index-th stack entry. (In current version).
begin
for J in 1 .. Stack.Top loop
Offset (J + 1) := Offset (J) +
Stack.Node (J).Span (Nodes.Text_Length, Now);
end loop;
Jam_Offset := Offset (Offset'Last);
-- Consider each node on the stack, until we reach bos.
for J in reverse 1 .. Stack.Top loop
Node := Stack.Node (J);
-- If the root of this subtree is new, keep looking down the
-- parse stack.
if Node.Exists (Previous) then
if Is_Valid_Isolation (Node, Offset (J), Stack.State (J)) then
Isolate (Node, J);
-- Isolate (Node, SP, 1);
return;
end if;
-- Try searching node's ancestors.
loop
Ancestor := Node.Parent (Previous);
exit when Ancestor = Document.Ultra_Root;
Cut := Get_Cut (Ancestor, Offset, J);
exit when Cut = 0;
-- if not chached
if Is_Valid_Isolation
(Ancestor, Offset (Cut), Stack.State (Cut))
then
Isolate (Ancestor, Cut);
return;
end if;
Node := Ancestor;
end loop;
end if;
end loop;
-- Isolate root non-terminal
Node := Document.Ultra_Root.Child (2, Reference);
if Stack.Top = 1 then
Do_Shift (Node);
end if;
Isolate (Node, 2);
Discard_Changes_And_Mark_Errors (Document.Start_Of_Stream);
Discard_Changes_And_Mark_Errors (Document.End_Of_Stream);
end Recover_2;
---------------------
-- Right_Breakdown --
---------------------
procedure Right_Breakdown is
Node : Nodes.Node_Access;
Limit : constant Natural := Stack.Top - 1;
begin
loop
Pop (Stack, State, Node);
exit when Node.Is_Token;
for J in 1 .. Node.Arity loop
Do_Shift (Node.Child (J, Now));
end loop;
if Stack.Top = Limit then
-- Empty subtree was on the top of the stack
return;
end if;
end loop;
Do_Shift (Node);
end Right_Breakdown;
Verify : Boolean := False;
Lexing : Boolean := False;
EOF : Boolean := False;
Term : Nodes.Tokens.Token_Access;
LA : access Nodes.Node'Class := Document.Start_Of_Stream;
Next : Action;
begin
Document.Start_Of_Stream.Set_Text
(League.Strings.Empty_Universal_String);
Document.End_Of_Stream.Set_Text
(League.Strings.Empty_Universal_String);
Lexer.Prepare_Document (Document, Reference);
Clear (Stack);
Push (Stack, State, Nodes.Node_Access (Document.Start_Of_Stream));
if not LA.Get_Flag (Nodes.Need_Analysis) then
LA := LA.Next_Subtree (Reference);
end if;
loop
if LA.Is_Token then
if not Lexing
and then LA.Get_Flag (Nodes.Need_Analysis)
and then not EOF
then
Term := Lexer.First_New_Token (Nodes.Tokens.Token_Access (LA));
LA := Term;
Lexing := True;
else
Term := Nodes.Tokens.Token_Access (LA);
end if;
Next := Next_Action (State, Term.Kind);
case Next.Kind is
when Finish =>
if Term.Kind = 0 then -- End_Of_Stream
declare
Node : Nodes.Node_Access;
begin
Pop (Stack, State, Node);
Document.Ultra_Root.Set_Child (2, Node);
return;
end;
else
Recover (Nodes.Node_Access (LA));
end if;
when Reduce =>
On_Reduce (Next.Prod);
when Shift =>
Verify := False;
On_Shift (State, Next.State, Term);
if not Lexing then
LA := Term.Next_Subtree (Reference);
elsif Lexer.Is_Synchronized then
LA := Lexer.Synchronized_Token;
Lexing := False;
if LA = null then
EOF := True;
LA := Document.End_Of_Stream;
end if;
else
LA := Lexer.Next_New_Token;
end if;
when Error =>
if Verify then
Verify := False;
Right_Breakdown;
else
Recover (Nodes.Node_Access (LA));
end if;
end case;
elsif LA.Nested_Changes (Reference, Now) then
LA := Left_Breakdown (LA.all'Access);
else
Next := Next_Action (State, LA.Kind);
case Next.Kind is
when Finish =>
raise Program_Error;
when Reduce =>
On_Reduce (Next.Prod);
when Shift =>
Verify := True;
On_Shift (State, Next.State, LA);
LA := LA.Next_Subtree (Reference);
when Error =>
if LA.Arity > 0 then
LA := Left_Breakdown (LA.all'Access);
else
LA := LA.Next_Subtree (Reference);
end if;
end case;
end if;
end loop;
end Run;
end Incr.Parsers.Incremental;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--*
-- CHECK THAT CONSTRAINT_ERROR IS NOT RAISED FOR ACCESS PARAMETERS
-- IN THE FOLLOWING CIRCUMSTANCES:
-- (1)
-- (2) AFTER THE CALL, WHEN AN IN OUT OR OUT FORMAL
-- ACCESS VALUE IS NULL, AND THE ACTUAL PARAMETER HAS
-- DIFFERENT CONSTRAINTS.
-- (3)
-- SUBTESTS ARE:
-- (C) CASE 2, IN OUT MODE, STATIC PRIVATE DISCRIMINANT.
-- (D) CASE 2, OUT MODE, DYNAMIC TWO DIMENSIONAL BOUNDS.
-- (E) SAME AS (C), WITH TYPE CONVERSION.
-- (F) SAME AS (D), WITH TYPE CONVERSION.
-- JRK 3/20/81
-- SPS 10/26/82
-- CPP 8/8/84
WITH REPORT;
PROCEDURE C64105C IS
USE REPORT;
BEGIN
TEST ("C64105C", "CHECK THAT CONSTRAINT_ERROR IS NOT RAISED " &
"AFTER THE CALL, WHEN AN IN OUT OR OUT FORMAL " &
"ACCESS VALUE IS NULL, AND THE ACTUAL PARAMETER HAS " &
"DIFFERENT CONSTRAINTS" );
--------------------------------------------------
DECLARE -- (C)
PACKAGE PKG IS
TYPE E IS (E1, E2);
TYPE T (D : E := E1) IS PRIVATE;
PRIVATE
TYPE T (D : E := E1) IS
RECORD
I : INTEGER;
CASE D IS
WHEN E1 =>
B : BOOLEAN;
WHEN E2 =>
C : CHARACTER;
END CASE;
END RECORD;
END PKG;
USE PKG;
TYPE A IS ACCESS T;
SUBTYPE SA IS A(E2);
V : A (E1) := NULL;
ENTERED : BOOLEAN := FALSE;
PROCEDURE P (X : IN OUT SA) IS
BEGIN
ENTERED := TRUE;
X := NULL;
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED IN PROCEDURE - (C)");
END P;
BEGIN -- (C)
P (V);
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF NOT ENTERED THEN
FAILED ("EXCEPTION RAISED BEFORE CALL - (C)");
ELSE
FAILED ("EXCEPTION RAISED ON RETURN - (C)");
END IF;
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED - (C)");
END; -- (C)
--------------------------------------------------
DECLARE -- (D)
TYPE T IS ARRAY (CHARACTER RANGE <>, BOOLEAN RANGE <>) OF
INTEGER;
TYPE A IS ACCESS T;
SUBTYPE SA IS A ('D'..'F', FALSE..FALSE);
V : A (IDENT_CHAR('A') .. IDENT_CHAR('B'),
IDENT_BOOL(TRUE) .. IDENT_BOOL(TRUE)) := NULL;
ENTERED : BOOLEAN := FALSE;
PROCEDURE P (X : OUT SA) IS
BEGIN
ENTERED := TRUE;
X := NULL;
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED IN PROCEDURE - (D)");
END P;
BEGIN -- (D)
P (V);
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF NOT ENTERED THEN
FAILED ("EXCEPTION RAISED BEFORE CALL - (D)");
ELSE
FAILED ("EXCEPTION RAISED ON RETURN - (D)");
END IF;
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED - (D)");
END; -- (D)
--------------------------------------------------
DECLARE -- (E)
PACKAGE PKG IS
TYPE E IS (E1, E2);
TYPE T (D : E := E1) IS PRIVATE;
PRIVATE
TYPE T (D : E := E1) IS
RECORD
I : INTEGER;
CASE D IS
WHEN E1 =>
B : BOOLEAN;
WHEN E2 =>
C : CHARACTER;
END CASE;
END RECORD;
END PKG;
USE PKG;
TYPE A IS ACCESS T;
SUBTYPE SA IS A(E2);
V : A (E1) := NULL;
ENTERED : BOOLEAN := FALSE;
PROCEDURE P (X : IN OUT SA) IS
BEGIN
ENTERED := TRUE;
X := NULL;
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED IN PROCEDURE - (C)");
END P;
BEGIN -- (E)
P (SA(V));
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF NOT ENTERED THEN
FAILED ("EXCEPTION RAISED BEFORE CALL - (E)");
ELSE
FAILED ("EXCEPTION RAISED ON RETURN - (E)");
END IF;
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED - (E)");
END; -- (E)
--------------------------------------------------
DECLARE -- (F)
TYPE T IS ARRAY (CHARACTER RANGE <>, BOOLEAN RANGE <>) OF
INTEGER;
TYPE A IS ACCESS T;
SUBTYPE SA IS A ('D'..'F', FALSE..FALSE);
V : A (IDENT_CHAR('A') .. IDENT_CHAR('B'),
IDENT_BOOL(TRUE) .. IDENT_BOOL(TRUE)) := NULL;
ENTERED : BOOLEAN := FALSE;
PROCEDURE P (X : OUT SA) IS
BEGIN
ENTERED := TRUE;
X := NULL;
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED IN PROCEDURE - (D)");
END P;
BEGIN -- (D)
P (SA(V));
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF NOT ENTERED THEN
FAILED ("EXCEPTION RAISED BEFORE CALL - (F)");
ELSE
FAILED ("EXCEPTION RAISED ON RETURN - (F)");
END IF;
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED - (F)");
END; -- (F)
--------------------------------------------------
RESULT;
END C64105C;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- (above). The System V function takes no arguments and puts the calling
-- process in its on group like `setpgid (0, 0)'.
-- New programs should always use `setpgid' instead.
-- GNU provides the POSIX.1 function.
-- Set the process group ID of the calling process to its own PID.
-- This is exactly the same as `setpgid (0, 0)'.
function setpgrp return int; -- unistd.h:663
pragma Import (C, setpgrp, "setpgrp");
-- Create a new session with the calling process as its leader.
-- The process group IDs of the session and the calling process
-- are set to the process ID of the calling process, which is returned.
function setsid return CUPS.bits_types_h.uu_pid_t; -- unistd.h:670
pragma Import (C, setsid, "setsid");
-- Return the session ID of the given process.
function getsid (uu_pid : CUPS.bits_types_h.uu_pid_t) return CUPS.bits_types_h.uu_pid_t; -- unistd.h:674
pragma Import (C, getsid, "getsid");
-- Get the real user ID of the calling process.
function getuid return CUPS.bits_types_h.uu_uid_t; -- unistd.h:678
pragma Import (C, getuid, "getuid");
-- Get the effective user ID of the calling process.
function geteuid return CUPS.bits_types_h.uu_uid_t; -- unistd.h:681
pragma Import (C, geteuid, "geteuid");
-- Get the real group ID of the calling process.
function getgid return CUPS.bits_types_h.uu_gid_t; -- unistd.h:684
pragma Import (C, getgid, "getgid");
-- Get the effective group ID of the calling process.
function getegid return CUPS.bits_types_h.uu_gid_t; -- unistd.h:687
pragma Import (C, getegid, "getegid");
-- If SIZE is zero, return the number of supplementary groups
-- the calling process is in. Otherwise, fill in the group IDs
-- of its supplementary groups in LIST and return the number written.
function getgroups (uu_size : int; uu_list : access CUPS.bits_types_h.uu_gid_t) return int; -- unistd.h:692
pragma Import (C, getgroups, "getgroups");
-- Return nonzero iff the calling process is in group GID.
function group_member (uu_gid : CUPS.bits_types_h.uu_gid_t) return int; -- unistd.h:696
pragma Import (C, group_member, "group_member");
-- Set the user ID of the calling process to UID.
-- If the calling process is the super-user, set the real
-- and effective user IDs, and the saved set-user-ID to UID;
-- if not, the effective user ID is set to UID.
function setuid (uu_uid : CUPS.bits_types_h.uu_uid_t) return int; -- unistd.h:703
pragma Import (C, setuid, "setuid");
-- Set the real user ID of the calling process to RUID,
-- and the effective user ID of the calling process to EUID.
function setreuid (uu_ruid : CUPS.bits_types_h.uu_uid_t; uu_euid : CUPS.bits_types_h.uu_uid_t) return int; -- unistd.h:708
pragma Import (C, setreuid, "setreuid");
-- Set the effective user ID of the calling process to UID.
function seteuid (uu_uid : CUPS.bits_types_h.uu_uid_t) return int; -- unistd.h:713
pragma Import (C, seteuid, "seteuid");
-- Set the group ID of the calling process to GID.
-- If the calling process is the super-user, set the real
-- and effective group IDs, and the saved set-group-ID to GID;
-- if not, the effective group ID is set to GID.
function setgid (uu_gid : CUPS.bits_types_h.uu_gid_t) return int; -- unistd.h:720
pragma Import (C, setgid, "setgid");
-- Set the real group ID of the calling process to RGID,
-- and the effective group ID of the calling process to EGID.
function setregid (uu_rgid : CUPS.bits_types_h.uu_gid_t; uu_egid : CUPS.bits_types_h.uu_gid_t) return int; -- unistd.h:725
pragma Import (C, setregid, "setregid");
-- Set the effective group ID of the calling process to GID.
function setegid (uu_gid : CUPS.bits_types_h.uu_gid_t) return int; -- unistd.h:730
pragma Import (C, setegid, "setegid");
-- Fetch the real user ID, effective user ID, and saved-set user ID,
-- of the calling process.
function getresuid
(uu_ruid : access CUPS.bits_types_h.uu_uid_t;
uu_euid : access CUPS.bits_types_h.uu_uid_t;
uu_suid : access CUPS.bits_types_h.uu_uid_t) return int; -- unistd.h:736
pragma Import (C, getresuid, "getresuid");
-- Fetch the real group ID, effective group ID, and saved-set group ID,
-- of the calling process.
function getresgid
(uu_rgid : access CUPS.bits_types_h.uu_gid_t;
uu_egid : access CUPS.bits_types_h.uu_gid_t;
uu_sgid : access CUPS.bits_types_h.uu_gid_t) return int; -- unistd.h:741
pragma Import (C, getresgid, "getresgid");
-- Set the real user ID, effective user ID, and saved-set user ID,
-- of the calling process to RUID, EUID, and SUID, respectively.
function setresuid
(uu_ruid : CUPS.bits_types_h.uu_uid_t;
uu_euid : CUPS.bits_types_h.uu_uid_t;
uu_suid : CUPS.bits_types_h.uu_uid_t) return int; -- unistd.h:746
pragma Import (C, setresuid, "setresuid");
-- Set the real group ID, effective group ID, and saved-set group ID,
-- of the calling process to RGID, EGID, and SGID, respectively.
function setresgid
(uu_rgid : CUPS.bits_types_h.uu_gid_t;
uu_egid : CUPS.bits_types_h.uu_gid_t;
uu_sgid : CUPS.bits_types_h.uu_gid_t) return int; -- unistd.h:751
pragma Import (C, setresgid, "setresgid");
-- Clone the calling process, creating an exact copy.
-- Return -1 for errors, 0 to the new process,
-- and the process ID of the new process to the old process.
function fork return CUPS.bits_types_h.uu_pid_t; -- unistd.h:759
pragma Import (C, fork, "fork");
-- Clone the calling process, but without copying the whole address space.
-- The calling process is suspended until the new process exits or is
-- replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
-- and the process ID of the new process to the old process.
function vfork return CUPS.bits_types_h.uu_pid_t; -- unistd.h:767
pragma Import (C, vfork, "vfork");
-- Return the pathname of the terminal FD is open on, or NULL on errors.
-- The returned storage is good only until the next call to this function.
function ttyname (uu_fd : int) return Interfaces.C.Strings.chars_ptr; -- unistd.h:773
pragma Import (C, ttyname, "ttyname");
-- Store at most BUFLEN characters of the pathname of the terminal FD is
-- open on in BUF. Return 0 on success, otherwise an error number.
function ttyname_r
(uu_fd : int;
uu_buf : Interfaces.C.Strings.chars_ptr;
uu_buflen : size_t) return int; -- unistd.h:777
pragma Import (C, ttyname_r, "ttyname_r");
-- Return 1 if FD is a valid descriptor associated
-- with a terminal, zero if not.
function isatty (uu_fd : int) return int; -- unistd.h:782
pragma Import (C, isatty, "isatty");
-- Return the index into the active-logins file (utmp) for
-- the controlling terminal.
function ttyslot return int; -- unistd.h:788
pragma Import (C, ttyslot, "ttyslot");
-- Make a link to FROM named TO.
function link (uu_from : Interfaces.C.Strings.chars_ptr; uu_to : Interfaces.C.Strings.chars_ptr) return int; -- unistd.h:793
pragma Import (C, link, "link");
-- Like link but relative paths in TO and FROM are interpreted relative
-- to FROMFD and TOFD respectively.
function linkat
(uu_fromfd : int;
uu_from : Interfaces.C.Strings.chars_ptr;
uu_tofd : int;
uu_to : Interfaces.C.Strings.chars_ptr;
uu_flags : int) return int; -- unistd.h:799
pragma Import (C, linkat, "linkat");
-- Make a symbolic link to FROM named TO.
function symlink (uu_from : Interfaces.C.Strings.chars_ptr; uu_to : Interfaces.C.Strings.chars_ptr) return int; -- unistd.h:806
pragma Import (C, symlink, "symlink");
-- Read the contents of the symbolic link PATH into no more than
-- LEN bytes of BUF. The contents are not null-terminated.
-- Returns the number of characters read, or -1 for errors.
function readlink
(uu_path : Interfaces.C.Strings.chars_ptr;
uu_buf : Interfaces.C.Strings.chars_ptr;
uu_len : size_t) return size_t; -- unistd.h:812
pragma Import (C, readlink, "readlink");
-- Like symlink but a relative path in TO is interpreted relative to TOFD.
function symlinkat
(uu_from : Interfaces.C.Strings.chars_ptr;
uu_tofd : int;
uu_to : Interfaces.C.Strings.chars_ptr) return int; -- unistd.h:819
pragma Import (C, symlinkat, "symlinkat");
-- Like readlink but a relative PATH is interpreted relative to FD.
function readlinkat
(uu_fd : int;
uu_path : Interfaces.C.Strings.chars_ptr;
uu_buf : Interfaces.C.Strings.chars_ptr;
uu_len : size_t) return size_t; -- unistd.h:823
pragma Import (C, readlinkat, "readlinkat");
-- Remove the link NAME.
function unlink (uu_name : Interfaces.C.Strings.chars_ptr) return int; -- unistd.h:829
pragma Import (C, unlink, "unlink");
-- Remove the link NAME relative to FD.
function unlinkat
(uu_fd : int;
uu_name : Interfaces.C.Strings.chars_ptr;
uu_flag : int) return int; -- unistd.h:833
pragma Import (C, unlinkat, "unlinkat");
-- Remove the directory PATH.
function rmdir (uu_path : Interfaces.C.Strings.chars_ptr) return int; -- unistd.h:838
pragma Import (C, rmdir, "rmdir");
-- Return the foreground process group ID of FD.
function tcgetpgrp (uu_fd : int) return CUPS.bits_types_h.uu_pid_t; -- unistd.h:842
pragma Import (C, tcgetpgrp, "tcgetpgrp");
-- Set the foreground process group ID of FD set PGRP_ID.
function tcsetpgrp (uu_fd : int; uu_pgrp_id : CUPS.bits_types_h.uu_pid_t) return int; -- unistd.h:845
pragma Import (C, tcsetpgrp, "tcsetpgrp");
-- Return the login name of the user.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
function getlogin return Interfaces.C.Strings.chars_ptr; -- unistd.h:852
pragma Import (C, getlogin, "getlogin");
-- Return at most NAME_LEN characters of the login name of the user in NAME.
-- If it cannot be determined or some other error occurred, return the error
-- code. Otherwise return 0.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
function getlogin_r (uu_name : Interfaces.C.Strings.chars_ptr; uu_name_len : size_t) return int; -- unistd.h:860
pragma Import (C, getlogin_r, "getlogin_r");
-- Set the login name returned by `getlogin'.
function setlogin (uu_name : Interfaces.C.Strings.chars_ptr) return int; -- unistd.h:865
pragma Import (C, setlogin, "setlogin");
-- Get definitions and prototypes for functions to process the
-- arguments in ARGV (ARGC of them, minus the program name) for
-- options given in OPTS.
-- Put the name of the current host in no more than LEN bytes of NAME.
-- The result is null-terminated if LEN is large enough for the full
-- name and the terminator.
function gethostname (uu_name : Interfaces.C.Strings.chars_ptr; uu_len : size_t) return int; -- unistd.h:882
pragma Import (C, gethostname, "gethostname");
-- Set the name of the current host to NAME, which is LEN bytes long.
-- This call is restricted to the super-user.
function sethostname (uu_name : Interfaces.C.Strings.chars_ptr; uu_len : size_t) return int; -- unistd.h:889
pragma Import (C, sethostname, "sethostname");
-- Set the current machine's Internet number to ID.
-- This call is restricted to the super-user.
function sethostid (uu_id : long) return int; -- unistd.h:894
pragma Import (C, sethostid, "sethostid");
-- Get and set the NIS (aka YP) domain name, if any.
-- Called just like `gethostname' and `sethostname'.
-- The NIS domain name is usually the empty string when not using NIS.
function getdomainname (uu_name : Interfaces.C.Strings.chars_ptr; uu_len : size_t) return int; -- unistd.h:900
pragma Import (C, getdomainname, "getdomainname");
function setdomainname (uu_name : Interfaces.C.Strings.chars_ptr; uu_len : size_t) return int; -- unistd.h:902
pragma Import (C, setdomainname, "setdomainname");
-- Revoke access permissions to all processes currently communicating
-- with the control terminal, and then send a SIGHUP signal to the process
-- group of the control terminal.
function vhangup return int; -- unistd.h:909
pragma Import (C, vhangup, "vhangup");
-- Revoke the access of all descriptors currently open on FILE.
function revoke (uu_file : Interfaces.C.Strings.chars_ptr) return int; -- unistd.h:912
pragma Import (C, revoke, "revoke");
-- Enable statistical profiling, writing samples of the PC into at most
-- SIZE bytes of SAMPLE_BUFFER; every processor clock tick while profiling
-- is enabled, the system examines the user PC and increments
-- SAMPLE_BUFFER[((PC - OFFSET) / 2) * SCALE / 65536]. If SCALE is zero,
-- disable profiling. Returns zero on success, -1 on error.
function profil
(uu_sample_buffer : access unsigned_short;
uu_size : size_t;
uu_offset : size_t;
uu_scale : unsigned) return int; -- unistd.h:920
pragma Import (C, profil, "profil");
-- Turn accounting on if NAME is an existing file. The system will then write
-- a record for each process as it terminates, to this file. If NAME is NULL,
-- turn accounting off. This call is restricted to the super-user.
function acct (uu_name : Interfaces.C.Strings.chars_ptr) return int; -- unistd.h:928
pragma Import (C, acct, "acct");
-- Successive calls return the shells listed in `/etc/shells'.
function getusershell return Interfaces.C.Strings.chars_ptr; -- unistd.h:932
pragma Import (C, getusershell, "getusershell");
-- Discard cached info.
procedure endusershell; -- unistd.h:933
pragma Import (C, endusershell, "endusershell");
-- Rewind and re-read the file.
procedure setusershell; -- unistd.h:934
pragma Import (C, setusershell, "setusershell");
-- Put the program in the background, and dissociate from the controlling
-- terminal. If NOCHDIR is zero, do `chdir ("/")'. If NOCLOSE is zero,
-- redirects stdin, stdout, and stderr to /dev/null.
function daemon (uu_nochdir : int; uu_noclose : int) return int; -- unistd.h:940
pragma Import (C, daemon, "daemon");
-- Make PATH be the root directory (the starting point for absolute paths).
-- This call is restricted to the super-user.
function chroot (uu_path : Interfaces.C.Strings.chars_ptr) return int; -- unistd.h:947
pragma Import (C, chroot, "chroot");
-- Prompt with PROMPT and read a string from the terminal without echoing.
-- Uses /dev/tty if possible; otherwise stderr and stdin.
function getpass (uu_prompt : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr; -- unistd.h:951
pragma Import (C, getpass, "getpass");
-- Make all changes done to FD actually appear on disk.
-- This function is a cancellation point and therefore not marked with
-- __THROW.
function fsync (uu_fd : int) return int; -- unistd.h:959
pragma Import (C, fsync, "fsync");
-- Make all changes done to all files on the file system associated
-- with FD actually appear on disk.
function syncfs (uu_fd : int) return int; -- unistd.h:965
pragma Import (C, syncfs, "syncfs");
-- Return identifier for the current host.
function gethostid return long; -- unistd.h:972
pragma Import (C, gethostid, "gethostid");
-- Make all changes done to all files actually appear on disk.
procedure sync; -- unistd.h:975
pragma Import (C, sync, "sync");
-- Return the number of bytes in a page. This is the system's page size,
-- which is not necessarily the same as the hardware page size.
function getpagesize return int; -- unistd.h:981
pragma Import (C, getpagesize, "getpagesize");
-- Return the maximum number of file descriptors
-- the current process could possibly have.
function getdtablesize return int; -- unistd.h:986
pragma Import (C, getdtablesize, "getdtablesize");
-- Truncate FILE to LENGTH bytes.
function truncate (uu_file : Interfaces.C.Strings.chars_ptr; uu_length : CUPS.bits_types_h.uu_off_t) return int; -- unistd.h:996
pragma Import (C, truncate, "truncate");
function truncate64 (uu_file : Interfaces.C.Strings.chars_ptr; uu_length : CUPS.bits_types_h.uu_off64_t) return int; -- unistd.h:1008
pragma Import (C, truncate64, "truncate64");
-- Truncate the file FD is open on to LENGTH bytes.
function ftruncate (uu_fd : int; uu_length : CUPS.bits_types_h.uu_off_t) return int; -- unistd.h:1019
pragma Import (C, ftruncate, "ftruncate");
function ftruncate64 (uu_fd : int; uu_length : CUPS.bits_types_h.uu_off64_t) return int; -- unistd.h:1029
pragma Import (C, ftruncate64, "ftruncate64");
-- Set the end of accessible data space (aka "the break") to ADDR.
-- Returns zero on success and -1 for errors (with errno set).
function brk (uu_addr : System.Address) return int; -- unistd.h:1040
pragma Import (C, brk, "brk");
-- Increase or decrease the end of accessible data space by DELTA bytes.
-- If successful, returns the address the previous end of data space
-- (i.e. the beginning of the new space, if DELTA > 0);
-- returns (void *) -1 for errors (with errno set).
function sbrk (uu_delta : intptr_t) return System.Address; -- unistd.h:1046
pragma Import (C, sbrk, "sbrk");
-- Invoke `system call' number SYSNO, passing it the remaining arguments.
-- This is completely system-dependent, and not often useful.
-- In Unix, `syscall' sets `errno' for all errors and most calls return -1
-- for errors; in many systems you cannot pass arguments or get return
-- values for all system calls (`pipe', `fork', and `getppid' typically
-- among them).
-- In Mach, all system calls take normal arguments and always return an
-- error code (zero for success).
function syscall (uu_sysno : long -- , ...
) return long; -- unistd.h:1061
pragma Import (C, syscall, "syscall");
-- NOTE: These declarations also appear in <fcntl.h>; be sure to keep both
-- files consistent. Some systems have them there and some here, and some
-- software depends on the macros being defined without including both.
-- `lockf' is a simpler interface to the locking facilities of `fcntl'.
-- LEN is always relative to the current file position.
-- The CMD argument is one of the following.
-- This function is a cancellation point and therefore not marked with
-- __THROW.
function lockf
(uu_fd : int;
uu_cmd : int;
uu_len : CUPS.bits_types_h.uu_off_t) return int; -- unistd.h:1084
pragma Import (C, lockf, "lockf");
function lockf64
(uu_fd : int;
uu_cmd : int;
uu_len : CUPS.bits_types_h.uu_off64_t) return int; -- unistd.h:1094
pragma Import (C, lockf64, "lockf64");
-- Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno'
-- set to EINTR.
-- Synchronize at least the data part of a file with the underlying
-- media.
function fdatasync (uu_fildes : int) return int; -- unistd.h:1115
pragma Import (C, fdatasync, "fdatasync");
-- XPG4.2 specifies that prototypes for the encryption functions must
-- be defined here.
-- Encrypt at most 8 characters from KEY using salt to perturb DES.
function crypt (uu_key : Interfaces.C.Strings.chars_ptr; uu_salt : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr; -- unistd.h:1123
pragma Import (C, crypt, "crypt");
-- Encrypt data in BLOCK in place if EDFLAG is zero; otherwise decrypt
-- block in place.
procedure encrypt (uu_glibc_block : Interfaces.C.Strings.chars_ptr; uu_edflag : int); -- unistd.h:1128
pragma Import (C, encrypt, "encrypt");
-- Swab pairs bytes in the first N bytes of the area pointed to by
-- FROM and copy the result to TO. The value of TO must not be in the
-- range [FROM - N + 1, FROM - 1]. If N is odd the first byte in FROM
-- is without partner.
procedure swab
(uu_from : System.Address;
uu_to : System.Address;
uu_n : size_t); -- unistd.h:1136
pragma Import (C, swab, "swab");
-- The Single Unix specification demands this prototype to be here.
-- It is also found in <stdio.h>.
-- Return the name of the controlling terminal.
-- Define some macros helping to catch buffer overflows.
end CUPS.unistd_h;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Runge_8th;
with Text_IO; use Text_IO;
with Quadrature;
with Ada.Numerics.Generic_Elementary_Functions;
procedure runge_8th_order_demo_3 is
type Real is digits 15;
package mth is new Ada.Numerics.Generic_Elementary_Functions(Real);
use mth; -- for Sin
package quadr is new Quadrature (Real, Sin);
use quadr;
package Area_Under_the_Curve is new
Runge_8th (Real, Dyn_Index, Dynamical_Variable, F, "*", "+", "-", Norm);
use Area_Under_the_Curve;
package rio is new Float_IO(Real);
use rio;
package iio is new Integer_IO(Step_Integer);
use iio;
Initial_Condition : Dynamical_Variable;
Previous_Y, Final_Y : Dynamical_Variable;
Final_Time, Starting_Time : Real;
Previous_t, Final_t : Real;
Delta_t : Real;
Steps : Step_Integer;
Error_Tolerance : Real := 1.0E-10;
Error_Control_Desired : Boolean := False;
Answer : Character := 'n';
begin
-- choose initial conditions
new_line;
put ("The test integrates (d/dt) Y(t) = Sin(t) for Y(t).");
new_line(2);
put ("Ordinary quadrature is just an area-under-the-curve problem, ");
new_line;
put ("where you solve: (d/dt) Y(t) = Sin(t) for Y.");
new_line(2);
put ("Input number of steps (try 16 with and without error control)");
new_line;
get (Steps);
new_line;
put ("Every time the integration advances this number of steps, ERROR is printed.");
new_line;
new_line;
put ("Use error control? Enter y or n:"); new_line; get (Answer);
if (Answer = 'Y') or (Answer = 'y') then
Error_Control_Desired := True;
put ("Error control it is."); new_line;
else
Error_Control_Desired := False;
put ("OK, no error control."); new_line;
end if;
Initial_Condition(0) := -1.0;
Starting_Time := 0.0;
Final_Time := 32.0;
Previous_Y := Initial_Condition;
Previous_t := Starting_Time;
Delta_t := Final_Time - Starting_Time;
for i in 1..20 loop
Final_t := Previous_t + Delta_t;
Integrate
(Final_State => Final_Y, -- the result (output).
Final_Time => Final_t, -- end integration here.
Initial_State => Previous_Y, -- the initial condition (input).
Initial_Time => Previous_t, -- start integrating here.
No_Of_Steps => Steps, -- if no err control, uses this.
Error_Control_Desired => Error_Control_Desired,
Error_Tolerance => Error_Tolerance);
Previous_Y := Final_Y;
Previous_t := Final_t;
new_line;
put ("Time = t =");
put (Final_t, Aft => 7);
put (", Error = (Cos (t) - Integrated Cos) = ");
put (Abs (-Cos(Final_t) - Final_Y(0)), Aft => 7);
end loop;
if (Answer = 'Y') or (Answer = 'y') then
new_line(2);
put ("With error control enabled, program attempted to reduce");
new_line;
put ("error *per step* to (well) under: ");
put (Error_Tolerance, Aft => 6);
new_line;
put ("Over thousands of steps, accumulated error will be much larger than that.");
new_line(2);
end if;
end;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Simple_Logging;
with Interfaces.C_Streams; use Interfaces.C_Streams;
package body FSmaker.Commands.Init is
-------------
-- Execute --
-------------
overriding
procedure Execute (This : in out Instance;
Args : AAA.Strings.Vector)
is
function ftruncate (FS : int;
Length : Long_Integer)
return int;
pragma Import (C, ftruncate, "ftruncate");
begin
case Args.Count is
when 0 =>
This.Failure ("Missing argument <size>");
when 1 =>
declare
Arg : constant String := Args (1);
Size : Natural;
begin
Size := Natural'Value (Args (1));
This.Setup_Image (To_Format => True);
if ftruncate (int (This.FD), Long_Integer (Size)) /= 0 then
raise Program_Error with "ftruncate error: " &
GNAT.OS_Lib.Errno_Message;
end if;
Simple_Logging.Always ("Format with Size:" & Size'Img);
This.Target.Format (This.FD, Size);
This.Success;
exception
when Constraint_Error =>
This.Failure ("Invalid size argument: '" & Arg & "'");
end;
when others =>
This.Failure ("Too many arguments");
end case;
end Execute;
--------------------
-- Setup_Switches --
--------------------
overriding
procedure Setup_Switches
(This : in out Instance;
Config : in out CLIC.Subcommand.Switches_Configuration)
is
begin
null;
end Setup_Switches;
end FSmaker.Commands.Init;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with
openGL.Model.any,
openGL.Visual,
openGL.Light.directional,
openGL.Demo;
procedure launch_render_Asteroids
--
-- Render with a few asteroids.
--
is
use openGL,
openGL.Math,
openGL.linear_Algebra_3d;
begin
Demo.define ("openGL 'Render Asteroids' Demo");
Demo.print_Usage ("Use space ' ' to cycle through models.");
Demo.Camera.Position_is ((0.0, 0.0, 200.0),
y_Rotation_from (to_Radians (0.0)));
declare
the_Light : openGL.Light.directional.item := Demo.Renderer.Light (1);
begin
the_Light.Site_is ((5_000.0, 2_000.0, 5_000.0));
Demo.Renderer.Light_is (1, the_Light);
end;
declare
-- The models.
--
gaspra_Model : constant openGL.Model.any.view := openGL.Model.any.new_Model (Model => to_Asset ("assets/gaspra.tab"),
Texture => null_Asset,
Texture_is_lucid => False);
the_Models : constant openGL.Model.views := (1 => gaspra_Model.all'unchecked_Access);
-- The visuals.
--
use openGL.Visual.Forge;
the_Visuals : openGL.Visual.views (the_Models'Range);
Current : Integer := the_Visuals'First;
begin
for i in the_Visuals'Range
loop
the_Visuals (i) := new_Visual (the_Models (i));
end loop;
-- Main loop.
--
while not Demo.Done
loop
Demo.Dolly.evolve;
Demo.Done := Demo.Dolly.quit_Requested;
declare
Command : Character;
Avail : Boolean;
begin
Demo.Dolly.get_last_Character (Command, Avail);
if Avail
then
case Command
is
when ' ' =>
if Current = the_Visuals'Last
then Current := the_Visuals'First;
else Current := Current + 1;
end if;
when others =>
null;
end case;
end if;
end;
-- Render all visuals.
--
Demo.Camera.render ((1 => the_Visuals (Current)));
while not Demo.Camera.cull_Completed
loop
delay Duration'Small;
end loop;
Demo.Renderer.render;
Demo.FPS_Counter.increment; -- Frames per second display.
end loop;
end;
Demo.destroy;
end launch_render_Asteroids;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Command_Line;
with Ada.Text_IO.Unbounded_IO;
with Ada.Strings.Unbounded;
with Markov;
procedure Test_Markov is
use Ada.Strings.Unbounded;
package IO renames Ada.Text_IO.Unbounded_IO;
Rule_File : Ada.Text_IO.File_Type;
Line_Count : Natural := 0;
begin
if Ada.Command_Line.Argument_Count /= 2 then
Ada.Text_IO.Put_Line ("Usage: test_markov ruleset_file source_file");
return;
end if;
Ada.Text_IO.Open
(File => Rule_File,
Mode => Ada.Text_IO.In_File,
Name => Ada.Command_Line.Argument (1));
while not Ada.Text_IO.End_Of_File (Rule_File) loop
Ada.Text_IO.Skip_Line (Rule_File);
Line_Count := Line_Count + 1;
end loop;
declare
Lines : Markov.String_Array (1 .. Line_Count);
begin
Ada.Text_IO.Reset (Rule_File);
for I in Lines'Range loop
Lines (I) := IO.Get_Line (Rule_File);
end loop;
Ada.Text_IO.Close (Rule_File);
declare
Ruleset : Markov.Ruleset := Markov.Parse (Lines);
Source_File : Ada.Text_IO.File_Type;
begin
Ada.Text_IO.Open
(File => Source_File,
Mode => Ada.Text_IO.In_File,
Name => Ada.Command_Line.Argument (2));
while not Ada.Text_IO.End_Of_File (Source_File) loop
Ada.Text_IO.Put_Line
(Markov.Apply (Ruleset, Ada.Text_IO.Get_Line (Source_File)));
end loop;
Ada.Text_IO.Close (Source_File);
end;
end;
end Test_Markov;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
package body GA_Base_Types is
function "*" (I1, I2 : NI_T) return float is
begin
return 0.0;
end "*";
-- -------------------------------------------------------------------------
function "*" (I : NI_T; O : NO_T) return float is
begin
-- return -I.Inf * O.Origin;
return -1.0;
end "*";
-- -------------------------------------------------------------------------
function "*" (O : NO_T; I : NI_T) return float is
begin
-- return -I.Inf * O.Origin;
return -1.0;
end "*";
-- -------------------------------------------------------------------------
function "*" (O1, O2 : NO_T) return float is
begin
return 0.0;
end "*";
-- -------------------------------------------------------------------------
function NI return float is
begin
return 1.0;
end NI;
-- ------------------------------------------------------------------------
function NI (N : NI_T) return float is
begin
return N.Inf;
end NI;
-- ------------------------------------------------------------------------
function NO return float is
begin
return 1.0;
end NO;
-- ------------------------------------------------------------------------
function NO (N : NO_T) return float is
begin
return N.Origin;
end NO;
-- ------------------------------------------------------------------------
procedure Set_NI (N : out NI_T; Inf : float) is
begin
N.Inf := Inf;
end Set_NI;
-- -------------------------------------------------------------------------
procedure Set_NO (N : out NO_T; Origin : float) is
begin
N.Origin := Origin;
end Set_NO;
-- -------------------------------------------------------------------------
end GA_Base_Types;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Text_Io; use Ada.Text_Io;
with Ada.Integer_Text_IO; use Ada.Integer_Text_Io;
with conecta4; use conecta4;
with Nt_Console; use Nt_console;
with colocar_ficha;
with imprimir_tablero;
with pedir_columna;
with inicializar_tablero;
procedure jugar_conecta4 is
Tablero : T_Tablero;
Ganador : Boolean;
Jugador : Integer;
CColum : Integer;
FichasColoc : Integer;
begin
-- Inicio del juego e instrucciones
new_line(2);
put(" Bienvenido a CONECTA4"); new_line(2);
put(" Jugador 1 juega con las fichas "); Set_Foreground(Light_Red); put("ROJAS"); Set_Foreground; new_line;
put(" Jugador 2 juega con las fichas "); Set_Foreground(Light_Blue); put("AZULES"); Set_Foreground; new_line;
new_line(2);
put(" Que jugador va a comenzar (1 o 2)? "); get(Jugador);
loop exit when Jugador = 1 or Jugador = 2;
Set_Foreground(Red);
new_line;
put_line(" ERROR, eliga Jugador 1 o Jugador 2 ");
new_line;
Set_Foreground;
Bleep;
put(" Que jugador va a comenzar (1 o 2)? "); get(Jugador);
end loop;
new_line(2);
Skip_Line;
put(" Pulsa INTRO para empezar a juegar...");
Skip_Line;
new_line;
-- Inicializamos el juego
Ganador := False;
FichasColoc := 0;
inicializar_tablero(Tablero);
imprimir_tablero(Tablero);
-- Mientras que no haya ganador ni empate
while Ganador = False and FichasColoc /= Max_Filas * Max_Columnas loop
CColum := Pedir_Columna(Tablero, Jugador);
FichasColoc := FichasColoc+1;
colocar_ficha (Tablero, Jugador, CColum, Ganador);
imprimir_tablero(Tablero);
-- Cambio de turno de un Jugador a otro
if Jugador = 1 then
Jugador := 2;
else
Jugador := 1;
end if;
end loop;
-- Final de partida
-- Empate (tablero lleno sin combinacion ganadora)
if FichasColoc = Max_Filas * Max_Columnas and Ganador = False then
new_line;
put_line(" Buena partida");
put_line(" --- EMPATE ---");
skip_line;
end if;
-- Un ganador, dependiendo del jugador dice cual es.
if Ganador = True then
new_line;
put_line(" La partida ha finalizado");
put (" Y el ganador es: ");
-- Como cambia de turno directamente, se invierte el orden de quien ha ganado
if Jugador = 2 then
Set_Foreground(Light_Red); put("Jugador 1"); Set_Foreground; new_line;
else
Set_Foreground(Light_Blue); put("Jugador 2"); Set_Foreground; new_line;
end if;
Skip_line;
end if;
end jugar_conecta4;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- { dg-do compile }
pragma Restrictions (No_Allocators);
procedure Test_BIP_No_Alloc is
type LR (B : Boolean) is limited record
X : Integer;
end record;
function FLR return LR is
begin
-- A return statement in a function with a limited and unconstrained
-- result subtype can result in expansion of an allocator for the
-- secondary stack, but that should not result in a violation of the
-- restriction No_Allocators.
return (B => False, X => 123);
end FLR;
Obj : LR := FLR;
begin
null;
end Test_BIP_No_Alloc;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Orka.Transforms.SIMD_Vectors;
with Orka.SIMD.SSE.Singles.Arithmetic;
with Orka.SIMD.SSE.Singles.Math;
with Orka.SIMD.SSE3.Singles.Arithmetic;
with Orka.SIMD.SSE4_1.Singles.Compare;
package Orka.Transforms.Singles.Vectors is new Orka.Transforms.SIMD_Vectors
(Float_32, SIMD.SSE.Singles.m128,
SIMD.SSE.Singles.Arithmetic."*", SIMD.SSE.Singles.Arithmetic."+",
SIMD.SSE.Singles.Arithmetic."-", SIMD.SSE.Singles.Arithmetic."-",
SIMD.SSE.Singles.Arithmetic."abs", SIMD.SSE3.Singles.Arithmetic.Sum,
SIMD.SSE.Singles.Arithmetic.Divide_Or_Zero,
SIMD.SSE.Singles.Math.Cross_Product,
SIMD.SSE4_1.Singles.Compare.Is_Equal);
pragma Pure (Orka.Transforms.Singles.Vectors);
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--
package body LALR_Symbol_Info is
SCCS_ID : constant String := "@(#) lalr_symbol_info_body.adadisk21~/rschm/hasee/sccs/ayacc, Version 1.2";
package Relation is
procedure Make_Reads_Relation;
procedure Make_Includes_Relation;
procedure Reads (LHS : Transition; RHS : in out Transition_Set);
procedure Includes(LHS : Transition; RHS : in out Transition_Set);
procedure Free_Includes;
end Relation;
package body Relation is
SCCS_ID : constant String := "@(#) lalr_symbol_info_body.adadisk21~/rschm/hasee/sccs/ayacc, Version 1.2";
package Includes_Relation is
new Ragged(Parse_State, Grammar_Symbol, Transition_Set,
Transition_Set_Pack.Make_Null);
procedure Make_Reads_Relation is
begin
-- Don't need to do anything. Get READS from the LR0 machine
null;
end Make_Reads_Relation;
-- Implements Algorithm D1 in Park's paper
-- "A New Analysis of LALR Formalisms" Park et al.
-- ACM Transactions on Programming Languages and Systems,
-- Vol 7,January 85.
use Includes_Relation, Item_Set_Pack,
Parse_State_Set_Pack, Transition_Set_Pack;
procedure Make_Includes_Relation is
Preds : Parse_State_Set;
Pred_Loop : Parse_State_Iterator;
Temp : Transition;
A , B : Grammar_Symbol;
R : Parse_State;
I : Item;
Items : Item_Set;
Item_Index : Item_Iterator;
begin
Make_Array(First_Parse_State,Last_Parse_State);
for Q in First_Parse_State .. Last_Parse_State loop
-- Loop over all items [B ->B1 . A B2] in state Q
-- Where A is a nonterminal and the string B2 is nullable.
Get_Kernel(Q, Items);
Closure(Items);
Initialize(Item_Index, Items);
while More(Item_Index) loop
Next(Item_Index,I);
-- Is the item of the form [B ->B1 . A B2] ?
if I.Dot_Position = Length_of(I.Rule_ID) then
goto Continue; -- Nothing to the right of dot
elsif I.Dot_Position + 1 < Get_Null_Pos(I.Rule_ID) then
goto Continue; -- B2 is not nullable
end if;
A := Get_RHS(I.Rule_ID, I.Dot_Position + 1);
B := Get_LHS(I.Rule_ID);
if Is_Terminal(A) then
goto Continue; -- A is not a nonterminal
end if;
-- for all states R in PRED(Q,B1) (Q,A) INCLUDES (R,B)
Make_Null(Preds);
Get_Pred_Set(Q,I,Preds);
Initialize(Pred_Loop, Preds);
while More(Pred_Loop) loop
Next(Pred_Loop, R);
Temp.State_ID := R;
Temp.Symbol := B;
Insert(Temp, Into => Includes_Relation.Lval(Q,A).Value);
end loop;
<<Continue>> null;
end loop;
end loop;
-- Free
Make_Null(Preds);
Make_Null(Items);
end Make_Includes_Relation;
procedure Free_Includes is
begin
Includes_Relation.Free_Array;
end Free_Includes;
use Grammar_Symbol_Set_Pack, Transition_Set_Pack;
procedure Reads (LHS : Transition; RHS : in out Transition_Set) is
Temp : Transition;
Gotos : Grammar_Symbol_Set;
Index : Grammar_Symbol_Iterator;
begin
Make_Null(RHS);
Temp.State_ID := Get_Goto(LHS.State_ID, LHS.Symbol);
Get_Transition_Symbols(Temp.State_ID, Nonterminals, Gotos);
Initialize(Index, Gotos);
while More(Index) loop
Next(Index, Temp.Symbol);
if Is_Nullable(Temp.Symbol) then
Insert(Temp, Into => RHS);
end if;
end loop;
-- Free
Make_Null(Gotos);
end Reads;
use Includes_Relation, Transition_Set_Pack;
procedure Includes (LHS : Transition; RHS : in out Transition_Set) is
begin
-- Free
Make_Null(RHS);
-- Could use fassign but dangerous
Assign(RHS, Includes_Relation.Lval(LHS.State_ID,LHS.Symbol).Value);
end Includes;
end Relation;
--------------------------------------------------------------------------
use Relation;
package LALR_Sets_Pack is
procedure Make_Dr_Sets;
procedure Make_Read_Sets;
procedure Make_Follow_Sets;
procedure Follow(
Trans : Transition;
Follow_Set: in out Grammar_Symbol_Set);
procedure Union_Follow_Sets(
Trans : Transition;
Follow_Set : in out Grammar_Symbol_Set);
end LALR_Sets_Pack;
package body LALR_Sets_Pack is
SCCS_ID : constant String := "@(#) lalr_symbol_info_body.adadisk21~/rschm/hasee/sccs/ayacc, Version 1.2";
-- The DR, Read, and Follow sets are all stored in the same data
-- structure in package lalr_sets.
type Relation_Type is (Use_Reads, Use_Includes);
package LALR_Sets is new
Ragged(Parse_State, Grammar_Symbol,
Grammar_Symbol_Set, Grammar_Symbol_Set_Pack.Make_Null);
use LALR_Sets, Grammar_Symbol_Set_Pack, Transition_Set_Pack;
procedure Make_Dr_Sets is
Trans : Transition;
-- gotos : transition_set;
Goto_Index : Nt_Transition_Iterator;
Term_Sym : Grammar_Symbol;
Terms : Grammar_Symbol_Set;
Term_Index : Grammar_Symbol_Iterator;
begin
-- Make storage to hold the DR sets.
LALR_Sets.Make_Array(First_Parse_State, Last_Parse_State);
-- DR(P,Symbol) = { x is a terminal|P -Symbol-> Next_State -x->}
for P in First_Parse_State..Last_Parse_State loop
-- Get all transitions (Symbol,Next_State) out of state P
-- get_transitions(P, nonterminals, gotos);
Initialize(Goto_Index, P);
while More(Goto_Index) loop
Next(Goto_Index, Trans);
Get_Transition_Symbols(Trans.State_ID, Terminals, Terms);
Initialize(Term_Index, Terms);
while More(Term_Index) loop
Next(Term_Index, Term_Sym);
Insert(Term_Sym,
Into => LALR_Sets.Lval(P,Trans.Symbol).Value);
end loop;
end loop;
end loop;
-- make_null(gotos);
Make_Null(Terms);
end Make_Dr_Sets;
procedure Initialize_N(X: in out Integer) is
begin
X := 0;
end Initialize_N;
procedure Digraph(R : Relation_Type) is
package N is new Ragged(Parse_State, Grammar_Symbol, Integer,
Initialize_N);
package Transition_Stack is new Stack_Pack(Transition);
use Transition_Stack, Transition_Set_Pack;
Trans_Stack : Stack;
Symbol : Grammar_Symbol;
Gotos : Grammar_Symbol_Set;
Goto_Index : Grammar_Symbol_Iterator;
Trans : Transition;
procedure Traverse(X: Transition) is
Infinity : constant Integer := Integer'Last;
Depth : Integer;
LALR_Sets_lval_Index : LALR_Sets.Index;
Minimum : Integer;
Y, Top : Transition;
RHS_Set : Transition_Iterator;
Related : Transition_Set;
begin
Push(Trans_Stack,X);
Depth := Depth_of_Stack(Trans_Stack);
N.Lval(X.State_ID,X.Symbol).Value := Depth;
-- Should take a procedure parameter instead of a key
if R = Use_Reads then
Reads(X, Related);
else
Includes(X, Related);
end if;
Initialize(RHS_Set, Related);
while More(RHS_Set) loop
Next(RHS_Set, Y);
if N.Lval(Y.State_ID, Y.Symbol).Value = 0 then
Traverse(Y);
end if;
Minimum := N.Rval(Y.State_ID, Y.Symbol).Value;
if Minimum < N.Rval(X.State_ID, X.Symbol).Value then
N.Lval(X.State_ID, X.Symbol).Value := Minimum;
end if;
Insert(LALR_Sets.Lval(Y.State_ID,Y.Symbol).Value,
Into => LALR_Sets.Lval(X.State_ID,X.Symbol).Value);
end loop;
if N.Rval(X.State_ID, X.Symbol).Value = Depth then
loop
Top := Top_Value(Trans_Stack);
N.Lval(Top.State_ID,Top.Symbol).Value:= Infinity;
LALR_Sets_lval_Index := LALR_Sets.Lval(Top.State_ID, Top.Symbol);
Assign(LALR_Sets_lval_Index.Value,
LALR_Sets.Rval(X.State_ID, X.Symbol).Value);
Pop(Trans_Stack, Top);
exit when Top = X;
end loop;
end if;
-- Free
Make_Null(Related);
exception
when Value_Range_Error =>
Put_Line("Ayacc: Value Range Error in Traverse");
raise;
when Stack_Underflow =>
Put_Line("Ayacc: Stack Underflow in Traverse");
raise;
when others =>
Put_Line("Ayacc: Unexpected Error in Traverse");
raise;
end Traverse;
begin -- digraph
Make_Stack(Trans_Stack);
N.Make_Array(First_Parse_State, Last_Parse_State);
-- Call traverse(X) for all unexamined nonterminal transitions X
for State in First_Parse_State .. Last_Parse_State loop
Get_Transition_Symbols(State, Nonterminals, Gotos);
Initialize(Goto_Index, Gotos);
while More(Goto_Index) loop
Next(Goto_Index, Symbol);
if N.Lval(State, Symbol).Value = 0 then
Trans.State_ID := State;
Trans.Symbol := Symbol;
Traverse(Trans);
end if;
end loop;
end loop;
Free_Stack(Trans_Stack);
N.Free_Array;
-- Free
Make_Null(Gotos);
exception
when Value_Range_Error =>
Put_Line("Ayacc: Value Range Error in Digraph");
raise;
when Stack_Underflow =>
Put_Line("Ayacc: Stack Underflow in Digraph");
raise;
when others =>
Put_Line("Ayacc: Unexpected Error in Digraph");
raise;
end Digraph;
procedure Make_Read_Sets is
begin
Digraph(Use_Reads);
end Make_Read_Sets;
procedure Make_Follow_Sets is
begin
Digraph(Use_Includes);
Free_Includes;
end Make_Follow_Sets;
procedure Follow(
Trans : Transition;
Follow_Set : in out Grammar_Symbol_Set) is
begin
Make_Null(Follow_Set);
Assign(Follow_Set,
LALR_Sets.Lval(Trans.State_ID,Trans.Symbol).Value);
-- used to rval
end Follow;
procedure Union_Follow_Sets(
Trans : Transition;
Follow_Set: in out Grammar_Symbol_Set) is
begin
Insert(LALR_Sets.Rval(Trans.State_ID,Trans.Symbol).Value,
Into => Follow_Set);
end Union_Follow_Sets;
end LALR_Sets_Pack;
--------------------------------------------------------------------------
use Relation, LALR_Sets_Pack;
procedure Make_LALR_Sets is
begin
Make_Dr_Sets;
Make_Reads_Relation;
Make_Read_Sets;
Make_Includes_Relation;
Make_Follow_Sets;
end Make_LALR_Sets;
--------------------------------------------------------------------------
use Grammar_Symbol_Set_Pack, Parse_State_Set_Pack;
procedure Get_LA(State_ID : Parse_State;
Item_ID : Item;
Look_Aheads : in out Grammar_Symbol_Set) is
Predecessors : Parse_State_Set;
Pred_Loop : Parse_State_Iterator;
Temp : Transition;
begin
Make_Null(Look_Aheads);
Temp.Symbol := Get_LHS(Item_ID.Rule_ID);
Make_Null(Predecessors);
Get_Pred_Set(State_ID, Item_ID ,Predecessors);
Initialize(Pred_Loop, Predecessors);
while More(Pred_Loop) loop
Next(Pred_Loop, Temp.State_ID);
Union_Follow_Sets(Temp, Look_Aheads);
end loop;
-- Free
Make_Null(Predecessors);
end Get_LA;
end LALR_Symbol_Info;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--
with Ada.Command_Line, GNAT.Command_Line;
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO;
with Ada.Containers.Vectors;
with lists.Fixed;
with lists.Bounded;
with lists.Dynamic;
with lists.Vectors;
procedure Test_list_iface_wrec is
type Element_Type is new Integer;
package ACV is new Ada.Containers.Vectors(Positive, Element_Type);
package PL is new Lists(Natural, Element_Type);
package PLF is new PL.Fixed;
package PLB is new PL.Bounded;
package PLD is new PL.Dynamic;
package PLV is new PL.Vectors;
begin -- main
Put_Line("testing Ada.Containers.Vectors..");
declare
type VRec is record
f : ACV.Vector;
end record;
v : VRec := (f => ACV.To_Vector(5));
begin
Put("assigning values .. ");
for i in Integer range 1 .. 5 loop
v.f(i) := Element_Type(i);
end loop;
Put_Line("done;");
Put(" indices: First =" & v.f.First_Index'img & ", Last =" & v.f.Last_Index'img);
Put_Line(", Length =" & v.f.Length'img);
Put(" values, the 'of loop': ");
for n of v.f loop
Put(n'Img);
end loop;
Put("; direct indexing: ");
for i in Positive range 1 .. 5 loop
Put(Element_Type'Image(v.f(i)));
end loop;
end;
New_Line;
--
--
-- New_Line;
-- Put_Line("testing Lists.Fixed..");
-- declare
-- type FRec (N : Positive) is record
-- f : PLF.List(N);
-- end record;
-- lf : FRec(5);
-- begin
-- Put("assigning values .. ");
-- for i in Integer range 1 .. 5 loop
-- lf.f(i) := Element_Type(i);
-- end loop;
-- Put_Line("done;");
-- Put(" indices: First =" & lf.f.First_Index'img & ", Last =" & lf.f.Last_Index'img);
-- Put_Line(", Length =" & lf.f.Length'img);
-- Put(" values, the 'of loop': ");
-- for n of lf.f loop
-- Put(n'Img);
-- end loop;
-- Put("; direct indexing: ");
-- for i in Positive range 1 .. 5 loop
-- Put(Element_Type'Image(lf.f(i)));
-- end loop;
-- end;
-- New_Line;
--
--
-- New_Line;
-- Put_Line("testing Lists.Bounded..");
-- declare
-- type BRec (N : Positive) is record
-- f : PLB.List(N);
-- end record;
-- lb : BRec(5);
-- begin
-- Put("assigning values .. ");
-- for i in Integer range 1 .. 5 loop
-- lb.f(i) := Element_Type(i);
-- end loop;
-- Put_Line("done;");
-- Put(" indices: First =" & lb.f.First_Index'img & ", Last =" & lb.f.Last_Index'img);
-- Put_Line(", Length =" & lb.f.Length'img);
-- Put(" values, the 'of loop': ");
-- for n of lb.f loop
-- Put(n'Img);
-- end loop;
-- Put("; direct indexing: ");
-- for i in Positive range 1 .. 5 loop
-- Put(Element_Type'Image(lb.f(i)));
-- end loop;
-- end;
-- New_Line;
--
--
New_Line;
Put_Line("testing Lists.Dynamic..");
declare
type DRec is record
f : PLD.List;
end record;
ld : DRec := (f => PLD.To_Vector(5));
begin
Put("assigning values .. ");
for i in Integer range 1 .. 5 loop
ld.f(i) := Element_Type(i);
end loop;
Put_Line("done;");
Put(" indices: First =" & ld.f.First_Index'img & ", Last =" & ld.f.Last_Index'img);
Put_Line(", Length =" & ld.f.Length'img);
Put(" values, the 'of loop': ");
for n of ld.f loop
Put(n'Img);
end loop;
Put("; direct indexing: ");
for i in Positive range 1 .. 5 loop
Put(Element_Type'Image(ld.f(i)));
end loop;
end;
New_Line;
--
--
New_Line;
Put_Line("testing Lists.Vectors ..");
declare
type VRec is record
f : PLV.List;
end record;
lv : VRec := (f => PLV.To_Vector(5));
begin
Put("assigning values .. ");
for i in Integer range 1 .. 5 loop
lv.f(i) := Element_Type(i);
end loop;
Put_Line("done;");
Put(" indices: First =" & lv.f.First_Index'img & ", Last =" & lv.f.Last_Index'img);
Put_Line(", Length =" & Ada.Containers.Count_Type'Image(lv.f.Length)); -- apparently ACV.Vector methods are not masked enough here..
Put(" values, the 'of loop': ");
for n of lv.f loop
Put(n'Img);
end loop;
Put("; direct indexing: ");
for i in Positive range 1 .. 5 loop
Put(Element_Type'Image(lv.f(i)));
end loop;
end;
New_Line;
--
--
-- New_Line;
-- Put_Line("testing List_Interface'Class ..");
-- declare
-- -- we cannot have indeterminate ('Class) type as a "primitive" record field,
-- -- we have to pass some info as a discriminant, and via Access.
-- -- Need to figure out the way to use it here that actually makes utilitary sense.
-- -- May not be very useful with untagged Element_Type..
-- type CRec (f : access PL.List_Interface'Class) is null record;
-- lc : CRec (f => PLD.To_Vector(5)'Access); -- what to pass here??
-- -- May try to use Reference_Type, but that is already entering that interface based
-- -- type hierarchy of iface_lists..
-- begin
-- Put("assigning values .. ");
-- for i in Integer range 1 .. 5 loop
-- lc.f(i) := Element_Type(i);
-- end loop;
-- Put_Line("done;");
-- Put(" indices: First =" & lc.f.First_Index'img & ", Last =" & lc.f.Last_Index'img);
-- Put_Line(", Length =" & lc.f.Length'img);
-- Put(" values, the 'of loop': ");
-- for n of lc.f loop
-- Put(n'Img);
-- end loop;
-- Put("; direct indexing: ");
-- for i in Positive range 1 .. 5 loop
-- Put(Element_Type'Image(lc.f(i)));
-- end loop;
-- end;
-- New_Line;
end Test_list_iface_wrec;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
with Ada.Calendar;
with Ada.Real_Time;
with Util.Refs;
with Helios.Schemas;
-- == Data Representation ==
-- The monitored data is collected into snapshots and snapshots are stored in a queue
-- before being flushed.
package Helios.Datas is
subtype Definition_Type_Access is Schemas.Definition_Type_Access;
type Snapshot_Type;
type Snapshot_Type_Access is access all Snapshot_Type;
type Snapshot_Type is tagged limited private;
type Snapshot_Queue_Type is limited private;
-- Initialize the snapshot queue for the schema.
procedure Initialize (Queue : in out Snapshot_Queue_Type;
Schema : in Helios.Schemas.Definition_Type_Access;
Count : in Positive);
-- Get the snapshot start time.
function Get_Start_Time (Data : in Snapshot_Type) return Ada.Real_Time.Time;
-- Get the snapshot end time.
function Get_End_Time (Data : in Snapshot_Type) return Ada.Real_Time.Time;
-- Finish updating the current values of the snapshot.
procedure Finish (Data : in out Snapshot_Type);
-- Set the value in the snapshot.
procedure Set_Value (Into : in out Snapshot_Type;
Def : in Schemas.Definition_Type_Access;
Value : in Uint64);
-- Iterate over the values in the snapshot and collected for the definition node.
procedure Iterate (Data : in Snapshot_Type;
Node : in Definition_Type_Access;
Process : not null access procedure (Value : in Uint64));
procedure Iterate (Data : in Snapshot_Type;
Node : in Definition_Type_Access;
Process_Snapshot : not null access procedure (D : in Snapshot_Type;
N : in Definition_Type_Access);
Process_Values : not null access procedure (D : in Snapshot_Type;
N : in Definition_Type_Access));
-- Prepare the snapshot queue to collect new values.
procedure Prepare (Queue : in out Snapshot_Queue_Type;
Snapshot : out Snapshot_Type_Access);
-- Flush the snapshot to start a fresh one for the queue.
procedure Flush (Queue : in out Snapshot_Queue_Type);
type Report_Queue_Type is private;
function Get_Report return Report_Queue_Type;
-- Iterate over the values of the reports.
procedure Iterate (Report : in Report_Queue_Type;
Process : not null access procedure (Data : in Snapshot_Type;
Node : in Definition_Type_Access));
private
subtype Value_Index is Schemas.Value_Index;
subtype Value_Array_Index is Value_Index range 1 .. Value_Index'Last;
type Snapshot_Index is new Natural;
type Report_Index is new Natural;
type Value_Array is array (Value_Array_Index range <>) of Uint64;
type Value_Array_Access is access all Value_Array;
type Snapshot_Type is tagged limited record
Schema : Helios.Schemas.Definition_Type_Access;
Next : Snapshot_Type_Access;
Count : Value_Index := 0;
Time : Ada.Calendar.Time;
Start_Time : Ada.Real_Time.Time;
End_Time : Ada.Real_Time.Time;
Offset : Value_Index := 0;
Values : Value_Array_Access;
end record;
type Snapshot_List is new Util.Refs.Ref_Entity with record
First : Snapshot_Type_Access;
end record;
type Snapshot_List_Access is access all Snapshot_List;
-- Release the snapshots when the reference counter reaches 0.
overriding
procedure Finalize (Object : in out Snapshot_List);
package Snapshot_Refs is new Util.Refs.References (Element_Type => Snapshot_List,
Element_Access => Snapshot_List_Access);
subtype Snapshot_Accessor is Snapshot_Refs.Element_Accessor;
type Snapshot_Queue_Type is limited record
Count : Natural := 0;
Schema : Helios.Schemas.Definition_Type_Access;
Current : Snapshot_Type_Access;
end record;
type Snapshot_Queue_Access is access all Snapshot_Queue_Type;
type Report_Queue_Type is record
Snapshot : Snapshot_Refs.Ref;
end record;
end Helios.Datas;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-----------------------------------------------------------------------
with Servlet.Routes;
with Servlet.Routes.Servlets.Rest;
with Servlet.Core.Rest;
with EL.Contexts.Default;
with Util.Log.Loggers;
package body Servlet.Rest is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Servlet.Rest");
-- ------------------------------
-- Get the permission index associated with the REST operation.
-- ------------------------------
function Get_Permission (Handler : in Descriptor)
return Security.Permissions.Permission_Index is
begin
return Handler.Permission;
end Get_Permission;
-- ------------------------------
-- Register the API descriptor in a list.
-- ------------------------------
procedure Register (List : in out Descriptor_Access;
Item : in Descriptor_Access) is
begin
Item.Next := List;
List := Item;
end Register;
-- ------------------------------
-- Register the list of API descriptors for a given servlet and a root path.
-- ------------------------------
procedure Register (Registry : in out Servlet.Core.Servlet_Registry;
Name : in String;
URI : in String;
ELContext : in EL.Contexts.ELContext'Class;
List : in Descriptor_Access) is
procedure Insert (Route : in out Servlet.Routes.Route_Type_Ref);
Item : Descriptor_Access := List;
procedure Insert (Route : in out Servlet.Routes.Route_Type_Ref) is
begin
if not Route.Is_Null then
declare
R : constant Servlet.Routes.Route_Type_Accessor := Route.Value;
D : access Servlet.Routes.Servlets.Rest.API_Route_Type'Class;
begin
if not (R in Servlet.Routes.Servlets.Rest.API_Route_Type'Class) then
Log.Error ("Route API for {0}/{1} already used by another page",
URI, Item.Pattern.all);
return;
end if;
D := Servlet.Routes.Servlets.Rest.API_Route_Type'Class (R.Element.all)'Access;
if D.Descriptors (Item.Method) /= null then
Log.Error ("Route API for {0}/{1} is already used", URI, Item.Pattern.all);
end if;
D.Descriptors (Item.Method) := Item;
end;
else
declare
D : access Servlet.Routes.Servlets.Rest.API_Route_Type'Class;
begin
D := Servlet.Core.Rest.Create_Route (Registry, Name);
Route := Servlet.Routes.Route_Type_Refs.Create (D.all'Access);
if D.Descriptors (Item.Method) /= null then
Log.Error ("Route API for {0}/{1} is already used", URI, Item.Pattern.all);
end if;
D.Descriptors (Item.Method) := Item;
end;
end if;
end Insert;
begin
Log.Info ("Adding API route {0}", URI);
while Item /= null loop
Log.Debug ("Adding API route {0}/{1}", URI, Item.Pattern.all);
Registry.Add_Route (URI & "/" & Item.Pattern.all, ELContext, Insert'Access);
Item := Item.Next;
end loop;
end Register;
-- ------------------------------
-- Dispatch the request to the API handler.
-- ------------------------------
overriding
procedure Dispatch (Handler : in Static_Descriptor;
Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Output_Stream'Class) is
begin
Handler.Handler (Req, Reply, Stream);
end Dispatch;
-- ------------------------------
-- Register the API definition in the servlet registry.
-- ------------------------------
procedure Register (Registry : in out Servlet.Core.Servlet_Registry'Class;
Definition : in Descriptor_Access) is
use type Servlet.Core.Servlet_Access;
procedure Insert (Route : in out Routes.Route_Type_Ref);
Dispatcher : constant Servlet.Core.Request_Dispatcher
:= Registry.Get_Request_Dispatcher (Definition.Pattern.all);
Servlet : constant Core.Servlet_Access := Core.Get_Servlet (Dispatcher);
procedure Insert (Route : in out Routes.Route_Type_Ref) is
begin
if not Route.Is_Null then
declare
R : constant Routes.Route_Type_Accessor := Route.Value;
D : access Routes.Servlets.Rest.API_Route_Type'Class;
begin
if not (R in Routes.Servlets.Rest.API_Route_Type'Class) then
Log.Error ("Route API for {0} already used by another page",
Definition.Pattern.all);
D := Core.Rest.Create_Route (Servlet);
Route := Routes.Route_Type_Refs.Create (D.all'Access);
else
D := Routes.Servlets.Rest.API_Route_Type'Class (R.Element.all)'Access;
end if;
if D.Descriptors (Definition.Method) /= null then
Log.Error ("Route API for {0} is already used", Definition.Pattern.all);
end if;
D.Descriptors (Definition.Method) := Definition;
end;
else
declare
D : access Routes.Servlets.Rest.API_Route_Type'Class;
begin
D := Core.Rest.Create_Route (Servlet);
Route := Routes.Route_Type_Refs.Create (D.all'Access);
if D.Descriptors (Definition.Method) /= null then
Log.Error ("Route API for {0} is already used", Definition.Pattern.all);
end if;
D.Descriptors (Definition.Method) := Definition;
end;
end if;
end Insert;
Ctx : EL.Contexts.Default.Default_Context;
begin
if Servlet = null then
Log.Error ("Cannot register REST operation {0}: no REST servlet",
Definition.Pattern.all);
return;
end if;
Registry.Add_Route (Definition.Pattern.all, Ctx, Insert'Access);
end Register;
end Servlet.Rest;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Text_IO; use Ada.Text_IO;
package body oop_mixin is
overriding
procedure simple(Self : Derived) is
begin
Put_Line(" oop:simple");
end;
overriding
procedure compound(Self : Derived) is
begin
Put_Line(" oop:compound, calling Derived.simple");
Self.simple;
end;
overriding
procedure redispatching(Self : Derived) is
begin
Put_Line(" oop:redispatching, calling Derived'Class.simple");
Derived'Class(Self).simple;
end;
end oop_mixin;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
generic
with procedure Start_Emitting is <>;
with procedure Finish_Emitting is <>;
with procedure Start_Parsed_Input is <>;
with procedure End_Parsed_Input is <>;
with procedure Start_Parsed_Output is <>;
with procedure End_Parsed_Output is <>;
with procedure Start_Rendered_Event (E : Event) is <>;
with procedure End_Rendered_Event is <>;
with procedure Emit_Whitespace (Content : String) is <>;
with procedure Emit_Comment (Content : String) is <>;
with procedure Emit_Anchor (Content : String) is <>;
with procedure Emit_Tag (Content : String) is <>;
with procedure Emit_Event_Content (Content : String) is <>;
with procedure Emit_Raw_Event (E : Event) is <>;
with procedure Emit_Unparseable (Content : String) is <>;
with procedure Emit_Lexer_Error (Token_Start, Error_Char : Mark;
Error_Message : String) is <>;
with procedure Emit_Parser_Error (Token_Start, Token_End : Mark;
Error_Message : String) is <>;
procedure Yaml.Inspect (Input : String);
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Text_IO, Ada.Containers.Ordered_Sets;
procedure Set_Demo is
package CS is new Ada.Containers.Ordered_Sets(Character); use CS;
package IO renames Ada.Text_IO;
-- helper functions for string to something conversion, and vice versa
function To_Set(S: String) return Set is
Result: Set;
begin
for I in S'Range loop
begin
Result.Insert(S(I));
-- raises Constraint_Error if S(I) is already in Result
exception
when Constraint_Error => null;
end;
end loop;
return Result;
end To_Set;
function Image(S: Set) return String is
C: Character;
T: Set := S;
begin
if T.Is_Empty then
return "";
else
C:= T.First_Element;
T.Delete_First;
return C & Image(T);
end if;
end Image;
function Image(C: Ada.Containers.Count_Type) return String renames
Ada.Containers.Count_Type'Image;
S1, S2: Set;
begin -- main program
loop
S1 := To_Set(Ada.Text_IO.Get_Line);
exit when S1 = To_Set("quit!");
S2 := To_Set(Ada.Text_IO.Get_Line);
IO.Put_Line("Sets [" & Image(S1) & "], [" & Image(S2) & "] of size"
& Image(S1.Length) & " and" & Image(S2.Length) & ".");
IO.Put_Line("Intersection: [" & Image(Intersection(S1, S2)) & "],");
IO.Put_Line("Union: [" & Image(Union(S1, S2)) & "],");
IO.Put_Line("Difference: [" & Image(Difference(S1, S2)) & "],");
IO.Put_Line("Symmetric Diff: [" & Image(S1 xor S2) & "],");
IO.Put_Line("Subset: " & Boolean'Image(S1.Is_Subset(S2))
& ", Equal: " & Boolean'Image(S1 = S2) & ".");
end loop;
end Set_Demo;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Strings.Fixed;
with Interfaces.C.Strings;
with GL.API;
with GL.Enums.Getter;
with GL.Errors;
package body GL.Context is
function Major_Version return Int is
Result : aliased Int;
begin
API.Get_Integer (Enums.Getter.Major_Version, Result'Access);
Raise_Exception_On_OpenGL_Error;
return Result;
end Major_Version;
function Minor_Version return Int is
Result : aliased Int;
begin
API.Get_Integer (Enums.Getter.Minor_Version, Result'Access);
Raise_Exception_On_OpenGL_Error;
return Result;
end Minor_Version;
function Version_String return String is
begin
return C.Strings.Value (API.Get_String (Enums.Getter.Version));
end Version_String;
function Vendor return String is
begin
return C.Strings.Value (API.Get_String (Enums.Getter.Vendor));
end Vendor;
function Renderer return String is
begin
return C.Strings.Value (API.Get_String (Enums.Getter.Renderer));
end Renderer;
function Extensions return String_List is
use Ada.Strings.Unbounded;
use type Errors.Error_Code;
Count : aliased Int;
begin
API.Get_Integer (Enums.Getter.Num_Extensions, Count'Access);
if API.Get_Error = Errors.No_Error then
-- we are on OpenGL 3
return List : String_List (1 .. Positive (Count)) do
for I in List'Range loop
List (I) := To_Unbounded_String
(C.Strings.Value (API.Get_String_I
(Enums.Getter.Extensions, UInt (I - 1))));
end loop;
end return;
else
-- OpenGL 2 fallback
declare
Raw : constant String := C.Strings.Value
(API.Get_String (Enums.Getter.Extensions));
Cur_Pos : Positive := Raw'First;
Next_Space : Natural;
begin
if Raw'Length = 0 then
return Null_String_List;
end if;
return List : String_List
(1 .. Ada.Strings.Fixed.Count (Raw, " ") + 1) do
for I in List'Range loop
Next_Space := Ada.Strings.Fixed.Index (Raw, " ", Cur_Pos);
if Next_Space = 0 then
-- this is the last token, there is no space behind it.
Next_Space := Raw'Last + 1;
end if;
List (I) := To_Unbounded_String
(Raw (Cur_Pos .. Next_Space - 1));
Cur_Pos := Next_Space + 1;
end loop;
end return;
end;
end if;
end Extensions;
function Has_Extension (Name : String) return Boolean is
use type Errors.Error_Code;
Count : aliased Int;
begin
API.Get_Integer (Enums.Getter.Num_Extensions, Count'Access);
if API.Get_Error = Errors.No_Error then
-- we are on OpenGL 3
for I in 1 .. Count loop
declare
Extension : constant String := C.Strings.Value
(API.Get_String_I (Enums.Getter.Extensions, UInt (I - 1)));
begin
if Extension = Name then
return True;
end if;
end;
end loop;
else
-- OpenGL 2 fallback
declare
Raw : constant String := C.Strings.Value
(API.Get_String (Enums.Getter.Extensions));
Cur_Pos : Positive := Raw'First;
Next_Space : Natural;
begin
if Raw'Length = 0 then
return False;
end if;
for I in 1 .. Ada.Strings.Fixed.Count (Raw, " ") + 1 loop
Next_Space := Ada.Strings.Fixed.Index (Raw, " ", Cur_Pos);
if Next_Space = 0 then
Next_Space := Raw'Last + 1;
end if;
if Raw (Cur_Pos .. Next_Space - 1) = Name then
return True;
end if;
Cur_Pos := Next_Space + 1;
end loop;
end;
end if;
return False;
end Has_Extension;
function Primary_Shading_Language_Version return String is
Result : constant String := C.Strings.Value
(API.Get_String (Enums.Getter.Shading_Language_Version));
begin
Raise_Exception_On_OpenGL_Error;
return Result;
end Primary_Shading_Language_Version;
function Supported_Shading_Language_Versions return String_List is
use Ada.Strings.Unbounded;
use type Errors.Error_Code;
Count : aliased Int;
begin
API.Get_Integer (Enums.Getter.Num_Shading_Language_Versions, Count'Access);
if API.Get_Error = Errors.Invalid_Enum then
raise Feature_Not_Supported_Exception;
end if;
return List : String_List (1 .. Positive (Count)) do
for I in List'Range loop
List (I) := To_Unbounded_String
(C.Strings.Value (API.Get_String_I (
Enums.Getter.Shading_Language_Version, UInt (I - 1))));
end loop;
end return;
end Supported_Shading_Language_Versions;
function Supports_Shading_Language_Version (Name : String) return Boolean is
Count : aliased Int;
begin
API.Get_Integer (Enums.Getter.Num_Shading_Language_Versions, Count'Access);
Raise_Exception_On_OpenGL_Error;
for I in 1 .. Count loop
if C.Strings.Value
(API.Get_String_I (Enums.Getter.Shading_Language_Version,
UInt (I - 1))) = Name then
return True;
end if;
end loop;
return False;
end Supports_Shading_Language_Version;
end GL.Context;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-------------------------------------------------------------------------------
package body Keccak.Generic_Parallel_Sponge
is
--------------
-- Lemmas --
--------------
pragma Warnings (Off, "postcondition does not check the outcome");
procedure Lemma_Remaining_Mod_Rate_Preserve
(Offset, Remaining, Length : in Natural;
Rate : in Positive)
with Global => null,
Ghost,
Pre => (Offset <= Length
and then Remaining <= Length
and then Length - Remaining = Offset
and then Remaining < Rate
and then Offset mod Rate = 0),
Post => ((Remaining mod Rate = 0) = (Length mod Rate = 0));
procedure Lemma_Offset_Mod_Rate_Preserve
(Offset : in Natural;
Rate : in Positive)
with Global => null,
Ghost,
Pre => (Offset <= Natural'Last - Rate
and Offset mod Rate = 0),
Post => (Offset + Rate) mod Rate = 0;
pragma Warnings (On, "postcondition does not check the outcome");
procedure Lemma_Remaining_Mod_Rate_Preserve
(Offset, Remaining, Length : in Natural;
Rate : in Positive)
is
begin
pragma Assert (Offset + Remaining = Length);
pragma Assert (Remaining mod Rate = Length mod Rate);
end Lemma_Remaining_Mod_Rate_Preserve;
procedure Lemma_Offset_Mod_Rate_Preserve
(Offset : in Natural;
Rate : in Positive)
is
begin
pragma Assert ((Offset + Rate) mod Rate = 0);
end Lemma_Offset_Mod_Rate_Preserve;
-------------------
-- Add_Padding --
-------------------
procedure Add_Padding (Ctx : in out Context)
with Global => null,
Pre => State_Of (Ctx) = Absorbing,
Post => State_Of (Ctx) = Squeezing;
------------
-- Init --
------------
procedure Init (Ctx : out Context)
is
begin
Ctx.Rate := (State_Size - Ctx.Capacity) / 8;
Ctx.State := Absorbing;
Init (Ctx.Permutation_State);
pragma Assert (State_Of (Ctx) = Absorbing);
end Init;
-----------------------------
-- Absorb_Bytes_Separate --
-----------------------------
procedure Absorb_Bytes_Separate (Ctx : in out Context;
Data : in Types.Byte_Array)
is
Block_Size : constant Natural := Data'Length / Num_Parallel_Instances;
Rate_Bytes : constant Rate_Bytes_Number := Ctx.Rate;
Buffer_Size : constant Natural := Rate_Bytes * Num_Parallel_Instances;
Remaining : Natural := Block_Size;
Offset : Natural := 0;
Pos : Types.Index_Number;
Buf_First : Types.Index_Number;
Buf_Last : Types.Index_Number;
Buffer : Types.Byte_Array (0 .. Buffer_Size - 1) := (others => 0);
begin
while Remaining >= Ctx.Rate loop
pragma Loop_Invariant (Offset + Remaining = Block_Size);
pragma Loop_Invariant (Offset mod Ctx.Rate = 0);
pragma Loop_Invariant (Offset <= Block_Size);
XOR_Bits_Into_State_Separate
(S => Ctx.Permutation_State,
Data => Data,
Data_Offset => Offset,
Bit_Len => Ctx.Rate * 8);
Permute_All (Ctx.Permutation_State);
Lemma_Offset_Mod_Rate_Preserve (Offset, Ctx.Rate);
Offset := Offset + Ctx.Rate;
Remaining := Remaining - Ctx.Rate;
end loop;
pragma Assert (Remaining < Ctx.Rate);
pragma Assert (Offset mod Ctx.Rate = 0);
pragma Assert (Offset + Remaining = Block_Size);
Lemma_Remaining_Mod_Rate_Preserve (Offset, Remaining, Block_Size, Ctx.Rate);
if Remaining > 0 then
pragma Assert (Remaining mod Ctx.Rate /= 0);
pragma Assert (Block_Size mod Ctx.Rate /= 0);
Ctx.State := Squeezing;
-- Apply the padding rule to the final chunk of data.
for I in 0 .. Num_Parallel_Instances - 1 loop
Pos := Data'First + (I * Block_Size) + Offset;
Buf_First := (Ctx.Rate * I);
Buf_Last := (Ctx.Rate * I) + (Remaining - 1);
Buffer (Buf_First .. Buf_Last) := Data (Pos .. Pos + (Remaining - 1));
pragma Assert (Buf_First + (Ctx.Rate - 1) in Buffer'Range);
Pad (Block => Buffer (Buf_First .. Buf_First + (Ctx.Rate - 1)),
Num_Used_Bits => Remaining * 8,
Max_Bit_Length => Ctx.Rate * 8);
end loop;
XOR_Bits_Into_State_Separate
(S => Ctx.Permutation_State,
Data => Buffer,
Data_Offset => 0,
Bit_Len => Ctx.Rate * 8);
Permute_All (Ctx.Permutation_State);
else
-- Help prove contract case.
pragma Assert ((Data'Length / Num_Parallel_Instances) mod (Rate_Of (Ctx) / 8) = 0);
end if;
end Absorb_Bytes_Separate;
------------------------
-- Absorb_Bytes_All --
------------------------
procedure Absorb_Bytes_All (Ctx : in out Context;
Data : in Types.Byte_Array)
is
Rate_Bytes : constant Positive := Ctx.Rate;
Offset : Natural := 0;
Remaining : Natural := Data'Length;
Pos : Types.Index_Number;
Buffer : Types.Byte_Array (0 .. Rate_Bytes - 1);
begin
while Remaining >= Ctx.Rate loop
pragma Loop_Invariant (Offset + Remaining = Data'Length);
pragma Loop_Invariant (Offset mod Ctx.Rate = 0);
pragma Loop_Invariant (Offset <= Data'Length);
Pos := Data'First + Offset;
XOR_Bits_Into_State_All
(S => Ctx.Permutation_State,
Data => Data (Pos .. Pos + Ctx.Rate - 1),
Bit_Len => Ctx.Rate * 8);
Permute_All (Ctx.Permutation_State);
Lemma_Offset_Mod_Rate_Preserve (Offset, Ctx.Rate);
Offset := Offset + Ctx.Rate;
Remaining := Remaining - Ctx.Rate;
end loop;
pragma Assert (Remaining < Ctx.Rate);
pragma Assert (Offset mod Ctx.Rate = 0);
pragma Assert (Offset + Remaining = Data'Length);
if Remaining > 0 then
pragma Assert (Remaining mod Ctx.Rate /= 0);
pragma Assert (Data'Length mod Ctx.Rate /= 0);
Ctx.State := Squeezing;
Buffer := (others => 0);
Buffer (0 .. Remaining - 1) := Data (Data'First + Offset .. Data'Last);
Pad (Block => Buffer,
Num_Used_Bits => Remaining * 8,
Max_Bit_Length => Ctx.Rate * 8);
XOR_Bits_Into_State_All
(S => Ctx.Permutation_State,
Data => Buffer,
Bit_Len => Ctx.Rate * 8);
Permute_All (Ctx.Permutation_State);
end if;
end Absorb_Bytes_All;
------------------------------------
-- Absorb_Bytes_All_With_Suffix --
------------------------------------
procedure Absorb_Bytes_All_With_Suffix
(Ctx : in out Context;
Data : in Types.Byte_Array;
Suffix : in Types.Byte;
Suffix_Len : in Natural)
is
Rate_Bytes : constant Positive := Ctx.Rate;
Offset : Natural;
Remaining : Natural;
Num_Full_Blocks : Natural;
Length : Natural;
Buffer : Types.Byte_Array (0 .. Rate_Bytes - 1) := (others => 0);
begin
Num_Full_Blocks := Data'Length / Ctx.Rate;
-- Process full blocks of data, if available.
if Num_Full_Blocks > 0 then
Length := Num_Full_Blocks * Ctx.Rate;
Absorb_Bytes_All
(Ctx => Ctx,
Data => Data (Data'First .. Data'First + Length - 1));
Offset := Length;
Remaining := Data'Length - Length;
else
Offset := 0;
Remaining := Data'Length;
end if;
Ctx.State := Squeezing;
if Remaining > 0 then
-- Append suffix + padding to remaining bytes
Buffer (0 .. Remaining - 1) := Data (Data'First + Offset .. Data'Last);
Buffer (Remaining) := Suffix;
Pad (Block => Buffer,
Num_Used_Bits => (Remaining * 8) + Suffix_Len,
Max_Bit_Length => Ctx.Rate * 8);
else
-- No remaining data, just process suffix + padding
Buffer (0) := Suffix;
Pad (Block => Buffer,
Num_Used_Bits => Suffix_Len,
Max_Bit_Length => Ctx.Rate * 8);
end if;
XOR_Bits_Into_State_All
(S => Ctx.Permutation_State,
Data => Buffer,
Bit_Len => Ctx.Rate * 8);
Permute_All (Ctx.Permutation_State);
end Absorb_Bytes_All_With_Suffix;
-----------------------------------------
-- Absorb_Bytes_Separate_With_Suffix --
-----------------------------------------
procedure Absorb_Bytes_Separate_With_Suffix
(Ctx : in out Context;
Data : in Types.Byte_Array;
Suffix : in Types.Byte;
Suffix_Len : in Natural)
is
Block_Size : constant Natural := Data'Length / Num_Parallel_Instances;
Rate_Bytes : constant Rate_Bytes_Number := Ctx.Rate;
Buffer_Size : constant Natural := Rate_Bytes * Num_Parallel_Instances;
Remaining : Natural := Block_Size;
Offset : Natural := 0;
Pos : Types.Index_Number;
Buf_First : Types.Index_Number;
Buf_Last : Types.Index_Number;
Buffer : Types.Byte_Array (0 .. Buffer_Size - 1) := (others => 0);
begin
Ctx.State := Squeezing;
while Remaining >= Ctx.Rate loop
pragma Loop_Invariant (Offset + Remaining = Block_Size);
pragma Loop_Invariant (Offset mod Ctx.Rate = 0);
pragma Loop_Invariant (Offset <= Block_Size);
XOR_Bits_Into_State_Separate
(S => Ctx.Permutation_State,
Data => Data,
Data_Offset => Offset,
Bit_Len => Ctx.Rate * 8);
Permute_All (Ctx.Permutation_State);
Lemma_Offset_Mod_Rate_Preserve (Offset, Ctx.Rate);
Remaining := Remaining - Ctx.Rate;
Offset := Offset + Ctx.Rate;
end loop;
if Remaining > 0 then
-- Apply the padding rule to the final chunk of data + suffix.
for I in 0 .. Num_Parallel_Instances - 1 loop
Pos := Data'First + (I * Block_Size) + Offset;
Buf_First := (Ctx.Rate * I);
Buf_Last := (Ctx.Rate * I) + (Remaining - 1);
Buffer (Buf_First .. Buf_Last) := Data (Pos .. Pos + (Remaining - 1));
Buffer (Buf_Last + 1) := Suffix;
Pad (Block => Buffer (Buf_First .. Buf_First + (Ctx.Rate - 1)),
Num_Used_Bits => (Remaining * 8) + Suffix_Len,
Max_Bit_Length => Ctx.Rate * 8);
end loop;
else
-- Apply the padding rule to the suffix only.
Buffer := (0 => Suffix,
others => 0);
Pad (Block => Buffer (0 .. Ctx.Rate - 1),
Num_Used_Bits => Suffix_Len,
Max_Bit_Length => Ctx.Rate * 8);
-- Replicate the padding for each parallel instance.
for I in 1 .. Num_Parallel_Instances - 1 loop
Buffer (I * Ctx.Rate .. I * Ctx.Rate + Ctx.Rate - 1) :=
Buffer (0 .. Ctx.Rate - 1);
end loop;
end if;
XOR_Bits_Into_State_Separate
(S => Ctx.Permutation_State,
Data => Buffer,
Data_Offset => 0,
Bit_Len => Ctx.Rate * 8);
Permute_All (Ctx.Permutation_State);
end Absorb_Bytes_Separate_With_Suffix;
-------------------
-- Add_Padding --
-------------------
procedure Add_Padding (Ctx : in out Context)
is
Rate_Bytes : constant Rate_Bytes_Number := Ctx.Rate;
Buffer : Types.Byte_Array (0 .. (Rate_Bytes * Num_Parallel_Instances) - 1);
begin
Buffer := (others => 0);
Pad (Block => Buffer (0 .. Ctx.Rate - 1),
Num_Used_Bits => 0,
Max_Bit_Length => Ctx.Rate * 8);
-- Replicate the padding for each parallel instance.
for I in 1 .. Num_Parallel_Instances - 1 loop
Buffer (I * Ctx.Rate .. I * Ctx.Rate + Ctx.Rate - 1) :=
Buffer (0 .. Ctx.Rate - 1);
end loop;
XOR_Bits_Into_State_Separate
(S => Ctx.Permutation_State,
Data => Buffer,
Data_Offset => 0,
Bit_Len => Ctx.Rate * 8);
Permute_All (Ctx.Permutation_State);
Ctx.State := Squeezing;
pragma Assert (State_Of (Ctx) = Squeezing);
end Add_Padding;
------------------------------
-- Squeeze_Bytes_Separate --
------------------------------
procedure Squeeze_Bytes_Separate (Ctx : in out Context;
Data : out Types.Byte_Array)
is
Block_Size : constant Natural := Data'Length / Num_Parallel_Instances;
Remaining : Natural := Block_Size;
Offset : Natural := 0;
begin
-- If we're coming straight from the absorbing phase then we need to
-- apply the padding rule before proceeding to the squeezing phase,
if Ctx.State = Absorbing then
Add_Padding (Ctx);
end if;
while Remaining >= Ctx.Rate loop
pragma Loop_Invariant (Offset + Remaining = Block_Size);
pragma Loop_Invariant (Offset mod Ctx.Rate = 0);
pragma Loop_Invariant (Offset <= Block_Size);
Extract_Bytes
(S => Ctx.Permutation_State,
Data => Data,
Data_Offset => Offset,
Byte_Len => Ctx.Rate);
pragma Annotate
(GNATprove, False_Positive,
"""Data"" is not initialized",
"The array will be wholly initialized at the end of this procedure");
Permute_All (Ctx.Permutation_State);
Lemma_Offset_Mod_Rate_Preserve (Offset, Ctx.Rate);
Remaining := Remaining - Ctx.Rate;
Offset := Offset + Ctx.Rate;
end loop;
pragma Assert (Remaining < Ctx.Rate);
pragma Assert (Offset mod Ctx.Rate = 0);
pragma Assert (Offset + Remaining = Block_Size);
Lemma_Remaining_Mod_Rate_Preserve (Offset, Remaining, Block_Size, Ctx.Rate);
if Remaining > 0 then
pragma Assert (Remaining mod Ctx.Rate /= 0);
pragma Assert (Block_Size mod Ctx.Rate /= 0);
Ctx.State := Finished;
Extract_Bytes
(S => Ctx.Permutation_State,
Data => Data,
Data_Offset => Offset,
Byte_Len => Remaining);
pragma Annotate
(GNATprove, False_Positive,
"""Data"" might not be initialized",
"The array will be wholly initialized at the end of this procedure");
end if;
end Squeeze_Bytes_Separate;
end Keccak.Generic_Parallel_Sponge;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
Pragma Ada_2012;
Pragma Assertion_Policy( Check );
With
Unchecked_Conversion,
Ada.Text_IO;
Procedure Test_Roman_Numerals is
-- We create an enumeration of valid characters, note that they are
-- character-literals, this is so that we can use literal-strings,
-- and that their size is that of Integer.
Type Roman_Digits is ('I', 'V', 'X', 'L', 'C', 'D', 'M' )
with Size => Integer'Size;
-- We use a representation-clause ensure the proper integral-value
-- of each individual character.
For Roman_Digits use
(
'I' => 1,
'V' => 5,
'X' => 10,
'L' => 50,
'C' => 100,
'D' => 500,
'M' => 1000
);
-- To convert a Roman_Digit to an integer, we now only need to
-- read its value as an integer.
Function Convert is new Unchecked_Conversion
( Source => Roman_Digits, Target => Integer );
-- Romena_Numeral is a string of Roman_Digit.
Type Roman_Numeral is array (Positive range <>) of Roman_Digits;
-- The Numeral_List type is used herein only for testing
-- and verification-data.
Type Numeral_List is array (Positive range <>) of
not null access Roman_Numeral;
-- The Test_Cases subtype ensures that Test_Data and Validation_Data
-- both contain the same number of elements, and that the indecies
-- are the same; essentially the same as:
--
-- pragma Assert( Test_Data'Length = Validation_Data'Length
-- AND Test_Data'First = Validation_Data'First);
subtype Test_Cases is Positive range 1..14;
Test_Data : constant Numeral_List(Test_Cases):=
(
New Roman_Numeral'("III"), -- 3
New Roman_Numeral'("XXX"), -- 30
New Roman_Numeral'("CCC"), -- 300
New Roman_Numeral'("MMM"), -- 3000
New Roman_Numeral'("VII"), -- 7
New Roman_Numeral'("LXVI"), -- 66
New Roman_Numeral'("CL"), -- 150
New Roman_Numeral'("MCC"), -- 1200
New Roman_Numeral'("IV"), -- 4
New Roman_Numeral'("IX"), -- 9
New Roman_Numeral'("XC"), -- 90
New Roman_Numeral'("ICM"), -- 901
New Roman_Numeral'("CIM"), -- 899
New Roman_Numeral'("MDCLXVI") -- 1666
);
Validation_Data : constant array(Test_Cases) of Natural:=
( 3, 30, 300, 3000,
7, 66, 150, 1200,
4, 9, 90,
901, 899,
1666
);
-- In Roman numerals, the subtractive form [IV = 4] was used
-- very infrequently, the most common form was the addidive
-- form [IV = 6]. (Consider military logistics and squads.)
-- SUM returns the Number, read in the additive form.
Function Sum( Number : Roman_Numeral ) return Natural is
begin
Return Result : Natural:= 0 do
For Item of Number loop
Result:= Result + Convert( Item );
end loop;
End Return;
end Sum;
-- EVAL returns Number read in the subtractive form.
Function Eval( Number : Roman_Numeral ) return Natural is
Current : Roman_Digits:= 'I';
begin
Return Result : Natural:= 0 do
For Item of Number loop
if Current < Item then
Result:= Convert(Item) - Result;
Current:= Item;
else
Result:= Result + Convert(Item);
end if;
end loop;
End Return;
end Eval;
-- Display the given Roman_Numeral via Text_IO.
Procedure Put( S: Roman_Numeral ) is
begin
For Ch of S loop
declare
-- The 'Image attribute returns the character inside
-- single-quotes; so we select the character itself.
C : Character renames Roman_Digits'Image(Ch)(2);
begin
Ada.Text_IO.Put( C );
end;
end loop;
end;
-- This displays pass/fail dependant on the parameter.
Function PF ( Value : Boolean ) Return String is
begin
Return Result : String(1..4):= ( if Value then"pass"else"fail" );
End PF;
Begin
Ada.Text_IO.Put_Line("Starting Test:");
for Index in Test_Data'Range loop
declare
Item : Roman_Numeral renames Test_Data(Index).all;
Value : constant Natural := Eval(Item);
begin
Put( Item );
Ada.Text_IO.Put( ASCII.HT & "= ");
Ada.Text_IO.Put( Value'Img );
Ada.Text_IO.Put_Line( ASCII.HT & '[' &
PF( Value = Validation_Data(Index) )& ']');
end;
end loop;
Ada.Text_IO.Put_Line("Testing complete.");
End Test_Roman_Numerals;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- DESCRIPTION command line interface body for use with VAX/VMS
-- NOTES this file is system dependent
with Tstring;
with Handle_Foreign_Command;
package body Command_Line_Interface is
subtype Argument_Number is Integer range 1 .. Max_Number_Args;
procedure Handle (N : Argument_Number; A : String);
procedure Process_Command_Line is new Handle_Foreign_Command
(Argument_Count => Argument_Number,
Handle_Argument => Handle);
procedure Handle (N : Argument_Number; A : String) is
begin
Argv (N) := Tstring.Vstr (A);
Argc := N + 1;
end Handle;
procedure Initialize_Command_Line is
begin
Argc := 1;
Argv (0) := Tstring.Vstr ("Aflex");
Process_Command_Line;
end Initialize_Command_Line;
end Command_Line_Interface;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Characters.Latin_1;
use Ada.Characters;
package body Lexer is
procedure Open(lexer : out Lexer_Type;
file_name : in String) is
begin
Character_IO.Open(File => lexer.file,
Mode => Character_IO.In_File,
Name => file_name);
Next(lexer);
end Open;
procedure Close(lexer : in out Lexer_Type) is
begin
Character_IO.Close(lexer.file);
end Close;
procedure Get_Buffer_Token(lexer : in out Lexer_Type) is
len : constant Natural := Length(lexer.buffer);
begin
if len = 0 then
lexer.token := Invalid;
lexer.value := Null_Unbounded_String;
else
case Element(lexer.buffer, 1) is
when '(' =>
lexer.token := Open;
lexer.value := Head(lexer.buffer, 1);
Delete(lexer.buffer, 1, 1);
when ')' =>
lexer.token := Close;
lexer.value := Head(lexer.buffer, 1);
Delete(lexer.buffer, 1, 1);
when others =>
lexer.token := Literal;
lexer.value := lexer.buffer;
Delete(lexer.buffer, 1, len);
end case;
end if;
end Get_Buffer_Token;
function Is_Space(ch : Character) return Boolean is
begin
case ch is
when ' ' | Latin_1.LF | Latin_1.CR | Latin_1.VT =>
return True;
when others =>
return False;
end case;
end Is_Space;
function Is_Stop(ch : Character) return Boolean is
begin
if Is_Space(ch) then
return True;
else
case ch is
when '(' | ')' =>
return True;
when others =>
return False;
end case;
end if;
end Is_Stop;
procedure Next(lexer : in out Lexer_Type) is
ch : Character;
in_comment : Boolean := False;
begin
loop
loop
Character_IO.Read(lexer.file, ch);
if ch = ';' then
in_comment := True;
elsif ch = Latin_1.LF then
lexer.line := lexer.line + 1;
in_comment := False;
end if;
exit when not in_comment;
end loop;
if Is_Space(ch) then
if Length(lexer.buffer) > 0 then
Get_Buffer_Token(lexer);
return;
end if;
else
if Is_Stop(ch) and Length(lexer.buffer) > 0 then
Get_Buffer_Token(lexer);
Append(lexer.buffer, ch);
return;
else
if Length(lexer.buffer) > 0 then
if Is_Stop(Element(lexer.buffer, 1)) then
Get_Buffer_Token(lexer);
Append(lexer.buffer, ch);
return;
end if;
end if;
Append(lexer.buffer, ch);
end if;
end if;
end loop;
exception
when Character_IO.End_Error =>
if Length(lexer.buffer) > 0 then
Get_Buffer_Token(lexer);
else
lexer.token := EOF;
lexer.value := To_Unbounded_String("<EOF>");
end if;
end Next;
function Get_Type(lexer : Lexer_Type) return Token_Type is
begin
return lexer.token;
end Get_Type;
function Get_Value(lexer : Lexer_Type) return String is
begin
return To_String(lexer.value);
end Get_Value;
function Get_File_Name(lexer : Lexer_Type) return String is
begin
return Character_IO.Name(lexer.file);
end Get_File_Name;
function Get_Line(lexer : Lexer_Type) return Positive is
begin
return lexer.line;
end Get_Line;
end Lexer;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--*
-- CHECK THAT A RENDEZVOUS REQUESTED BY A CONDITIONAL_ENTRY_CALL
-- IS PERFORMED ONLY IF IMMEDIATELY POSSIBLE.
-- CASE D: THE BODY OF THE TASK CONTAINING THE CALLED ENTRY
-- DOES NOT CONTAIN AN ACCEPT_STATEMENT FOR THAT ENTRY -
-- AND THIS FACT IS DETERMINED STATICALLY.
-- RM 4/12/82
WITH REPORT; USE REPORT;
PROCEDURE C97201D IS
ELSE_BRANCH_TAKEN : BOOLEAN := FALSE ;
BEGIN
TEST ("C97201D", "CHECK THAT NO RENDEZVOUS REQUESTED BY" &
" A CONDITIONAL_ENTRY_CALL CAN EVER OCCUR" &
" IN THE ABSENCE OF A CORRESPONDING " &
" ACCEPT_STATEMENT " );
DECLARE
TASK T IS
ENTRY DO_IT_NOW_ORELSE ;
ENTRY KEEP_ALIVE ;
END T ;
TASK BODY T IS
BEGIN
-- NO ACCEPT_STATEMENT FOR THE ENTRY_CALL BEING TESTED
ACCEPT KEEP_ALIVE ; -- TO PREVENT THIS SERVER TASK FROM
-- TERMINATING IF
-- UPON ACTIVATION
-- IT GETS TO RUN
-- AHEAD OF THE CALLER (WHICH
-- WOULD LEAD TO A SUBSEQUENT
-- TASKING_ERROR AT THE TIME OF
-- THE NO-WAIT CALL).
END ;
BEGIN
SELECT
T.DO_IT_NOW_ORELSE ;
ELSE -- (I.E. CALLER ADOPTS A NO-WAIT POLICY)
-- THEREFORE THIS BRANCH MUST BE CHOSEN
ELSE_BRANCH_TAKEN := TRUE ;
COMMENT( "ELSE_BRANCH TAKEN" );
END SELECT;
T.KEEP_ALIVE ; -- THIS ALSO UPDATES THE NONLOCALS
END; -- END OF BLOCK CONTAINING THE ENTRY CALL
-- BY NOW, THE TASK IS TERMINATED
IF ELSE_BRANCH_TAKEN THEN
NULL ;
ELSE
FAILED( "RENDEZVOUS ATTEMPTED?" );
END IF;
RESULT;
END C97201D ;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
package body cached_Rotation
is
use ada.Numerics,
float_elementary_Functions;
the_Cache : array (0 .. slot_Count - 1) of aliased Matrix_2x2_type;
Pi_x_2 : constant := Pi * 2.0;
last_slot_Index : constant Float_type := Float_type (slot_Count - 1);
index_Factor : constant Float_type := last_slot_Index / Pi_x_2;
function to_Rotation (Angle : in Float_type) return access constant Matrix_2x2_type
is
the_Index : standard.Integer := standard.Integer (Angle * index_Factor) mod slot_Count;
begin
if the_Index < 0
then
the_index := the_Index + slot_Count;
end if;
return the_Cache (the_Index)'Access;
end to_Rotation;
begin
for Each in the_Cache'Range
loop
declare
Angle : constant Float_type := ( Float_type (Each) / Float_type (slot_Count - 1)
* Pi_x_2);
C : constant Float_type := Cos (Angle);
S : constant Float_type := Sin (Angle);
begin
the_Cache (Each) := to_Matrix_2x2 (C, -S,
S, C);
end;
end loop;
end cached_Rotation;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with
Asis.Iterator,
AdaM.Assist.Query.find_Entities.Actuals_for_traversing;
package body AdaM.Assist.Query.find_Entities.element_Processing
is
procedure Recursive_Construct_Processing is new
Asis.Iterator.Traverse_Element
(State_Information => AdaM.Assist.Query.find_Entities.Actuals_for_traversing.Traversal_State,
Pre_Operation => AdaM.Assist.Query.find_Entities.Actuals_for_traversing.Pre_Op,
Post_Operation => AdaM.Assist.Query.find_Entities.Actuals_for_traversing.Post_Op);
procedure Process_Construct (The_Element : Asis.Element)
is
Process_Control : Asis.Traverse_Control := Asis.Continue;
Process_State : AdaM.Assist.Query.find_Entities.Actuals_for_traversing.Traversal_State
:= AdaM.Assist.Query.find_Entities.Actuals_for_traversing.Initial_Traversal_State;
begin
Recursive_Construct_Processing
(Element => The_Element,
Control => Process_Control,
State => Process_State);
end Process_Construct;
end AdaM.Assist.Query.find_Entities.element_Processing;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
----------------------------------------------------------------
with Ada.Strings.Unbounded;
with Ada.Characters.Wide_Wide_Latin_1;
with Ada.Integer_Text_IO;
package body Custom_Writers is
New_Line : constant Wide_Wide_String :=
(1 => Ada.Characters.Wide_Wide_Latin_1.LF);
Amp_Entity_Reference : constant String
:= "&";
-- Apos_Entity_Reference : constant String
-- := "'";
Quot_Entity_Reference : constant String
:= """;
Gt_Entity_Reference : constant String
:= ">";
Lt_Entity_Reference : constant String
:= "<";
procedure Close_Tag (Self : in out Writer'Class);
function Escape
(Text : League.Strings.Universal_String;
Escape_All : Boolean := False)
return League.Strings.Universal_String;
----------------
-- Characters --
----------------
overriding procedure Characters
(Self : in out Writer;
Text : League.Strings.Universal_String;
Success : in out Boolean)
is
pragma Unreferenced (Success);
begin
Self.Close_Tag;
if Self.CDATA then
Self.Output.Put (Text);
else
Self.Output.Put (Escape (Text, False));
end if;
end Characters;
---------------
-- Close_Tag --
---------------
procedure Close_Tag (Self : in out Writer'Class) is
begin
if not Self.Tag.Is_Empty then
Self.Output.Put (">");
Self.Tag.Clear;
end if;
end Close_Tag;
-------------
-- Comment --
-------------
overriding procedure Comment
(Self : in out Writer;
Text : League.Strings.Universal_String;
Success : in out Boolean)
is
pragma Unreferenced (Success);
begin
Self.Output.Put ("<!--");
Self.Output.Put (Text);
Self.Output.Put ("-->");
end Comment;
---------------
-- End_CDATA --
---------------
overriding procedure End_CDATA
(Self : in out Writer;
Success : in out Boolean)
is
pragma Unreferenced (Success);
begin
Self.CDATA := False;
Self.Output.Put ("]]>");
end End_CDATA;
-----------------
-- End_Element --
-----------------
overriding procedure End_Element
(Self : in out Writer;
Namespace_URI : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String;
Success : in out Boolean)
is
pragma Unreferenced (Namespace_URI, Qualified_Name, Success);
use type League.Strings.Universal_String;
begin
if Self.Tag = Local_Name and then
Self.Tag.To_Wide_Wide_String not in "code" | "html" | "a" | "li"
and then (Self.Tag.Length = 1 or else
Self.Tag (2).To_Wide_Wide_Character not in '1' .. '9')
then
Self.Output.Put ("/>");
Self.Tag.Clear;
else
Self.Close_Tag;
Self.Output.Put ("</");
Self.Output.Put (Local_Name);
Self.Output.Put (">");
end if;
if Local_Name.Starts_With ("h") or else
Local_Name.To_Wide_Wide_String = "p"
then
Self.Output.Put (New_Line);
end if;
end End_Element;
------------------
-- Error_String --
------------------
overriding function Error_String
(Self : Writer) return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return League.Strings.Empty_Universal_String;
end Error_String;
function Escape
(Text : League.Strings.Universal_String;
Escape_All : Boolean := False)
return League.Strings.Universal_String
is
UTF_8 : constant String := Text.To_UTF_8_String;
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
for Code of UTF_8 loop
case Code is
when '&' =>
Ada.Strings.Unbounded.Append (Result, Amp_Entity_Reference);
when '"' =>
if Escape_All then
Ada.Strings.Unbounded.Append (Result, "%22");
else
Ada.Strings.Unbounded.Append (Result, Quot_Entity_Reference);
end if;
when '>' =>
Ada.Strings.Unbounded.Append (Result, Gt_Entity_Reference);
when '<' =>
Ada.Strings.Unbounded.Append (Result, Lt_Entity_Reference);
when 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' |
'-' | '_' | '.' | '~' | '/' | '@' | '+' | ',' |
'(' | ')' | '#' | '?' | '=' | ':' | '*'
=>
Ada.Strings.Unbounded.Append (Result, Code);
-- when '\' =>
-- if Escape_All then
-- Ada.Strings.Unbounded.Append (Result, "%5C");
-- else
-- Ada.Strings.Unbounded.Append (Result, Code);
-- end if;
when others =>
if Escape_All or
Character'Pos (Code) in 16#1# .. 16#8#
| 16#B# .. 16#C#
| 16#E# .. 16#1F#
| 16#7F#
then
declare
Image : String (1 .. 7); -- -#16#xx#
begin
Ada.Integer_Text_IO.Put
(To => Image,
Item => Character'Pos (Code),
Base => 16);
Ada.Strings.Unbounded.Append (Result, "%");
Ada.Strings.Unbounded.Append (Result, Image (5 .. 6));
end;
else
Ada.Strings.Unbounded.Append (Result, Code);
end if;
end case;
end loop;
return League.Strings.From_UTF_8_String
(Ada.Strings.Unbounded.To_String (Result));
end Escape;
overriding procedure Processing_Instruction
(Self : in out Writer;
Target : League.Strings.Universal_String;
Data : League.Strings.Universal_String;
Success : in out Boolean)
is
pragma Unreferenced (Success);
begin
Self.Output.Put ("<?");
Self.Output.Put (Target);
if not Data.Is_Empty then
Self.Output.Put (" ");
Self.Output.Put (Data);
end if;
Self.Output.Put ("?>");
end Processing_Instruction;
----------------------------
-- Set_Output_Destination --
----------------------------
procedure Set_Output_Destination
(Self : in out Writer'Class;
Output : not null SAX_Output_Destination_Access) is
begin
Self.Output := Output;
end Set_Output_Destination;
-----------------
-- Start_CDATA --
-----------------
overriding procedure Start_CDATA
(Self : in out Writer;
Success : in out Boolean)
is
pragma Unreferenced (Success);
begin
Self.Output.Put ("<![CDATA[");
Self.CDATA := True;
end Start_CDATA;
-------------------
-- Start_Element --
-------------------
overriding procedure Start_Element
(Self : in out Writer;
Namespace_URI : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean) is
pragma Unreferenced (Success, Namespace_URI, Qualified_Name);
begin
Self.Close_Tag;
Self.Output.Put ("<");
Self.Output.Put (Local_Name);
if Local_Name.To_Wide_Wide_String = "hr" then
Self.Output.Put (" ");
end if;
for J in 1 .. Attributes.Length loop
Self.Output.Put (" ");
Self.Output.Put (Attributes.Local_Name (J));
Self.Output.Put ("=""");
if Attributes.Local_Name (J).To_Wide_Wide_String = "href" then
Self.Output.Put (Escape (Attributes.Value (J), True));
elsif Attributes.Local_Name (J).To_Wide_Wide_String = "class" then
Self.Output.Put (Attributes.Value (J));
else
Self.Output.Put (Escape (Attributes.Value (J), False));
end if;
Self.Output.Put ("""");
end loop;
Self.Tag := Local_Name;
end Start_Element;
--------------------------
-- Unescaped_Characters --
--------------------------
not overriding procedure Unescaped_Characters
(Self : in out Writer;
Text : League.Strings.Universal_String) is
begin
Self.Close_Tag;
Self.Output.Put (Text);
end Unescaped_Characters;
end Custom_Writers;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- and unmodified if sources are distributed further.
-------------------------------------------------------------------------
with GL.Errors;
-- with Ada.Numerics.Generic_Elementary_Functions;
-- with Ada.Text_IO; use Ada.Text_IO;
-- with System;
package body GL.Buffer.general is
use Element_Pointers;
function to_gl_Pointer is new Ada.Unchecked_Conversion (Element_Pointers.Pointer, GL.pointer);
function to_element_Pointer is new Ada.Unchecked_Conversion (GL.pointer, Element_Pointers.Pointer);
-- vertex buffer object
--
function To_Buffer (From : access Element_Array; Usage : VBO_Usage) return General_Object is
use type GL.sizeiPtr;
new_Buffer : General_Object;
begin
Verify_Name (new_Buffer);
new_Buffer.Length := From'Length;
Enable (new_Buffer);
GL.Buffer_Data (Extract_VBO_Target (new_Buffer), From.all'Size / 8,
to_gl_Pointer (From.all (From'First)'Access),
Usage);
return new_Buffer;
end To_Buffer;
procedure Set (Self : in out General_Object;
Set_Position : Positive := 1;
To : Element_Array) is
use type GL.sizeiPtr;
new_Vertices : aliased Element_Array := To;
Vertex_Size_in_bits : constant Natural := To (To'First)'Size;
begin
Enable (Self);
GL.BufferSubData (Extract_VBO_Target (Self), offset => GL.intPtr ((Set_Position - 1) * Vertex_Size_in_bits / 8),
size => new_Vertices'Size / 8,
data => to_gl_Pointer (new_Vertices (new_Vertices'First)'Unchecked_Access));
GL.Errors.log;
end Set;
function Get (Self : access General_Object) return Element_Array is
-- use GL.Geometry, GL.Buffer;
use GL.Buffer;
the_Map : read_only_Map'Class renames Map (Self);
the_Vertices : constant Element_Array := Get (the_Map, Index'First, Self.all.Length);
begin
Release (the_Map);
return the_Vertices;
end Get;
-- memory Maps
--
procedure Release (Self : memory_Map) is
Status : constant GL_Boolean := UnmapBuffer (Self.vbo_Target);
begin
if Status /= GL_True then
raise Corrupt_Buffer;
end if;
end Release;
function Get (Self : memory_Map; Get_Position : Index) return Element is
use Interfaces.C;
Start : constant Element_Pointers.Pointer := Self.Data + ptrdiff_t (Get_Position - 1);
begin
return Value (Start, 1) (1);
end Get;
function Get (Self : memory_Map;
Get_Position : Index;
Count : Positive) return Element_Array is
use Interfaces.C;
Start : constant Element_Pointers.Pointer := Self.Data + ptrdiff_t (Get_Position - 1);
begin
return Value (Start, ptrdiff_t (Count));
end Get;
procedure Set (Self : memory_Map;
Set_Position : Index;
To : access Element) is
-- use GL.Geometry, Element_Pointers, interfaces.C;
use Interfaces.C;
begin
Copy_Array (Element_Pointers.Pointer (To), Self.Data + ptrdiff_t (Set_Position - 1), 1);
end Set;
procedure Set (Self : memory_Map;
Set_Position : Index;
To : Element) is
the_Vertex : aliased Element := To;
begin
Set (Self, Set_Position, To => the_Vertex'Unchecked_Access);
end Set;
-- read - only
function Map (Self : access General_Object) return read_only_Map'Class is
-- use GL.Geometry;
the_Map : read_only_Map;
begin
Enable (Self.all);
the_Map.Data := to_element_Pointer (MapBuffer (Extract_VBO_Target (Self.all), GL.READ_ONLY));
if the_Map.Data = null then
raise GL.Buffer.no_platform_Support;
end if;
the_Map.Last := Index (Self.all.Length);
the_Map.vbo_Target := Extract_VBO_Target (Self.all);
return the_Map;
end Map;
function Get (Self : read_only_Map; Get_Position : Index) return Element is (Get (memory_Map (Self), Get_Position));
function Get (Self : read_only_Map;
Get_Position : Index;
Count : Positive) return Element_Array is (Get (memory_Map (Self), Get_Position, Count));
-- write - only
function Map (Self : access General_Object) return write_only_Map'Class is
-- use GL.Geometry;
the_Map : write_only_Map;
begin
Enable (Self.all);
the_Map.Data := to_element_Pointer (MapBuffer (Extract_VBO_Target (Self.all), GL.WRITE_ONLY));
if the_Map.Data = null then
raise GL.Buffer.no_platform_Support;
end if;
the_Map.Last := Index (Self.all.Length);
the_Map.vbo_Target := Extract_VBO_Target (Self.all);
return the_Map;
end Map;
procedure Set (Self : write_only_Map;
Set_Position : Index;
To : access Element) is
begin
Set (memory_Map (Self), Set_Position, To);
end Set;
procedure Set (Self : write_only_Map;
Set_Position : Index;
To : Element) is
begin
Set (memory_Map (Self), Set_Position, To);
end Set;
-- read - write
function Map (Self : access General_Object) return read_write_Map'Class is
-- use GL.Geometry;
the_Map : read_write_Map;
begin
Enable (Self.all);
the_Map.Data := to_element_Pointer (MapBuffer (Extract_VBO_Target (Self.all), GL.READ_WRITE));
if the_Map.Data = null then
raise GL.Buffer.no_platform_Support;
end if;
the_Map.Last := Index (Self.all.Length);
the_Map.vbo_Target := Extract_VBO_Target (Self.all);
return the_Map;
end Map;
function Get (Self : read_write_Map; Get_Position : Index) return Element is (Get (memory_Map (Self), Get_Position));
function Get (Self : read_write_Map;
Get_Position : Index;
Count : Positive) return Element_Array is (Get (memory_Map (Self), Get_Position, Count));
procedure Set (Self : read_write_Map;
Set_Position : Index;
To : access Element) is
begin
Set (memory_Map (Self), Set_Position, To);
end Set;
procedure Set (Self : read_write_Map;
Set_Position : Index;
To : Element) is
begin
Set (memory_Map (Self), Set_Position, To);
end Set;
end GL.Buffer.general;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
generic
type Element is (<>);
with function Image(E: Element) return String;
package Set_Cons is
type Set is private;
-- constructor and manipulation functions for type Set
function "+"(E: Element) return Set;
function "+"(Left, Right: Element) return Set;
function "+"(Left: Set; Right: Element) return Set;
function "-"(Left: Set; Right: Element) return Set;
-- compare, unite or output a Set
function Nonempty_Intersection(Left, Right: Set) return Boolean;
function Union(Left, Right: Set) return Set;
function Image(S: Set) return String;
type Set_Vec is array(Positive range <>) of Set;
-- output a Set_Vec
function Image(V: Set_Vec) return String;
private
type Set is array(Element) of Boolean;
end Set_Cons;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with AUnit.Assertions;
with AUnit.Test_Caller;
with JSON.Parsers;
with JSON.Streams;
with JSON.Types;
package body Test_Streams is
package Types is new JSON.Types (Long_Integer, Long_Float);
package Parsers is new JSON.Parsers (Types);
use AUnit.Assertions;
package Caller is new AUnit.Test_Caller (Test);
Test_Suite : aliased AUnit.Test_Suites.Test_Suite;
function Suite return AUnit.Test_Suites.Access_Test_Suite is
Name : constant String := "(Streams) ";
begin
Test_Suite.Add_Test (Caller.Create
(Name & "Parse float_number.txt", Test_Stream_IO'Access));
return Test_Suite'Access;
end Suite;
use Types;
procedure Test_Stream_IO (Object : in out Test) is
File_Name : constant String := "float_number.txt";
Parser : Parsers.Parser := Parsers.Create_From_File (File_Name);
Value : constant JSON_Value := Parser.Parse;
begin
Assert (Value.Kind = Float_Kind, "Not a float");
Assert (Value.Value = 3.14, "Expected float value to be equal to 3.14");
end Test_Stream_IO;
end Test_Streams;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Aof.Core.Root_Objects;
with Aof.Core.Generic_Properties;
with Ada.Strings.Unbounded;
package Aof.Core.Properties is
pragma Preelaborate;
-- Instantiations of the Generic_Properties package of commonly
-- used types.
package Unbounded_Strings is new Aof.Core.Generic_Properties
(Object => Aof.Core.Root_Objects.Root_Object,
Access_Object => Aof.Core.Root_Objects.Access_Object,
T => Ada.Strings.Unbounded.Unbounded_String);
package Booleans is new Aof.Core.Generic_Properties
(Object => Aof.Core.Root_Objects.Root_Object,
Access_Object => Aof.Core.Root_Objects.Access_Object,
T => Boolean);
package Naturals is new Aof.Core.Generic_Properties
(Object => Aof.Core.Root_Objects.Root_Object,
Access_Object => Aof.Core.Root_Objects.Access_Object,
T => Natural);
package Integers is new Aof.Core.Generic_Properties
(Object => Aof.Core.Root_Objects.Root_Object,
Access_Object => Aof.Core.Root_Objects.Access_Object,
T => Integer);
package Floats is new Aof.Core.Generic_Properties
(Object => Aof.Core.Root_Objects.Root_Object,
Access_Object => Aof.Core.Root_Objects.Access_Object,
T => Float);
package Long_Floats is new Aof.Core.Generic_Properties
(Object => Aof.Core.Root_Objects.Root_Object,
Access_Object => Aof.Core.Root_Objects.Access_Object,
T => Long_Float);
end Aof.Core.Properties;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Interfaces;
with Ada.Streams.Stream_IO;
with Ada.Numerics.Float_Random;
with Ada.Numerics.Generic_Elementary_Functions;
with Vector_Math;
use Interfaces;
use Ada.Streams.Stream_IO;
use Vector_Math;
package body Geometry is
package Float_Functions is new Ada.Numerics.Generic_Elementary_Functions(float);
use Float_Functions;
function IntersectPlaneXZ (r : Ray; planeMat : MaterialRef) return Hit is
t : float := infinity;
x,y : float;
begin
if abs(r.direction.y) > 0.0 then
t := - r.origin.y / r.direction.y;
x := r.origin.x + r.direction.x * t;
y := r.origin.z + r.direction.z * t;
return ( prim_type => Plane_TypeId,
prim_index => 0,
is_hit => (t > 0.0) and (abs(x) < 200.0) and (abs(y) < 200.0),
t => t,
mat => planeMat,
matId => 0, -- not used
tx => x,
ty => y,
normal => (0.0, 1.0, 0.0)
);
else
return null_hit;
end if;
end IntersectPlaneXZ;
function IntersectAllSpheres (r : Ray; a_spheres : Spheres_Array_Ptr) return Hit is
min_t : float := infinity;
t1, t2 : float;
min_i : Integer := 0;
k : float3;
is_hit : boolean := false;
b, c, d, sqrtd : float;
finalNormal : float3 := (0.0, 1.0, 0.0);
begin
for i in a_spheres'First .. a_spheres'Last loop
k := r.origin - a_spheres(i).pos;
b := dot(k,r.direction);
c := dot(k,k) - a_spheres(i).r*a_spheres(i).r;
d := b * b - c;
if d >= 0.0 then
sqrtd := sqrt(d);
t1 := -b - sqrtd;
t2 := -b + sqrtd;
if t1 > 0.0 and t1 < min_t then
min_t := t1;
min_i := i;
elsif t2 > 0.0 and t2 < min_t then
min_t := t2;
min_i := i;
end if;
end if;
end loop;
is_hit := (min_t > 0.0 and min_t < infinity);
if not is_hit then
min_t := 1.0; -- to prevent constraint error
else
finalNormal := normalize((r.origin + r.direction*min_t) - a_spheres(min_i).pos);
end if;
return ( prim_type => Sphere_TypeId,
prim_index => min_i,
is_hit => is_hit,
t => min_t,
mat => a_spheres(min_i).mat,
matId => 0, -- not used
normal => finalNormal,
tx => 0.0, ty => 0.0
);
exception
when Constraint_Error =>
return ( prim_type => Sphere_TypeId,
prim_index => 0,
is_hit => False,
t => 1.0,
mat => a_spheres(0).mat,
matId => 0, -- not used
normal => finalNormal,
tx => 0.0, ty => 0.0
);
end IntersectAllSpheres;
function IntersectFlatLight(r: Ray; lightGeom : FlatLight; lMat : MaterialRef) return Hit is
is_hit : boolean := false;
tmin : float := 1.0e38;
inv_dir_y : float := 1.0/r.direction.y;
hit_point : float3;
begin
tmin := (lightGeom.boxMax.y - r.origin.y)*inv_dir_y;
hit_point := r.origin + tmin*r.direction;
is_hit := (hit_point.x > lightGeom.boxMin.x) and (hit_point.x < lightGeom.boxMax.x) and
(hit_point.z > lightGeom.boxMin.z) and (hit_point.z < lightGeom.boxMax.z) and
(tmin >= 0.0);
return ( prim_type => Quad_TypeId,
prim_index => 0,
is_hit => is_hit,
t => tmin,
mat => lMat,
matId => 0, -- not used
normal => (0.0,-1.0,0.0),
tx => 0.0,
ty => 0.0
);
end IntersectFlatLight;
function IntersectBox(r: Ray; box : AABB) return LiteGeomHit is
tmin,tmax : float := 0.0;
lo,hi,lo1,hi1,lo2,hi2 : float;
inv_dir_x,inv_dir_y,inv_dir_z : float;
res : LiteGeomHit;
--epsilonDiv : constant float := 1.0e-25;
begin
inv_dir_x := 1.0/r.direction.x;
inv_dir_y := 1.0/r.direction.y;
inv_dir_z := 1.0/r.direction.z;
lo := (box.max.x - r.origin.x)*inv_dir_x;
hi := (box.min.x - r.origin.x)*inv_dir_x;
lo1 := (box.max.y - r.origin.y)*inv_dir_y;
hi1 := (box.min.y - r.origin.y)*inv_dir_y;
lo2 := (box.max.z - r.origin.z)*inv_dir_z;
hi2 := (box.min.z - r.origin.z)*inv_dir_z;
tmin := min(lo,hi);
tmax := max(lo,hi);
tmin := max(tmin, min(lo1,hi1));
tmax := min(tmax, max(lo1,hi1));
tmin := max(tmin, min(lo2,hi2));
tmax := min(tmax, max(lo2,hi2));
res.tmin := tmin;
res.tmax := tmax;
res.is_hit := (tmax > 0.0) and (tmin <= tmax);
return res;
exception
when Constraint_Error =>
res.tmin := 0.0;
res.tmax := 0.0;
res.is_hit := False;
return res;
end IntersectBox;
function IntersectCornellBox(r: Ray; boxData : CornellBox) return Hit is
eps : float := 1.0e-5;
p : float3;
tmpHit : LiteGeomHit;
planeId : integer := 0;
begin
tmpHit := IntersectBox(r, boxData.box);
if tmpHit.is_hit then
p := r.origin + tmpHit.tmax*r.direction;
if abs(p.x - boxData.box.min.x) < eps then planeId := 0; end if;
if abs(p.x - boxData.box.max.x) < eps then planeId := 1; end if;
if abs(p.y - boxData.box.min.y) < eps then planeId := 2; end if;
if abs(p.y - boxData.box.max.y) < eps then planeId := 3; end if;
if abs(p.z - boxData.box.min.z) < eps then planeId := 4; end if;
if abs(p.z - boxData.box.max.z) < eps then planeId := 5; end if;
return( prim_type => Plane_TypeId,
prim_index => planeId,
is_hit => not (planeId = 5),
t => tmpHit.tmax,
mat => null, --g_scn.materials(boxData.mat_indices(planeId)),
matId => boxData.mat_indices(planeId),
normal => boxData.normals(planeId),
tx => 0.0,
ty => 0.0
);
else
return null_hit;
end if;
end IntersectCornellBox;
function IntersectTriangle(r: Ray; A : float3; B : float3; C : float3; t_min : float; t_max : float) return LiteGeomHit is
res : LiteGeomHit;
edge1, edge2, pvec, qvec, tvec : float3;
invDet,u,v,t : float;
epsilonDiv : constant float := 1.0e-25;
begin
edge1 := B - A;
edge2 := C - A;
pvec := cross(r.direction, edge2);
tvec := r.origin - A;
qvec := cross(tvec, edge1);
invDet := 1.0 / max(dot(edge1, pvec), epsilonDiv);
v := dot(tvec, pvec)*invDet;
u := dot(qvec, r.direction)*invDet;
t := dot(edge2, qvec)*invDet;
res.is_hit := false;
if (v > 0.0 and u > 0.0 and u + v < 1.0 and t > t_min and t < t_max) then
res.u := u;
res.v := v;
res.tmin := t;
res.tmax := t + 1.0e-6;
res.is_hit := true;
end if;
return res;
end IntersectTriangle;
function IntersectMeshBF(r: Ray; meshGeom : Mesh) return Hit is
tmpHit, nearestHit : LiteGeomHit;
triInd : Triangle;
A,B,C : float3;
nearestTriId : integer := 0;
begin
tmpHit := IntersectBox(r, meshGeom.bbox);
if tmpHit.is_hit then
nearestHit.tmin := 0.0; -- tmpHit.tmin; strange bug; does not work when ray start inside bbox
nearestHit.tmax := 1000000.0; -- tmpHit.tmax; strange bug; does not work when ray start inside bbox
nearestHit.is_hit := false;
for i in meshGeom.triangles'First .. meshGeom.triangles'Last loop
triInd := meshGeom.triangles(i);
A := meshGeom.vert_positions(triInd.A_index);
B := meshGeom.vert_positions(triInd.B_index);
C := meshGeom.vert_positions(triInd.C_index);
tmpHit := IntersectTriangle(r,A,B,C,nearestHit.tmin,nearestHit.tmax);
if tmpHit.is_hit then
nearestHit := tmpHit;
nearestTriId := i;
end if;
end loop;
triInd := meshGeom.triangles(nearestTriId);
declare
inorm : float3 := (1.0 - nearestHit.u - nearestHit.v)*meshGeom.vert_normals (triInd.A_index) + nearestHit.v*meshGeom.vert_normals (triInd.B_index) + nearestHit.u*meshGeom.vert_normals (triInd.C_index);
itx : float := (1.0 - nearestHit.u - nearestHit.v)*meshGeom.vert_tex_coords(triInd.A_index).x + nearestHit.v*meshGeom.vert_tex_coords(triInd.B_index).x + nearestHit.u*meshGeom.vert_tex_coords(triInd.C_index).x;
ity : float := (1.0 - nearestHit.u - nearestHit.v)*meshGeom.vert_tex_coords(triInd.A_index).y + nearestHit.v*meshGeom.vert_tex_coords(triInd.B_index).y + nearestHit.u*meshGeom.vert_tex_coords(triInd.C_index).y;
begin
return( prim_type => Triangle_TypeId,
prim_index => nearestTriId,
is_hit => nearestHit.is_hit,
t => nearestHit.tmin,
mat => null,
matId => 2, --meshGeom.material_ids(nearestTriId), -- (-1.0)*normalize(cross(A-B, A-C)),
normal => inorm,
tx => itx,
ty => ity
);
end;
else
return null_hit;
end if;
end IntersectMeshBF;
procedure FreeData(self: in out Mesh) is
begin
if self.vert_positions /= null then
delete(self.vert_positions);
self.vert_positions := null;
end if;
if self.vert_normals /= null then
delete(self.vert_normals);
self.vert_normals := null;
end if;
if self.vert_tex_coords /= null then
delete(self.vert_tex_coords);
self.vert_tex_coords := null;
end if;
if self.triangles /= null then
delete(self.triangles);
self.triangles := null;
end if;
if self.material_ids /= null then
delete(self.material_ids);
self.material_ids := null;
end if;
end FreeData;
procedure AllocData(self: in out Mesh; vnum,inum: integer) is
begin
self.vert_positions := new Float3_Array(0..vnum-1);
self.vert_normals := new Float3_Array(0..vnum-1);
self.vert_tex_coords := new Float2_Array(0..vnum-1);
self.triangles := new Triangle_Array (0..inum/3-1);
self.material_ids := new MaterialsId_Array(0..inum/3-1);
end AllocData;
procedure ComputeFlatNormals(self: in out Mesh) is
A,B,C,norm : float3;
begin
for tIndex in self.triangles'First .. self.triangles'Last loop
A := self.vert_positions(self.triangles(tIndex).A_index);
B := self.vert_positions(self.triangles(tIndex).B_index);
C := self.vert_positions(self.triangles(tIndex).C_index);
norm := normalize(cross(C-A,C-B));
self.vert_normals(self.triangles(tIndex).A_index) := norm;
self.vert_normals(self.triangles(tIndex).B_index) := norm;
self.vert_normals(self.triangles(tIndex).C_index) := norm;
end loop;
end;
procedure CreatePrism(self: out Mesh; mTransform : in float4x4; size,angle : in float; matId : in integer) is
frontBound, backBound, leftBound, rightBound, h : float;
begin
FreeData(self);
AllocData(self, 4*3 + 3*2, 3*2+2);
frontBound := -size;
backBound := size;
leftBound := -size/2.0;
rightBound := size/2.0;
h := rightBound/safe_tan(angle/2.0);
--Put("size = "); Put_Line(float'Image(size));
--Put("angle = "); Put_Line(float'Image(angle));
--Put("h = "); Put_Line(float'Image(h));
--Put("lb = "); Put_Line(float'Image(leftBound));
-- left frace
--
self.vert_positions(0) := (leftBound, 0.0, frontBound);
self.vert_positions(1) := (leftBound, 0.0, backBound);
self.vert_positions(2) := (0.0,h,backBound);
self.vert_positions(3) := (0.0,h,frontBound);
self.triangles(0).A_index := 1;
self.triangles(0).B_index := 0;
self.triangles(0).C_index := 2;
self.triangles(1).A_index := 0;
self.triangles(1).B_index := 3;
self.triangles(1).C_index := 2;
-- right frace
--
self.vert_positions(4) := (rightBound,0.0,frontBound);
self.vert_positions(5) := (rightBound,0.0,backBound);
self.vert_positions(6) := (0.0,h,backBound);
self.vert_positions(7) := (0.0,h,frontBound);
self.triangles(2).A_index := 4;
self.triangles(2).B_index := 5;
self.triangles(2).C_index := 6;
self.triangles(3).A_index := 4;
self.triangles(3).B_index := 6;
self.triangles(3).C_index := 7;
-- down frace
--
self.vert_positions(8) := (leftBound, 0.0,frontBound);
self.vert_positions(9) := (leftBound, 0.0,backBound);
self.vert_positions(10) := (rightBound,0.0,backBound);
self.vert_positions(11) := (rightBound,0.0,frontBound);
self.triangles(4).A_index := 8;
self.triangles(4).B_index := 9;
self.triangles(4).C_index := 10;
self.triangles(5).A_index := 8;
self.triangles(5).B_index := 10;
self.triangles(5).C_index := 11;
-- front frace
--
self.vert_positions(12) := (leftBound, 0.0, frontBound);
self.vert_positions(13) := (rightBound, 0.0, frontBound);
self.vert_positions(14) := (0.0, h, frontBound);
self.triangles(6).A_index := 12;
self.triangles(6).B_index := 13;
self.triangles(6).C_index := 14;
-- back frace
--
self.vert_positions(15) := (leftBound,0.0, backBound);
self.vert_positions(16) := (rightBound,0.0, backBound);
self.vert_positions(17) := (0.0, h, backBound);
self.triangles(7).A_index := 15;
self.triangles(7).B_index := 16;
self.triangles(7).C_index := 17;
for i in self.material_ids'First .. self.material_ids'Last loop
self.material_ids(i) := matId;
end loop;
--ComputeFlatNormals(self);
self.bbox.min := (INFINITY, INFINITY, INFINITY);
self.bbox.max := (-INFINITY, -INFINITY, -INFINITY);
-- transform geometry with matrix and find bbox
--
for i in self.vert_positions'First..self.vert_positions'Last loop
self.vert_positions(i) := mTransform*self.vert_positions(i);
self.bbox.min.x := min(self.bbox.min.x, self.vert_positions(i).x);
self.bbox.min.y := min(self.bbox.min.y, self.vert_positions(i).y);
self.bbox.min.z := min(self.bbox.min.z, self.vert_positions(i).z);
self.bbox.max.x := max(self.bbox.max.x, self.vert_positions(i).x);
self.bbox.max.y := max(self.bbox.max.y, self.vert_positions(i).y);
self.bbox.max.z := max(self.bbox.max.z, self.vert_positions(i).z);
--self.vert_normals(i) := TransformNormal(mTransform, self.vert_normals(i));
end loop;
ComputeFlatNormals(self);
end CreatePrism;
type VSGF_Header is record
fileSizeInBytes : Long_Long_Integer; -- Unsigned_64
verticesNum : Integer;
indicesNum : Integer;
materialsNum : Integer;
flags : Integer;
end record;
procedure LoadMeshFromVSGF(self: out Mesh; mTransform : in float4x4; a_fileName : String) is
VSGF_File : Ada.Streams.Stream_IO.File_Type;
S : Stream_Access;
header : VSGF_Header;
temp4 : float4 := (0.0, 0.0, 0.0, 0.0);
temp2 : float2 := (0.0, 0.0);
begin
Open(File => VSGF_File,
Mode => In_File,
Name => a_fileName,
Form => "");
S := Stream(VSGF_File);
VSGF_Header'Read(S, header);
Put("load vsgf file :"); Put_Line(a_fileName);
Put("sizeInBytes :"); Put_Line(Long_Long_Integer'Image(header.fileSizeInBytes));
Put("vertices :"); Put_Line(Integer'Image(header.verticesNum));
Put("triangles :"); Put_Line(Integer'Image(header.indicesNum/3));
--Put("materials :"); Put_Line(Integer'Image(header.materialsNum));
FreeData(self);
AllocData(self, header.verticesNum, header.indicesNum);
-- read positions
--
for i in 0 .. header.verticesNum - 1 loop
float4'Read(S, temp4);
self.vert_positions(i).x := temp4.x;
self.vert_positions(i).y := temp4.y;
self.vert_positions(i).z := temp4.z;
end loop;
-- read normals
--
for i in 0 .. header.verticesNum - 1 loop
float4'Read(S, temp4);
--Put("i = "); Put(i'Image); Put("; vn.xyz = "); Put(temp4.x'Image); Put(", "); Put(temp4.y'Image); Put(", "); Put_Line(temp4.z'Image);
self.vert_normals(i).x := temp4.x;
self.vert_normals(i).y := temp4.y;
self.vert_normals(i).z := temp4.z;
end loop;
-- read texcoords
--
for i in 0 .. header.verticesNum - 1 loop -- TODO: texture coordinates could be invalid; in that case set them to 0.
float2'Read(S, temp2);
--Put("(x,y) = ("); Put(temp2.x'Image); Put(","); Put(temp2.y'Image); Put_Line(")");
self.vert_tex_coords(i).x := 0.0; -- temp2.x;
self.vert_tex_coords(i).y := 0.0; -- temp2.y;
end loop;
-- read tangents
--
if header.flags /= 0 then
for i in 0 .. header.verticesNum - 1 loop
float4'Read(S, temp4);
end loop;
end if;
-- read indices
--
for i in 0 .. (header.indicesNum/3-1) loop
Triangle'Read(S, self.triangles(i));
end loop;
-- read material indices
--
for i in 0 .. (header.indicesNum/3-1) loop
--Put_Line(i'Image);
integer'Read(S, self.material_ids(i));
end loop;
Close(VSGF_File);
for i in self.vert_positions'First..self.vert_positions'Last loop
self.vert_positions(i) := mTransform*self.vert_positions(i);
self.bbox.min.x := min(self.bbox.min.x, self.vert_positions(i).x);
self.bbox.min.y := min(self.bbox.min.y, self.vert_positions(i).y);
self.bbox.min.z := min(self.bbox.min.z, self.vert_positions(i).z);
self.bbox.max.x := max(self.bbox.max.x, self.vert_positions(i).x);
self.bbox.max.y := max(self.bbox.max.y, self.vert_positions(i).y);
self.bbox.max.z := max(self.bbox.max.z, self.vert_positions(i).z);
--self.vert_normals(i) := TransformNormal(mTransform, self.vert_normals(i));
end loop;
end LoadMeshFromVSGF;
end Geometry;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Unchecked_Deallocation;
use Ada.Text_IO, Ada.Integer_Text_IO;
package body Int_Binary_Tree is
type Compare_Result_Type is ( Less_Than, Equal, Greater_Than );
type Traced_Node_Type is
record
Node : Tree_Node_Ptr;
Parent : Tree_Node_Ptr;
end record;
----------------------------------------------------------------------
procedure Free is new Ada.Unchecked_Deallocation( Tree_Node,
Tree_Node_Ptr );
----------------------------------------------------------------------
function Compare( Left, Right : in Integer ) return
Compare_Result_Type is
begin
if Left < Right then
return Less_Than;
elsif Left > Right then
return Greater_Than;
else
return Equal;
end if;
end Compare;
----------------------------------------------------------------------
function Find_Node( Tree: in T; Number: in Integer ) return
Traced_Node_Type is
T_Node : Traced_Node_Type := Traced_Node_Type'( Node => Tree.Root,
Parent => null );
Node : Tree_Node_Ptr renames T_Node.Node;
Parent : Tree_Node_Ptr renames T_Node.Parent;
begin
while Node /= null loop
case Compare ( Number, Node.Data ) is
when Equal =>
return T_Node;
when Less_Than =>
Parent := Node;
Node := Node.Left;
when Greater_Than =>
Parent := Node;
Node := Node.Right;
end case;
end loop;
return T_Node;
end Find_Node;
----------------------------------------------------------------------
function Is_In_Tree( Tree: in T; Number: in Integer ) return Boolean is
T_Node : Traced_Node_Type := Find_Node( Tree, Number );
begin
if T_Node.Node /= null then
return True;
else
return False;
end if;
end Is_In_Tree;
----------------------------------------------------------------------
procedure Insert( Tree: in out T; Number: in Integer ) is
T_Node : Traced_Node_Type := Find_Node( Tree, Number );
New_Node : Tree_Node_Ptr := new Tree_Node'( Data => Number,
Left => null,
Right => null );
begin
if T_Node.Node /= null then
return;
elsif T_Node.Parent = null then
Tree.Root := New_Node;
else
case Compare( Number, T_Node.Parent.Data ) is
when Less_Than =>
T_Node.Parent.Left := New_Node;
when Greater_Than =>
T_Node.Parent.Right := New_Node;
when Equal =>
null;
end case;
end if;
end Insert;
----------------------------------------------------------------------
procedure Remove( Tree: in out T; Number: in Integer ) is
Remove_Node : Traced_Node_Type := Find_Node( Tree, Number );
Pivot_Node : Tree_Node_Ptr;
Pivot_Node_Parent : Tree_Node_Ptr;
procedure Graft( Tree: in out T;
Old_Node,
New_Node,
Parent: in out Tree_Node_Ptr ) is
begin
if Parent /= null then
if Parent.Left = Old_Node then
Parent.Left := New_Node;
else
Parent.Right := New_Node;
end if;
else
Tree.Root := New_Node;
end if;
end Graft;
begin
if Remove_Node.Node = null then
return;
end if;
if Remove_Node.Node.Left = null then
Graft( Tree, Remove_Node.Node, Remove_Node.Node.Right, Remove_Node.Parent );
Free( Remove_Node.Node );
elsif Remove_Node.Node.Right = null then
Graft( Tree, Remove_Node.Node, Remove_Node.Node.Left, Remove_Node.Parent );
Free( Remove_Node.Node );
else
Pivot_Node_Parent := Remove_Node.Node;
Pivot_Node := Remove_Node.Node.Left;
while Pivot_Node.Right /= null loop
Pivot_Node_Parent := Pivot_Node;
Pivot_Node := Pivot_Node.Right;
end loop;
if Pivot_Node_Parent = Remove_Node.Node then
Pivot_Node.Right := Remove_Node.Node.Right;
else
Pivot_Node_Parent.Right := Pivot_Node.Left;
Pivot_Node.Left := Remove_Node.Node.Left;
Pivot_Node.Right := Remove_Node.Node.Right;
end if;
Graft( Tree, Remove_Node.Node, Pivot_Node, Remove_Node.Parent );
end if;
end Remove;
----------------------------------------------------------------------
procedure Print( Tree: in T ) is
procedure Print_Node( Node: in Tree_Node_Ptr ) is
begin
if Node.Left /= null then
Print_Node( Node.Left );
end if;
Put(Node.Data);
New_Line;
if Node.Right /= null then
Print_Node( Node.Right );
end if;
end;
begin
Print_Node( Tree.Root );
end Print;
----------------------------------------------------------------------
procedure Debug_Print( Tree: in T ) is
procedure Print_Node( Node: in Tree_Node_Ptr ) is
procedure Print_Branch( Node: in Tree_Node_Ptr ) is
begin
if Node = null then
Put(" null");
else
Put(Node.Data);
end if;
end Print_Branch;
begin
if Node.Left /= null then
Print_Node( Node.Left );
end if;
Put(Node.Data);
Put(" Left: "); Print_Branch(Node.Left);
Put(" Right:"); Print_Branch(Node.Right);
New_Line;
if Node.Right /= null then
Print_Node( Node.Right );
end if;
end Print_Node;
begin
Print_Node( Tree.Root );
end Debug_Print;
end Int_Binary_Tree;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-- SOFTWARE.
with Aunit.Test_Suites; use Aunit.Test_Suites;
with Nanomsg.Test_Socket_Create_Close;
with Nanomsg.Test_Socket_Bind_Connect;
with Nanomsg.Test_Message_Send_Receive;
with Nanomsg.Test_Send_Binary_File;
with Nanomsg.Test_Message_Long_Text;
with Nanomsg.Test_Message_Text_Convert;
with Nanomsg.Test_Req_Rep;
with Nanomsg.Test_Pair;
with Nanomsg.Test_Pub_sub;
with Nanomsg.Test_Survey;
with Nanomsg.Test_Socket_Name;
with Nanomsg.Test_Message_Send_Receive_Million;
function Test_Suite return Access_Test_Suite is
TS_Ptr : constant Access_Test_Suite := new Aunit.Test_Suites.Test_Suite;
begin
Ts_Ptr.Add_Test (new Nanomsg.Test_Socket_Create_Close.Tc);
Ts_Ptr.Add_Test (new Nanomsg.Test_Socket_Name.Tc);
Ts_Ptr.Add_Test (new Nanomsg.Test_Socket_Bind_Connect.Tc);
Ts_Ptr.Add_Test (new Nanomsg.Test_Message_Text_Convert.Tc);
Ts_Ptr.Add_Test (new Nanomsg.Test_Message_Long_Text.Tc);
Ts_Ptr.Add_Test (new Nanomsg.Test_Message_Send_Receive.Tc);
Ts_Ptr.Add_Test (new Nanomsg.Test_Req_Rep.Tc);
Ts_Ptr.Add_Test (new Nanomsg.Test_Pair.Tc);
Ts_Ptr.Add_Test (new Nanomsg.Test_Pub_Sub.Tc);
Ts_Ptr.Add_Test (new Nanomsg.Test_Survey.Tc);
Ts_Ptr.Add_Test (new Nanomsg.Test_Message_Send_Receive_Million.Tc);
return Ts_Ptr;
end Test_Suite;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Containers.Vectors;
with Ada.Iterator_Interfaces;
with EU_Projects.Node_Tables;
--
-- A partner descriptor keeps some basic information about the
-- partner such as
--
-- * The name (a short version, too)
-- * A label
-- * An index
--
-- Moreover, every partner has
--
-- * One or more roles (name, description and PM cost)
-- * One or more expenses
--
-- Expenses can be divisible or undivisible. Divisible expenses are related
-- to a collections of goods/services where one pays a price per unit.
-- For example, the expense for buying one or more cards is divisible.
-- An example of undivisible expense is the expense for a single service.
-- Honestly, the distintion is quite fuzzy (it is an undivisible expense or
-- it is a divisble one with just one object?), but in some context it
-- could be handy to be able to do this distinction.
--
-- It is possible to iterate over all the roles and all the expenses using
-- All_Expenses and All_Roles.
--
package EU_Projects.Nodes.Partners is
type Partner (<>) is new Nodes.Node_Type with private;
type Partner_Access is access all Partner;
subtype Partner_Index is Node_Index;
No_Partner : constant Extended_Node_Index := No_Index;
type Partner_Label is new Node_Label;
type Partner_Name_Array is array (Partner_Index range <>) of Partner_Label;
type Role_Name is new Dotted_Identifier;
subtype Country_Code is String (1 .. 2)
with Dynamic_Predicate => (for all C of Country_Code => C in 'A' .. 'Z');
function Create (ID : Partner_Label;
Name : String;
Short_Name : String;
Country : Country_Code;
Node_Dir : in out Node_Tables.Node_Table)
return Partner_Access;
procedure Set_Index (Item : in out Partner;
Idx : Partner_Index);
function Country (Item : Partner) return Country_Code;
function Dependency_List (Item : partner)
return Node_Label_Lists.Vector
is (Node_Label_Lists.Empty_Vector);
overriding function Full_Index (Item : Partner;
Prefixed : Boolean) return String;
procedure Add_Role (To : in out Partner;
Role : in Role_Name;
Description : in String;
Monthly_Cost : in Currency);
procedure Add_Undivisible_Expense (To : in out Partner;
Description : in String;
Cost : in Currency);
procedure Add_Divisible_Expense (To : in out Partner;
Description : in String;
Unit_Cost : in Currency;
Amount : in Natural);
type Cursor is private;
function Has_Element (X : Cursor) return Boolean;
package Expense_Iterator_Interfaces is
new Ada.Iterator_Interfaces (Cursor => Cursor,
Has_Element => Has_Element);
function All_Expenses
(Item : Partner)
return Expense_Iterator_Interfaces.Forward_Iterator'Class;
function Is_Divisible (Pos : Cursor) return Boolean;
function Unit_Cost (Pos : Cursor) return Currency
with
Pre => Is_Divisible (Pos);
function Amount (Pos : Cursor) return Natural
with
Pre => Is_Divisible (Pos);
function Total_Cost (Pos : Cursor) return Currency;
function Description (Pos : Cursor) return String;
type Role_Cursor is private;
function Has_Element (X : Role_Cursor) return Boolean;
package Role_Iterator_Interfaces is
new Ada.Iterator_Interfaces (Cursor => Role_Cursor,
Has_Element => Has_Element);
function All_Roles
(Item : Partner)
return Role_Iterator_Interfaces.Forward_Iterator'Class;
function Cost (Pos : Role_Cursor) return Currency;
function Description (Pos : Role_Cursor) return String;
function Name (Pos : Role_Cursor) return String;
pragma Warnings (Off);
overriding function Get_Symbolic_Instant
(X : Partner;
Var : Simple_Identifier)
return Times.Time_Expressions.Symbolic_Instant
is (raise Unknown_Instant_Var);
overriding function Get_Symbolic_Duration
(X : Partner;
Var : Simple_Identifier)
return Times.Time_Expressions.Symbolic_Duration
is (raise Unknown_Duration_Var);
pragma Warnings (On);
private
type Personnel_Cost is
record
Role : Role_Name;
Monthly_Cost : Currency;
Description : Unbounded_String;
end record;
type Expense (Divisible : Boolean := False) is
record
Description : Unbounded_String;
case Divisible is
when True =>
Unit_Cost : Currency;
Amount : Natural;
when False =>
Cost : Currency;
end case;
end record;
package Personnel_Cost_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Personnel_Cost);
package Other_Cost_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Expense);
type Partner is new Nodes.Node_Type
with
record
Personnel_Costs : Personnel_Cost_Vectors.Vector;
Other_Costs : Other_Cost_Vectors.Vector;
Country : Country_Code;
end record;
function Country (Item : Partner) return Country_Code
is (Item.Country);
type Cursor is
record
Pos : Other_Cost_Vectors.Cursor;
end record;
type Role_Cursor is
record
Pos : Personnel_Cost_Vectors.Cursor;
end record;
type Expense_Iterator is
new Expense_Iterator_Interfaces.Forward_Iterator
with
record
Start : Other_Cost_Vectors.Cursor;
end record;
overriding
function Full_Index (Item : Partner;
Prefixed : Boolean) return String
is (Image (Item.Index));
overriding
function First (Object : Expense_Iterator) return Cursor
is (Cursor'(Pos => Object.Start));
overriding
function Next
(Object : Expense_Iterator;
Position : Cursor) return Cursor
is (Cursor'(Pos => Other_Cost_Vectors.Next (Position.Pos)));
function All_Expenses
(Item : Partner)
return Expense_Iterator_Interfaces.Forward_Iterator'Class
is (Expense_Iterator'(Expense_Iterator_Interfaces.Forward_Iterator
with
Start => Item.Other_Costs.First));
function Has_Element (X : Cursor) return Boolean
is (Other_Cost_Vectors.Has_Element (X.Pos));
function Is_Divisible (Pos : Cursor) return Boolean
is (Other_Cost_Vectors.Element (Pos.Pos).Divisible);
function Unit_Cost (Pos : Cursor) return Currency
is (Other_Cost_Vectors.Element (Pos.Pos).Unit_Cost);
function Total_Cost (Pos : Cursor) return Currency
is (
if Is_Divisible (Pos)
then
Unit_Cost (Pos) * Amount (Pos)
else
Other_Cost_Vectors.Element (Pos.Pos).Cost
);
function Amount (Pos : Cursor) return Natural
is (Other_Cost_Vectors.Element (Pos.Pos).Amount);
function Description (Pos : Cursor) return String
is (To_String (Other_Cost_Vectors.Element (Pos.Pos).Description));
type Role_Iterator is
new Role_Iterator_Interfaces.Forward_Iterator
with
record
Start : Personnel_Cost_Vectors.Cursor;
end record;
function First (Object : Role_Iterator) return Role_Cursor
is (Role_Cursor'(Pos => Object.Start));
overriding
function Next
(Object : Role_Iterator;
Position : Role_Cursor) return Role_Cursor
is (Role_Cursor'(Pos => Personnel_Cost_Vectors.Next (Position.Pos)));
function Has_Element (X : Role_Cursor) return Boolean
is (Personnel_Cost_Vectors.Has_Element (X.Pos));
function All_Roles
(Item : Partner)
return Role_Iterator_Interfaces.Forward_Iterator'Class
is (Role_Iterator'(Role_Iterator_Interfaces.Forward_Iterator
with
Start => Item.Personnel_Costs.First));
function Cost (Pos : Role_Cursor) return Currency
is (Personnel_Cost_Vectors.Element (Pos.Pos).Monthly_Cost);
function Description (Pos : Role_Cursor) return String
is (To_String (Personnel_Cost_Vectors.Element (Pos.Pos).Description));
function Name (Pos : Role_Cursor) return String
is (Image (Personnel_Cost_Vectors.Element (Pos.Pos).Role));
end EU_Projects.Nodes.Partners;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;
procedure Error is
-- Note: If Constrained_Integer is constrained to 0
-- .. Integer'Last then Constraint_Error is raised when
-- Result1 is calculated. It appears to me that the
-- boundry check is occurring after the calculation
-- completed and doesn't check the signs of the terms
-- vs. the results. Similar results occur with addition.
subtype Constrained_Integer is Integer
range Integer'First .. Integer'Last;
subtype Small_Integer is Integer range 0 .. 1000;
Multiplicand1 : Integer;
Multiplicand2 : Integer;
Result1 : Constrained_Integer;
Result2 : Small_Integer;
begin
Multiplicand1 := 2;
Multiplicand2 := Constrained_Integer'Last;
-- Constraint_Error should get raised with this
-- statement.
Result1 := Multiplicand1 * Multiplicand2;
Put("The result of multiplying ");
Put(Multiplicand1);
Put(" and ");
Put(Multiplicand2);
Put(" is ");
Put(Result1);
Put_Line(".");
Flush;
Multiplicand2 := Small_Integer'Last;
-- Constraint_Error should get raised with this
-- statement.
Result2 := Multiplicand1 * Multiplicand2;
Put("The result of multiplying ");
Put(Multiplicand1);
Put(" and ");
Put(Multiplicand2);
Put(" is ");
Put(Result2);
Put_Line(".");
Flush;
end Error;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
package body collada.Library.geometries
is
-----------
--- Utility
--
function "+" (From : in ada.Strings.unbounded.unbounded_String) return String
renames ada.Strings.unbounded.to_String;
-------------
--- Primitive
--
function vertex_Offset_of (Self : in Primitive) return math.Index
is
the_Input : constant Input_t := find_in (Self.Inputs.all, Vertex);
begin
return math.Index (the_Input.Offset);
end vertex_Offset_of;
function normal_Offset_of (Self : in Primitive) return math.Index
is
the_Input : constant Input_t := find_in (Self.Inputs.all, Normal);
begin
return math.Index (the_Input.Offset);
end normal_Offset_of;
function coord_Offset_of (Self : in Primitive) return math.Index
is
the_Input : constant Input_t := find_in (Self.Inputs.all, TexCoord);
begin
if the_Input = null_Input
then
raise no_coord_Offset;
end if;
return math.Index (the_Input.Offset);
end coord_Offset_of;
--------
--- Mesh
--
function Source_of (Self : in Mesh;
source_Name : in String) return Source
is
use ada.Strings.unbounded;
begin
for i in Self.Sources'Range
loop
if Self.Sources (i).Id = source_Name (source_Name'First+1 .. source_Name'Last)
then
return Self.Sources (i);
end if;
end loop;
declare
null_Source : Source;
begin
return null_Source;
end;
end Source_of;
function Positions_of (Self : in Mesh) return access float_Array
is
the_Input : constant Input_t := find_in (Self.Vertices.Inputs.all, Position);
begin
if the_Input = null_Input
then
return null;
end if;
declare
the_Source : constant Source := Source_of (Self, +the_Input.Source);
begin
return the_Source.Floats;
end;
end Positions_of;
function Normals_of (Self : in Mesh;
for_Primitive : in Primitive) return access float_Array
is
the_Primitive : Primitive renames for_Primitive;
the_Input : constant Input_t := find_in (the_Primitive.Inputs.all, Normal);
begin
if the_Input = null_Input then
return null;
end if;
declare
the_Source : constant Source := Source_of (Self, +the_Input.Source);
begin
return the_Source.Floats;
end;
end Normals_of;
function Coords_of (Self : in Mesh;
for_Primitive : in Primitive) return access float_Array
is
the_Primitive : Primitive renames for_Primitive;
the_Input : constant Input_t := find_in (the_Primitive.Inputs.all, TexCoord);
begin
if the_Input = null_Input
then
return null;
end if;
declare
the_Source : constant Source := Source_of (Self, +the_Input.Source);
begin
return the_Source.Floats;
end;
end Coords_of;
end collada.Library.geometries;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Strings.Unbounded;
with Ada.Strings.Unbounded.Hash;
with Ada.Containers.Vectors;
with Ada.Containers.Hashed_Maps;
with Ada.Text_IO;
package GPR_Tools.Pkg2gpr is
use Ada.Strings.Unbounded;
package String_Vectors is new Ada.Containers.Vectors (Natural, Unbounded_String);
package String_Maps is new Ada.Containers.Hashed_Maps (Unbounded_String, Unbounded_String, Hash, "=", "=");
type Descr is tagged record
Default_Include : String_Vectors.Vector;
Default_Libs : String_Vectors.Vector;
Variables : String_Maps.Map;
Name : Unbounded_String;
FName : Unbounded_String;
SrcFile : Unbounded_String;
Description : Unbounded_String;
URL : Unbounded_String;
Version : Unbounded_String;
Requires : String_Vectors.Vector;
Requires_Private : String_Vectors.Vector;
Conflicts : String_Vectors.Vector;
Cflags : String_Vectors.Vector;
Libs : String_Vectors.Vector;
Libs_Private : String_Vectors.Vector;
end record;
procedure Read_Pkg (Item : in out Descr; From : String);
procedure Write_GPR (Item : Descr; To : String);
procedure Write_GPR (Item : Descr; Output : Ada.Text_IO.File_Type);
function Get_Source_Dirs (Item : Descr) return String_Vectors.Vector;
function Get_GPR (Item : Descr) return String;
function Get_GPR (Item : String) return String;
function Image (Item : String_Vectors.Vector) return String;
function Linker_Options (Item : Descr) return String;
function Get_Include (Cpp : String := "cpp") return String_Vectors.Vector;
function Get_Libs (Gcc : String := "gcc") return String_Vectors.Vector;
function Compiler_Default_Switches (Item : Descr) return String_Vectors.Vector;
end GPR_Tools.Pkg2gpr;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with impact.d3.collision.convex_penetration_depth_Solver,
impact.d3.collision.simplex_Solver,
impact.d3.Shape.convex;
package impact.d3.collision.convex_penetration_depth_Solver.gjk_epa
--
-- EpaPenetrationDepthSolver uses the Expanding Polytope Algorithm to
-- calculate the penetration depth between two convex shapes.
--
is
type Item is new impact.d3.collision.convex_penetration_depth_Solver.item with
record
null;
end record;
overriding function calcPenDepth (Self : access Item; simplexSolver : access impact.d3.collision.simplex_Solver.Item'Class;
pConvexA, pConvexB : in impact.d3.Shape.convex.view;
transformA, transformB : in Transform_3d;
v : access math.Vector_3;
wWitnessOnA, wWitnessOnB : access math.Vector_3) return Boolean;
end impact.d3.collision.convex_penetration_depth_Solver.gjk_epa;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
package Geometry is
type Point is record
x : Float;
y : Float;
z : Float;
end record;
type Angle is new Float range -360.0 .. 360.0;
type Axes is record
yaw : Angle;
pitch : Angle;
roll : Angle;
end record;
type Shape is tagged record
position : Point;
rotation : Axes;
end record;
type Rectangle is new Shape with record
width : Float;
length : Float;
height : Float;
end record;
function volume(s : Rectangle) return Float;
function surface_area(s : Rectangle) return Float;
type Circle is new Shape with record
radius : Float;
end record;
function surface_area(s : Circle) return Float;
function circumference(s : Circle) return Float;
type Ellipse is new Shape with record
a : Float;
b : Float;
end record;
function surface_area(s : Ellipse) return Float;
function circumference(s : Ellipse) return Float;
type Cylinder is new Shape with record
radius : Float;
height : Float;
end record;
function volume(s : Cylinder) return Float;
function surface_area(s : Cylinder) return Float;
type Sphere is new Shape with record
radius : Float;
end record;
function volume(s : Sphere) return Float;
function surface_area(s : Sphere) return Float;
function distance(point1, point2 : Point) return Float;
function midpoint(point1, point2 : Point) return Point;
end Geometry;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
--*
-- CHECK THAT THE ATTRIBUTES FIRST AND LAST RETURN VALUES HAVING THE
-- SAME BASE TYPE AS THE PREFIX WHEN THE PREFIX IS A FLOATING POINT
-- TYPE.
-- THIS CHECK IS PROVIDED THROUGH THE USE OF THIS TEST IN CONJUNCTION
-- WITH TEST B35801C.
-- R.WILLIAMS 8/21/86
WITH REPORT; USE REPORT;
PROCEDURE A35801F IS
TYPE REAL IS DIGITS 3 RANGE -100.0 .. 100.0;
SUBTYPE SURREAL IS REAL RANGE -50.0 .. 50.0;
TYPE NFLT IS NEW FLOAT;
SUBTYPE UNIT IS NFLT RANGE -1.0 .. 1.0;
SUBTYPE EMPTY IS FLOAT RANGE 1.0 .. -1.0;
R1 : REAL := SURREAL'FIRST; -- OK.
R2 : REAL := SURREAL'LAST; -- OK.
N1 : NFLT := UNIT'FIRST; -- OK.
N2 : NFLT := UNIT'LAST; -- OK.
F1 : FLOAT := FLOAT'FIRST; -- OK.
F2 : FLOAT := FLOAT'LAST; -- OK.
E1 : FLOAT := EMPTY'FIRST; -- OK.
E2 : FLOAT := EMPTY'LAST; -- OK.
BEGIN
TEST ( "A35801F", "CHECK THAT THE ATTRIBUTES FIRST AND LAST " &
"RETURN VALUES HAVING THE SAME BASE TYPE AS " &
"THE PREFIX WHEN THE PREFIX IS A FLOATING " &
"POINT TYPE" );
RESULT;
END A35801F;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with Ada.Real_Time; use Ada.Real_Time;
package body TT_Patterns is
--------------------
-- Simple_TT_Task --
--------------------
task body Simple_TT_Task is
begin
Task_State.Work_Id := Work_Id;
if Synced_Init then
TTS.Wait_For_Activation (Work_Id, Task_State.Release_Time);
end if;
Task_State.Initialize;
loop
TTS.Wait_For_Activation (Work_Id, Task_State.Release_Time);
Task_State.Main_Code;
end loop;
end Simple_TT_Task;
---------------------------
-- Initial_Final_TT_Task --
---------------------------
task body Initial_Final_TT_Task is
begin
Task_State.Work_Id := Work_Id;
if Synced_Init then
TTS.Wait_For_Activation (Work_Id, Task_State.Release_Time);
end if;
Task_State.Initialize;
loop
TTS.Wait_For_Activation (Work_Id, Task_State.Release_Time);
Task_State.Initial_Code;
TTS.Wait_For_Activation (Work_Id, Task_State.Release_Time);
Task_State.Final_Code;
end loop;
end Initial_Final_TT_Task;
-------------------------------------
-- Initial_Mandatory_Final_TT_Task --
-------------------------------------
task body Initial_Mandatory_Final_TT_Task is
begin
Task_State.Work_Id := Work_Id;
if Synced_Init then
TTS.Wait_For_Activation (Work_Id, Task_State.Release_Time);
end if;
Task_State.Initialize;
loop
TTS.Wait_For_Activation (Work_Id, Task_State.Release_Time);
Task_State.Initial_Code;
TTS.Wait_For_Activation (Work_Id, Task_State.Release_Time);
Task_State.Mandatory_Code;
TTS.Wait_For_Activation (Work_Id, Task_State.Release_Time);
Task_State.Final_Code;
end loop;
end Initial_Mandatory_Final_TT_Task;
------------------------------------------
-- InitialMandatorySliced_Final_TT_Task --
------------------------------------------
task body InitialMandatorySliced_Final_TT_Task is
begin
Task_State.Work_Id := Work_Id;
if Synced_Init then
TTS.Wait_For_Activation (Work_Id, Task_State.Release_Time);
end if;
Task_State.Initialize;
loop
TTS.Wait_For_Activation (Work_Id, Task_State.Release_Time);
Task_State.Initial_Code;
TTS.Continue_Sliced;
Task_State.Mandatory_Code;
TTS.Wait_For_Activation (Work_Id, Task_State.Release_Time);
Task_State.Final_Code;
end loop;
end InitialMandatorySliced_Final_TT_Task;
------------------------------------
-- Iniitial_OptionalFinal_TT_Task --
------------------------------------
task body Initial_OptionalFinal_TT_Task is
begin
if Synced_Init then
TTS.Wait_For_Activation (Initial_Work_Id, Task_State.Release_Time);
Task_State.Work_Id := Initial_Work_Id;
end if;
Task_State.Initialize;
loop
TTS.Wait_For_Activation (Initial_Work_Id, Task_State.Release_Time);
Task_State.Work_Id := Initial_Work_Id;
Task_State.Initial_Code;
if (Task_State.Final_Is_Required) then
TTS.Wait_For_Activation (Optional_Work_Id, Task_State.Release_Time);
Task_State.Work_Id := Optional_Work_Id;
Task_State.Final_Code;
end if;
end loop;
end Initial_OptionalFinal_TT_Task;
---------------------------
-- Simple_Synced_ET_Task --
---------------------------
task body Simple_Synced_ET_Task is
begin
Task_State.Sync_Id := Sync_Id;
if Synced_Init then
TTS.Wait_For_Sync (Sync_Id, Task_State.Release_Time);
end if;
Task_State.Initialize;
loop
TTS.Wait_For_Sync (Sync_Id, Task_State.Release_Time);
Task_State.Main_Code;
end loop;
end Simple_Synced_ET_Task;
-----------------------------------------
-- SyncedInitial_OptionalFinal_ET_Task --
-----------------------------------------
task body SyncedInitial_OptionalFinal_ET_Task is
begin
Task_State.Work_Id := Work_Id;
Task_State.Sync_Id := Sync_Id;
if Synced_Init then
TTS.Wait_For_Sync (Sync_Id, Task_State.Release_Time);
end if;
Task_State.Initialize;
loop
TTS.Wait_For_Sync (Sync_Id, Task_State.Release_Time);
Task_State.Initial_Code;
if (Task_State.Final_Is_Required) then
TTS.Wait_For_Activation (Work_Id, Task_State.Release_Time);
Task_State.Final_Code;
end if;
end loop;
end SyncedInitial_OptionalFinal_ET_Task;
end TT_Patterns;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
-------------------------------------------------------------------------------
with Ada.Real_Time; use Ada.Real_Time;
with Ada.Synchronous_Task_Control; use Ada.Synchronous_Task_Control;
with DecaDriver;
with DW1000.BSP;
with DW1000.Driver; use DW1000.Driver;
with DW1000.Types;
with Tx_Power;
-- This simple example demonstrates how to transmit packets.
procedure Transmit_Example
with SPARK_Mode,
Global => (Input => Ada.Real_Time.Clock_Time,
In_Out => (DW1000.BSP.Device_State,
DecaDriver.Driver,
DecaDriver.Tx_Complete_Flag)),
Depends => (DecaDriver.Driver =>+ DW1000.BSP.Device_State,
DW1000.BSP.Device_State =>+ DecaDriver.Driver,
DecaDriver.Tx_Complete_Flag =>+ null,
null => Ada.Real_Time.Clock_Time)
is
Packet : constant DW1000.Types.Byte_Array (1 .. 10) := (others => 16#AA#);
Now : Ada.Real_Time.Time;
begin
-- Driver must be initialized once before it is used.
DecaDriver.Driver.Initialize
(Load_Antenna_Delay => True,
Load_XTAL_Trim => True,
Load_UCode_From_ROM => True);
-- Configure the DW1000
DecaDriver.Driver.Configure
(DecaDriver.Configuration_Type'
(Channel => 1,
PRF => PRF_64MHz,
Tx_Preamble_Length => PLEN_1024,
Rx_PAC => PAC_8,
Tx_Preamble_Code => 9,
Rx_Preamble_Code => 9,
Use_Nonstandard_SFD => False,
Data_Rate => Data_Rate_110k,
PHR_Mode => Standard_Frames,
SFD_Timeout => 1024 + 64 + 1));
-- Configure the transmit power for the PRF and channel chosen.
-- We use the reference values for the EVB1000 in this example.
DW1000.Driver.Configure_Tx_Power
(Tx_Power.Manual_Tx_Power_Table (1, PRF_64MHz));
-- Enable the LEDs controlled by the DW1000.
DW1000.Driver.Configure_LEDs
(Tx_LED_Enable => True, -- Enable transmit LED
Rx_LED_Enable => True, -- Enable receive LED
Rx_OK_LED_Enable => False,
SFD_LED_Enable => False,
Test_Flash => True); -- Flash both LEDs once
Now := Ada.Real_Time.Clock;
-- Send packets at a rate of 1 packet per second
loop
-- Load the packet into the transmitter's buffer.
DW1000.Driver.Set_Tx_Data
(Data => Packet,
Offset => 0);
-- Tell the driver the length of the packet and its position in the
-- transmit buffer.
DW1000.Driver.Set_Tx_Frame_Length
(Length => Packet'Length,
Offset => 0);
-- Start transmitting the packet now.
-- (don't turn on the receiver after transmitting).
DecaDriver.Driver.Start_Tx_Immediate (Rx_After_Tx => False,
Auto_Append_FCS => False);
-- Wait for the packet to finish sending.
Suspend_Until_True (DecaDriver.Tx_Complete_Flag);
-- Wait for the time to send the next packet (1 second delay)
Now := Now + Seconds (1);
delay until Now;
end loop;
end Transmit_Example;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
with ada.characters.latin_1;
with point_list;
use point_list;
with point;
use point;
with logger;
use logger;
-- ATTENTION: dans ce fichier, le terme "queue" est équivalent à "queue et encoche"
-- exemple: la fonction add_queues ajoue queues ET encoches.
package body halfbox_panel is
function get_bottom_panel(halfbox_info : halfbox_info_t) return halfbox_panel_t is
-- Petit poucet pour tracer la face
poucet : petit_poucet_t := get_petit_poucet((0.0, 0.0));
-- espace dispo pour les encoches en longueur
l_queue_space : constant integer := halfbox_info.length - 2 * halfbox_info.thickness;
-- nombre d'encoches à mettre en longueur
l_raw_queue_count : constant integer := l_queue_space / halfbox_info.queue_length;
-- nombre d'encoches à mettre en longueur ramené à l'impair inférieur
l_queue_count : constant integer := l_raw_queue_count - (l_raw_queue_count + 1) mod 2;
-- marge à répartir pour centrer les encoches en longueur
l_queue_margin : constant integer := l_queue_space - l_queue_count * halfbox_info.queue_length;
-- espace dispo pour les encoches en largeur
w_queue_space : constant integer := halfbox_info.width - 2 * halfbox_info.thickness;
-- nombre d'encoches à mettre en largeur
w_raw_queue_count : constant integer := w_queue_space / halfbox_info.queue_length;
-- nombre d'encoches à mettre en largeur ramené à l'impair inférieur
w_queue_count : integer := w_raw_queue_count - (w_raw_queue_count + 1) mod 2;
-- marge à répartir pour centrer les encoches en largeur
w_queue_margin : integer := w_queue_space - w_queue_count * halfbox_info.queue_length;
begin
debug("Génération de la face du fond");
debug("Marge calculée en longueur: " & integer'image(l_queue_margin));
debug("Marge calculée en largeur: " & integer'image(w_queue_margin));
-- Si possible, réduction du nombre d'encoches à mettre en largeur
-- pour éviter des "cassures" physiques du coin d'une face
if halfbox_info.width = 2 * halfbox_info.thickness + w_queue_count * halfbox_info.queue_length and w_queue_count >= 3 then
debug("Réduction du nombre d'encoches en largeur de 2");
w_queue_count := w_queue_count - 2;
-- L'espace manquant est compensé dans la marge
w_queue_margin := w_queue_margin + 2 * halfbox_info.queue_length;
end if;
-- Bord haut de la face
-- Marge de t à gauche pour les encoches
-- + la moitié de la marge de centrage des encoches en longueur
mv_r(poucet, float(halfbox_info.thickness) + float(l_queue_margin) / 2.0);
-- Ajout des queues et des encoches en longueur
add_queues(poucet, halfbox_info.queue_length, halfbox_info.thickness, l_queue_count, mv_r_ptr, mv_u_ptr, mv_d_ptr, false);
-- Marge de t à droite pour les encoches
-- + l'autre moitié de la marge de centrage des encoches en longueur
mv_r(poucet, float(halfbox_info.thickness) + float(l_queue_margin) / 2.0);
-- Bord droit de la face
-- Marge de t en haut pour les encoches
-- + la moitié de la marge de centrage des encoches en largeur
mv_d(poucet, float(halfbox_info.thickness) + float(w_queue_margin) / 2.0);
-- Ajout des queues et des encoches en largeur
add_queues(poucet, halfbox_info.queue_length, halfbox_info.thickness, w_queue_count, mv_d_ptr, mv_r_ptr, mv_l_ptr, false);
-- Marge de t en bas pour les encoches
-- + l'autre moitié de la marge de centrage des encoches en largeur
mv_d(poucet, float(halfbox_info.thickness) + float(w_queue_margin) / 2.0);
-- Bord bas de la face
-- Marge de t à droite pour les encoches
-- + la moitié de la marge de centrage des encoches en longueur
mv_l(poucet, float(halfbox_info.thickness) + float(l_queue_margin) / 2.0);
-- Ajout des queues et des encoches en longueur
add_queues(poucet, halfbox_info.queue_length, halfbox_info.thickness, l_queue_count, mv_l_ptr, mv_d_ptr, mv_u_ptr, false);
-- Marge de t à gauche pour les encoches
-- + l'autre moitié de la marge de centrage des encoches en longueur
mv_l(poucet, float(halfbox_info.thickness) + float(l_queue_margin) / 2.0);
-- Bord gauche de la face
-- Marge de t en bas pour les encoches
-- + la moitié de la marge de centrage des encoches en largeur
mv_u(poucet, float(halfbox_info.thickness) + float(w_queue_margin) / 2.0);
-- Ajout des queues et des encoches en largeur
add_queues(poucet, halfbox_info.queue_length, halfbox_info.thickness, w_queue_count, mv_u_ptr, mv_l_ptr, mv_r_ptr, false);
-- Marge de t en haut pour les encoches
-- + l'autre moitié de la marge de centrage des encoches en largeur
mv_u(poucet, float(halfbox_info.thickness) + float(w_queue_margin) / 2.0);
-- On doit être revenu pos. 0,0
return (polygon => get_points(poucet));
end;
function get_back_panel(halfbox_info : halfbox_info_t) return halfbox_panel_t is
begin
debug("Génération de la face de derrière");
return get_front_and_back_panel(halfbox_info.length, halfbox_info.height, halfbox_info.thickness, halfbox_info.queue_length);
end;
function get_front_panel(halfbox_info : halfbox_info_t) return halfbox_panel_t is
begin
debug("Génération de la face de devant");
return get_front_and_back_panel(halfbox_info.length, halfbox_info.height, halfbox_info.thickness, halfbox_info.queue_length);
end;
function get_right_panel(halfbox_info : halfbox_info_t) return halfbox_panel_t is
begin
debug("Génération de la face de droite");
return get_right_and_left_panel(halfbox_info.width, halfbox_info.height, halfbox_info.thickness, halfbox_info.queue_length);
end;
function get_left_panel(halfbox_info : halfbox_info_t) return halfbox_panel_t is
begin
debug("Génération de la face de gauche");
return get_right_and_left_panel(halfbox_info.width, halfbox_info.height, halfbox_info.thickness, halfbox_info.queue_length);
end;
function get_front_and_back_panel(length, width, thickness, queue_length : integer) return halfbox_panel_t is
-- poucet de tracer de la face
-- commence directement à 0;t
poucet : petit_poucet_t := get_petit_poucet((0.0, float(thickness)));
-- espace dispo pour les encoches en longueur
l_queue_space : constant integer := length - 2 * thickness;
-- nombre d'encoches à mettre en longueur
l_raw_queue_count : constant integer := l_queue_space / queue_length;
-- nombre d'encoches à mettre en longueur ramené à l'impair inférieur
l_queue_count : constant integer := l_raw_queue_count - (l_raw_queue_count + 1) mod 2;
-- marge à répartir pour centrer les encoches en longueur
l_queue_margin : constant integer := l_queue_space - l_queue_count * queue_length;
-- espace dispo pour les encoches en largeur
w_queue_space : constant integer := width - 2 * thickness;
-- nombre d'encoches à mettre en largeur
w_raw_queue_count : constant integer := w_queue_space / queue_length;
-- nombre d'encoches à mettre en largeur ramené à l'impair inférieur
w_queue_count : constant integer := w_raw_queue_count - (w_raw_queue_count + 1) mod 2;
-- marge à répartir pour centrer les encoches en largeur
w_queue_margin : constant integer := w_queue_space - w_queue_count * queue_length;
begin
debug("Marge calculée en longueur: " & integer'image(l_queue_margin));
debug("Marge calculée en largeur: " & integer'image(w_queue_margin));
-- Bord haut de la face
-- Marge de t à gauche pour les encoches
-- + la moitié de la marge de centrage des encoches en longueur
mv_r(poucet, float(thickness) + float(l_queue_margin) / 2.0);
-- Ajout des queues et des encoches en longueur
add_queues(poucet, queue_length, thickness, l_queue_count, mv_r_ptr, mv_u_ptr, mv_d_ptr, true);
-- Marge de t à droite pour les encoches
-- + l'autre moitié de la marge de centrage des encoches en longueur
mv_r(poucet, float(thickness) + float(l_queue_margin) / 2.0);
-- Bord droit de la face
-- Marge de t en haut pour les encoches
-- + l'autre moitié de la marge de centrage des encoches en largeur
mv_d(poucet, float(thickness) + float(w_queue_margin) / 2.0);
-- Ajout des queues et des encoches en largeur
add_queues(poucet, queue_length, thickness, w_queue_count, mv_d_ptr, mv_r_ptr, mv_l_ptr, false);
-- Marge de t en bas pour les encoches
-- + l'autre moitié de la marge de centrage des encoches en largeur
mv_d(poucet, float(thickness) + float(w_queue_margin) / 2.0);
-- Bord bas de la face
-- Le bord bas est un bord droit ("lisse")
mv_l(poucet, float(length));
-- Bord gauche de la face
-- Marge de t en bas pour les encoches
-- + la moitié de la marge de centrage des encoches en largeur
mv_u(poucet, float(thickness) + float(w_queue_margin) / 2.0);
-- Ajout des queues et des encoches en largeur
add_queues(poucet, queue_length, thickness, w_queue_count, mv_u_ptr, mv_l_ptr, mv_r_ptr, false);
-- Marge de t en haut pour les encoches
-- + la moitié de la marge de centrage des encoches en largeur
mv_u(poucet, float(thickness) + float(w_queue_margin) / 2.0);
-- On doit être revenu pos. 0,t
return (polygon => get_points(poucet));
end;
function get_right_and_left_panel(length, width, thickness, queue_length : integer) return halfbox_panel_t is
-- poucet de tracer de la face
-- commence directement à t;t
poucet : petit_poucet_t := get_petit_poucet((float(thickness), float(thickness)));
-- espace dispo pour les encoches en longueur
l_queue_space : constant integer := length - 2 * thickness;
-- nombre d'encoches à mettre en longueur
l_raw_queue_count : constant integer := l_queue_space / queue_length;
-- nombre d'encoches à mettre en longueur ramené à l'impair inférieur
l_queue_count : integer := l_raw_queue_count - (l_raw_queue_count + 1) mod 2;
-- marge à répartir pour centrer les encoches en longueur
l_queue_margin : integer := l_queue_space - l_queue_count * queue_length;
-- espace dispo pour les encoches en largeur
w_queue_space : constant integer := width - 2 * thickness;
-- nombre d'encoches à mettre en largeur
w_raw_queue_count : constant integer := w_queue_space / queue_length;
-- nombre d'encoches à mettre en largeur ramené à l'impair inférieur
w_queue_count : constant integer := w_raw_queue_count - (w_raw_queue_count + 1) mod 2;
-- marge à répartir pour centrer les encoches en largeur
w_queue_margin : constant integer := w_queue_space - w_queue_count * queue_length;
begin
debug("Marge calculée en longueur: " & integer'image(l_queue_margin));
debug("Marge calculée en largeur: " & integer'image(w_queue_margin));
-- Si possible, réduction du nombre d'encoches à mettre sur la face du haut
-- pour éviter des "cassures" physiques du coin de la face inférieure
if length = 2 * thickness + l_queue_count * queue_length and l_queue_count >= 3 then
l_queue_count := l_queue_count - 2;
-- L'espace manquant est compensé dans la marge
l_queue_margin := l_queue_margin + 2 * queue_length;
end if;
-- Bord haut de la face
-- Marge de t à gauche pour les encoches
-- + la moitié de la marge de centrage des encoches en longueur
mv_r(poucet, float(thickness) + float(l_queue_margin) / 2.0);
-- Ajout des queues et des encoches en longueur
add_queues(poucet, queue_length, thickness, l_queue_count, mv_r_ptr, mv_u_ptr, mv_d_ptr, true);
-- Marge de t à droite pour les encoches
-- + l'autre moitié de la marge de centrage des encoches en longueur
mv_r(poucet, float(thickness) + float(l_queue_margin) / 2.0);
-- Bord droit de la face
-- Marge de t en haut pour les encoches
-- + l'autre moitié de la marge de centrage des encoches en largeur
mv_d(poucet, float(thickness) + float(w_queue_margin) / 2.0);
-- Ajout des queues et des encoches en largeur
add_queues(poucet, queue_length, thickness, w_queue_count, mv_d_ptr, mv_r_ptr, mv_l_ptr, true);
-- Marge de t en bas pour les encoches
-- + l'autre moitié de la marge de centrage des encoches en largeur
mv_d(poucet, float(thickness) + float(w_queue_margin) / 2.0);
-- Bord bas de la face
-- Le bord bas est un bord droit ("lisse")
mv_l(poucet, float(length));
-- Bord gauche de la face
-- Marge de t en bas pour les encoches
-- + la moitié de la marge de centrage des encoches en largeur
mv_u(poucet, float(thickness) + float(w_queue_margin) / 2.0);
-- Ajout des queues et des encoches en largeur
add_queues(poucet, queue_length, thickness, w_queue_count, mv_u_ptr, mv_l_ptr, mv_r_ptr, true);
-- Marge de t en haut pour les encoches
-- + la moitié de la marge de centrage des encoches en largeur
mv_u(poucet, float(thickness) + float(w_queue_margin) / 2.0);
-- On doit être revenu pos. t,t
return (polygon => get_points(poucet));
end;
-- Ajoute les queues et les encoches
-- poucet : le petit poucet !
-- queue_length : longueur des queues
-- queue_width : largeur des queues
-- queue_count : le nombre de queues
-- mv_line : fonction de mouvement formant la grande ligne entre une queue et une encoche (et inversement)
-- mv_queue : fonction de mouvement pour une queue
-- mv_encoche : fonction de mouvement pour une encoche
-- queue_first : si on commence par une queue
procedure add_queues(poucet : in out petit_poucet_t; queue_length, queue_width, queue_count : integer; mv_line, mv_queue, mv_socket : mv_poucet_ptr; queue_first : boolean) is
begin
debug("Ajout des queues et des encoches.");
debug("Commence queue: " & boolean'image(queue_first) & ". Nombre:" & integer'image(queue_count));
for i in 1 .. queue_count loop
-- permet de commencer par une encoche ou une queue
if i mod 2 = boolean'pos(queue_first) mod 2 then
mv_queue(poucet, float(queue_width));
mv_line(poucet, float(queue_length));
else -- les pairs sont des queues
mv_socket(poucet, float(queue_width));
mv_line(poucet, float(queue_length));
end if;
end loop;
if queue_first then
mv_socket(poucet, float(queue_width));
else
mv_queue(poucet, float(queue_width));
end if;
end;
procedure destroy(panel : in out halfbox_panel_t) is
begin
point_list.destroy(panel.polygon);
end;
function to_string(panel : halfbox_panel_t) return string is
lf : constant character := ada.characters.latin_1.LF;
begin
-- le to_string en pointeur de fonction est celui du point
return "[" & lf & to_string(panel.polygon, to_string'access) & "]";
end;
end halfbox_panel;
|
{
"source": "starcoderdata",
"programming_language": "ada"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.