text
stringlengths
437
491k
meta
dict
with GL.Low_Level; package GL.Objects.Queries is pragma Preelaborate; type Query_Type is (Vertices_Submitted, Primitives_Submitted, Vertex_Shader_Invocations, Tess_Control_Shader_Invocations, Tess_Evaluation_Shader_Invocations, Geometry_Shader_Primitives_Emitted, Fragment_Shader_Invocations, Compute_Shader_Invocations, Clipping_Input_Primitives, Clipping_Output_Primitives, Geometry_Shader_Invocations, Time_Elapsed, Samples_Passed, Any_Samples_Passed, Primitives_Generated, Any_Samples_Passed_Conservative, Timestamp); -- Has to be defined here because of the subtype declaration below for Query_Type use (Vertices_Submitted => 16#82EE#, Primitives_Submitted => 16#82EF#, Vertex_Shader_Invocations => 16#82F0#, Tess_Control_Shader_Invocations => 16#82F1#, Tess_Evaluation_Shader_Invocations => 16#82F2#, Geometry_Shader_Primitives_Emitted => 16#82F3#, Fragment_Shader_Invocations => 16#82F4#, Compute_Shader_Invocations => 16#82F5#, Clipping_Input_Primitives => 16#82F6#, Clipping_Output_Primitives => 16#82F7#, Geometry_Shader_Invocations => 16#887F#, Time_Elapsed => 16#88BF#, Samples_Passed => 16#8914#, Any_Samples_Passed => 16#8C2F#, Primitives_Generated => 16#8C87#, Any_Samples_Passed_Conservative => 16#8D6A#, Timestamp => 16#8E28#); for Query_Type'Size use Low_Level.Enum'Size; subtype Async_Query_Type is Query_Type range Vertices_Submitted .. Any_Samples_Passed_Conservative; subtype Timestamp_Query_Type is Query_Type range Timestamp .. Timestamp; subtype Stream_Query_Type is Query_Type with Static_Predicate => Stream_Query_Type in Primitives_Generated; type Query_Param is (Result, Result_Available, Result_No_Wait); type Query (Target : Query_Type) is new GL_Object with private; overriding procedure Initialize_Id (Object : in out Query); overriding procedure Delete_Id (Object : in out Query); overriding function Identifier (Object : Query) return Types.Debug.Identifier is (Types.Debug.Query); type Active_Query is limited new Ada.Finalization.Limited_Controlled with private; function Begin_Query (Object : in out Query; Index : in Natural := 0) return Active_Query'Class with Pre => Object.Target in Async_Query_Type and (if Object.Target not in Stream_Query_Type then Index = 0); -- Start an asynchronous query. The value returned is of a controlled -- type, meaning you must assign it to some local variable, so that -- the query will be automatically ended when the variable goes out -- of scope. -- -- Queries of type Timestamp are not used within a scope. For such -- a query you can record the time into the query object by calling -- Record_Current_Time. -- -- Certain queries support multiple query operations; one for each -- index. The index represents the vertex output stream used in a -- Geometry Shader. These targets are: -- -- * Primitives_Generated function Result_Available (Object : in out Query) return Boolean; -- Return true if a result is available, false otherwise. This function -- can be used to avoid calling Result (and thereby stalling the CPU) -- when the result is not yet available. function Result_If_Available (Object : in out Query; Default : Boolean) return Boolean; function Result_If_Available (Object : in out Query; Default : Natural) return Natural; function Result_If_Available (Object : in out Query; Default : UInt64) return UInt64; -- Return the result if available, otherwise return the default value function Result (Object : in out Query) return Boolean; function Result (Object : in out Query) return Natural; function Result (Object : in out Query) return UInt64; -- Return the result. If the result is not yet available, then the -- CPU will stall until the result becomes available. This means -- that if you do not call Result_Available, then this function call -- will make the query synchronous. procedure Record_Current_Time (Object : in out Query); -- Record the time when the GPU has completed all previous commands -- in a query object. The result must be retrieved asynchronously using -- one of the Result functions. function Get_Current_Time return Long; -- Return the time when the GPU has received (but not necessarily -- completed) all previous commands. Calling this function stalls the CPU. private for Query_Param use (Result => 16#8866#, Result_Available => 16#8867#, Result_No_Wait => 16#9194#); for Query_Param'Size use Low_Level.Enum'Size; type Query (Target : Query_Type) is new GL_Object with null record; type Active_Query is limited new Ada.Finalization.Limited_Controlled with record Target : Query_Type; Index : Natural; Finalized : Boolean; end record; overriding procedure Finalize (Object : in out Active_Query); end GL.Objects.Queries;
{ "source": "starcoderdata", "programming_language": "ada" }
----------------------------------------------------------------------- with Util.Strings; with Util.Log.Loggers; with Util.Http.Clients.Curl.Constants; package body Util.Http.Clients.Curl is use System; pragma Linker_Options ("-lcurl"); Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Util.Http.Clients.Curl"); function Get_Request (Http : in Client'Class) return Curl_Http_Request_Access; Manager : aliased Curl_Http_Manager; -- ------------------------------ -- Register the CURL Http manager. -- ------------------------------ procedure Register is begin Default_Http_Manager := Manager'Access; end Register; -- ------------------------------ -- Check the CURL result code and report and exception and a log message if -- the CURL code indicates an error. -- ------------------------------ procedure Check_Code (Code : in CURL_Code; Message : in String) is begin if Code /= CURLE_OK then declare Error : constant Chars_Ptr := Curl_Easy_Strerror (Code); Msg : constant String := Interfaces.C.Strings.Value (Error); begin Log.Error ("{0}: {1}", Message, Msg); raise Connection_Error with Msg; end; end if; end Check_Code; -- ------------------------------ -- Create a new HTTP request associated with the current request manager. -- ------------------------------ procedure Create (Manager : in Curl_Http_Manager; Http : in out Client'Class) is pragma Unreferenced (Manager); Request : Curl_Http_Request_Access; Data : CURL; begin Data := Curl_Easy_Init; if Data = System.Null_Address then raise Storage_Error with "curl_easy_init cannot create the CURL instance"; end if; Request := new Curl_Http_Request; Request.Data := Data; Http.Delegate := Request.all'Access; end Create; function Get_Request (Http : in Client'Class) return Curl_Http_Request_Access is begin return Curl_Http_Request'Class (Http.Delegate.all)'Access; end Get_Request; -- ------------------------------ -- This function is called by CURL when a response line was read. -- ------------------------------ function Read_Response (Data : in Chars_Ptr; Size : in Size_T; Nmemb : in Size_T; Response : in Curl_Http_Response_Access) return Size_T is Total : constant Size_T := Size * Nmemb; Line : constant String := Interfaces.C.Strings.Value (Data, Total); begin Log.Info ("RCV: {0}", Line); if Response.Parsing_Body then Ada.Strings.Unbounded.Append (Response.Content, Line); elsif Total = 2 and then Line (1) = ASCII.CR and then Line (2) = ASCII.LF then Response.Parsing_Body := True; else declare Pos : constant Natural := Util.Strings.Index (Line, ':'); Start : Natural; Last : Natural; begin if Pos > 0 then Start := Pos + 1; while Start <= Line'Last and Line (Start) = ' ' loop Start := Start + 1; end loop; Last := Line'Last; while Last >= Start and (Line (Last) = ASCII.CR or Line (Last) = ASCII.LF) loop Last := Last - 1; end loop; Response.Add_Header (Name => Line (Line'First .. Pos - 1), Value => Line (Start .. Last)); end if; end; end if; return Total; end Read_Response; procedure Do_Get (Manager : in Curl_Http_Manager; Http : in Client'Class; URI : in String; Reply : out Response'Class) is pragma Unreferenced (Manager); use Interfaces.C; Req : constant Curl_Http_Request_Access := Get_Request (Http); Result : CURL_Code; Response : Curl_Http_Response_Access; Status : aliased C.long; begin Log.Info ("GET {0}", URI); Result := Curl_Easy_Setopt_Write_Callback (Req.Data, Constants.CURLOPT_WRITEUNCTION, Read_Response'Access); Check_Code (Result, "set callback"); Interfaces.C.Strings.Free (Req.URL); Req.URL := Strings.New_String (URI); Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_HEADER, 1); Check_Code (Result, "set header"); Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_URL, Req.URL); Check_Code (Result, "set url"); Response := new Curl_Http_Response; Result := Curl_Easy_Setopt_Data (Req.Data, Constants.CURLOPT_WRITEDATA, Response); Check_Code (Result, "set write data"); Reply.Delegate := Response.all'Access; Result := Curl_Easy_Perform (Req.Data); Check_Code (Result, "get request"); Result := Curl_Easy_Getinfo_Long (Req.Data, Constants.CURLINFO_RESPONSE_CODE, Status'Access); Check_Code (Result, "get response code"); Response.Status := Natural (Status); end Do_Get; procedure Do_Post (Manager : in Curl_Http_Manager; Http : in Client'Class; URI : in String; Data : in String; Reply : out Response'Class) is pragma Unreferenced (Manager); use Interfaces.C; Req : constant Curl_Http_Request_Access := Get_Request (Http); Result : CURL_Code; Response : Curl_Http_Response_Access; Status : aliased C.long; begin Log.Info ("POST {0}", URI); Result := Curl_Easy_Setopt_Write_Callback (Req.Data, Constants.CURLOPT_WRITEUNCTION, Read_Response'Access); Check_Code (Result, "set callback"); Interfaces.C.Strings.Free (Req.URL); Req.URL := Strings.New_String (URI); Interfaces.C.Strings.Free (Req.Content); Req.Content := Strings.New_String (Data); Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_HEADER, 1); Check_Code (Result, "set header"); Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_URL, Req.URL); Check_Code (Result, "set url"); Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_POSTFIELDS, Req.Content); Check_Code (Result, "set post data"); Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_POSTFIELDSIZE, Data'Length); Check_Code (Result, "set post data"); Response := new Curl_Http_Response; Result := Curl_Easy_Setopt_Data (Req.Data, Constants.CURLOPT_WRITEDATA, Response); Check_Code (Result, "set write data"); Reply.Delegate := Response.all'Access; Result := Curl_Easy_Perform (Req.Data); Check_Code (Result, "get request"); Result := Curl_Easy_Getinfo_Long (Req.Data, Constants.CURLINFO_RESPONSE_CODE, Status'Access); Check_Code (Result, "get response code"); Response.Status := Natural (Status); end Do_Post; overriding procedure Finalize (Request : in out Curl_Http_Request) is begin if Request.Data /= System.Null_Address then Curl_Easy_Cleanup (Request.Data); Request.Data := System.Null_Address; end if; if Request.Headers /= null then Curl_Slist_Free_All (Request.Headers); Request.Headers := null; end if; Interfaces.C.Strings.Free (Request.URL); Interfaces.C.Strings.Free (Request.Content); end Finalize; -- ------------------------------ -- Get the response body as a string. -- ------------------------------ overriding function Get_Body (Reply : in Curl_Http_Response) return String is begin return Ada.Strings.Unbounded.To_String (Reply.Content); end Get_Body; -- ------------------------------ -- Get the response status code. -- ------------------------------ overriding function Get_Status (Reply : in Curl_Http_Response) return Natural is begin return Reply.Status; end Get_Status; end Util.Http.Clients.Curl;
{ "source": "starcoderdata", "programming_language": "ada" }
------------------------------------------------------------------------------- with Interfaces; with Ada.Characters.Latin_1; with Audio.Wavefiles; with Audio.RIFF.Wav.Formats; with Audio.RIFF.Wav.GUIDs; package body WaveFiles_Gtk.Wavefile_Manager is -------------- -- Get_Info -- -------------- function Get_Info (Wavefile : String) return String is WF_In : Audio.Wavefiles.Wavefile; RIFF_Data : Audio.RIFF.Wav.Formats.Wave_Format_Extensible; function Get_RIFF_GUID_String (Sub_Format : Audio.RIFF.Wav.Formats.GUID) return String; function Get_RIFF_Extended (RIFF_Data : Audio.RIFF.Wav.Formats.Wave_Format_Extensible) return String; package Wav_Read renames Audio.Wavefiles; use Interfaces; function Get_RIFF_GUID_String (Sub_Format : Audio.RIFF.Wav.Formats.GUID) return String is use type Audio.RIFF.Wav.Formats.GUID; begin if Sub_Format = Audio.RIFF.Wav.GUIDs.GUID_Undefined then return "Subformat: undefined"; elsif Sub_Format = Audio.RIFF.Wav.GUIDs.GUID_PCM then return "Subformat: KSDATAFORMAT_SUBTYPE_PCM (IEC 60958 PCM)"; elsif Sub_Format = Audio.RIFF.Wav.GUIDs.GUID_IEEE_Float then return "Subformat: KSDATAFORMAT_SUBTYPE_IEEE_FLOAT " & "(IEEE Floating-Point PCM)"; else return "Subformat: unknown"; end if; end Get_RIFF_GUID_String; function Get_RIFF_Extended (RIFF_Data : Audio.RIFF.Wav.Formats.Wave_Format_Extensible) return String is S : constant String := ("Valid bits per sample: " & Unsigned_16'Image (RIFF_Data.Valid_Bits_Per_Sample)); begin if RIFF_Data.Size > 0 then return (S & Ada.Characters.Latin_1.LF & Get_RIFF_GUID_String (RIFF_Data.Sub_Format)); else return ""; end if; end Get_RIFF_Extended; begin Wav_Read.Open (WF_In, Wav_Read.In_File, Wavefile); RIFF_Data := Wav_Read.Format_Of_Wavefile (WF_In); Wav_Read.Close (WF_In); declare S_Wav_1 : constant String := ("Bits per sample: " & Audio.RIFF.Wav.Formats.Wav_Bit_Depth'Image (RIFF_Data.Bits_Per_Sample) & Ada.Characters.Latin_1.LF & "Channels: " & Unsigned_16'Image (RIFF_Data.Channels) & Ada.Characters.Latin_1.LF & "Samples per second: " & Audio.RIFF.Wav.Formats.Wav_Sample_Rate'Image (RIFF_Data.Samples_Per_Sec) & Ada.Characters.Latin_1.LF & "Extended size: " & Unsigned_16'Image (RIFF_Data.Size) & Ada.Characters.Latin_1.LF); S_Wav_2 : constant String := Get_RIFF_Extended (RIFF_Data); begin return "File: " & Wavefile & Ada.Characters.Latin_1.LF & S_Wav_1 & S_Wav_2; end; end Get_Info; end WaveFiles_Gtk.Wavefile_Manager;
{ "source": "starcoderdata", "programming_language": "ada" }
with SPARKNaCl.PDebug; with SPARKNaCl.Debug; with SPARKNaCl.Utils; with SPARKNaCl.Car; with Ada.Text_IO; use Ada.Text_IO; package body SPARKNaCl.Tests is GF_2 : constant Normal_GF := (2, others => 0); P : constant Normal_GF := (0 => 16#FFED#, 15 => 16#7FFF#, others => 16#FFFF#); P_Minus_1 : constant Normal_GF := (0 => 16#FFEC#, 15 => 16#7FFF#, others => 16#FFFF#); P_Plus_1 : constant Normal_GF := (0 => 16#FFEE#, 15 => 16#7FFF#, others => 16#FFFF#); procedure GF_Stress is A, B, C : Normal_GF; C2 : GF32; D : Product_GF; begin Put_Line ("GF_Stress case 1 - 0 * 0"); A := (others => 0); B := (others => 0); C := A * B; PDebug.DH16 ("Result is", C); Put_Line ("GF_Stress case 2 - FFFF * FFFF"); A := (others => 16#FFFF#); B := (others => 16#FFFF#); C := A * B; PDebug.DH16 ("Result is", C); Put_Line ("GF_Stress case 3 - Seminormal Product GF Max"); D := (0 => 132_051_011, others => 16#FFFF#); C2 := Car.Product_To_Seminormal (D); PDebug.DH32 ("Result is", C2); Put_Line ("GF_Stress case 4 - Seminormal Product tricky case"); D := (0 => 131_071, others => 16#FFFF#); C2 := Car.Product_To_Seminormal (D); PDebug.DH32 ("Result is", C2); end GF_Stress; procedure Car_Stress is A : GF64; C : Product_GF; SN : Seminormal_GF; NGF : Nearlynormal_GF; R : Normal_GF; begin -- Case 1 - using typed API A := (0 .. 14 => 65535, 15 => 65535 + 2**32); PDebug.DH64 ("Case 1 - A is", A); SN := Car.Product_To_Seminormal (A); PDebug.DH32 ("Case 1 - SN is", SN); NGF := Car.Seminormal_To_Nearlynormal (SN); PDebug.DH32 ("Case 1 - NGF is", NGF); R := Car.Nearlynormal_To_Normal (NGF); PDebug.DH16 ("Case 1 - R is", R); -- Case 2 Upper bounds on all limbs of a Product_GF C := (0 => MGFLC * MGFLP, 1 => (MGFLC - 37 * 1) * MGFLP, 2 => (MGFLC - 37 * 2) * MGFLP, 3 => (MGFLC - 37 * 3) * MGFLP, 4 => (MGFLC - 37 * 4) * MGFLP, 5 => (MGFLC - 37 * 5) * MGFLP, 6 => (MGFLC - 37 * 6) * MGFLP, 7 => (MGFLC - 37 * 7) * MGFLP, 8 => (MGFLC - 37 * 8) * MGFLP, 9 => (MGFLC - 37 * 9) * MGFLP, 10 => (MGFLC - 37 * 10) * MGFLP, 11 => (MGFLC - 37 * 11) * MGFLP, 12 => (MGFLC - 37 * 12) * MGFLP, 13 => (MGFLC - 37 * 13) * MGFLP, 14 => (MGFLC - 37 * 14) * MGFLP, 15 => (MGFLC - 37 * 15) * MGFLP); PDebug.DH64 ("Case 2 - C is", C); SN := Car.Product_To_Seminormal (C); PDebug.DH32 ("Case 2 - SN is", SN); NGF := Car.Seminormal_To_Nearlynormal (SN); PDebug.DH32 ("Case 2 - NGF is", NGF); R := Car.Nearlynormal_To_Normal (NGF); PDebug.DH16 ("Case 2 - R is", R); -- Intermediate (pre-normalization) result of -- Square (Normal_GF'(others => 16#FFFF)) A := (16#23AFB8A023B#, 16#215FBD40216#, 16#1F0FC1E01F1#, 16#1CBFC6801CC#, 16#1A6FCB201A7#, 16#181FCFC0182#, 16#15CFD46015D#, 16#137FD900138#, 16#112FDDA0113#, 16#EDFE2400EE#, 16#C8FE6E00C9#, 16#A3FEB800A4#, 16#7EFF02007F#, 16#59FF4C005A#, 16#34FF960035#, 16#FFFE00010#); PDebug.DH64 ("Case 3 - A is", A); SN := Car.Product_To_Seminormal (A); PDebug.DH32 ("Case 3 - SN is", SN); NGF := Car.Seminormal_To_Nearlynormal (SN); PDebug.DH32 ("Case 3 - NGF is", NGF); R := Car.Nearlynormal_To_Normal (NGF); PDebug.DH16 ("Case 3 - R is", R); end Car_Stress; procedure Diff_Car_Stress is C : Nearlynormal_GF; R : Normal_GF; begin C := (others => 0); PDebug.DH32 ("Case 1 - C is", C); R := Car.Nearlynormal_To_Normal (C); PDebug.DH16 ("Case 1 - R is", R); C := (others => 16#ffff#); PDebug.DH32 ("Case 2 - C is", C); R := Car.Nearlynormal_To_Normal (C); PDebug.DH16 ("Case 2 - R is", R); for I in I32 range 65536 .. 65573 loop C (0) := I; PDebug.DH32 ("Case 3," & I'Img & " C is", C); R := Car.Nearlynormal_To_Normal (C); PDebug.DH16 ("Case 3 - R is", R); end loop; C := (others => 0); for I in I32 range -38 .. -1 loop C (0) := I; PDebug.DH32 ("Case 4," & I'Img & " C is", C); R := Car.Nearlynormal_To_Normal (C); PDebug.DH16 ("Case 4 - R is", R); end loop; end Diff_Car_Stress; procedure Pack_Stress is A : Normal_GF; R : Bytes_32; Two_P : constant Normal_GF := P * GF_2; Two_P_Minus_1 : constant Normal_GF := Two_P - GF_1; Two_P_Plus_1 : constant Normal_GF := Two_P + GF_1; begin A := (others => 0); PDebug.DH16 ("Pack Stress - Case 1 - A is", A); R := Utils.Pack_25519 (A); Debug.DH ("Pack Stress - Case 1 - R is", R); A := (others => 65535); PDebug.DH16 ("Pack Stress - Case 2 - A is", A); R := Utils.Pack_25519 (A); Debug.DH ("Pack Stress - Case 2 - R is", R); A := P; PDebug.DH16 ("Pack Stress - Case 3 - A is P", A); R := Utils.Pack_25519 (A); Debug.DH ("Pack Stress - Case 3 - R is", R); A := P_Minus_1; PDebug.DH16 ("Pack Stress - Case 4 - A is P_Minus_1", A); R := Utils.Pack_25519 (A); Debug.DH ("Pack Stress - Case 4 - R is", R); A := P_Plus_1; PDebug.DH16 ("Pack Stress - Case 5 - A is P_Plus_1", A); R := Utils.Pack_25519 (A); Debug.DH ("Pack Stress - Case 5 - R is", R); A := Two_P; PDebug.DH16 ("Pack Stress - Case 6 - A is Two_P", A); R := Utils.Pack_25519 (A); Debug.DH ("Pack Stress - Case 6 - R is", R); A := Two_P_Minus_1; PDebug.DH16 ("Pack Stress - Case 7 - A is Two_P_Minus_1", A); R := Utils.Pack_25519 (A); Debug.DH ("Pack Stress - Case 7 - R is", R); A := Two_P_Plus_1; PDebug.DH16 ("Pack Stress - Case 8 - A is Two_P_Plus_1", A); R := Utils.Pack_25519 (A); Debug.DH ("Pack Stress - Case 8 - R is", R); end Pack_Stress; end SPARKNaCl.Tests;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Text_IO; use Ada.Text_IO; procedure Crossroad is -- Colors type colors is (red, redyellow, green, yellow); -- Lamp protected Lamp is procedure Switch; function Color return colors; private currentColor : colors := red; end Lamp; protected body Lamp is procedure Switch is begin if currentColor = yellow then currentColor := red; else currentColor := colors'Succ(currentColor); end if; Put_Line("Lamp switched to " & colors'Image(currentColor)); end Switch; function Color return colors is begin return currentColor; end Color; end Lamp; -- Controller task Controller is entry Stop; end Controller; task body Controller is stopped : Boolean := false; begin while not stopped loop select accept Stop do stopped := true; end Stop; or -- red delay 3.0; Lamp.Switch; -- redyellow delay 1.0; Lamp.Switch; -- green delay 3.0; Lamp.Switch; -- yellow delay 2.0; Lamp.Switch; end select; end loop; end Controller; type String_Access is access String; task type Vehicle(plate: String_Access); type Vehicle_Access is access Vehicle; task body Vehicle is crossed : Boolean := false; begin Put_Line(plate.all & " arrived"); while not crossed loop if Lamp.Color = green then Put_Line(plate.all & " crossed"); crossed := true; else Put_Line(plate.all & " waiting"); delay 0.2; end if; end loop; end Vehicle; vehicles : array(1 .. 10) of Vehicle_Access; plate : String_Access; begin for i in 1 .. 10 loop plate := new String'("CAR" & Integer'Image(i)); vehicles(i) := new Vehicle(plate); delay 0.5; end loop; --Skip_Line(); delay 15.0; Controller.Stop; end Crossroad;
{ "source": "starcoderdata", "programming_language": "ada" }
package body Ada.Calendar.Naked is function To_Native_Time (T : Time) return System.Native_Calendar.Native_Time is begin return System.Native_Calendar.To_Native_Time (Duration (T)); end To_Native_Time; function To_Time (T : System.Native_Calendar.Native_Time) return Time is begin return Time (System.Native_Calendar.To_Time (T)); end To_Time; function Seconds_From_2150 (T : Time) return Duration is begin return Duration (T); end Seconds_From_2150; procedure Delay_Until (T : Time) is begin System.Native_Calendar.Delay_Until (To_Native_Time (T)); end Delay_Until; end Ada.Calendar.Naked;
{ "source": "starcoderdata", "programming_language": "ada" }
------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Natools.Web.Simple_Pages provides a simple implementation of Sites.Page -- -- and Tags.Visible, representing a single page in a usual blog-style -- -- static site. -- ------------------------------------------------------------------------------ with Ada.Calendar; with Natools.S_Expressions.Atom_Refs; with Natools.S_Expressions.Lockable; with Natools.Web.Sites; with Natools.Web.Tags; private with Natools.References; private with Natools.S_Expressions.Caches; private with Natools.Storage_Pools; private with Natools.Web.Containers; private with Natools.Web.Comments; private with Natools.Web.String_Tables; package Natools.Web.Simple_Pages is type Page_Template is private; procedure Set_Comments (Object : in out Page_Template; Expression : in out S_Expressions.Lockable.Descriptor'Class); procedure Set_Comment_Path_Prefix (Object : in out Page_Template; Prefix : in S_Expressions.Atom); procedure Set_Comment_Path_Suffix (Object : in out Page_Template; Suffix : in S_Expressions.Atom); procedure Set_Elements (Object : in out Page_Template; Expression : in out S_Expressions.Lockable.Descriptor'Class); procedure Set_Component (Object : in out Page_Template; Name : in S_Expressions.Atom; Arguments : in out S_Expressions.Lockable.Descriptor'Class; Known_Component : out Boolean); procedure Update (Object : in out Page_Template; Expression : in out S_Expressions.Lockable.Descriptor'Class); Default_Template : constant Page_Template; type Page_Ref is new Tags.Visible and Sites.Page with private; function Create (File_Path, Web_Path : in S_Expressions.Atom_Refs.Immutable_Reference; Template : in Page_Template := Default_Template; Name : in S_Expressions.Atom := S_Expressions.Null_Atom) return Page_Ref; function Create (Expression : in out S_Expressions.Lockable.Descriptor'Class; Template : in Page_Template := Default_Template; Name : in S_Expressions.Atom := S_Expressions.Null_Atom) return Page_Ref; procedure Get_Lifetime (Page : in Page_Ref; Publication : out Ada.Calendar.Time; Has_Publication : out Boolean; Expiration : out Ada.Calendar.Time; Has_Expiration : out Boolean); function Get_Tags (Page : Page_Ref) return Tags.Tag_List; procedure Register (Page : in Page_Ref; Builder : in out Sites.Site_Builder; Path : in S_Expressions.Atom); overriding procedure Render (Exchange : in out Sites.Exchange; Object : in Page_Ref; Expression : in out S_Expressions.Lockable.Descriptor'Class); overriding procedure Respond (Object : in out Page_Ref; Exchange : in out Sites.Exchange; Extra_Path : in S_Expressions.Atom); type Loader is new Sites.Page_Loader with private; overriding procedure Load (Object : in out Loader; Builder : in out Sites.Site_Builder; Path : in S_Expressions.Atom); function Create (File : in S_Expressions.Atom) return Sites.Page_Loader'Class; procedure Register_Loader (Site : in out Sites.Site); private type Page_Template is record Comments : Containers.Optional_Expression; Comment_Path_Prefix : S_Expressions.Atom_Refs.Immutable_Reference; Comment_Path_Suffix : S_Expressions.Atom_Refs.Immutable_Reference; Elements : Containers.Expression_Maps.Constant_Map; Name : S_Expressions.Atom_Refs.Immutable_Reference; end record; Default_Template : constant Page_Template := (others => <>); type Page_Data is new Tags.Visible with record Self : Tags.Visible_Access; File_Path : S_Expressions.Atom_Refs.Immutable_Reference; Web_Path : S_Expressions.Atom_Refs.Immutable_Reference; Elements : Containers.Expression_Maps.Constant_Map; Tags : Web.Tags.Tag_List; Dates : Containers.Date_Maps.Constant_Map; Comment_List : Comments.Comment_List; Maps : String_Tables.String_Table_Map; end record; not overriding procedure Get_Element (Data : in Page_Data; Name : in S_Expressions.Atom; Element : out S_Expressions.Caches.Cursor; Found : out Boolean); overriding procedure Render (Exchange : in out Sites.Exchange; Object : in Page_Data; Expression : in out S_Expressions.Lockable.Descriptor'Class); package Data_Refs is new References (Page_Data, Storage_Pools.Access_In_Default_Pool'Storage_Pool, Storage_Pools.Access_In_Default_Pool'Storage_Pool); type Page_Ref is new Tags.Visible and Sites.Page with record Ref : Data_Refs.Reference; end record; function Get_Tags (Page : Page_Ref) return Tags.Tag_List is (Page.Ref.Query.Data.Tags); type Loader is new Sites.Page_Loader with record File_Path : S_Expressions.Atom_Refs.Immutable_Reference; end record; end Natools.Web.Simple_Pages;
{ "source": "starcoderdata", "programming_language": "ada" }
package Sort is SIZE : constant Integer := 40; SubType v_range is Integer Range -500..500; type m_array is array(1..SIZE) of v_range; procedure MergeSort(A : in out m_array); -- Internal functions procedure MergeSort(A : in out m_array; startIndex : Integer; endIndex : Integer); procedure ParallelMergeSort(A : in out m_array; startIndex : Integer; midIndex : Integer; endIndex : Integer); procedure Merge(A : in out m_array; startIndex, midIndex, endIndex : in Integer); end sort;
{ "source": "starcoderdata", "programming_language": "ada" }
------------------------------------------------------------- package body Ada_Pretty.Statements is -------------- -- Document -- -------------- overriding function Document (Self : Block_Statement; Printer : not null access League.Pretty_Printers.Printer'Class; Pad : Natural) return League.Pretty_Printers.Document is pragma Unreferenced (Pad); Result : League.Pretty_Printers.Document := Printer.New_Document; begin if Self.Declarations /= null then Result.New_Line; Result.Put ("declare"); Result.Append (Self.Declarations.Document (Printer, 0).Nest (3)); end if; Result.New_Line; Result.Put ("begin"); if Self.Statements = null then declare Nil : League.Pretty_Printers.Document := Printer.New_Document; begin Nil.New_Line; Nil.Put ("null;"); Nil.Nest (3); Result.Append (Nil); end; else Result.Append (Self.Statements.Document (Printer, 0).Nest (3)); end if; if Self.Exceptions /= null then Result.New_Line; Result.Put ("exception"); Result.Append (Self.Exceptions.Document (Printer, 0).Nest (3)); end if; Result.New_Line; Result.Put ("end;"); return Result; end Document; -------------- -- Document -- -------------- overriding function Document (Self : Case_Statement; Printer : not null access League.Pretty_Printers.Printer'Class; Pad : Natural) return League.Pretty_Printers.Document is Result : League.Pretty_Printers.Document := Printer.New_Document; begin Result.New_Line; Result.Put ("case "); Result.Append (Self.Expression.Document (Printer, Pad)); Result.Put (" is"); Result.Append (Self.List.Document (Printer, Pad).Nest (3)); Result.New_Line; Result.Put ("end case;"); return Result; end Document; -------------- -- Document -- -------------- overriding function Document (Self : Case_Path; Printer : not null access League.Pretty_Printers.Printer'Class; Pad : Natural) return League.Pretty_Printers.Document is Result : League.Pretty_Printers.Document := Printer.New_Document; begin Result.New_Line; Result.Put ("when "); Result.Append (Self.Choice.Document (Printer, Pad)); Result.Put (" =>"); Result.Append (Self.List.Document (Printer, Pad).Nest (3)); return Result; end Document; -------------- -- Document -- -------------- overriding function Document (Self : Elsif_Statement; Printer : not null access League.Pretty_Printers.Printer'Class; Pad : Natural) return League.Pretty_Printers.Document is Result : League.Pretty_Printers.Document := Printer.New_Document; begin Result.New_Line; Result.New_Line; Result.Put ("elsif "); Result.Append (Self.Condition.Document (Printer, Pad)); Result.Put (" then"); Result.Append (Self.List.Document (Printer, Pad).Nest (3)); return Result; end Document; -------------- -- Document -- -------------- overriding function Document (Self : Extended_Return_Statement; Printer : not null access League.Pretty_Printers.Printer'Class; Pad : Natural) return League.Pretty_Printers.Document is Result : League.Pretty_Printers.Document := Printer.New_Document; begin Result.New_Line; Result.Put ("return "); Result.Append (Self.Name.Document (Printer, Pad)); Result.Put (" : "); Result.Append (Self.Type_Definition.Document (Printer, Pad).Nest (2)); if Self.Initialization /= null then declare Init : League.Pretty_Printers.Document := Printer.New_Document; begin Init.New_Line; Init.Append (Self.Initialization.Document (Printer, 0)); Init.Nest (2); Init.Group; Result.Put (" :="); Result.Append (Init); end; end if; Result.New_Line; Result.Put ("do"); Result.Append (Self.Statements.Document (Printer, 0).Nest (3)); Result.New_Line; Result.Put ("end return;"); return Result; end Document; -------------- -- Document -- -------------- overriding function Document (Self : For_Statement; Printer : not null access League.Pretty_Printers.Printer'Class; Pad : Natural) return League.Pretty_Printers.Document is Result : League.Pretty_Printers.Document := Printer.New_Document; begin Result.New_Line; Result.Put ("for "); Result.Append (Self.Name.Document (Printer, Pad)); declare Init : League.Pretty_Printers.Document := Printer.New_Document; begin Init.Put (" in "); Init.Append (Self.Iterator.Document (Printer, 0).Nest (2)); Init.New_Line; Init.Put ("loop"); Init.Group; Result.Append (Init); end; Result.Append (Self.Statements.Document (Printer, 0).Nest (3)); Result.New_Line; Result.Put ("end loop;"); return Result; end Document; -------------- -- Document -- -------------- overriding function Document (Self : Loop_Statement; Printer : not null access League.Pretty_Printers.Printer'Class; Pad : Natural) return League.Pretty_Printers.Document is Result : League.Pretty_Printers.Document := Printer.New_Document; Init : League.Pretty_Printers.Document := Printer.New_Document; begin Result.New_Line; if Self.Condition = null then Result.Put ("loop"); else Init.Put ("while "); Init.Append (Self.Condition.Document (Printer, Pad).Nest (2)); Init.New_Line; Init.Put ("loop"); Init.Group; Result.Append (Init); end if; Result.Append (Self.Statements.Document (Printer, 0).Nest (3)); Result.New_Line; Result.Put ("end loop;"); return Result; end Document; -------------- -- Document -- -------------- overriding function Document (Self : If_Statement; Printer : not null access League.Pretty_Printers.Printer'Class; Pad : Natural) return League.Pretty_Printers.Document is Result : League.Pretty_Printers.Document := Printer.New_Document; begin Result.New_Line; Result.Put ("if "); Result.Append (Self.Condition.Document (Printer, Pad)); Result.Put (" then"); Result.Append (Self.Then_Path.Document (Printer, Pad).Nest (3)); if Self.Elsif_List /= null then Result.Append (Self.Elsif_List.Document (Printer, Pad)); end if; if Self.Else_Path /= null then Result.Append (Self.Else_Path.Document (Printer, Pad).Nest (3)); end if; Result.New_Line; Result.Put ("end if;"); return Result; end Document; -------------- -- Document -- -------------- overriding function Document (Self : Return_Statement; Printer : not null access League.Pretty_Printers.Printer'Class; Pad : Natural) return League.Pretty_Printers.Document is Result : League.Pretty_Printers.Document := Printer.New_Document; begin Result.New_Line; Result.Put ("return"); if Self.Expression /= null then Result.Put (" "); Result.Append (Self.Expression.Document (Printer, Pad)); end if; Result.Put (";"); return Result; end Document; -------------- -- Document -- -------------- overriding function Document (Self : Statement; Printer : not null access League.Pretty_Printers.Printer'Class; Pad : Natural) return League.Pretty_Printers.Document is Result : League.Pretty_Printers.Document := Printer.New_Document; begin Result.New_Line; if Self.Expression = null then Result.Put ("null"); else Result.Append (Self.Expression.Document (Printer, Pad)); end if; Result.Put (";"); return Result; end Document; -------------- -- Document -- -------------- overriding function Document (Self : Assignment; Printer : not null access League.Pretty_Printers.Printer'Class; Pad : Natural) return League.Pretty_Printers.Document is Result : League.Pretty_Printers.Document := Printer.New_Document; Right : League.Pretty_Printers.Document := Printer.New_Document; begin Result.New_Line; Result.Append (Self.Left.Document (Printer, Pad)); Result.Put (" :="); Right.New_Line; Right.Append (Self.Right.Document (Printer, Pad)); Right.Nest (2); Right.Group; Result.Append (Right); Result.Put (";"); return Result; end Document; -------------------- -- New_Assignment -- -------------------- function New_Assignment (Left : not null Node_Access; Right : not null Node_Access) return Node'Class is begin return Assignment'(Left, Right); end New_Assignment; ------------------------- -- New_Block_Statement -- ------------------------- function New_Block_Statement (Declarations : Node_Access; Statements : Node_Access; Exceptions : Node_Access) return Node'Class is begin return Block_Statement'(Declarations, Statements, Exceptions); end New_Block_Statement; -------------- -- New_Case -- -------------- function New_Case (Expression : not null Node_Access; List : not null Node_Access) return Node'Class is begin return Case_Statement'(Expression, List); end New_Case; ------------------- -- New_Case_Path -- ------------------- function New_Case_Path (Choice : not null Node_Access; List : not null Node_Access) return Node'Class is begin return Case_Path'(Choice, List); end New_Case_Path; --------------- -- New_Elsif -- --------------- function New_Elsif (Condition : not null Node_Access; List : not null Node_Access) return Node'Class is begin return Elsif_Statement'(Condition, List); end New_Elsif; ------------------------- -- New_Extended_Return -- ------------------------- function New_Extended_Return (Name : not null Node_Access; Type_Definition : not null Node_Access; Initialization : Node_Access; Statements : not null Node_Access) return Node'Class is begin return Extended_Return_Statement' (Name, Type_Definition, Initialization, Statements); end New_Extended_Return; ------------- -- New_For -- ------------- function New_For (Name : not null Node_Access; Iterator : not null Node_Access; Statements : not null Node_Access) return Node'Class is begin return For_Statement'(Name, Iterator, Statements); end New_For; ------------ -- New_If -- ------------ function New_If (Condition : not null Node_Access; Then_Path : not null Node_Access; Elsif_List : Node_Access; Else_Path : Node_Access) return Node'Class is begin return If_Statement'(Condition, Then_Path, Elsif_List, Else_Path); end New_If; -------------- -- New_Loop -- -------------- function New_Loop (Condition : Node_Access; Statements : not null Node_Access) return Node'Class is begin return Loop_Statement'(Condition, Statements); end New_Loop; ---------------- -- New_Return -- ---------------- function New_Return (Expression : Node_Access) return Node'Class is begin return Return_Statement'(Expression => Expression); end New_Return; ------------------- -- New_Statement -- ------------------- function New_Statement (Expression : Node_Access) return Node'Class is begin return Statement'(Expression => Expression); end New_Statement; end Ada_Pretty.Statements;
{ "source": "starcoderdata", "programming_language": "ada" }
------------------------------------------------------------------------------- with SP.Strings; with Ada.Containers.Ordered_Maps; with Ada.Strings.Unbounded; -- Super simple text file caching. -- -- While `Async_File_Cache` provides parallel loading, access to the cache -- itself is protected. -- -- Provides a means to load entire directory structures into memory and then -- use it as needed. This is intended for text files only, in particular, to -- speed text searches of large read-only code bases. -- -- This is super simple and straightforward, but works well enough. -- It probably better done with mmap to load files directly to memory. It -- eliminates line-splitting when printing output. If this were in C++, -- it would be possible to do something like store the file as a huge byte -- block with mmap and then replace newlines with '\0' and store byte counts -- to the initial part of every string. -- package SP.Cache is use Ada.Strings.Unbounded; use SP.Strings; package File_Maps is new Ada.Containers.Ordered_Maps ( Key_Type => Ada.Strings.Unbounded.Unbounded_String, Element_Type => String_Vectors.Vector, "<" => Ada.Strings.Unbounded."<", "=" => String_Vectors."="); -- The available in-memory contents of files loaded from files. -- -- Files are stored by full path name, with the OS's preference for path -- separators. -- -- TODO: Add monitoring of files for changes. protected type Async_File_Cache is procedure Clear; -- Cache the contents of a file, replacing any existing contents. procedure Cache_File (File_Name : Unbounded_String; Lines : String_Vectors.Vector); -- The total number of loaded files in the file cache. function Num_Files return Natural; -- The total number of loaded lines in the file cache. function Num_Lines return Natural; function Lines (File_Name : Unbounded_String) return String_Vectors.Vector; function Files return String_Vectors.Vector; function File_Line (File_Name : Unbounded_String; Line : Positive) return Unbounded_String; private -- A list of all top level directories which need to be searched. Top_Level_Directories : SP.Strings.String_Sets.Set; Contents : File_Maps.Map; end Async_File_Cache; -- Adds a directory and all of its recursive subdirectories into the file cache. function Add_Directory_Recursively (A : in out Async_File_Cache; Dir : String) return Boolean; end SP.Cache;
{ "source": "starcoderdata", "programming_language": "ada" }
with openGL.Palette, openGL.Light; package openGL.Program.lit -- -- Models an openGL program which uses lighting. -- is type Item is new openGL.Program.item with private; type View is access all Item'Class; ------------ -- Uniforms -- overriding procedure camera_Site_is (Self : in out Item; Now : in Vector_3); overriding procedure model_Matrix_is (Self : in out Item; Now : in Matrix_4x4); overriding procedure Lights_are (Self : in out Item; Now : in Light.items); overriding procedure set_Uniforms (Self : in Item); procedure specular_Color_is (Self : in out Item; Now : in Color); private type Item is new openGL.Program.item with record Lights : Light.items (1 .. 50); light_Count : Natural := 0; specular_Color : Color := Palette.Grey; -- The materials specular color. camera_Site : Vector_3; model_Transform : Matrix_4x4 := Identity_4x4; end record; end openGL.Program.lit;
{ "source": "starcoderdata", "programming_language": "ada" }
with ada.text_io; with ada.strings.fixed; with ada.strings.maps.constants; with ada.strings.unbounded; with numbers; use numbers; package strings is package natural_io is new ada.text_io.integer_io(natural); package unb renames ada.strings.unbounded; package fix renames ada.strings.fixed; procedure print (s : string) renames ada.text_io.put_line; procedure put (s : string) renames ada.text_io.put; procedure put (s : character) renames ada.text_io.put; procedure print (c : character); procedure print (us : unb.unbounded_string); function first_element (s : string) return character; function last_element (s : string) return character; function first_element (us : unb.unbounded_string) return character; function last_element (us : unb.unbounded_string) return character; function endswith (s, p : string) return boolean; function endswith (s : string; c : character) return boolean; function startswith (s, p : string) return boolean; function startswith (s : string; c : character) return boolean; function ltrim (s : string; c : character := ' ') return string; function rtrim (s : string; c : character := ' ') return string; function trim (s : string; c : character := ' ') return string; procedure clear (us : out unb.unbounded_string); function remove_ret_car (s : string) return string; function lowercase (s : string) return string; function uppercase (s : string) return string; function car (s : string) return character renames first_element; function cdr (str : string; offset : positive := 1) return string; procedure void (s : string); function "=" (us : unb.unbounded_string; s : string) return boolean; function "=" (s : string; us : unb.unbounded_string) return boolean; end strings;
{ "source": "starcoderdata", "programming_language": "ada" }
XFXUN : constant Word_T := 8#015#; -- EXTENDED MOUNT A UNIT XFXML : constant Word_T := 8#016#; -- EXTENDED MOUNT A LABELED TAPE XFHOL : constant Word_T := 8#017#; -- HOLD A QUEUE ENTRY XFUNH : constant Word_T := 8#020#; -- UNHOLD A QUEUE ENTRY XFCAN : constant Word_T := 8#021#; -- CANCEL A QUEUE ENTRY XFSTS : constant Word_T := 8#022#; -- OBTAIN RELATIONSHIP TO EXEC XFQST : constant Word_T := 8#023#; -- GET QUEUE TYPE FROM QUEUE NAME -- THE FOLLOWING FUNCTIONS ARE RESERVED FOR INTERNAL USE XFLO : constant Word_T := 8#024#; -- LABELED TAPE OPEN XFLC : constant Word_T := 8#025#; -- LABELED TAPE CLOSE XFME : constant Word_T := 8#026#; -- MOUNT ERROR XFNV : constant Word_T := 8#027#; -- MOUNT NEXT VOLUME XF30R : constant Word_T := 8#030#; -- Reserved XFSV : constant Word_T := 8#031#; -- MOUNT SPECIFIC VOLUME XFMNT : constant Word_T := 8#032#; -- Submit a job to a MOUNT queue XFBAT : constant Word_T := 8#033#; -- Submit a job to a BATCH queue XFMOD : constant Word_T := 8#034#; -- Modify parameters of a queued job XFSQT : constant Word_T := 8#035#; -- Get queue type by sequence number XFNQN : constant Word_T := 8#036#; -- Get list of queue names XFQDS : constant Word_T := 8#037#; -- Given a queuename, -- Get info on all jobs in queue XFXDU : constant Word_T := 8#040#; -- Extended Dismount -- END OF INTERNAL FUNCTIONS -- PACKET OFFSETS FOR xfxts XFP1 : constant Phys_Addr_T := 2; -- FIRST PARAMETER XFP2 : constant Phys_Addr_T := 3; -- SECOND PARAMETER XFP2L : constant Phys_Addr_T := XFP2 + 1; -- LOWER PORTION OF xfp2 XFP3 : constant Phys_Addr_T := XFP2L + 1; -- 3RD PARAMETER - RESERVED XFP4 : constant Phys_Addr_T := XFP3 + 1; -- 15-BIT PID -- PACKET TO GET SYSTEM INFORMATION (sinfo) SIRN : constant Phys_Addr_T := 0; -- SYSTEM REV, LEFT BYTE=MAJOR, RIGHT BYTE=MINOR SIRS : constant Phys_Addr_T := SIRN + 1; -- RESERVED SIMM : constant Phys_Addr_T := SIRS + 1; -- LENGTH OF PHYSICAL MEMORY (HPAGE) SIML : constant Phys_Addr_T := SIMM + 1; -- LOWER PORTION OF simm SILN : constant Phys_Addr_T := SIML + 1; -- BYTE POINTER TO RECEIVE MASTER LDU NAME SILL : constant Phys_Addr_T := SILN + 1; -- LOWER PORTION OF siln SIID : constant Phys_Addr_T := SILL + 1; -- BYTE POINTER TO RECEIVE SYSTEM IDENTIFIER SIIL : constant Phys_Addr_T := SIID + 1; -- LOWER PORTION OF siid SIPL : constant Phys_Addr_T := SIIL + 1; -- UNEXTENDED PACKET LENGTH SIOS : constant Phys_Addr_T := SIIL + 1; -- BYTE POINTER TO EXECUTING OP SYS PATHNAME SIOL : constant Phys_Addr_T := SIOS + 1; -- LOWER PORTION OF sios SSIN : constant Phys_Addr_T := SIOL + 1; -- SYSTEM IMPLEMENTATION NUMBER (savs FOR AOSVS) SIEX : constant Phys_Addr_T := SSIN + 6; -- EXTENDED PACKET LENGTH (INCLUDE 3 DOUBLE -- WORDS FOR FUTURE EXPANSIONS) SAVS : constant Word_T := 2; -- AOS/VS -- SYSTEM RECORD I/O PACKET FOR ALL DISK AND MAG. TAPEAND MCA REQUESTS FROM EITHER THE AGENT OR USER CONTEXTS. USED FOR rdb/wrb, prdb/PWRB, spage AND allocate -- Used for ?SPAGE, ?RDB, ?WDB PSTI : constant Phys_Addr_T := 0; -- RECORD COUNT (RIGHT), STATUS IN (LEFT) PSTO : constant Phys_Addr_T := PSTI + 1; -- RESERVED (LEFT) PRIORITY (RIGHT) PCAD : constant Phys_Addr_T := PSTO + 1; -- WORD ADDRESS FOR DATA PCDL : constant Phys_Addr_T := PCAD + 1; -- LOW ORDER PORTION OF pcad PRNH : constant Phys_Addr_T := PCDL + 1; -- RECORD NUMBER (HIGH) LINK # (MCA) PRNL : constant Phys_Addr_T := PRNH + 1; -- RECORD NUMBER (LOW) RETRY COUNT (MCA) PRCL : constant Phys_Addr_T := PRNL + 1; -- MAX LENGTH OF EACH RECORD (MAG TAPE) -- BYTE COUNT IN LAST BLOCK (DISK WRITES) -- BYTE COUNT (MCA) PRES : constant Phys_Addr_T := PRCL + 1; -- RESERVED WORD PBLT : constant Phys_Addr_T := PRES + 1; -- PACKET SIZE -- PACKET FOR DIRECTORY ENTRY CREATION (create) CFTYP : constant Phys_Addr_T := 0; -- ENTRY TYPE (RH) AND RECORD FORMAT (LH) CPOR : constant Phys_Addr_T := 1; -- PORT NUMBER (IPC TYPES ONLY) CHFS : constant Phys_Addr_T := 1; -- HASH FRAME SIZE (DIRECTORY TYPES ONLY) CHID : constant Phys_Addr_T := 1; -- HOST ID (frem TYPE FILES ONLY ) CCPS : constant Phys_Addr_T := 1; -- FILE CONTROL PARAMETER (OTHERS) CTIM : constant Phys_Addr_T := 2; -- POINTER TO TIME BLOCK CTIL : constant Phys_Addr_T := CTIM + 1; -- LOWER PORTION OF ctim CACP : constant Phys_Addr_T := CTIL + 1; -- POINTER TO INITIAL ACL CACL : constant Phys_Addr_T := CACP + 1; -- LOWER PORTION OF cacp CMSH : constant Phys_Addr_T := CACL + 1; -- MAX SPACE ALLOCATED (fcpd) CMSL : constant Phys_Addr_T := CMSH + 1; -- MAX SPACE ALLOCATED (LOW) CDEH : constant Phys_Addr_T := CACL + 1; -- RESERVED CDEL : constant Phys_Addr_T := CDEH + 1; -- FILE ELEMENT SIZE CMIL : constant Phys_Addr_T := CDEL + 1; -- MAXIMUM INDEX LEVEL DEPTH CMRS : constant Phys_Addr_T := CMIL + 1; -- RESERVED CLTH : constant Phys_Addr_T := CMRS + 1; -- LENGTH OF THE PARAMETER BLOCK -- ENTRY TYPE RANGES SMIN :constant Word_T := 0; -- SYSTEM MINIMUM SMAX :constant Word_T := 63; -- SYSTEM MAXIMUM DMIN :constant Word_T := smax + 1; -- DGC MINIMUM DMAX :constant Word_T := 127; -- DGC MAXIMUM UMIN :constant Word_T := dmax + 1; -- USER MINIMUM UMAX :constant Word_T := 255; -- USER MAXIMUM -- SYSTEM ENTRY TYPES -- MISC FLNK : constant Word_T := SMIN; -- LINK FSDF : constant Word_T := FLNK + 1; -- SYSTEM DATA FILE FMTF : constant Word_T := FSDF + 1; -- MAG TAPE FILE FGFN : constant Word_T := FMTF + 1; -- GENERIC FILE NAME -- DIRECTORIES (DO NOT CHANGE THEIR ORDER) FDIR : constant Word_T := 10; -- DISK DIRECTORY FLDU : constant Word_T := FDIR + 1; -- LD ROOT DIRECTORY FCPD : constant Word_T := FLDU + 1; -- CONTROL POINT DIRECTORY FMTV : constant Word_T := FCPD + 1; -- MAG TAPE VOLUME FMDR : constant Word_T := FMTV + 1; -- RESERVED FOR RT32(MEM DIRS), NOT LEGAL FOR AOS FGNR : constant Word_T := FMDR + 1; -- RESERVED FOR RT32, NOT LEGAL FOR AOS LDIR : constant Word_T := FDIR; -- LOW DIR TYPE HDIR : constant Word_T := FGNR; -- HIGH DIR TYPE LCPD : constant Word_T := FLDU; -- LOW CONTROL POINT DIR TYPE HCPD : constant Word_T := FCPD; -- HIGH CONTROL POINT DIR TYPE -- UNITS FDKU : constant Word_T := 20; -- DISK UNIT FMCU : constant Word_T := FDKU + 1; -- MULTIPROCESSOR COMMUNICATIONS UNIT FMTU : constant Word_T := FMCU + 1; -- MAG TAPE UNIT FLPU : constant Word_T := FMTU + 1; -- DATA CHANNEL LINE PRINTER FLPD : constant Word_T := FLPU + 1; -- DATA CHANNEL LP2 UNIT FLPE : constant Word_T := FLPD + 1; -- DATA CHANNEL LINE PRINTER (LASER) FPGN : constant Word_T := FLPE + 1; -- RESERVED FOR RT32(PROCESS GROUP) FLTU : constant Word_T := FLPU + 1; -- LABELLED MAG TAPE UNIT -- ***** NO LONGER USED ***** LUNT : constant Word_T := FDKU; -- LOW UNIT TYPE HUNT : constant Word_T := FPGN; -- HIGH UNIT TYPE -- IPC ENTRY TYPES FIPC : constant Word_T := 30; -- IPC PORT ENTRY -- DGC ENTRY TYPES FUDF : constant Word_T := DMIN; -- USER DATA FILE FPRG : constant Word_T := FUDF + 1; -- PROGRAM FILE FUPF : constant Word_T := FPRG + 1; -- USER PROFILE FILE FSTF : constant Word_T := FUPF + 1; -- SYMBOL TABLE FILE FTXT : constant Word_T := FSTF + 1; -- TEXT FILE FLOG : constant Word_T := FTXT + 1; -- SYSTEM LOG FILE (ACCOUNTING FILE) FNCC : constant Word_T := FLOG + 1; -- FORTRAN CARRIAGE CONTROL FILE FLCC : constant Word_T := FNCC + 1; -- FORTRAN CARRIAGE CONTROL FILE FFCC : constant Word_T := FLCC + 1; -- FORTRAN CARRIAGE CONTROL FILE FOCC : constant Word_T := FFCC + 1; -- FORTRAN CARRIAGE CONTROL FILE FPRV : constant Word_T := FOCC + 1; -- AOS/VS PROGRAM FILE FWRD : constant Word_T := FPRV + 1; -- WORD PROCESSING FAFI : constant Word_T := FWRD + 1; -- APL FILE FAWS : constant Word_T := FAFI + 1; -- APL WORKSPACE FILE FBCI : constant Word_T := FAWS + 1; -- BASIC CORE IMAGE FILE FDCF : constant Word_T := FBCI + 1; -- DEVICE CONFIGURATION FILE (NETWORKING) FLCF : constant Word_T := FDCF + 1; -- LINK CONFIGURATION FILE (NETWORKING) FLUG : constant Word_T := FLCF + 1; -- LOGICAL UNIT GROUP FILE (SNA) FRTL : constant Word_T := FLUG + 1; -- AOS/RT32 RESERVED FILE TYPE RANGE (LO) FRTH : constant Word_T := FRTL + 4; -- AOS/RT32 RESERVED FILE TYPE RANGE (HI) FUNX : constant Word_T := FRTH + 1; -- VS/UNIX FILE FBBS : constant Word_T := FUNX + 1; -- BUSINESS BASIC SYMBOL FILE FVLF : constant Word_T := FBBS + 1; -- BUSINESS BASIC VOLUME LABEL FILE FDBF : constant Word_T := FVLF + 1; -- BUSINESS BASIC DATA BASE FILE -- CEO FILE TYPES FGKM : constant Word_T := FDBF + 1; -- DG GRAPHICS KERNAL METAFILE FVDM : constant Word_T := FGKM + 1; -- VIRTUAL DEVICE METAFILE FNAP : constant Word_T := FVDM + 1; -- NAPLPS STANDARD GRAPH FILE FTRV : constant Word_T := FNAP + 1; -- TRENDVIEW COMMAND FILE FSPD : constant Word_T := FTRV + 1; -- SPREADSHEET FILE FQRY : constant Word_T := FSPD + 1; -- PRESENT QUERY MACRO FDTB : constant Word_T := FQRY + 1; -- PHD DATA TABLE FFMT : constant Word_T := FDTB + 1; -- PHD FORMAT FILE FWPT : constant Word_T := FFMT + 1; -- TEXT INTERCHANGE FORMAT FDIF : constant Word_T := FWPT + 1; -- DATA INTERCHANGE FORMAT FVIF : constant Word_T := FDIF + 1; -- VOICE IMAGE FILE FIMG : constant Word_T := FVIF + 1; -- FACSIMILE IMAGE FPRF : constant Word_T := FIMG + 1; -- PRINT READY FILE -- MORE DGC ENTRY TYPES FPIP : constant Word_T := FPRF + 1; -- PIPE FILE FTTX : constant Word_T := FPIP + 1; -- TELETEX FILE FDXF : constant Word_T := FTTX + 1; -- RESERVED FOR DXA FDXR : constant Word_T := FDXF + 1; -- RESERVED FOR DXA FCWP : constant Word_T := FDXR + 1; -- CEO WORD PROCESSOR FILE FCWT : constant Word_T := FCWP; -- CEOwrite WORD PROCESSOR FILE FRPT : constant Word_T := FCWP + 1; -- PHD REPORT FILE -- INTERPROCESS COMMUNICATION SYSTEM (IPC) PARAMETERS -- -- HIGHEST LEGAL LOCAL PORT NUMBER IMPRT : constant Natural := 2047; -- MAX LEGAL USER LOCAL PORT # MXLPN : constant Natural := 4095; -- MAX LEGAL LOCAL PORT # -- IPC MESSAGE HEADER ISFL : constant Phys_Addr_T := 0; -- SYSTEM FLAGS IUFL : constant Phys_Addr_T := 1; -- USER FLAGS -- PORT NUMBERS FOR ?ISEND IDPH : constant Phys_Addr_T := 2; -- DESTINATION PORT NUMBER (HIGH) IDPL : constant Phys_Addr_T := 3; -- DESTINATION PORT NUMBER (LOW) IOPN : constant Phys_Addr_T := 4; -- ORIGIN PORT NUMBER -- PORT NUMBERS FOR ?IREC IOPH : constant Phys_Addr_T := 2; -- ORIGIN PORT NUMBER (HIGH) IOPL : constant Phys_Addr_T := 3; -- ORIGIN PORT NUMBER (LOW) IDPN : constant Phys_Addr_T := 4; -- DESTINATION PORT NUMBER ILTH : constant Phys_Addr_T := 5; -- LENGTH OF MESSAGE OR BUFFER (IN WORDS) IPTR : constant Phys_Addr_T := 6; -- POINTER TO MESSAGE/BUFFER IPTL : constant Phys_Addr_T := IPTR+1; -- LOWER PORTION OF IPTR IPLTH : constant Phys_Addr_T := IPTL+1; -- LENGTH OF HEADER IRSV : constant Phys_Addr_T := IPTL+1; -- RESERVED IRLT : constant Phys_Addr_T := IRSV+1; -- IS.R RECEIVE BUFFER LENGTH IRPT : constant Phys_Addr_T := IRLT+1; -- IS.R RECEIVE BUFFER POINTER IRPL : constant Phys_Addr_T := IRPT+1; -- LOWER PORTION OF IRPT IPRLTH : constant Phys_Addr_T := IRPL+1; -- LENGTH OF ?IS.R HEADER -- PACKET FOR TASK DEFINITION (?TASK) DLNK : constant Phys_Addr_T := 0; -- NON-ZERO = SHORT PACKET, ZERO = EXTENDED DLNL : constant Phys_Addr_T := DLNK + 1; -- 1 LOWER PORTION OF ?DLNK DLNKB : constant Phys_Addr_T := DLNL + 1; -- 2 BACKWARDS LINK (UPPER PORTION) DLNKBL : constant Phys_Addr_T := DLNKB + 1; -- 3 BACKWARDS LINK (LOWER PORTION) DPRI : constant Phys_Addr_T := DLNKBL + 1; --4 PRIORITY, ZERO TO USE CALLER'S DID : constant Phys_Addr_T := DPRI + 1; -- 5 I.D., ZERO FOR NONE DPC : constant Phys_Addr_T := DID + 1; -- 6 STARTING ADDRESS OR RESOURCE ENTRY DPCL : constant Phys_Addr_T := DPC + 1; -- 7 LOWER PORTION OF ?DPC DAC2 : constant Phys_Addr_T := DPCL + 1; -- 8 INITIAL AC2 CONTENTS DCL2 : constant Phys_Addr_T := DAC2 + 1; -- 9 LOWER PORTION OF ?DAC2 DSTB : constant Phys_Addr_T := DCL2 + 1; -- 10 STACK BASE, MINUS ONE FOR NO STACK DSTL : constant Phys_Addr_T := DSTB + 1; -- 11 LOWER PORTION OF ?DSTB DSFLT : constant Phys_Addr_T := DSTL + 1; -- 12 STACK FAULT ROUTINE ADDR OR -1 IF SAME AS CURRENT DSSZ : constant Phys_Addr_T := DSFLT + 1;-- 13 STACK SIZE, IGNORED IF NO STACK DSSL : constant Phys_Addr_T := DSSZ + 1; -- 14 LOWER PORTION OF ?DSSZ DFLGS : constant Phys_Addr_T := DSSL + 1; -- 15 FLAGS -- DFL0 : constant Phys_Addr_T := 1B0 -- RESERVED FOR SYSTEM -- DFLRC : constant Phys_Addr_T := 1B1 -- RESOURCE CALL TASK -- DFL15 : constant Phys_Addr_T := 1B15 -- RESERVED FOR SYSTEM DRES : constant Phys_Addr_T := DFLGS + 1; -- 16 RESERVED FOR SYSTEM DNUM : constant Phys_Addr_T := DRES + 1; -- 17 NUMBER OF TASKS TO CREATE DSLTH : constant Phys_Addr_T := DNUM + 1; -- LENGTH OF SHORT PACKET DSH : constant Phys_Addr_T := DNUM + 1; -- STARTING HOUR, -1 IF IMMEDIATE DSMS : constant Phys_Addr_T := DSH + 1; -- STARTING SECOND IN HOUR, IGNORED IF IMMEDIATE DCC : constant Phys_Addr_T := DSMS + 1; -- NUMBER OF TIMES TO CREATE TASK(S) DCI : constant Phys_Addr_T := DCC + 1; -- CREATION INCREMENT IN SECONDS DXLTH :constant Phys_Addr_T := DCI + 1; -- LENGTH OF EXTENDED PACKET -- ?RNGPR PACKET OFFSETS -- RNGBP : constant Phys_Addr_T := 0; -- BYTE POINTER TO BUFFER (2 WORDS) RNGNM : constant Phys_Addr_T := RNGBP + 2; -- RING # OF RING TO CHECK RNGLB : constant Phys_Addr_T := RNGNM + 1; -- BUFFER BYTE LENGTH RNGPL : constant Phys_Addr_T := RNGLB + 1; -- PACKET LENGTH -- ?UIDSTAT UUID : constant Phys_Addr_T := 0; -- Unique task identifier UTSTAT : constant Phys_Addr_T := UUID + 1; -- Task Status Word UTID : constant Phys_Addr_T := UTSTAT + 1; -- Standard Task ID UTPRI : constant Phys_Addr_T := UTID + 1; -- Task Prioroty end PARU_32;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Finalization; with Adabots_Lua_Dispatcher; package Adabots is type Turtle is new Ada.Finalization.Limited_Controlled with private; type Turtle_Inventory_Slot is range 1 .. 16; type Stack_Count is range 0 .. 64; type Item_Detail is record Count : Stack_Count; Name : Ada.Strings.Unbounded.Unbounded_String; end record; function Create_Turtle return Turtle; function Create_Turtle (Port : Integer) return Turtle; -- Movement procedure Turn_Right (T : Turtle); procedure Turn_Left (T : Turtle); function Forward (T : Turtle) return Boolean; function Back (T : Turtle) return Boolean; function Up (T : Turtle) return Boolean; function Down (T : Turtle) return Boolean; -- Digging function Dig_Down (T : Turtle) return Boolean; function Dig_Up (T : Turtle) return Boolean; function Dig (T : Turtle) return Boolean; -- Placing function Place (T : Turtle) return Boolean; function Place_Down (T : Turtle) return Boolean; function Place_Up (T : Turtle) return Boolean; -- Inventory management procedure Select_Slot (T : Turtle; Slot : Turtle_Inventory_Slot); function Get_Item_Count (T : Turtle; Slot : Turtle_Inventory_Slot) return Stack_Count; function Get_Selected_Slot (T : Turtle) return Turtle_Inventory_Slot; -- TODO really implement these two: function Get_Item_Detail (T : Turtle) return Item_Detail; function Get_Item_Detail (T : Turtle; Slot : Turtle_Inventory_Slot) return Item_Detail; -- https://tweaked.cc/module/turtle.html#v:drop function Drop (T : Turtle; Amount : Stack_Count := 64) return Boolean; -- function DropUp (T : Turtle; Amount : Stack_Count := 64) return Boolean; -- function DropDown (T : Turtle; Amount : Stack_Count := 64) return Boolean; function Detect (T : Turtle) return Boolean; function Detect_Down (T : Turtle) return Boolean; function Detect_Up (T : Turtle) return Boolean; -- these procedures assert that the function of the same name returned true procedure Forward (T : Turtle); procedure Back (T : Turtle); procedure Up (T : Turtle); procedure Down (T : Turtle); procedure Dig_Down (T : Turtle); procedure Dig_Up (T : Turtle); procedure Dig (T : Turtle); procedure Place (T : Turtle); procedure Place_Down (T : Turtle); procedure Place_Up (T : Turtle); procedure Drop (T : Turtle; Amount : Stack_Count := 64); -- these procedures don't care what the result is procedure Maybe_Dig_Down (T : Turtle); procedure Maybe_Dig_Up (T : Turtle); procedure Maybe_Dig (T : Turtle); procedure Maybe_Place (T : Turtle); procedure Maybe_Place_Down (T : Turtle); procedure Maybe_Place_Up (T : Turtle); type Command_Computer is new Ada.Finalization.Limited_Controlled with private; function Create_Command_Computer return Command_Computer; function Create_Command_Computer (Port : Integer) return Command_Computer; type Material is (Grass, Planks, Air, Glass, Ice, Gold_Block, Sand, Bedrock, Stone); type Relative_Location is record X_Offset : Integer := 0; Y_Offset : Integer := 0; Z_Offset : Integer := 0; end record; function Image (P : Relative_Location) return String is (P.X_Offset'Image & ", " & P.Y_Offset'Image & ", " & P.Z_Offset'Image); function "+" (A, B : Relative_Location) return Relative_Location; function "-" (A, B : Relative_Location) return Relative_Location; type Absolute_Location is record X : Integer := 0; Y : Integer := 0; Z : Integer := 0; end record; function "+" (A, B : Absolute_Location) return Absolute_Location; function "+" (A : Absolute_Location; B : Relative_Location) return Absolute_Location; function Set_Block (C : Command_Computer; L : Relative_Location; B : Material) return Boolean; procedure Maybe_Set_Block (C : Command_Computer; L : Relative_Location; B : Material); procedure Set_Cube (C : Command_Computer; First : Relative_Location; Last : Relative_Location; B : Material); function Get_Block_Info (C : Command_Computer; L : Absolute_Location) return Material; private type Turtle is new Ada.Finalization.Limited_Controlled with record Dispatcher : Adabots_Lua_Dispatcher.Lua_Dispatcher; end record; function Parse_Item_Details (Table : String) return Item_Detail; type Command_Computer is new Ada.Finalization.Limited_Controlled with record Dispatcher : Adabots_Lua_Dispatcher.Lua_Dispatcher; end record; end Adabots;
{ "source": "starcoderdata", "programming_language": "ada" }
pragma Warnings (Off); pragma Ada_95; pragma Source_File_Name (ada_main, Spec_File_Name => "b__main.ads"); pragma Source_File_Name (ada_main, Body_File_Name => "b__main.adb"); pragma Suppress (Overflow_Check); package body ada_main is E78 : Short_Integer; pragma Import (Ada, E78, "memory_barriers_E"); E76 : Short_Integer; pragma Import (Ada, E76, "cortex_m__nvic_E"); E68 : Short_Integer; pragma Import (Ada, E68, "nrf__events_E"); E28 : Short_Integer; pragma Import (Ada, E28, "nrf__gpio_E"); E70 : Short_Integer; pragma Import (Ada, E70, "nrf__gpio__tasks_and_events_E"); E72 : Short_Integer; pragma Import (Ada, E72, "nrf__interrupts_E"); E34 : Short_Integer; pragma Import (Ada, E34, "nrf__rtc_E"); E37 : Short_Integer; pragma Import (Ada, E37, "nrf__spi_master_E"); E56 : Short_Integer; pragma Import (Ada, E56, "nrf__tasks_E"); E54 : Short_Integer; pragma Import (Ada, E54, "nrf__adc_E"); E84 : Short_Integer; pragma Import (Ada, E84, "nrf__clock_E"); E80 : Short_Integer; pragma Import (Ada, E80, "nrf__ppi_E"); E41 : Short_Integer; pragma Import (Ada, E41, "nrf__timers_E"); E44 : Short_Integer; pragma Import (Ada, E44, "nrf__twi_E"); E48 : Short_Integer; pragma Import (Ada, E48, "nrf__uart_E"); E06 : Short_Integer; pragma Import (Ada, E06, "nrf__device_E"); E52 : Short_Integer; pragma Import (Ada, E52, "nrf52_dk__ios_E"); E82 : Short_Integer; pragma Import (Ada, E82, "nrf52_dk__time_E"); E87 : Short_Integer; pragma Import (Ada, E87, "sensor_E"); Sec_Default_Sized_Stacks : array (1 .. 1) of aliased System.Secondary_Stack.SS_Stack (System.Parameters.Runtime_Default_Sec_Stack_Size); procedure adainit is Binder_Sec_Stacks_Count : Natural; pragma Import (Ada, Binder_Sec_Stacks_Count, "__gnat_binder_ss_count"); Default_Secondary_Stack_Size : System.Parameters.Size_Type; pragma Import (C, Default_Secondary_Stack_Size, "__gnat_default_ss_size"); Default_Sized_SS_Pool : System.Address; pragma Import (Ada, Default_Sized_SS_Pool, "__gnat_default_ss_pool"); begin null; ada_main'Elab_Body; Default_Secondary_Stack_Size := System.Parameters.Runtime_Default_Sec_Stack_Size; Binder_Sec_Stacks_Count := 1; Default_Sized_SS_Pool := Sec_Default_Sized_Stacks'Address; E78 := E78 + 1; Cortex_M.Nvic'Elab_Spec; E76 := E76 + 1; E68 := E68 + 1; E28 := E28 + 1; E70 := E70 + 1; Nrf.Interrupts'Elab_Body; E72 := E72 + 1; E34 := E34 + 1; E37 := E37 + 1; E56 := E56 + 1; E54 := E54 + 1; E84 := E84 + 1; E80 := E80 + 1; E41 := E41 + 1; E44 := E44 + 1; E48 := E48 + 1; Nrf.Device'Elab_Spec; Nrf.Device'Elab_Body; E06 := E06 + 1; NRF52_DK.IOS'ELAB_SPEC; NRF52_DK.IOS'ELAB_BODY; E52 := E52 + 1; NRF52_DK.TIME'ELAB_BODY; E82 := E82 + 1; E87 := E87 + 1; end adainit; procedure Ada_Main_Program; pragma Import (Ada, Ada_Main_Program, "_ada_main"); procedure main is Ensure_Reference : aliased System.Address := Ada_Main_Program_Name'Address; pragma Volatile (Ensure_Reference); begin adainit; Ada_Main_Program; end; -- BEGIN Object file/option list -- C:\GNAT\Ada_Drivers_Library\examples\NRF52_DK\project2\obj\sensor.o -- C:\GNAT\Ada_Drivers_Library\examples\NRF52_DK\project2\obj\main.o -- -LC:\GNAT\Ada_Drivers_Library\examples\NRF52_DK\project2\obj\ -- -LC:\GNAT\Ada_Drivers_Library\examples\NRF52_DK\project2\obj\ -- -LC:\GNAT\Ada_Drivers_Library\boards\NRF52_DK\obj\zfp_lib_Debug\ -- -LC:\gnat\2020-arm-elf\arm-eabi\lib\gnat\zfp-cortex-m4f\adalib\ -- -static -- -lgnat -- END Object file/option list end ada_main;
{ "source": "starcoderdata", "programming_language": "ada" }
with DOM.Core.Documents; with Project_Processor.Parsers.Parser_Tables; with XML_Utilities; with XML_Scanners; with DOM.Core.Nodes; with EU_Projects.Nodes.Action_Nodes.Tasks; with EU_Projects.Nodes.Action_Nodes.WPs; with EU_Projects.Nodes.Timed_Nodes.Milestones; with Project_Processor.Parsers.XML_Parsers.Sub_Parsers; with EU_Projects.Nodes.Timed_Nodes.Deliverables; package body Project_Processor.Parsers.XML_Parsers is use XML_Scanners; use EU_Projects.Projects; ------------ -- Create -- ------------ function Create (Params : not null access Plugins.Parameter_Maps.Map) return Parser_Type is pragma Unreferenced (Params); Result : Parser_Type; begin return Result; end Create; procedure Parse_Project (Parser : in out Parser_Type; Project : out Project_Descriptor; N : in DOM.Core.Node) is pragma Unreferenced (Parser); use EU_Projects.Nodes; Scanner : XML_Scanner := Create_Child_Scanner (N); procedure Add_Partner (N : DOM.Core.Node) is begin Project.Add_Partner (Sub_Parsers.Parse_Partner (N)); end Add_Partner; procedure Add_Milestone (N : DOM.Core.Node) is Milestone : Timed_Nodes.Milestones.Milestone_Access; begin Sub_Parsers.Parse_Milestone (N, Milestone); Project.Add_Milestone (Milestone); end Add_Milestone; procedure Add_WP (N : DOM.Core.Node) is WP : Action_Nodes.WPs.Project_WP_Access; begin Sub_Parsers.Parse_WP (N, WP); Project.Add_WP (WP); end Add_WP; procedure Handle_Configuration (N : DOM.Core.Node) is begin Sub_Parsers.Parse_Configuration (Project, N); end Handle_Configuration; procedure Add_Risk (N : DOM.Core.Node) is begin Project.Add_Risk (Sub_Parsers.Parse_Risk (N)); end Add_Risk; procedure Add_Deliverable (N : DOM.Core.Node) is Deliv : Timed_Nodes.Deliverables.Deliverable_Access; begin Sub_Parsers.Parse_Deliverable (N, Deliv); Project.Add_Deliverable (Deliv); end Add_Deliverable; begin if DOM.Core.Nodes.Node_Name (N) /= "project" then raise Parsing_Error; end if; Dom.Core.Nodes.Print (N); Scanner.Parse_Optional ("configuration", Handle_Configuration'Access); Scanner.Parse_Sequence ("partner", Add_Partner'Access); Scanner.Parse_Sequence ("wp", Add_WP'Access); Scanner.Parse_Sequence ("milestone", Add_Milestone'Access); Scanner.Parse_Sequence (Name => "deliverable", Callback => Add_Deliverable'Access, Min_Length => 0); Scanner.Parse_Sequence (Name => "risk", Callback => Add_Risk'Access, Min_Length => 0); end Parse_Project; ----------- -- Parse -- ----------- procedure Parse (Parser : in out Parser_Type; Project : out EU_Projects.Projects.Project_Descriptor; Input : String) is use DOM.Core.Documents; begin Parse_Project (Parser => Parser, Project => Project, N => Get_Element (XML_Utilities.Parse_String (Input))); Project.Freeze; end Parse; begin Parser_Tables.Register (ID => "xml", Tag => Parser_Type'Tag); end Project_Processor.Parsers.XML_Parsers;
{ "source": "starcoderdata", "programming_language": "ada" }
pragma Profile(No_Implementation_Extensions); package body Parse_Args.Testable is ------------------ -- Command_Name -- ------------------ overriding function Command_Name (A : in Testable_Argument_Parser) return String is (To_String(A.Command_Name_Override)); -------------------- -- Argument_Count -- -------------------- overriding function Argument_Count (A : in Testable_Argument_Parser) return Natural is (Natural(A.Input_Arguments.Length)); -------------- -- Argument -- -------------- overriding function Argument (A : in Testable_Argument_Parser; Number : in Positive) return String is (To_String(A.Input_Arguments(Number))); --------------------- -- Clear_Arguments -- --------------------- not overriding procedure Clear_Arguments (A : in out Testable_Argument_Parser) is begin A.Input_Arguments.Clear; end Clear_Arguments; --------------------- -- Append_Argument -- --------------------- not overriding procedure Append_Argument (A : in out Testable_Argument_Parser; S : in String) is begin A.Input_Arguments.Append(To_Unbounded_String(S)); end Append_Argument; ---------------------- -- Append_Arguments -- ---------------------- not overriding procedure Append_Arguments (A : in out Testable_Argument_Parser; S : in Unbounded_String_Array) is begin for I of S loop A.Input_Arguments.Append(I); end loop; end Append_Arguments; ---------------------- -- Set_Command_Name -- ---------------------- not overriding procedure Set_Command_Name(A : in out Testable_Argument_Parser; S : in String) is begin A.Command_Name_Override := To_Unbounded_String(S); end Set_Command_Name; end Parse_Args.Testable;
{ "source": "starcoderdata", "programming_language": "ada" }
------------------------------------------------------------- package body Program.Nodes.Exception_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; Exception_Token : not null Program.Lexical_Elements .Lexical_Element_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 Exception_Declaration is begin return Result : Exception_Declaration := (Names => Names, Colon_Token => Colon_Token, Exception_Token => Exception_Token, 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; 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) return Implicit_Exception_Declaration is begin return Result : Implicit_Exception_Declaration := (Names => Names, 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, Enclosing_Element => null) do Initialize (Result); end return; end Create; overriding function Names (Self : Base_Exception_Declaration) return not null Program.Elements.Defining_Identifiers .Defining_Identifier_Vector_Access is begin return Self.Names; end Names; overriding function Aspects (Self : Base_Exception_Declaration) return Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access is begin return Self.Aspects; end Aspects; overriding function Colon_Token (Self : Exception_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Colon_Token; end Colon_Token; overriding function Exception_Token (Self : Exception_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Exception_Token; end Exception_Token; overriding function With_Token (Self : Exception_Declaration) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.With_Token; end With_Token; overriding function Semicolon_Token (Self : Exception_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Semicolon_Token; end Semicolon_Token; overriding function Is_Part_Of_Implicit (Self : Implicit_Exception_Declaration) return Boolean is begin return Self.Is_Part_Of_Implicit; end Is_Part_Of_Implicit; overriding function Is_Part_Of_Inherited (Self : Implicit_Exception_Declaration) return Boolean is begin return Self.Is_Part_Of_Inherited; end Is_Part_Of_Inherited; overriding function Is_Part_Of_Instance (Self : Implicit_Exception_Declaration) return Boolean is begin return Self.Is_Part_Of_Instance; end Is_Part_Of_Instance; procedure Initialize (Self : in out Base_Exception_Declaration'Class) is begin for Item in Self.Names.Each_Element loop Set_Enclosing_Element (Item.Element, Self'Unchecked_Access); end loop; for Item in Self.Aspects.Each_Element loop Set_Enclosing_Element (Item.Element, Self'Unchecked_Access); end loop; null; end Initialize; overriding function Is_Exception_Declaration (Self : Base_Exception_Declaration) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Exception_Declaration; overriding function Is_Declaration (Self : Base_Exception_Declaration) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Declaration; overriding procedure Visit (Self : not null access Base_Exception_Declaration; Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is begin Visitor.Exception_Declaration (Self); end Visit; overriding function To_Exception_Declaration_Text (Self : in out Exception_Declaration) return Program.Elements.Exception_Declarations .Exception_Declaration_Text_Access is begin return Self'Unchecked_Access; end To_Exception_Declaration_Text; overriding function To_Exception_Declaration_Text (Self : in out Implicit_Exception_Declaration) return Program.Elements.Exception_Declarations .Exception_Declaration_Text_Access is pragma Unreferenced (Self); begin return null; end To_Exception_Declaration_Text; end Program.Nodes.Exception_Declarations;
{ "source": "starcoderdata", "programming_language": "ada" }
------------------------------------------------------------------------------ with Ada.Iterator_Interfaces; with Ada.Containers.Helpers; private with Ada.Containers.Red_Black_Trees; private with Ada.Finalization; private with Ada.Streams; private with Ada.Strings.Text_Output; generic type Element_Type is private; with function "<" (Left, Right : Element_Type) return Boolean is <>; with function "=" (Left, Right : Element_Type) return Boolean is <>; package Ada.Containers.Ordered_Sets with SPARK_Mode => Off is pragma Annotate (CodePeer, Skip_Analysis); pragma Preelaborate; pragma Remote_Types; function Equivalent_Elements (Left, Right : Element_Type) return Boolean; type Set is tagged private with Constant_Indexing => Constant_Reference, Default_Iterator => Iterate, Iterator_Element => Element_Type; -- Aggregate => (Empty => Empty, -- Add_Unnamed => Include); pragma Preelaborable_Initialization (Set); type Cursor is private; pragma Preelaborable_Initialization (Cursor); function Has_Element (Position : Cursor) return Boolean; Empty_Set : constant Set; function Empty return Set; No_Element : constant Cursor; package Set_Iterator_Interfaces is new Ada.Iterator_Interfaces (Cursor, Has_Element); function "=" (Left, Right : Set) return Boolean; function Equivalent_Sets (Left, Right : Set) return Boolean; function To_Set (New_Item : Element_Type) return Set; function Length (Container : Set) return Count_Type; function Is_Empty (Container : Set) return Boolean; procedure Clear (Container : in out Set); function Element (Position : Cursor) return Element_Type; procedure Replace_Element (Container : in out Set; Position : Cursor; New_Item : Element_Type); procedure Query_Element (Position : Cursor; Process : not null access procedure (Element : Element_Type)); type Constant_Reference_Type (Element : not null access constant Element_Type) is private with Implicit_Dereference => Element; function Constant_Reference (Container : aliased Set; Position : Cursor) return Constant_Reference_Type; pragma Inline (Constant_Reference); procedure Assign (Target : in out Set; Source : Set); function Copy (Source : Set) return Set; procedure Move (Target : in out Set; Source : in out Set); procedure Insert (Container : in out Set; New_Item : Element_Type; Position : out Cursor; Inserted : out Boolean); procedure Insert (Container : in out Set; New_Item : Element_Type); procedure Include (Container : in out Set; New_Item : Element_Type); procedure Replace (Container : in out Set; New_Item : Element_Type); procedure Exclude (Container : in out Set; Item : Element_Type); procedure Delete (Container : in out Set; Item : Element_Type); procedure Delete (Container : in out Set; Position : in out Cursor); procedure Delete_First (Container : in out Set); procedure Delete_Last (Container : in out Set); procedure Union (Target : in out Set; Source : Set); function Union (Left, Right : Set) return Set; function "or" (Left, Right : Set) return Set renames Union; procedure Intersection (Target : in out Set; Source : Set); function Intersection (Left, Right : Set) return Set; function "and" (Left, Right : Set) return Set renames Intersection; procedure Difference (Target : in out Set; Source : Set); function Difference (Left, Right : Set) return Set; function "-" (Left, Right : Set) return Set renames Difference; procedure Symmetric_Difference (Target : in out Set; Source : Set); function Symmetric_Difference (Left, Right : Set) return Set; function "xor" (Left, Right : Set) return Set renames Symmetric_Difference; function Overlap (Left, Right : Set) return Boolean; function Is_Subset (Subset : Set; Of_Set : Set) return Boolean; function First (Container : Set) return Cursor; function First_Element (Container : Set) return Element_Type; function Last (Container : Set) return Cursor; function Last_Element (Container : Set) return Element_Type; function Next (Position : Cursor) return Cursor; procedure Next (Position : in out Cursor); function Previous (Position : Cursor) return Cursor; procedure Previous (Position : in out Cursor); function Find (Container : Set; Item : Element_Type) return Cursor; function Floor (Container : Set; Item : Element_Type) return Cursor; function Ceiling (Container : Set; Item : Element_Type) return Cursor; function Contains (Container : Set; Item : Element_Type) return Boolean; function "<" (Left, Right : Cursor) return Boolean; function ">" (Left, Right : Cursor) return Boolean; function "<" (Left : Cursor; Right : Element_Type) return Boolean; function ">" (Left : Cursor; Right : Element_Type) return Boolean; function "<" (Left : Element_Type; Right : Cursor) return Boolean; function ">" (Left : Element_Type; Right : Cursor) return Boolean; procedure Iterate (Container : Set; Process : not null access procedure (Position : Cursor)); procedure Reverse_Iterate (Container : Set; Process : not null access procedure (Position : Cursor)); function Iterate (Container : Set) return Set_Iterator_Interfaces.Reversible_Iterator'class; function Iterate (Container : Set; Start : Cursor) return Set_Iterator_Interfaces.Reversible_Iterator'class; generic type Key_Type (<>) is private; with function Key (Element : Element_Type) return Key_Type; with function "<" (Left, Right : Key_Type) return Boolean is <>; package Generic_Keys is function Equivalent_Keys (Left, Right : Key_Type) return Boolean; function Key (Position : Cursor) return Key_Type; function Element (Container : Set; Key : Key_Type) return Element_Type; procedure Replace (Container : in out Set; Key : Key_Type; New_Item : Element_Type); procedure Exclude (Container : in out Set; Key : Key_Type); procedure Delete (Container : in out Set; Key : Key_Type); function Find (Container : Set; Key : Key_Type) return Cursor; function Floor (Container : Set; Key : Key_Type) return Cursor; function Ceiling (Container : Set; Key : Key_Type) return Cursor; function Contains (Container : Set; Key : Key_Type) return Boolean; procedure Update_Element_Preserving_Key (Container : in out Set; Position : Cursor; Process : not null access procedure (Element : in out Element_Type)); type Reference_Type (Element : not null access Element_Type) is private with Implicit_Dereference => Element; function Reference_Preserving_Key (Container : aliased in out Set; Position : Cursor) return Reference_Type; function Constant_Reference (Container : aliased Set; Key : Key_Type) return Constant_Reference_Type; function Reference_Preserving_Key (Container : aliased in out Set; Key : Key_Type) return Reference_Type; private type Set_Access is access all Set; for Set_Access'Storage_Size use 0; type Key_Access is access all Key_Type; package Impl is new Helpers.Generic_Implementation; type Reference_Control_Type is new Impl.Reference_Control_Type with record Container : Set_Access; Pos : Cursor; Old_Key : Key_Access; end record; overriding procedure Finalize (Control : in out Reference_Control_Type); pragma Inline (Finalize); type Reference_Type (Element : not null access Element_Type) is record Control : Reference_Control_Type; end record; use Ada.Streams; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Reference_Type); for Reference_Type'Write use Write; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Reference_Type); for Reference_Type'Read use Read; end Generic_Keys; private pragma Inline (Next); pragma Inline (Previous); type Node_Type; type Node_Access is access Node_Type; type Node_Type is limited record Parent : Node_Access; Left : Node_Access; Right : Node_Access; Color : Red_Black_Trees.Color_Type := Red_Black_Trees.Red; Element : aliased Element_Type; end record; package Tree_Types is new Red_Black_Trees.Generic_Tree_Types (Node_Type, Node_Access); type Set is new Ada.Finalization.Controlled with record Tree : Tree_Types.Tree_Type; end record with Put_Image => Put_Image; procedure Put_Image (S : in out Ada.Strings.Text_Output.Sink'Class; V : Set); overriding procedure Adjust (Container : in out Set); overriding procedure Finalize (Container : in out Set) renames Clear; use Red_Black_Trees; use Tree_Types, Tree_Types.Implementation; use Ada.Finalization; use Ada.Streams; procedure Write (Stream : not null access Root_Stream_Type'Class; Container : Set); for Set'Write use Write; procedure Read (Stream : not null access Root_Stream_Type'Class; Container : out Set); for Set'Read use Read; type Set_Access is access all Set; for Set_Access'Storage_Size use 0; type Cursor is record Container : Set_Access; Node : Node_Access; end record; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Cursor); for Cursor'Write use Write; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Cursor); for Cursor'Read use Read; subtype Reference_Control_Type is Implementation.Reference_Control_Type; -- It is necessary to rename this here, so that the compiler can find it type Constant_Reference_Type (Element : not null access constant Element_Type) is record Control : Reference_Control_Type := raise Program_Error with "uninitialized reference"; -- The RM says, "The default initialization of an object of -- type Constant_Reference_Type or Reference_Type propagates -- Program_Error." end record; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Constant_Reference_Type); for Constant_Reference_Type'Write use Write; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Constant_Reference_Type); for Constant_Reference_Type'Read use Read; -- Three operations are used to optimize in the expansion of "for ... of" -- loops: the Next(Cursor) procedure in the visible part, and the following -- Pseudo_Reference and Get_Element_Access functions. See Sem_Ch5 for -- details. function Pseudo_Reference (Container : aliased Set'Class) return Reference_Control_Type; pragma Inline (Pseudo_Reference); -- Creates an object of type Reference_Control_Type pointing to the -- container, and increments the Lock. Finalization of this object will -- decrement the Lock. type Element_Access is access all Element_Type with Storage_Size => 0; function Get_Element_Access (Position : Cursor) return not null Element_Access; -- Returns a pointer to the element designated by Position. Empty_Set : constant Set := (Controlled with others => <>); function Empty return Set is (Empty_Set); No_Element : constant Cursor := Cursor'(null, null); type Iterator is new Limited_Controlled and Set_Iterator_Interfaces.Reversible_Iterator with record Container : Set_Access; Node : Node_Access; end record with Disable_Controlled => not T_Check; overriding procedure Finalize (Object : in out Iterator); overriding function First (Object : Iterator) return Cursor; overriding function Last (Object : Iterator) return Cursor; overriding function Next (Object : Iterator; Position : Cursor) return Cursor; overriding function Previous (Object : Iterator; Position : Cursor) return Cursor; end Ada.Containers.Ordered_Sets;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Unchecked_Deallocation; -- we need to explicitly with all annotations because their package -- initialization adds them to the annotation map. with Yaml.Transformator.Annotation.Identity; with Yaml.Transformator.Annotation.Concatenation; with Yaml.Transformator.Annotation.Vars; with Yaml.Transformator.Annotation.For_Loop; with Yaml.Transformator.Annotation.Inject; pragma Unreferenced (Yaml.Transformator.Annotation.Concatenation); pragma Unreferenced (Yaml.Transformator.Annotation.Vars); pragma Unreferenced (Yaml.Transformator.Annotation.For_Loop); pragma Unreferenced (Yaml.Transformator.Annotation.Inject); package body Yaml.Transformator.Annotation_Processor is use type Text.Reference; use type Annotation.Node_Context_Type; procedure Free_Array is new Ada.Unchecked_Deallocation (Node_Array, Node_Array_Pointer); procedure Free_Transformator is new Ada.Unchecked_Deallocation (Transformator.Instance'Class, Transformator.Pointer); function New_Processor (Pool : Text.Pool.Reference; Externals : Events.Store.Reference := Events.Store.New_Store) return Pointer is (new Instance'(Ada.Finalization.Limited_Controlled with Pool => Pool, Context => Events.Context.Create (Externals), others => <>)); procedure Finalize_Finished_Annotation_Impl (Object : in out Instance) is begin if Object.Level_Count = Object.Annotations (Object.Annotation_Count).Depth and then not Object.Annotations (Object.Annotation_Count).Impl.Has_Next then if Object.Annotations (Object.Annotation_Count).Swallows_Next then Object.Current_State := Swallowing_Document_End; Object.Current := (Kind => Document_End, others => <>); end if; Free_Transformator (Object.Annotations (Object.Annotation_Count).Impl); Object.Annotation_Count := Object.Annotation_Count - 1; if Object.Annotation_Count = 0 and Object.Next_Event_Storage = Yes then if Object.Current_State = Existing then Object.Next_Event_Storage := Finishing; else Object.Next_Event_Storage := No; end if; end if; end if; end Finalize_Finished_Annotation_Impl; procedure Shift_Through (Object : in out Instance; Start : Natural; E : Event) with Pre => Start <= Object.Annotation_Count is Cur_Annotation : Natural := Start; Cur_Event : Event := E; begin while Cur_Annotation > 0 loop Object.Annotations (Cur_Annotation).Impl.Put (Cur_Event); if Object.Annotations (Cur_Annotation).Impl.Has_Next then Cur_Event := Object.Annotations (Cur_Annotation).Impl.Next; if (Cur_Annotation = Object.Annotation_Count and Object.May_Finish_Transformation) then Finalize_Finished_Annotation_Impl (Object); end if; Cur_Annotation := Cur_Annotation - 1; else loop Cur_Annotation := Cur_Annotation + 1; if Cur_Annotation > Object.Annotation_Count then if Object.May_Finish_Transformation then Finalize_Finished_Annotation_Impl (Object); end if; return; end if; if Object.Annotations (Cur_Annotation).Impl.Has_Next then Cur_Event := Object.Annotations (Cur_Annotation).Impl.Next; if (Cur_Annotation = Object.Annotation_Count and Object.May_Finish_Transformation) then Finalize_Finished_Annotation_Impl (Object); end if; Cur_Annotation := Cur_Annotation - 1; exit; end if; end loop; end if; end loop; Object.Current := Cur_Event; Object.Current_State := (if Object.Current_State = Event_Held_Back then Releasing_Held_Back else Existing); end Shift_Through; procedure Append (Object : in out Instance; E : Event) is begin if Object.Annotation_Count > 0 then if Object.Current_State = Event_Held_Back then Object.May_Finish_Transformation := Object.Held_Back.Kind in Sequence_End | Mapping_End | Scalar | Alias; if E.Kind = Annotation_Start then if Object.Annotation_Count = 1 then Object.Current := Object.Held_Back; Object.Held_Back := E; Object.Current_State := Releasing_Held_Back; return; else Shift_Through (Object, Object.Annotation_Count, Object.Held_Back); end if; else Shift_Through (Object, Object.Annotation_Count, Object.Held_Back); end if; if Object.Current_State = Existing then Object.Held_Back := E; Object.Current_State := Releasing_Held_Back; return; end if; Object.Current_State := Absent; end if; Object.May_Finish_Transformation := E.Kind in Sequence_End | Mapping_End | Scalar | Alias; Shift_Through (Object, Object.Annotation_Count, E); elsif Object.Current_State = Event_Held_Back then Object.Current := Object.Held_Back; Object.Held_Back := E; Object.Current_State := Releasing_Held_Back; else Object.Current := E; Object.Current_State := Existing; end if; end Append; generic type Element_Type is private; type Array_Type is array (Positive range <>) of Element_Type; type Pointer_Type is access Array_Type; procedure Grow (Target : in out not null Pointer_Type; Last : in out Natural); procedure Grow (Target : in out not null Pointer_Type; Last : in out Natural) is procedure Free_Array is new Ada.Unchecked_Deallocation (Array_Type, Pointer_Type); begin if Last = Target'Last then declare Old_Array : Pointer_Type := Target; begin Target := new Array_Type (1 .. Last * 2); Target (1 .. Last) := Old_Array.all; Free_Array (Old_Array); end; end if; Last := Last + 1; end Grow; procedure Grow_Levels is new Grow (Annotation.Node_Context_Type, Level_Array, Level_Array_Pointer); procedure Grow_Annotations is new Grow (Annotated_Node, Node_Array, Node_Array_Pointer); procedure Put (Object : in out Instance; E : Event) is Locals : constant Events.Store.Accessor := Object.Context.Document_Store; begin if Object.Level_Count > 0 then case Object.Levels (Object.Level_Count) is when Annotation.Mapping_Key => Object.Levels (Object.Level_Count) := Annotation.Mapping_Value; when Annotation.Mapping_Value => Object.Levels (Object.Level_Count) := Annotation.Mapping_Key; when others => null; end case; end if; case E.Kind is when Annotation_Start => Locals.Memorize (E); declare use type Annotation.Maps.Cursor; Pos : constant Annotation.Maps.Cursor := (if E.Namespace = Standard_Annotation_Namespace then Annotation.Map.Find (E.Name.Value) else Annotation.Maps.No_Element); begin Grow_Annotations (Object.Annotations, Object.Annotation_Count); if Object.Annotation_Count = 1 then Object.Next_Event_Storage := (if E.Annotation_Properties.Anchor /= Text.Empty then Searching else No); end if; declare Swallows_Previous : Boolean := False; Impl : constant Transformator.Pointer := (if Pos = Annotation.Maps.No_Element then Annotation.Identity.New_Identity else Annotation.Maps.Element (Pos).all (Object.Pool, Object.Levels (Object.Level_Count), Object.Context, Swallows_Previous)); begin Object.Annotations (Object.Annotation_Count) := (Impl => Impl, Depth => Object.Level_Count, Swallows_Next => Swallows_Previous and Object.Level_Count = 1); if Swallows_Previous then if Object.Current_State /= Event_Held_Back then raise Annotation_Error with E.Namespace & E.Name & " applied to a value of a non-scalar mapping key"; end if; Object.Current_State := Absent; end if; Object.Append (E); end; end; Grow_Levels (Object.Levels, Object.Level_Count); Object.Levels (Object.Level_Count) := Annotation.Parameter_Item; when Annotation_End => Locals.Memorize (E); Object.Append (E); Object.Level_Count := Object.Level_Count - 1; when Document_Start => Locals.Clear; Object.Held_Back := E; Object.Current_State := Event_Held_Back; Grow_Levels (Object.Levels, Object.Level_Count); Object.Levels (Object.Level_Count) := Annotation.Document_Root; when Mapping_Start => Locals.Memorize (E); Object.Append (E); Grow_Levels (Object.Levels, Object.Level_Count); Object.Levels (Object.Level_Count) := Annotation.Mapping_Value; when Sequence_Start => Locals.Memorize (E); Object.Append (E); Grow_Levels (Object.Levels, Object.Level_Count); Object.Levels (Object.Level_Count) := Annotation.Sequence_Item; when Mapping_End | Sequence_End => Object.Level_Count := Object.Level_Count - 1; Locals.Memorize (E); Object.Append (E); when Document_End => if Object.Current_State = Swallowing_Document_End then Object.Current_State := Absent; else Object.Current := E; Object.Current_State := Existing; end if; Object.Level_Count := Object.Level_Count - 1; when Scalar => Locals.Memorize (E); if Object.Levels (Object.Level_Count) = Annotation.Mapping_Key then Object.Held_Back := E; Object.Current_State := Event_Held_Back; else Object.Append (E); end if; when Alias => Locals.Memorize (E); Object.Append (E); when Stream_Start | Stream_End => Object.Append (E); end case; end Put; function Has_Next (Object : Instance) return Boolean is (Object.Current_State in Existing | Releasing_Held_Back | Localizing_Alias or (Object.Current_State = Swallowing_Document_End and Object.Current.Kind /= Document_End)); function Next (Object : in out Instance) return Event is procedure Look_For_Additional_Element is begin if Object.Current_State /= Releasing_Held_Back then Object.Current_State := Absent; end if; for Cur_Annotation in 1 .. Object.Annotation_Count loop if Object.Annotations (Cur_Annotation).Impl.Has_Next then declare Next_Event : constant Event := Object.Annotations (Cur_Annotation).Impl.Next; begin if Cur_Annotation = Object.Annotation_Count and Object.May_Finish_Transformation then Finalize_Finished_Annotation_Impl (Object); end if; Shift_Through (Object, Cur_Annotation - 1, Next_Event); end; exit; end if; end loop; if Object.Current_State = Releasing_Held_Back then Object.Current_State := Absent; if Object.Annotation_Count > 0 then Object.May_Finish_Transformation := Object.Held_Back.Kind in Sequence_End | Mapping_End | Scalar | Alias; Shift_Through (Object, Object.Annotation_Count, Object.Held_Back); else Object.Current := Object.Held_Back; Object.Current_State := Existing; end if; end if; end Look_For_Additional_Element; procedure Update_Exists_In_Output (Anchor : Text.Reference) is use type Events.Context.Cursor; begin if Anchor /= Text.Empty then declare Pos : Events.Context.Cursor := Events.Context.Position (Object.Context, Anchor); begin if Pos /= Events.Context.No_Element then declare Referenced : constant Event := Events.Context.First (Pos); begin if Referenced.Start_Position = Object.Current.Start_Position and Referenced.Kind = Object.Current.Kind then Events.Context.Set_Exists_In_Output (Pos); end if; end; end if; end; end if; end Update_Exists_In_Output; procedure Update_Next_Storage (E : Event) is begin case Object.Next_Event_Storage is when Searching => if (case E.Kind is when Annotation_Start => E.Annotation_Properties.Anchor /= Text.Empty, when Mapping_Start | Sequence_Start => E.Collection_Properties.Anchor /= Text.Empty, when Scalar => E.Scalar_Properties.Anchor /= Text.Empty, when others => False) then Object.Context.Transformed_Store.Memorize (E); Object.Next_Event_Storage := Yes; else Object.Next_Event_Storage := No; end if; when Finishing => Object.Context.Transformed_Store.Memorize (E); Object.Next_Event_Storage := No; when Yes => Object.Context.Transformed_Store.Memorize (E); when No => null; end case; end Update_Next_Storage; begin case Object.Current_State is when Existing | Releasing_Held_Back => case Object.Current.Kind is when Alias => if Object.Current_State = Releasing_Held_Back then raise Program_Error with "internal error: alias may never generated while event is held back!"; end if; declare Pos : Events.Context.Cursor := Events.Context.Position (Object.Context, Object.Current.Target); begin if not Events.Context.Exists_In_Ouput (Pos) then Events.Context.Set_Exists_In_Output (Pos); Object.Current_Stream := Events.Context.Retrieve (Pos).Optional; return Ret : constant Event := Object.Current_Stream.Value.Next do Update_Next_Storage (Ret); case Ret.Kind is when Scalar => Object.Current_Stream.Clear; Look_For_Additional_Element; when Mapping_Start | Sequence_Start => Object.Current_State := Localizing_Alias; Object.Stream_Depth := Object.Stream_Depth + 1; when others => raise Program_Error with "alias refers to " & Object.Current.Kind'Img; end case; end return; end if; end; when Scalar => Update_Exists_In_Output (Object.Current.Scalar_Properties.Anchor); when Mapping_Start | Sequence_Start => Update_Exists_In_Output (Object.Current.Collection_Properties.Anchor); when others => null; end case; return Ret : constant Event := Object.Current do Update_Next_Storage (Ret); Look_For_Additional_Element; end return; when Localizing_Alias => return Ret : constant Event := Object.Current_Stream.Value.Next do Update_Next_Storage (Ret); case Ret.Kind is when Mapping_Start | Sequence_Start => Object.Stream_Depth := Object.Stream_Depth + 1; when Mapping_End | Sequence_End => Object.Stream_Depth := Object.Stream_Depth - 1; if Object.Stream_Depth = 0 then Object.Current_Stream.Clear; Look_For_Additional_Element; end if; when others => null; end case; end return; when Swallowing_Document_End => if Object.Current.Kind = Document_End then raise Constraint_Error with "no event to retrieve"; else return Ret : constant Event := Object.Current do Update_Next_Storage (Ret); Object.Current := (Kind => Document_End, others => <>); end return; end if; when Absent | Event_Held_Back => raise Constraint_Error with "no event to retrieve"; end case; end Next; procedure Finalize (Object : in out Instance) is Ptr : Node_Array_Pointer := Object.Annotations; begin for I in 1 .. Object.Annotation_Count loop Free_Transformator (Object.Annotations (I).Impl); end loop; Free_Array (Ptr); end Finalize; end Yaml.Transformator.Annotation_Processor;
{ "source": "starcoderdata", "programming_language": "ada" }
with Gtkada.Builder; with Gtk.List_Store; with Gtk.Status_Bar; with Gtk.Text_Buffer; with Gtk.Widget; package gui is builder : Gtkada.Builder.Gtkada_Builder; topLevelWindow : Gtk.Widget.Gtk_Widget; textbuf : Gtk.Text_Buffer.Gtk_Text_Buffer; statusBar : Gtk.Status_Bar.Gtk_Status_Bar; --statusBarContext : Gtk.Status_Bar.Context_Id; machinecodeList : Gtk.List_Store.Gtk_List_Store; memoryList : Gtk.List_Store.Gtk_List_Store; registerList : Gtk.List_Store.Gtk_List_Store; procedure load; procedure setTitle(newTitle : String); procedure updateGUI_VM; end gui;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Text_IO; with Interfaces.C; use Interfaces.C; with Interfaces.C.Strings; with System; use System; with System.Address_Image; with System.Address_To_Access_Conversions; with Ada.Environment_Variables; with opencl_api_spec; with dl_loader; package body opencl is use opencl_api_spec; type C_Address_Array is array (Interfaces.C.size_t range 1 .. 64) of aliased Raw_Address; type C_Char_Buffer is array (Interfaces.C.size_t range 1 .. 1024) of aliased Interfaces.C.char; type C_SizeT_Array is array (Interfaces.C.size_t range 1 .. 64) of aliased Interfaces.C.size_t; type Context_Property is new Long_Long_Integer; pragma Convention (Convention => C, Entity => C_Address_Array); pragma Convention (Convention => C, Entity => C_Char_Buffer); package C_Addr_Arr_Conv is new System.Address_To_Access_Conversions(Object => C_Address_Array); package C_Char_Buff_Conv is new System.Address_To_Access_Conversions(Object => C_Char_Buffer); package C_SizeT_Arr_Conv is new System.Address_To_Access_Conversions(Object => C_SizeT_Array); function Convert(code: in Interfaces.C.int) return Status is result: Status; begin begin if code = -9999 then Ada.Text_IO.Put_Line("CODE 9999!"); return opencl.INVALID_VALUE; end if; result := Status'Enum_Val(code); exception when E: Constraint_Error => Ada.Text_IO.Put_Line("Status code not recognized: " & code'Image); raise; end; return result; end Convert; function Convert(code: in cl_int) return Status is begin return Convert(Interfaces.C.int(code)); end Convert; cl_lib_handle: dl_loader.Handle; function To_Ada(s: in C_Char_Buffer; size: Interfaces.C.size_t) return String is result: String(1 .. Integer(size)) := (others => ASCII.NUL); begin for idx in 1 .. size loop result(Integer(idx)) := Interfaces.C.To_Ada(s(idx)); end loop; return result; end To_Ada; function Convert(event_list: in Events) return C_Address_Array is result: C_Address_Array := (others => 0); begin for i in 1 .. event_list'Length loop result(Interfaces.C.size_t(i)) := Raw_Address(event_list(i)); end loop; return result; end Convert; --TODO better check function Get_OpenCL_Path(arch: Arch_Type) return String is is_linux: constant Boolean := Ada.Environment_Variables.Exists("HOME"); begin if is_linux then return "TODO"; else return (if arch = ARCH_64 then "C:/Windows/SysWOW64/OpenCL.dll" else "C:/Windows/System32/OpenCL.dll"); end if; end Get_OpenCL_Path; function Init(path: String) return Status is result: Boolean; begin result := dl_loader.Open(path, cl_lib_handle); if result then result := opencl_api_spec.Load_From(cl_lib_handle); end if; return (if result then SUCCESS else INVALID_VALUE); end Init; function Get_Platforms(result_status: out Status) return Platforms is function Impl(num_entries_p: Interfaces.C.unsigned; platforms_ptr_p: System.Address; num_platforms_p: access Interfaces.C.unsigned) return Interfaces.C.int with Import, Address => clGetPlatformIDs, Convention => C; num_platforms: aliased Interfaces.C.unsigned := 0; platforms_ptr: aliased C_Address_Array := (others => 0); cl_code: Interfaces.C.int; current_index: Interfaces.C.size_t := 1; null_platforms: constant Platforms(1 .. 0) := (others => 0); begin if clGetPlatformIDs = System.Null_Address then result_status := INVALID_PLATFORM; return null_platforms; end if; cl_code := Impl(platforms_ptr'Length, C_Addr_Arr_Conv.To_Address(platforms_ptr'Unchecked_Access), num_platforms'Access); result_status := Convert(cl_code); if result_status = SUCCESS then return result: Platforms(1 .. Integer(num_platforms)) do for ptr of result loop if current_index <= Interfaces.C.size_t(num_platforms) then ptr := Platform_ID(platforms_ptr(current_index)); else ptr := Platform_ID(0); end if; current_index := current_index + 1; end loop; end return; end if; return null_platforms; end Get_Platforms; function Get_Platform_Info(id: in Platform_ID; info: Platform_Info; result_status: out Status) return String is function Impl(p: Raw_Address; info: Interfaces.C.unsigned; val_size: Interfaces.C.size_t; val: System.Address; val_size_ret: access Interfaces.C.size_t) return Interfaces.C.int with Import, Address => clGetPlatformInfo, Convention => C; cl_code: Interfaces.C.Int; size_ret: aliased Interfaces.C.size_t; string_ret: aliased C_Char_Buffer; begin cl_code := Impl(Raw_Address(id), Platform_Info'Enum_Rep(info), string_ret'Length, C_Char_Buff_Conv.To_Address(string_ret'Unchecked_Access), size_ret'Access); result_status := Convert(cl_code); return To_Ada(string_ret, size_ret - 1); end Get_Platform_Info; function Get_Devices(id: in Platform_ID; dev_type: in Device_Type; result_status: out Status) return Devices is null_devices: constant Devices(1 .. 0) := (others => 0); function Impl(p: Raw_Address; dev_t: Interfaces.C.unsigned; num_entries: Interfaces.C.unsigned; out_devices: System.Address; num_devs: access Interfaces.C.unsigned) return Interfaces.C.int with Import, Address => clGetDeviceIDs, Convention => C; num_devices: aliased Interfaces.C.unsigned := 0; device_ids: aliased C_Address_Array := (others => 0); cl_res: Interfaces.C.int; begin cl_res := Impl(p => Raw_Address(id), dev_t => Device_Type'Enum_Rep(dev_type), num_entries => device_ids'Length, out_devices => C_Addr_Arr_Conv.To_Address(device_ids'Unchecked_Access), num_devs => num_devices'Access); result_status := Convert(cl_res); if result_status = SUCCESS then return devs: Devices(1 .. Integer(num_devices)) do for idx in 1 .. num_devices loop devs(Integer(idx)) := Device_ID(device_ids(Interfaces.C.size_t(idx))); end loop; end return; end if; return null_devices; end Get_Devices; function Get_Device_Info(id: in Device_ID; info: in Device_Info_Bool; result_status: out Status) return Boolean is function Impl(p: Raw_Address; dev_i: Interfaces.C.unsigned; res_size: Interfaces.C.size_t; out_info: access Interfaces.C.unsigned; info_len: System.Address) return Interfaces.C.int with Import, Address => clGetDeviceInfo, Convention => C; flag_value: aliased Interfaces.C.unsigned := 0; cl_status: Interfaces.C.int := 0; begin cl_status := Impl(p => Raw_Address(id), dev_i => Device_Info_Bool'Enum_Rep(info), res_size => Interfaces.C.unsigned'Size, out_info => flag_value'Access, info_len => System.Null_Address); result_status := Convert(cl_status); return (if flag_value = 0 then False else True); end Get_Device_Info; function Get_Device_Info(id: in Device_ID; info: in Device_Info_String; result_status: out Status) return String is function Impl(p: Raw_Address; dev_i: Interfaces.C.unsigned; res_size: Interfaces.C.size_t; out_info: System.Address; info_len: access Interfaces.C.size_t) return Interfaces.C.int with Import, Address => clGetDeviceInfo, Convention => C; null_string: constant String(1 .. 0) := (others => ' '); cl_status: Interfaces.C.int := 0; buffer: aliased C_Char_Buffer; actual_length: aliased Interfaces.C.size_t := 0; begin cl_status := Impl(p => Raw_Address(id), dev_i => Device_Info_String'Enum_Rep(info), res_size => buffer'Length, out_info => C_Char_Buff_Conv.To_Address(buffer'Unchecked_Access), info_len => actual_length'Access); result_status := Convert(cl_status); if result_status = SUCCESS then return To_Ada(buffer, actual_length - 1); end if; return null_string; end Get_Device_Info; function Create_Context(context_platform: in Platform_ID; context_device: in Device_ID; result_status: out Status) return Context_ID is function Impl(ctx_props: System.Address; num_devs: Interfaces.C.unsigned; devs: System.Address; cb: System.Address; user_data: System.Address; err_code: access Interfaces.C.int) return Raw_Address with Import, Address => clCreateContext, Convention => C; properties: aliased C_Address_Array := (others => 0); dev_ids: aliased C_Address_Array := (others => 0); err_code: aliased Interfaces.C.int := 0; ctx_id: Raw_Address := 0; begin dev_ids(1) := Raw_Address(context_device); properties(1) := Raw_Address(Context_Properties'Enum_Rep(CONTEXT_PROP_PLATFORM)); properties(2) := Raw_Address(context_platform); ctx_id := Impl(ctx_props => C_Addr_Arr_Conv.To_Address(properties'Unchecked_Access), num_devs => 1, devs => C_Addr_Arr_Conv.To_Address(dev_ids'Unchecked_Access), cb => System.Null_Address, user_data => System.Null_Address, err_code => err_code'Access); result_status := Convert(err_code); return Context_ID(ctx_id); end Create_Context; function Release_Context(id: in Context_ID) return Status is function Impl(p: Raw_Address) return Interfaces.C.int with Import, Address => clReleaseContext, Convention => C; cl_code: Interfaces.C.int := 0; begin cl_code := Impl(Raw_Address(id)); return Convert(cl_code); end Release_Context; function Create_Program(ctx: in Context_ID; source: in String; result_status: out Status) return Program_ID is function Impl(ctx: Raw_Address; count: Interfaces.C.unsigned; strs: access Interfaces.C.Strings.chars_ptr; lengths: System.Address; err_code: access Interfaces.C.int) return Raw_Address with Import, Address => clCreateProgramWithSource, Convention => C; prog_id: Raw_Address := 0; err_code: aliased Interfaces.C.int := 0; lengths: aliased C_SizeT_Array := (others => 0); source_ptr: aliased Interfaces.C.Strings.chars_ptr; begin lengths(1) := source'Length; source_ptr := Interfaces.C.Strings.New_String(Str => source); prog_id := Impl(ctx => Raw_Address(ctx), count => 1, strs => source_ptr'Access, lengths => C_SizeT_Arr_Conv.To_Address(lengths'Unchecked_Access), err_code => err_code'Access); result_status := Convert(err_code); Interfaces.C.Strings.Free(Item => source_ptr); return Program_ID(prog_id); end Create_Program; function Build_Program(id: in Program_ID; device: in Device_ID; options: in String) return Status is function Impl(p_id: Raw_Address; num_devices: Interfaces.C.unsigned; device_list: System.Address; options: Interfaces.C.Strings.char_array_access; user_cb: System.Address; user_data: System.Address) return Interfaces.C.int with Import, Address => clBuildProgram, Convention => C; cl_code: Interfaces.C.int := 0; device_array: aliased C_Address_Array := (others => 0); opts: aliased Interfaces.C.char_array := Interfaces.C.To_C(options); begin device_array(1) := Raw_Address(device); cl_code := Impl(p_id => Raw_Address(id), num_devices => 1, device_list => C_Addr_Arr_Conv.To_Address(device_array'Unchecked_Access), options => opts'Unchecked_Access, user_cb => System.Null_Address, user_data => System.Null_Address); return Convert(cl_code); end Build_Program; function Get_Program_Build_Log(id: in Program_ID; device: in Device_ID; result_status: out Status) return String is function Impl(prog: Raw_Address; dev: Raw_Address; info: Interfaces.C.unsigned; available_size: Interfaces.C.size_t; ptr: System.Address; ret_size: access Interfaces.C.size_t) return Interfaces.C.int with Import, Address => clGetProgramBuildInfo, Convention => C; build_log_size: aliased Interfaces.C.size_t; cl_code: Interfaces.C.int := 0; begin cl_code := Impl(prog => Raw_Address(id), dev => Raw_Address(device), info => Program_Build_Info_String'Enum_Rep(PROGRAM_BUILD_LOG), available_size => 0, ptr => System.Null_Address, ret_size => build_log_size'Access); declare type C_Char_Buff is new Interfaces.C.char_array(1 .. build_log_size); build_log_buffer: aliased C_Char_Buff := (1 .. build_log_size => Interfaces.C.To_C(ASCII.NUL)); package Char_Arr_Addr_Conv is new System.Address_To_Access_Conversions(Object => C_Char_Buff); begin cl_code := Impl(prog => Raw_Address(id), dev => Raw_Address(device), info => Program_Build_Info_String'Enum_Rep(PROGRAM_BUILD_LOG), available_size => build_log_size, ptr => Char_Arr_Addr_Conv.To_Address(build_log_buffer'Unchecked_Access), ret_size => build_log_size'Access); result_status := Convert(cl_code); return Interfaces.C.To_Ada(Interfaces.C.char_array(build_log_buffer)); end; end Get_Program_Build_Log; function Release_Program(id: in Program_ID) return Status is function Impl(p: Raw_Address) return Interfaces.C.int with Import, Address => clReleaseProgram, Convention => C; cl_code: Interfaces.C.int := 0; begin cl_code := Impl(Raw_Address(id)); return Convert(cl_code); end Release_Program; function Create_Kernel(program: in Program_ID; name: in String; result_status: out Status) return Kernel_ID is function Impl(prog: Raw_Address; name_str: Interfaces.C.Strings.char_array_access; err_c: access Interfaces.C.int) return Raw_Address with Import, Address => clCreateKernel, Convention => C; cl_code: aliased Interfaces.C.int := 0; str_ptr: aliased Interfaces.C.char_array := Interfaces.C.To_C(name); result: Raw_Address := 0; begin result := Impl(prog => Raw_Address(program), name_str => str_ptr'Unchecked_Access, err_c => cl_code'Access); result_status := Convert(cl_code); return Kernel_ID(result); end Create_Kernel; function Release_Kernel(id: in Kernel_ID) return Status is function Impl(p: Raw_Address) return Interfaces.C.int with Import, Address => clReleaseKernel, Convention => C; cl_code: Interfaces.C.int := 0; begin cl_code := Impl(Raw_Address(id)); return Convert(cl_code); end Release_Kernel; function Set_Kernel_Arg(id: in Kernel_ID; index: Natural; size: Positive; address: System.Address) return Status is function Impl(k_id: Raw_Address; arg_index: Interfaces.C.unsigned; arg_size: Interfaces.C.size_t; arg_addr: System.Address) return Interfaces.C.int with Import, Address => clSetKernelArg, Convention => C; cl_code: Interfaces.C.int; arg_index: constant Interfaces.C.unsigned := Interfaces.C.unsigned(index); arg_size: constant Interfaces.C.size_t := Interfaces.C.size_t(size); begin cl_code := Impl(k_id => Raw_Address(id), arg_index => arg_index, arg_size => arg_size, arg_addr => address); return Convert(cl_code); end Set_Kernel_Arg; function Enqueue_Kernel(queue: in Command_Queue; kernel: in Kernel_ID; global_offset: in Offsets; global_work_size, local_work_size: in Dimensions; event_wait_list: in Events; event: out Event_ID) return Status is function Impl(q_id, k_id: Raw_Address; dims: Interfaces.C.unsigned; glob_off, glob_ws, local_ws: access C_SizeT_Array; num_wait_events: Interfaces.C.unsigned; event_wait: System.Address; event_res: access Raw_Address) return Interfaces.C.int with Import, Address => clEnqueueNDRangeKernel, Convention => C; event_result: aliased Raw_Address; result: Interfaces.C.int := 0; global_ws_array: aliased C_SizeT_Array := (others => 0); local_ws_array: aliased C_SizeT_Array := (others => 0); global_off_array: aliased C_SizeT_Array := (others => 0); event_wait_array: aliased C_Address_Array := Convert(event_wait_list); begin for i in 1 .. global_offset'Length loop global_off_array(Interfaces.C.size_t(i)) := Interfaces.C.size_t(global_offset(i)); end loop; for i in 1 .. global_work_size'Length loop global_ws_array(Interfaces.C.size_t(i)) := Interfaces.C.size_t(global_work_size(i)); end loop; for i in 1 .. local_work_size'Length loop local_ws_array(Interfaces.C.size_t(i)) := Interfaces.C.size_t(local_work_size(i)); end loop; result := Impl(q_id => Raw_Address(queue), k_id => Raw_Address(kernel), dims => global_work_size'Length, glob_off => global_off_array'Access, glob_ws => global_ws_array'Access, local_ws => local_ws_array'Access, num_wait_events => event_wait_list'Length, event_wait => (if event_wait_list'Length = 0 then System.Null_Address else C_Addr_Arr_Conv.To_Address(event_wait_array'Unchecked_Access)), event_res => event_result'Access); event := Event_ID(event_result); return Convert(result); end Enqueue_Kernel; function Create_Command_Queue(ctx: in Context_ID; dev: in Device_ID; result_status: out Status) return Command_Queue is function Impl(ctx_id: Raw_Address; dev_id: Raw_Address; props: System.Address; err_c: access Interfaces.C.int) return Raw_Address with Import, Address => clCreateCommandQueueWithProperties, Convention => C; cl_code: aliased Interfaces.C.int := 0; result: Raw_Address := 0; begin result := Impl(ctx_id => Raw_Address(ctx), dev_id => Raw_Address(dev), props => System.Null_Address, err_c => cl_code'Access); result_status := Convert(cl_code); return Command_Queue(result); end Create_Command_Queue; function Release_Command_Queue(id: in Command_Queue) return Status is function Impl(p: Raw_Address) return Interfaces.C.int with Import, Address => clReleaseCommandQueue, Convention => C; cl_code: Interfaces.C.int := 0; begin cl_code := Impl(Raw_Address(id)); return Convert(cl_code); end Release_Command_Queue; function Wait_For_Events(ev_list: Events) return Status is function Impl(num_events: Interfaces.C.unsigned; event_arr: access C_Address_Array) return Interfaces.C.int with Import, Address => clWaitForEvents, Convention => C; cl_code: Interfaces.C.int := 0; event_arr: aliased C_Address_Array := (others => 0); begin for i in 1 .. ev_list'Length loop event_arr(Interfaces.C.size_t(i)) := Raw_Address(ev_list(i)); end loop; cl_code := Impl(num_events => ev_list'Length, event_arr => event_arr'Access); return Convert(cl_code); end Wait_For_Events; function Release_Event(ev: in Event_ID) return Status is function Impl(p: Raw_Address) return cl_int with Import, Address => clReleaseEvent, Convention => C; cl_code: cl_int := 0; begin cl_code := Impl(Raw_Address(ev)); return Convert(cl_code); end Release_Event; function Retain_Event(ev: in Event_ID) return Status is function Impl(p: Raw_Address) return cl_int with Import, Address => clRetainEvent, Convention => C; cl_code: cl_int := 0; begin cl_code := Impl(Raw_Address(ev)); return Convert(cl_code); end Retain_Event; function Finish(queue: in Command_Queue) return Status is function Impl(p: Raw_Address) return Interfaces.C.int with Import, Address => clFinish, Convention => C; cl_code: Interfaces.C.int := 0; begin cl_code := Impl(Raw_Address(queue)); return Convert(cl_code); end Finish; function Convert(flags: in Mem_Flags) return cl_mem_flags is result: cl_mem_flags := 0; current_flag: cl_mem_flags := 0; begin for i in flags'Range loop if flags(i) then current_flag := cl_mem_flags(Mem_Flag'Enum_Rep(i)); result := result or current_flag; end if; end loop; return result; end Convert; function Create_Buffer(ctx: in Context_ID; flags: in Mem_Flags; size: Positive; host_ptr: System.Address; result_status: out Status) return Mem_ID is function Impl(ctx: Raw_Address; flags: cl_mem_flags; size: Interfaces.C.size_t; host_ptr: System.Address; result_code: access cl_int) return Raw_Address with Import, Address => clCreateBuffer, Convention => C; cl_code: aliased cl_int; size_p: constant Interfaces.C.size_t := Interfaces.C.size_t(size); raw_mem_id: Raw_Address; begin raw_mem_id := Impl(ctx => Raw_Address(ctx), flags => Convert(flags), size => size_p, host_ptr => host_ptr, result_code => cl_code'Access); result_status := Convert(cl_code); return Mem_ID(raw_mem_id); end Create_Buffer; function Enqueue_Read(queue: in Command_Queue; mem_ob: in Mem_ID; block_read: Boolean; offset: Natural; size: Positive; ptr: System.Address; events_to_wait_for: in Events; event: out Event_ID) return Status is function Impl(q: Raw_Address; mem: Raw_Address; block_read: cl_bool; offset, size: Interfaces.C.size_t; ptr: System.Address; num_wait_events: Interfaces.C.unsigned; event_wait: System.Address; event_res: access Raw_Address) return cl_int with Import, Address => clEnqueueReadBuffer, Convention => C; event_list: aliased C_Address_Array := Convert(events_to_wait_for); event_result: aliased Raw_Address; cl_code: cl_int; begin cl_code := Impl(q => Raw_Address(queue), mem => Raw_Address(mem_ob), block_read => cl_bool(if block_read then 1 else 0), offset => Interfaces.C.size_t(offset), size => Interfaces.C.size_t(size), ptr => ptr, num_wait_events => events_to_wait_for'Length, event_wait => (if events_to_wait_for'Length = 0 then System.Null_Address else C_Addr_Arr_Conv.To_Address(event_list'Unchecked_Access)), event_res => event_result'Access); event := Event_ID(event_result); return Convert(cl_code); end Enqueue_Read; function Enqueue_Write(queue: in Command_Queue; mem_ob: in Mem_ID; block_write: Boolean; offset: Natural; size: Positive; ptr: System.Address; events_to_wait_for: in Events; event: out Event_ID) return Status is function Impl(q: Raw_Address; mem: Raw_Address; block_write: cl_bool; offset, size: Interfaces.C.size_t; ptr: System.Address; num_wait_events: Interfaces.C.unsigned; event_wait: System.Address; event_res: access Raw_Address) return cl_int with Import, Address => clEnqueueWriteBuffer, Convention => C; event_list: aliased C_Address_Array := Convert(events_to_wait_for); event_result: aliased Raw_Address; cl_code: cl_int; begin cl_code := Impl(q => Raw_Address(queue), mem => Raw_Address(mem_ob), block_write => cl_bool(if block_write then 1 else 0), offset => Interfaces.C.size_t(offset), size => Interfaces.C.size_t(size), ptr => ptr, num_wait_events => events_to_wait_for'Length, event_wait => (if events_to_wait_for'Length = 0 then System.Null_Address else C_Addr_Arr_Conv.To_Address(event_list'Unchecked_Access)), event_res => event_result'Access); event := Event_ID(event_result); return Convert(cl_code); end Enqueue_Write; function Release(mem_ob: in Mem_ID) return Status is function Impl(id: Raw_Address) return Interfaces.C.int with Import, Address => clReleaseMemObject, Convention => C; cl_code: Interfaces.C.int; begin cl_code := Impl(Raw_Address(mem_ob)); return Convert(cl_code); end Release; function Get_Local_Work_Size(width, height: in Positive) return opencl.Dimensions is result: opencl.Dimensions := (1 => 1, 2 => 1); preferred_multiples: constant opencl.Dimensions := (32, 16, 8, 4, 2); begin for m of preferred_multiples loop if width rem m = 0 then result(1) := m; exit; end if; end loop; for m of preferred_multiples loop if height rem m = 0 then result(2) := m; exit; end if; end loop; return result; end Get_Local_Work_Size; end opencl;
{ "source": "starcoderdata", "programming_language": "ada" }
-- -- echo [string ...] -- -- Write arguments to the standard output -- -- The echo utility writes any specified operands, separated by single blank -- (`` '') characters and followed by a newline (``\n'') character, to the -- standard output. -- with Ada.Command_Line; with Ada.Text_IO; use Ada; procedure Echo is begin if Command_Line.Argument_Count > 0 then Text_IO.Put (Command_Line.Argument (1)); for Arg in 2 .. Command_Line.Argument_Count loop Text_IO.Put (' '); Text_IO.Put (Command_Line.Argument (Arg)); end loop; end if; Text_IO.New_Line; end Echo;
{ "source": "starcoderdata", "programming_language": "ada" }
-- with HAL; with HAL.SPI; with RP.Clock; with RP.GPIO; with RP.SPI; with RP.Device; with Pico; with SPI_Slave_Pico; procedure Main_Slave_Pico is Data_In : HAL.SPI.SPI_Data_16b (1 .. 1) := (others => 0); Status_In : HAL.SPI.SPI_Status; THE_VALUE : constant HAL.UInt16 := HAL.UInt16 (16#A5A5#); Data_Out : HAL.SPI.SPI_Data_16b (1 .. 1) := (others => THE_VALUE); Status_Out : HAL.SPI.SPI_Status; use HAL; begin RP.Clock.Initialize (Pico.XOSC_Frequency); RP.Device.Timer.Enable; Pico.LED.Configure (RP.GPIO.Output); SPI_Slave_Pico.Initialize; loop -- do this to get the slave ready SPI_Slave_Pico.SPI.Transmit (Data_Out, Status_Out); for I in 1 .. 1 loop SPI_Slave_Pico.SPI.Receive (Data_In, Status_In); Data_Out (1) := not Data_In (1); SPI_Slave_Pico.SPI.Transmit (Data_Out, Status_Out); end loop; RP.Device.Timer.Delay_Milliseconds (10); Pico.LED.Toggle; end loop; end Main_Slave_Pico;
{ "source": "starcoderdata", "programming_language": "ada" }
-- implementation of package Bubble -- see bubble.ads for a specification -- which gives a brief overview of the package with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; package body Bubble is protected body State is procedure Set_All(a, b, c, d : Integer) is begin State.a := a; State.b := b; State.c := c; State.d := d; Print_State; end Set_All; entry Wait_Until_Sorted(a, b, c, d : out Integer) when (a <= b and b <= c and c <= d) is begin a := State.a; b := State.b; c := State.c; d := State.d; end Wait_Until_Sorted; -- private procedure used to help user see what happens: procedure Print_State is begin Put("a = "); Put(a,2); Put("; "); Put("b = "); Put(b,2); Put("; "); Put("c = "); Put(c,2); Put("; "); Put("d = "); Put(d,2); Put("; "); Put_Line(""); end Print_State; procedure Swap(n, m : in out Integer) is temp : Integer; begin temp := n; n := m; m := temp; end Swap; entry BubbleAB when a > b is begin Swap(a,b); Print_State; end BubbleAB; entry BubbleBC when b > c is begin Swap(b,c); Print_State; end BubbleBC; entry BubbleCD when c > d is begin Swap(c,d); Print_State; end BubbleCD; end State; -- Tasks that keep calling Bubble.. to sort the numbers asap: task body BubbleAB is begin loop State.BubbleAB; end loop; end BubbleAB; -- Tasks that keep calling Bubble.. to sort the numbers asap: task body BubbleBC is begin loop State.BubbleBC; end loop; end BubbleBC; -- Tasks that keep calling Bubble.. to sort the numbers asap: task body BubbleCD is begin loop State.BubbleCD; end loop; end BubbleCD; end Bubble;
{ "source": "starcoderdata", "programming_language": "ada" }
----------------------------------------------------------------------- with CSS.Core.Styles; with CSS.Core.Vectors; with CSS.Core.Values; with CSS.Core.Properties; with CSS.Core.Medias; package CSS.Core.Sheets is type CSSStylesheet is new CSS.Core.StyleSheet with record Rules : CSS.Core.Vectors.Vector; Values : CSS.Core.Values.Repository_Type; end record; type CSSStylesheet_Access is access all CSSStylesheet'Class; -- Create a CSS rule. function Create_Rule (Document : in CSSStyleSheet) return Styles.CSSStyleRule_Access; -- Create a CSS font-face rule. function Create_Rule (Document : in CSSStyleSheet) return Styles.CSSFontfaceRule_Access; -- Create a CSS media rule. function Create_Rule (Document : in CSSStyleSheet) return Medias.CSSMediaRule_Access; -- Append the CSS rule to the document. procedure Append (Document : in out CSSStylesheet; Rule : in Styles.CSSStyleRule_Access; Line : in Natural; Column : in Natural); -- Append the media rule to the document. procedure Append (Document : in out CSSStylesheet; Rule : in Medias.CSSMediaRule_Access; Line : in Natural; Column : in Natural); -- Append the font-face rule to the document. procedure Append (Document : in out CSSStylesheet; Rule : in Styles.CSSFontfaceRule_Access; Line : in Natural; Column : in Natural); -- Append the CSS rule to the media. procedure Append (Document : in out CSSStylesheet; Media : in Medias.CSSMediaRule_Access; Rule : in Styles.CSSStyleRule_Access; Line : in Natural; Column : in Natural); -- Iterate over the properties of each CSS rule. The <tt>Process</tt> procedure -- is called with the CSS rule and the property as parameter. procedure Iterate_Properties (Document : in CSSStylesheet; Process : not null access procedure (Rule : in Styles.CSSStyleRule'Class; Property : in Properties.CSSProperty)); end CSS.Core.Sheets;
{ "source": "starcoderdata", "programming_language": "ada" }
----------------------------------------------------------------------- with Util.Strings; with AWA.Events.Action_Method; package body AWA.Mail.Beans is package Send_Mail_Binding is new AWA.Events.Action_Method.Bind (Bean => Mail_Bean, Method => Send_Mail, Name => "send"); Mail_Bean_Binding : aliased constant Util.Beans.Methods.Method_Binding_Array := (1 => Send_Mail_Binding.Proxy'Access); -- ------------------------------ -- Get the value identified by the name. -- ------------------------------ overriding function Get_Value (From : in Mail_Bean; Name : in String) return Util.Beans.Objects.Object is begin if Name = "template" then return Util.Beans.Objects.To_Object (From.Template); else declare Pos : constant Util.Beans.Objects.Maps.Cursor := From.Props.Find (Name); begin if Util.Beans.Objects.Maps.Has_Element (Pos) then return Util.Beans.Objects.Maps.Element (Pos); else return Util.Beans.Objects.Null_Object; end if; end; end if; end Get_Value; -- ------------------------------ -- Set the value identified by the name. -- ------------------------------ overriding procedure Set_Value (From : in out Mail_Bean; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "template" then From.Template := Util.Beans.Objects.To_Unbounded_String (Value); elsif Util.Strings.Starts_With (Name, "request.") then From.Params.Include (Name (Name'First + 8 .. Name'Last), Value); else From.Props.Include (Name, Value); end if; end Set_Value; -- ------------------------------ -- This bean provides some methods that can be used in a Method_Expression -- ------------------------------ overriding function Get_Method_Bindings (From : in Mail_Bean) return Util.Beans.Methods.Method_Binding_Array_Access is pragma Unreferenced (From); begin return Mail_Bean_Binding'Access; end Get_Method_Bindings; -- ------------------------------ -- Format and send the mail. -- ------------------------------ procedure Send_Mail (Bean : in out Mail_Bean; Event : in AWA.Events.Module_Event'Class) is use Ada.Strings.Unbounded; begin Bean.Module.Send_Mail (To_String (Bean.Template), Bean.Props, Bean.Params, Event); end Send_Mail; -- ------------------------------ -- Create the mail bean instance. -- ------------------------------ function Create_Mail_Bean (Module : in AWA.Mail.Modules.Mail_Module_Access) return Util.Beans.Basic.Readonly_Bean_Access is Result : constant Mail_Bean_Access := new Mail_Bean; begin Result.Module := Module; return Result.all'Access; end Create_Mail_Bean; end AWA.Mail.Beans;
{ "source": "starcoderdata", "programming_language": "ada" }
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- * Boston, MA 02111-1307, USA. -- type GstAppBuffer; --subtype GstAppBuffer is u_GstAppBuffer; -- gst/app/gstappbuffer.h:38 type GstAppBufferClass; --subtype GstAppBufferClass is u_GstAppBufferClass; -- gst/app/gstappbuffer.h:39 type GstAppBufferFinalizeFunc is access procedure (arg1 : System.Address); pragma Convention (C, GstAppBufferFinalizeFunc); -- gst/app/gstappbuffer.h:40 type GstAppBuffer is record buffer : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/app/gstappbuffer.h:44 finalize : GstAppBufferFinalizeFunc; -- gst/app/gstappbuffer.h:47 priv : System.Address; -- gst/app/gstappbuffer.h:48 end record; pragma Convention (C_Pass_By_Copy, GstAppBuffer); -- gst/app/gstappbuffer.h:42 --< private > type GstAppBufferClass is record buffer_class : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBufferClass; -- gst/app/gstappbuffer.h:53 end record; pragma Convention (C_Pass_By_Copy, GstAppBufferClass); -- gst/app/gstappbuffer.h:51 function gst_app_buffer_get_type return GLIB.GType; -- gst/app/gstappbuffer.h:56 pragma Import (C, gst_app_buffer_get_type, "gst_app_buffer_get_type"); function gst_app_buffer_new (data : System.Address; length : int; finalize : GstAppBufferFinalizeFunc; priv : System.Address) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/app/gstappbuffer.h:58 pragma Import (C, gst_app_buffer_new, "gst_app_buffer_new"); end GStreamer.GST_Low_Level.gstreamer_0_10_gst_app_gstappbuffer_h;
{ "source": "starcoderdata", "programming_language": "ada" }
with Linted.Errors; with Linted.KOs; with Linted.Update; with Linted.Triggers; package Linted.Update_Reader is pragma Elaborate_Body; type Event is record Data : Update.Packet; Err : Errors.Error := 0; end record; type Future is limited private with Preelaborable_Initialization; function Is_Live (F : Future) return Boolean; procedure Read (Object : KOs.KO; Signaller : Triggers.Signaller; F : out Future) with Post => Is_Live (F); procedure Read_Wait (F : in out Future; E : out Event) with Pre => Is_Live (F), Post => not Is_Live (F); procedure Read_Poll (F : in out Future; E : out Event; Init : out Boolean) with Pre => Is_Live (F), Post => (if Init then not Is_Live (F) else Is_Live (F)); private Max_Nodes : constant := 2; type Future is range 0 .. Max_Nodes + 1 with Default_Value => 0; end Linted.Update_Reader;
{ "source": "starcoderdata", "programming_language": "ada" }
-- { dg-do run } with Init9; use Init9; with Ada.Numerics; use Ada.Numerics; with Text_IO; use Text_IO; with Dump; procedure P9 is Local_R1 : R1; Local_R2 : R2; begin Put ("My_R1 :"); Dump (My_R1'Address, R1'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "My_R1 : 18 2d 44 54 fb 21 09 40.*\n" } Put ("My_R2 :"); Dump (My_R2'Address, R2'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "My_R2 : 40 09 21 fb 54 44 2d 18.*\n" } Local_R1 := My_R1; Put ("Local_R1 :"); Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "Local_R1 : 18 2d 44 54 fb 21 09 40.*\n" } Local_R2 := My_R2; Put ("Local_R2 :"); Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "Local_R2 : 40 09 21 fb 54 44 2d 18.*\n" } Local_R1.F := Pi; Put ("Local_R1 :"); Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "Local_R1 : 18 2d 44 54 fb 21 09 40.*\n" } Local_R2.F := Pi; Put ("Local_R2 :"); Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "Local_R2 : 40 09 21 fb 54 44 2d 18.*\n" } Local_R1.F := Local_R2.F; Put ("Local_R1 :"); Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "Local_R1 : 18 2d 44 54 fb 21 09 40.*\n" } Local_R2.F := Local_R1.F; Put ("Local_R2 :"); Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "Local_R2 : 40 09 21 fb 54 44 2d 18.*\n" } end;
{ "source": "starcoderdata", "programming_language": "ada" }
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with umingw_h; package ctype_h is -- unsupported macro: isascii __isascii -- unsupported macro: toascii __toascii -- unsupported macro: iscsymf __iscsymf -- unsupported macro: iscsym __iscsym -- skipped func _isctype -- skipped func _isctype_l function isalpha (u_C : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:102 pragma Import (C, isalpha, "isalpha"); -- skipped func _isalpha_l function isupper (u_C : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:104 pragma Import (C, isupper, "isupper"); -- skipped func _isupper_l function islower (u_C : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:106 pragma Import (C, islower, "islower"); -- skipped func _islower_l function isdigit (u_C : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:108 pragma Import (C, isdigit, "isdigit"); -- skipped func _isdigit_l function isxdigit (u_C : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:110 pragma Import (C, isxdigit, "isxdigit"); -- skipped func _isxdigit_l function isspace (u_C : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:112 pragma Import (C, isspace, "isspace"); -- skipped func _isspace_l function ispunct (u_C : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:114 pragma Import (C, ispunct, "ispunct"); -- skipped func _ispunct_l function isalnum (u_C : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:116 pragma Import (C, isalnum, "isalnum"); -- skipped func _isalnum_l function isprint (u_C : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:118 pragma Import (C, isprint, "isprint"); -- skipped func _isprint_l function isgraph (u_C : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:120 pragma Import (C, isgraph, "isgraph"); -- skipped func _isgraph_l function iscntrl (u_C : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:122 pragma Import (C, iscntrl, "iscntrl"); -- skipped func _iscntrl_l function toupper (u_C : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:124 pragma Import (C, toupper, "toupper"); function tolower (u_C : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:125 pragma Import (C, tolower, "tolower"); -- skipped func _tolower -- skipped func _tolower_l -- skipped func _toupper -- skipped func _toupper_l function isblank (u_C : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:136 pragma Import (C, isblank, "isblank"); function iswalpha (u_C : umingw_h.wint_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:143 pragma Import (C, iswalpha, "iswalpha"); -- skipped func _iswalpha_l function iswupper (u_C : umingw_h.wint_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:145 pragma Import (C, iswupper, "iswupper"); -- skipped func _iswupper_l function iswlower (u_C : umingw_h.wint_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:147 pragma Import (C, iswlower, "iswlower"); -- skipped func _iswlower_l function iswdigit (u_C : umingw_h.wint_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:149 pragma Import (C, iswdigit, "iswdigit"); -- skipped func _iswdigit_l function iswxdigit (u_C : umingw_h.wint_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:151 pragma Import (C, iswxdigit, "iswxdigit"); -- skipped func _iswxdigit_l function iswspace (u_C : umingw_h.wint_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:153 pragma Import (C, iswspace, "iswspace"); -- skipped func _iswspace_l function iswpunct (u_C : umingw_h.wint_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:155 pragma Import (C, iswpunct, "iswpunct"); -- skipped func _iswpunct_l function iswalnum (u_C : umingw_h.wint_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:157 pragma Import (C, iswalnum, "iswalnum"); -- skipped func _iswalnum_l function iswprint (u_C : umingw_h.wint_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:159 pragma Import (C, iswprint, "iswprint"); -- skipped func _iswprint_l function iswgraph (u_C : umingw_h.wint_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:161 pragma Import (C, iswgraph, "iswgraph"); -- skipped func _iswgraph_l function iswcntrl (u_C : umingw_h.wint_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:163 pragma Import (C, iswcntrl, "iswcntrl"); -- skipped func _iswcntrl_l function iswascii (u_C : umingw_h.wint_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:165 pragma Import (C, iswascii, "iswascii"); function isleadbyte (u_C : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:166 pragma Import (C, isleadbyte, "isleadbyte"); -- skipped func _isleadbyte_l function towupper (u_C : umingw_h.wint_t) return umingw_h.wint_t; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:168 pragma Import (C, towupper, "towupper"); -- skipped func _towupper_l function towlower (u_C : umingw_h.wint_t) return umingw_h.wint_t; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:170 pragma Import (C, towlower, "towlower"); -- skipped func _towlower_l function iswctype (u_C : umingw_h.wint_t; u_Type : umingw_h.wctype_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:172 pragma Import (C, iswctype, "iswctype"); -- skipped func _iswctype_l -- skipped func _iswcsymf_l -- skipped func _iswcsym_l function is_wctype (u_C : umingw_h.wint_t; u_Type : umingw_h.wctype_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:178 pragma Import (C, is_wctype, "is_wctype"); function iswblank (u_C : umingw_h.wint_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/ctype.h:181 pragma Import (C, iswblank, "iswblank"); end ctype_h;
{ "source": "starcoderdata", "programming_language": "ada" }
with AUnit.Assertions; with AUnit.Test_Caller; with Orka.SIMD.AVX.Doubles.Math; package body Test_SIMD_AVX_Math is use Orka; use Orka.SIMD.AVX.Doubles; use Orka.SIMD.AVX.Doubles.Math; 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 := "(SIMD - AVX - Math) "; begin Test_Suite.Add_Test (Caller.Create (Name & "Test Max function", Test_Max'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test Min function", Test_Min'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test Round_Nearest_Integer function", Test_Nearest_Integer'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test Floor function", Test_Floor'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test Ceil function", Test_Ceil'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test Round_Truncate function", Test_Truncate'Access)); return Test_Suite'Access; end Suite; procedure Test_Max (Object : in out Test) is Left : constant m256d := (0.0, 1.0, -2.0, 1.0); Right : constant m256d := (0.0, 0.0, 1.0, 2.0); Expected : constant m256d := (0.0, 1.0, 1.0, 2.0); Result : constant m256d := Max (Left, Right); begin for I in Index_Homogeneous loop Assert (Expected (I) = Result (I), "Unexpected Double at " & Index_Homogeneous'Image (I)); end loop; end Test_Max; procedure Test_Min (Object : in out Test) is Left : constant m256d := (0.0, 1.0, -2.0, 1.0); Right : constant m256d := (0.0, 0.0, 1.0, 2.0); Expected : constant m256d := (0.0, 0.0, -2.0, 1.0); Result : constant m256d := Min (Left, Right); begin for I in Index_Homogeneous loop Assert (Expected (I) = Result (I), "Unexpected Double at " & Index_Homogeneous'Image (I)); end loop; end Test_Min; procedure Test_Nearest_Integer (Object : in out Test) is Elements : constant m256d := (-1.5, 0.6, -0.4, 1.9); Expected : constant m256d := (-2.0, 1.0, 0.0, 2.0); Result : constant m256d := Round_Nearest_Integer (Elements); begin for I in Index_Homogeneous loop Assert (Expected (I) = Result (I), "Unexpected Double at " & Index_Homogeneous'Image (I)); end loop; end Test_Nearest_Integer; procedure Test_Floor (Object : in out Test) is Elements : constant m256d := (-1.5, 0.6, -0.4, 1.9); Expected : constant m256d := (-2.0, 0.0, -1.0, 1.0); Result : constant m256d := Floor (Elements); begin for I in Index_Homogeneous loop Assert (Expected (I) = Result (I), "Unexpected Double at " & Index_Homogeneous'Image (I)); end loop; end Test_Floor; procedure Test_Ceil (Object : in out Test) is Elements : constant m256d := (-1.5, 0.2, -0.4, 1.9); Expected : constant m256d := (-1.0, 1.0, 0.0, 2.0); Result : constant m256d := Ceil (Elements); begin for I in Index_Homogeneous loop Assert (Expected (I) = Result (I), "Unexpected Double at " & Index_Homogeneous'Image (I)); end loop; end Test_Ceil; procedure Test_Truncate (Object : in out Test) is Elements : constant m256d := (-1.5, 0.2, -0.4, 1.9); Expected : constant m256d := (-1.0, 0.0, 0.0, 1.0); Result : constant m256d := Round_Truncate (Elements); begin for I in Index_Homogeneous loop Assert (Expected (I) = Result (I), "Unexpected Double at " & Index_Homogeneous'Image (I)); end loop; end Test_Truncate; end Test_SIMD_AVX_Math;
{ "source": "starcoderdata", "programming_language": "ada" }
----------------------------------------------------------------------- with Interfaces; with Ada.IO_Exceptions; with Ada.Unchecked_Deallocation; package body Util.Streams.Buffered is procedure Free_Buffer is new Ada.Unchecked_Deallocation (Object => Stream_Element_Array, Name => Buffer_Access); -- ------------------------------ -- Initialize the stream to read or write on the given streams. -- An internal buffer is allocated for writing the stream. -- ------------------------------ procedure Initialize (Stream : in out Output_Buffer_Stream; Output : access Output_Stream'Class; Size : in Positive) is begin Free_Buffer (Stream.Buffer); Stream.Last := Stream_Element_Offset (Size); Stream.Buffer := new Stream_Element_Array (1 .. Stream.Last); Stream.Output := Output; Stream.Write_Pos := 1; Stream.Read_Pos := 1; Stream.No_Flush := False; end Initialize; -- ------------------------------ -- Initialize the stream to read from the string. -- ------------------------------ procedure Initialize (Stream : in out Input_Buffer_Stream; Content : in String) is begin Free_Buffer (Stream.Buffer); Stream.Last := Stream_Element_Offset (Content'Length); Stream.Buffer := new Stream_Element_Array (1 .. Content'Length); Stream.Input := null; Stream.Write_Pos := Stream.Last + 1; Stream.Read_Pos := 1; for I in Content'Range loop Stream.Buffer (Stream_Element_Offset (I - Content'First + 1)) := Character'Pos (Content (I)); end loop; end Initialize; -- ------------------------------ -- Initialize the stream with a buffer of <b>Size</b> bytes. -- ------------------------------ procedure Initialize (Stream : in out Output_Buffer_Stream; Size : in Positive) is begin Stream.Initialize (Output => null, Size => Size); Stream.No_Flush := True; Stream.Read_Pos := 1; end Initialize; -- ------------------------------ -- Initialize the stream to read or write on the given streams. -- An internal buffer is allocated for writing the stream. -- ------------------------------ procedure Initialize (Stream : in out Input_Buffer_Stream; Input : access Input_Stream'Class; Size : in Positive) is begin Free_Buffer (Stream.Buffer); Stream.Last := Stream_Element_Offset (Size); Stream.Buffer := new Stream_Element_Array (1 .. Stream.Last); Stream.Input := Input; Stream.Write_Pos := 1; Stream.Read_Pos := 1; end Initialize; -- ------------------------------ -- Initialize the stream from the buffer created for an output stream. -- ------------------------------ procedure Initialize (Stream : in out Input_Buffer_Stream; From : in out Output_Buffer_Stream'Class) is begin Free_Buffer (Stream.Buffer); Stream.Buffer := From.Buffer; From.Buffer := null; Stream.Input := null; Stream.Read_Pos := 1; Stream.Write_Pos := From.Write_Pos + 1; Stream.Last := From.Last; end Initialize; -- ------------------------------ -- Close the sink. -- ------------------------------ overriding procedure Close (Stream : in out Output_Buffer_Stream) is begin if Stream.Output /= null then Output_Buffer_Stream'Class (Stream).Flush; Stream.Output.Close; Free_Buffer (Stream.Buffer); end if; end Close; -- ------------------------------ -- Get the direct access to the buffer. -- ------------------------------ function Get_Buffer (Stream : in Output_Buffer_Stream) return Buffer_Access is begin return Stream.Buffer; end Get_Buffer; -- ------------------------------ -- Get the number of element in the stream. -- ------------------------------ function Get_Size (Stream : in Output_Buffer_Stream) return Natural is begin return Natural (Stream.Write_Pos - Stream.Read_Pos); end Get_Size; -- ------------------------------ -- Write the buffer array to the output stream. -- ------------------------------ overriding procedure Write (Stream : in out Output_Buffer_Stream; Buffer : in Ada.Streams.Stream_Element_Array) is Start : Stream_Element_Offset := Buffer'First; Pos : Stream_Element_Offset := Stream.Write_Pos; Avail : Stream_Element_Offset; Size : Stream_Element_Offset; begin while Start <= Buffer'Last loop Size := Buffer'Last - Start + 1; Avail := Stream.Last - Pos + 1; if Avail = 0 then if Stream.Output = null then raise Ada.IO_Exceptions.End_Error with "Buffer is full"; end if; Stream.Output.Write (Stream.Buffer (1 .. Pos - 1)); Stream.Write_Pos := 1; Pos := 1; Avail := Stream.Last - Pos + 1; end if; if Avail < Size then Size := Avail; end if; Stream.Buffer (Pos .. Pos + Size - 1) := Buffer (Start .. Start + Size - 1); Start := Start + Size; Pos := Pos + Size; Stream.Write_Pos := Pos; -- If we have still more data than the buffer size, flush and write -- the buffer directly. if Start < Buffer'Last and then Buffer'Last - Start > Stream.Buffer'Length then if Stream.Output = null then raise Ada.IO_Exceptions.End_Error with "Buffer is full"; end if; Stream.Output.Write (Stream.Buffer (1 .. Pos - 1)); Stream.Write_Pos := 1; Stream.Output.Write (Buffer (Start .. Buffer'Last)); return; end if; end loop; end Write; -- ------------------------------ -- Flush the stream. -- ------------------------------ overriding procedure Flush (Stream : in out Output_Buffer_Stream) is begin if not Stream.No_Flush then if Stream.Write_Pos > 1 then if Stream.Output /= null then Stream.Output.Write (Stream.Buffer (1 .. Stream.Write_Pos - 1)); end if; Stream.Write_Pos := 1; end if; if Stream.Output /= null then Stream.Output.Flush; end if; end if; end Flush; -- ------------------------------ -- Flush the buffer in the <tt>Into</tt> array and return the index of the -- last element (inclusive) in <tt>Last</tt>. -- ------------------------------ procedure Flush (Stream : in out Output_Buffer_Stream; Into : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset) is begin if Stream.Write_Pos > 1 then Into (Into'First .. Into'First + Stream.Write_Pos - 1) := Stream.Buffer (Stream.Buffer'First .. Stream.Write_Pos - 1); Stream.Write_Pos := 1; Last := Into'First + Stream.Write_Pos - 1; else Last := Into'First - 1; end if; end Flush; -- ------------------------------ -- Flush the buffer stream to the unbounded string. -- ------------------------------ procedure Flush (Stream : in out Output_Buffer_Stream; Into : out Ada.Strings.Unbounded.Unbounded_String) is begin Ada.Strings.Unbounded.Set_Unbounded_String (Into, ""); if Stream.Write_Pos > 1 then for I in 1 .. Stream.Write_Pos - 1 loop Ada.Strings.Unbounded.Append (Into, Character'Val (Stream.Buffer (I))); end loop; Stream.Write_Pos := 1; end if; end Flush; -- ------------------------------ -- Fill the buffer by reading the input stream. -- Raises Data_Error if there is no input stream; -- ------------------------------ procedure Fill (Stream : in out Input_Buffer_Stream) is begin if Stream.Input = null then Stream.Eof := True; else Stream.Input.Read (Stream.Buffer (1 .. Stream.Last - 1), Stream.Write_Pos); Stream.Eof := Stream.Write_Pos < 1; if not Stream.Eof then Stream.Write_Pos := Stream.Write_Pos + 1; end if; Stream.Read_Pos := 1; end if; end Fill; -- ------------------------------ -- Read one character from the input stream. -- ------------------------------ procedure Read (Stream : in out Input_Buffer_Stream; Char : out Character) is begin if Stream.Read_Pos >= Stream.Write_Pos then Stream.Fill; if Stream.Eof then raise Ada.IO_Exceptions.Data_Error with "End of buffer"; end if; end if; Char := Character'Val (Stream.Buffer (Stream.Read_Pos)); Stream.Read_Pos := Stream.Read_Pos + 1; end Read; procedure Read (Stream : in out Input_Buffer_Stream; Value : out Ada.Streams.Stream_Element) is begin if Stream.Read_Pos >= Stream.Write_Pos then Stream.Fill; if Stream.Eof then raise Ada.IO_Exceptions.Data_Error with "End of buffer"; end if; end if; Value := Stream.Buffer (Stream.Read_Pos); Stream.Read_Pos := Stream.Read_Pos + 1; end Read; -- ------------------------------ -- Read one character from the input stream. -- ------------------------------ procedure Read (Stream : in out Input_Buffer_Stream; Char : out Wide_Wide_Character) is use Interfaces; Val : Ada.Streams.Stream_Element; Result : Unsigned_32; begin Stream.Read (Val); -- UTF-8 conversion -- 7 U+0000 U+007F 1 0xxxxxxx if Val <= 16#7F# then Char := Wide_Wide_Character'Val (Val); -- 11 U+0080 U+07FF 2 110xxxxx 10xxxxxx elsif Val <= 16#DF# then Result := Shift_Left (Unsigned_32 (Val and 16#1F#), 6); Stream.Read (Val); Result := Result or Unsigned_32 (Val and 16#3F#); Char := Wide_Wide_Character'Val (Result); -- 16 U+0800 U+FFFF 3 1110xxxx 10xxxxxx 10xxxxxx elsif Val <= 16#EF# then Result := Shift_Left (Unsigned_32 (Val and 16#0F#), 12); Stream.Read (Val); Result := Result or Shift_Left (Unsigned_32 (Val and 16#3F#), 6); Stream.Read (Val); Result := Result or Unsigned_32 (Val and 16#3F#); Char := Wide_Wide_Character'Val (Result); -- 21 U+10000 U+1FFFFF 4 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx else Result := Shift_Left (Unsigned_32 (Val and 16#07#), 18); Stream.Read (Val); Result := Result or Shift_Left (Unsigned_32 (Val and 16#3F#), 12); Stream.Read (Val); Result := Result or Shift_Left (Unsigned_32 (Val and 16#3F#), 6); Stream.Read (Val); Result := Result or Unsigned_32 (Val and 16#3F#); Char := Wide_Wide_Character'Val (Result); end if; end Read; -- ------------------------------ -- Read into the buffer as many bytes as possible and return in -- <b>last</b> the position of the last byte read. -- ------------------------------ overriding procedure Read (Stream : in out Input_Buffer_Stream; Into : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset) is Start : Stream_Element_Offset := Into'First; Pos : Stream_Element_Offset := Stream.Read_Pos; Avail : Stream_Element_Offset; Size : Stream_Element_Offset; Total : Stream_Element_Offset := 0; begin while Start <= Into'Last loop Size := Into'Last - Start + 1; Avail := Stream.Write_Pos - Pos; if Avail = 0 then Stream.Fill; Pos := Stream.Read_Pos; Avail := Stream.Write_Pos - Pos; exit when Avail <= 0; end if; if Avail < Size then Size := Avail; end if; Into (Start .. Start + Size - 1) := Stream.Buffer (Pos .. Pos + Size - 1); Start := Start + Size; Pos := Pos + Size; Total := Total + Size; Stream.Read_Pos := Pos; end loop; Last := Total; end Read; -- ------------------------------ -- Read into the buffer as many bytes as possible and return in -- <b>last</b> the position of the last byte read. -- ------------------------------ procedure Read (Stream : in out Input_Buffer_Stream; Into : in out Ada.Strings.Unbounded.Unbounded_String) is Pos : Stream_Element_Offset := Stream.Read_Pos; Avail : Stream_Element_Offset; begin loop Avail := Stream.Write_Pos - Pos; if Avail = 0 then Stream.Fill; if Stream.Eof then return; end if; Pos := Stream.Read_Pos; Avail := Stream.Write_Pos - Pos; end if; for I in 1 .. Avail loop Ada.Strings.Unbounded.Append (Into, Character'Val (Stream.Buffer (Pos))); Pos := Pos + 1; end loop; Stream.Read_Pos := Pos; end loop; end Read; procedure Read (Stream : in out Input_Buffer_Stream; Into : in out Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String) is Pos : Stream_Element_Offset; Avail : Stream_Element_Offset; C : Wide_Wide_Character; begin loop Pos := Stream.Read_Pos; Avail := Stream.Write_Pos - Pos; if Avail = 0 then Stream.Fill; if Stream.Eof then return; end if; Pos := Stream.Read_Pos; Avail := Stream.Write_Pos - Pos; end if; Stream.Read (C); Ada.Strings.Wide_Wide_Unbounded.Append (Into, C); end loop; end Read; -- ------------------------------ -- Flush the stream and release the buffer. -- ------------------------------ overriding procedure Finalize (Stream : in out Output_Buffer_Stream) is begin if Stream.Buffer /= null then if Stream.Output /= null then Stream.Flush; end if; Free_Buffer (Stream.Buffer); end if; end Finalize; -- ------------------------------ -- Returns True if the end of the stream is reached. -- ------------------------------ function Is_Eof (Stream : in Input_Buffer_Stream) return Boolean is begin return Stream.Eof; end Is_Eof; -- ------------------------------ -- Flush the stream and release the buffer. -- ------------------------------ overriding procedure Finalize (Object : in out Input_Buffer_Stream) is begin if Object.Buffer /= null then Free_Buffer (Object.Buffer); end if; end Finalize; end Util.Streams.Buffered;
{ "source": "starcoderdata", "programming_language": "ada" }
-- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- -- SDL.Events -- -- Mapping to the underlying event handling system. -- -- WARNING!!!! -- I wanted to experiment with the event system and possibly hide all this and create an abstraction in another -- task so as to separate out the events from the main window. This could change. I really don't know yet. -------------------------------------------------------------------------------------------------------------------- with Ada.Unchecked_Conversion; package SDL.Events is pragma Preelaborate; type Event_Types is mod 2 ** 32 with Convention => C; type Button_State is (Released, Pressed) with Convention => C; for Button_State use (Released => 0, Pressed => 1); ----------------------------------------------------------------------------------------------------------------- -- Event types. ----------------------------------------------------------------------------------------------------------------- -- Handled via 'First attribute. First_Event : constant Event_Types := 16#0000_0000#; -- Application events. Quit : constant Event_Types := 16#0000_0100#; -- Mobile events. App_Terminating : constant Event_Types := Quit + 1; App_Low_Memory : constant Event_Types := Quit + 2; App_Will_Enter_Background : constant Event_Types := Quit + 3; App_Did_Enter_Background : constant Event_Types := Quit + 4; App_Will_Enter_Foreground : constant Event_Types := Quit + 5; App_Did_Enter_Foreground : constant Event_Types := Quit + 6; -- Clipboard events. Clipboard_Update : constant Event_Types := 16#0000_0900#; -- TODO: Audio hot plug events for 2.0.4 -- User events. User : constant Event_Types := 16#0000_8000#; Last_Event : constant Event_Types := 16#0000_FFFF#; type Padding_8 is mod 2 ** 8 with Convention => C, Size => 8; type Padding_16 is mod 2 ** 16 with Convention => C, Size => 16; type Time_Stamps is mod 2 ** 32 with Convention => C; type Common_Events is record Event_Type : Event_Types; Time_Stamp : Time_Stamps; end record with Convention => C; ----------------------------------------------------------------------------------------------------------------- -- TODO: Touch finger events ----------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------- -- TODO: Multi gesture events ----------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------- -- TODO: Dollar gesture events ----------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------- -- TODO: Drop events ----------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------- -- TODO: User events ----------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------- -- TODO: System window manager events ----------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------- -- TODO: Audio events - 2.0.4 ----------------------------------------------------------------------------------------------------------------- private for Common_Events use record Event_Type at 0 * SDL.Word range 0 .. 31; Time_Stamp at 1 * SDL.Word range 0 .. 31; end record; -- for Text_Editing_Events use -- record -- Event_Type at 0 * SDL.Word range 0 .. 31; -- Time_Stamp at 1 * SDL.Word range 0 .. 31; -- -- ID at 2 * SDL.Word range 0 .. 31; -- State at 3 * SDL.Word range 0 .. 7; -- Repeat at 3 * SDL.Word range 8 .. 15; -- Padding_2 at 3 * SDL.Word range 16 .. 23; -- Padding_3 at 3 * SDL.Word range 24 .. 31; -- end record; end SDL.Events;
{ "source": "starcoderdata", "programming_language": "ada" }
------------------------------------------------------------- with Program.Elements.Type_Definitions; with Program.Lexical_Elements; with Program.Elements.Definitions; package Program.Elements.Record_Types is pragma Pure (Program.Elements.Record_Types); type Record_Type is limited interface and Program.Elements.Type_Definitions.Type_Definition; type Record_Type_Access is access all Record_Type'Class with Storage_Size => 0; not overriding function Record_Definition (Self : Record_Type) return not null Program.Elements.Definitions.Definition_Access is abstract; type Record_Type_Text is limited interface; type Record_Type_Text_Access is access all Record_Type_Text'Class with Storage_Size => 0; not overriding function To_Record_Type_Text (Self : in out Record_Type) return Record_Type_Text_Access is abstract; not overriding function Abstract_Token (Self : Record_Type_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Tagged_Token (Self : Record_Type_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Limited_Token (Self : Record_Type_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Record_Types;
{ "source": "starcoderdata", "programming_language": "ada" }
-- -- This code is to be used for tutorial purposes only. -- You may not redistribute this code in any form without my express permission. --------------------------------------------------------------------------------- --with Ada.Real_Time; with Interfaces.C; with Unchecked_Conversion; with Text_Io; use Text_Io; with GL; with GLU; with GL.EXT; with Ada.Strings.Maps; with Ada.Strings.Fixed; with System; with Geometrical_Methods; with GLUtils; use type GL.GLbitfield; use type GL.EXT.glLockArraysEXTPtr; use type GL.EXT.glUnlockArraysEXTPtr; package body Example is package GM renames Geometrical_Methods; procedure PrintGLInfo is begin Put_Line("GL Vendor => " & GLUtils.GL_Vendor); Put_Line("GL Version => " & GLUtils.GL_Version); Put_Line("GL Renderer => " & GLUtils.GL_Renderer); Put_Line("GL Extensions => " & GLUtils.GL_Extensions); New_Line; Put_Line("GLU Version => " & GLUtils.GLU_Version); Put_Line("GLU Extensions => " & GLUtils.GLU_Extensions); New_Line; end PrintGLInfo; procedure PrintUsage is begin Put_Line("Keys"); Put_Line("Cursor keys => Rotate"); Put_Line("Page Down/Up => Zoom in/out"); Put_Line("F1 => Toggle Fullscreen"); Put_Line("Escape => Quit"); Put_Line("N & M/N & M + Shift => Move Dot in X"); Put_Line("O & K/O & K + Shift => Move Dot in Y"); Put_Line("D/D + Shift => Move Plane"); Put_Line("R => Reset"); end PrintUsage; procedure CalculateFPS is CurrentTime : Float := Float(SDL.Timer.GetTicks) / 1000.0; ElapsedTime : Float := CurrentTime - LastElapsedTime; FramesPerSecond : String(1 .. 10); MillisecondPerFrame : String(1 .. 10); package Float_InOut is new Text_IO.Float_IO(Float); use Float_InOut; begin FrameCount := FrameCount + 1; if ElapsedTime > 1.0 then FPS := Float(FrameCount) / ElapsedTime; Put(FramesPerSecond, FPS, Aft => 2, Exp => 0); Put(MillisecondPerFrame, 1000.0 / FPS, Aft => 2, Exp => 0); SDL.Video.WM_Set_Caption_Title(Example.GetTitle & " " & FramesPerSecond & " fps " & MillisecondPerFrame & " ms/frame"); LastElapsedTime := CurrentTime; FrameCount := 0; end if; end CalculateFPS; function Initialise return Boolean is begin GL.glClearColor(0.0, 0.0, 0.0, 0.0); -- Black Background. GL.glClearDepth(1.0); -- Depth Buffer Setup. GL.glDepthFunc(GL.GL_LEQUAL); -- The Type Of Depth Testing (Less Or Equal). GL.glEnable(GL.GL_DEPTH_TEST); -- Enable Depth Testing. GL.glShadeModel(GL.GL_SMOOTH); -- Select Smooth Shading. GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); -- Set Perspective Calculations To Most Accurate. -- GL.glFrontFace(GL.GL_CCW); -- GL.glCullFace(GL.GL_NONE); -- GL.glEnable(GL.GL_CULL_FACE); return True; end Initialise; procedure Uninitialise is begin null; end Uninitialise; -- procedure Update(Ticks : in Integer) is procedure Update is Result : Interfaces.C.int; begin -- Check the modifiers if Keys(SDL.Keysym.K_LSHIFT) = True or Keys(SDL.Keysym.K_RSHIFT) = True then ShiftPressed := True; else ShiftPressed := False; end if; if Keys(SDL.Keysym.K_LCTRL) = True or Keys(SDL.Keysym.K_RCTRL) = True then CtrlPressed := True; else CtrlPressed := False; end if; if Keys(SDL.Keysym.K_F1) = True then Result := SDL.Video.WM_ToggleFullScreen(ScreenSurface); end if; -- Move the camera. if Keys(SDL.Keysym.K_LEFT) = True then CameraYSpeed := CameraYSpeed - 0.1; end if; if Keys(SDL.Keysym.K_RIGHT) = True then CameraYSpeed := CameraYSpeed + 0.1; end if; if Keys(SDL.Keysym.K_UP) = True then CameraXSpeed := CameraXSpeed - 0.1; end if; if Keys(SDL.Keysym.K_DOWN) = True then CameraXSpeed := CameraXSpeed + 0.1; end if; if Keys(SDL.Keysym.K_PAGEUP) = True then Zoom := Zoom + 0.1; end if; if Keys(SDL.Keysym.K_PAGEDOWN) = True then Zoom := Zoom - 0.1; end if; if Keys(SDL.Keysym.K_ESCAPE) = True then AppQuit := True; end if; if Keys(SDL.Keysym.K_R) = True then TestLine.StartPoint := Vector3.Object'(-1.0, 0.0, 0.0); TestLine.EndPoint := Vector3.Object'(1.0, 0.0, 0.0); TestPlane.Distance := 0.0; end if; -- Move the dot. if Keys(SDL.Keysym.K_N) = True and NPressed = False then NPressed := True; if ShiftPressed = True then TestLine.StartPoint.X := TestLine.StartPoint.X - LineSmallDelta; TestLine.EndPoint.X := TestLine.EndPoint.X - LineSmallDelta; else TestLine.StartPoint.X := TestLine.StartPoint.X - LineDelta; TestLine.EndPoint.X := TestLine.EndPoint.X - LineDelta; end if; end if; if Keys(SDL.Keysym.K_N) = False then NPressed := False; end if; if Keys(SDL.Keysym.K_M) = True and MPressed = False then MPressed := True; if ShiftPressed = True then TestLine.StartPoint.X := TestLine.StartPoint.X + LineSmallDelta; TestLine.EndPoint.X := TestLine.EndPoint.X + LineSmallDelta; else TestLine.StartPoint.X := TestLine.StartPoint.X + LineDelta; TestLine.EndPoint.X := TestLine.EndPoint.X + LineDelta; end if; end if; if Keys(SDL.Keysym.K_M) = False then MPressed := False; end if; if Keys(SDL.Keysym.K_O) = True and OPressed = False then OPressed := True; if ShiftPressed = True then TestLine.StartPoint.Y := TestLine.StartPoint.Y + LineSmallDelta; TestLine.EndPoint.Y := TestLine.EndPoint.Y + LineSmallDelta; else TestLine.StartPoint.Y := TestLine.StartPoint.Y + LineDelta; TestLine.EndPoint.Y := TestLine.EndPoint.Y + LineDelta; end if; end if; if Keys(SDL.Keysym.K_O) = False then OPressed := False; end if; if Keys(SDL.Keysym.K_K) = True and KPressed = False then KPressed := True; if ShiftPressed = True then TestLine.StartPoint.Y := TestLine.StartPoint.Y - LineSmallDelta; TestLine.EndPoint.Y := TestLine.EndPoint.Y - LineSmallDelta; else TestLine.StartPoint.Y := TestLine.StartPoint.Y - LineDelta; TestLine.EndPoint.Y := TestLine.EndPoint.Y - LineDelta; end if; end if; if Keys(SDL.Keysym.K_K) = False then KPressed := False; end if; -- Move the plane along the normal (Distance). if Keys(SDL.Keysym.K_D) = True and DPressed = False then DPressed := True; if ShiftPressed = True then TestPlane.Distance := TestPlane.Distance - 0.5; else TestPlane.Distance := TestPlane.Distance + 0.5; end if; end if; if Keys(SDL.Keysym.K_D) = False then DPressed := False; end if; end Update; procedure Draw is Collision : Boolean := False; begin GL.glClear(GL.GL_COLOR_BUFFER_BIT or GL.GL_DEPTH_BUFFER_BIT); -- Clear Screen And Depth Buffer. GL.glLoadIdentity; -- Reset The Modelview Matrix. -- Move the camera aound the scene. GL.glTranslatef(0.0, 0.0, Zoom); GL.glRotatef(CameraXSpeed, 1.0, 0.0, 0.0); -- Rotate On The Y-Axis By angle. GL.glRotatef(CameraYSpeed, 0.0, 1.0, 0.0); -- Rotate On The Y-Axis By angle. Collision := GM.CollisionDetected(TestPlane, TestLine); -- Draw plane. GL.glBegin(GL.GL_QUADS); if Collision = True then GL.glColor3f(1.0, 0.0, 0.0); else GL.glColor3f(0.0, 0.2, 0.5); end if; --GL.glColor3f(0.0, 0.2, 0.5); GL.glVertex3f(GL.GLfloat(TestPlane.Distance), -1.0, -1.0); GL.glVertex3f(GL.GLfloat(TestPlane.Distance), 1.0, -1.0); GL.glVertex3f(GL.GLfloat(TestPlane.Distance), 1.0, 1.0); GL.glVertex3f(GL.GLfloat(TestPlane.Distance), -1.0, 1.0); GL.glNormal3f(GL.GLfloat(TestPlane.Normal.X), GL.GLfloat(TestPlane.Normal.Y), GL.GLfloat(TestPlane.Normal.Z)); gl.glEnd; GL.glBegin(GL.GL_LINES); if Collision = True then GL.glColor3f(1.0, 1.0, 0.0); else GL.glColor3f(1.0, 1.0, 1.0); end if; GL.glVertex3f(GL.GLfloat(TestLine.StartPoint.X), GL.GLfloat(TestLine.StartPoint.Y), GL.GLfloat(TestLine.StartPoint.Z)); GL.glVertex3f(GL.GLfloat(TestLine.EndPoint.X), GL.GLfloat(TestLine.EndPoint.Y), GL.GLfloat(TestLine.EndPoint.Z)); GL.glEnd; GL.glFlush; -- Flush The GL Rendering Pipeline. -- Text_IO.Put_Line("Dot: " & Vector3.Output(Dot)); end Draw; function GetTitle return String is begin return Title; end GetTitle; function GetWidth return Integer is begin return Width; end GetWidth; function GetHeight return Integer is begin return Height; end GetHeight; function GetBitsPerPixel return Integer is begin return BitsPerPixel; end GetBitsPerPixel; procedure SetLastTickCount(Ticks : in Integer) is begin LastTickCount := Ticks; end SetLastTickCount; procedure SetSurface(Surface : in SDL.Video.Surface_Ptr) is begin ScreenSurface := Surface; end SetSurface; function GetSurface return SDL.Video.Surface_Ptr is begin return ScreenSurface; end GetSurface; procedure SetKey(Key : in SDL.Keysym.Key; Down : in Boolean) is begin Keys(Key) := Down; end SetKey; procedure SetActive(Active : in Boolean) is begin AppActive := Active; end SetActive; function IsActive return Boolean is begin return AppActive; end IsActive; procedure SetQuit(Quit : in Boolean) is begin AppQuit := Quit; end SetQuit; function Quit return Boolean is begin return AppQuit; end Quit; end Example;
{ "source": "starcoderdata", "programming_language": "ada" }
with GL.Objects.Textures; with GL.Types.Colors; package GL.Objects.Samplers is pragma Preelaborate; type Sampler is new GL_Object with private; type Sampler_Array is array (Positive range <>) of Sampler; procedure Bind (Object : Sampler; Unit : Textures.Texture_Unit); procedure Bind (Objects : Sampler_Array; First_Unit : Textures.Texture_Unit); overriding procedure Initialize_Id (Object : in out Sampler); overriding procedure Delete_Id (Object : in out Sampler); overriding function Identifier (Object : Sampler) return Types.Debug.Identifier is (Types.Debug.Sampler); ----------------------------------------------------------------------------- -- Sampler Parameters -- ----------------------------------------------------------------------------- use GL.Objects.Textures; procedure Set_Minifying_Filter (Object : Sampler; Filter : Minifying_Function); procedure Set_Magnifying_Filter (Object : Sampler; Filter : Magnifying_Function); procedure Set_Minimum_LoD (Object : Sampler; Level : Double); procedure Set_Maximum_LoD (Object : Sampler; Level : Double); procedure Set_LoD_Bias (Object : Sampler; Level : Double); -- Adjust the selection of a mipmap image. A positive level will -- cause larger mipmaps to be selected. A too large bias can -- result in visual aliasing, but if the bias is small enough it -- can make the texture look a bit sharper. procedure Set_Seamless_Filtering (Object : Sampler; Enable : Boolean); -- Enable seamless cubemap filtering -- -- Texture must be a Texture_Cube_Map or Texture_Cube_Map_Array. -- -- Note: this procedure requires the ARB_seamless_cubemap_per_texture -- extension. If this extension is not available, you can enable seamless -- filtering globally via GL.Toggles. procedure Set_Max_Anisotropy (Object : Sampler; Degree : Double) with Pre => Degree >= 1.0; -- Set the maximum amount of anisotropy filtering to reduce the blurring -- of textures (caused by mipmap filtering) that are viewed at an -- oblique angle. -- -- For best results, combine the use of anisotropy filtering with -- a Linear_Mipmap_Linear minification filter and a Linear maxification -- filter. ----------------------------------------------------------------------------- function Minifying_Filter (Object : Sampler) return Minifying_Function; -- Return the minification function (default is Nearest_Mipmap_Linear) function Magnifying_Filter (Object : Sampler) return Magnifying_Function; -- Return the magnification function (default is Linear) function Minimum_LoD (Object : Sampler) return Double; -- Return the minimum LOD (default is -1000) function Maximum_LoD (Object : Sampler) return Double; -- Return the maximum LOD (default is 1000) function LoD_Bias (Object : Sampler) return Double; -- Return the LOD bias for the selection of a mipmap (default is 0.0) function Seamless_Filtering (Object : Sampler) return Boolean; -- Return whether seamless filtering is enabled for cube map -- textures (default is False) function Max_Anisotropy (Object : Sampler) return Double with Post => Max_Anisotropy'Result >= 1.0; ----------------------------------------------------------------------------- procedure Set_X_Wrapping (Object : Sampler; Mode : Wrapping_Mode); procedure Set_Y_Wrapping (Object : Sampler; Mode : Wrapping_Mode); procedure Set_Z_Wrapping (Object : Sampler; Mode : Wrapping_Mode); function X_Wrapping (Object : Sampler) return Wrapping_Mode; -- Return the wrapping mode for the X direction (default is Repeat) function Y_Wrapping (Object : Sampler) return Wrapping_Mode; -- Return the wrapping mode for the Y direction (default is Repeat) function Z_Wrapping (Object : Sampler) return Wrapping_Mode; -- Return the wrapping mode for the Z direction (default is Repeat) ----------------------------------------------------------------------------- procedure Set_Border_Color (Object : Sampler; Color : Colors.Border_Color); procedure Set_Compare_X_To_Texture (Object : Sampler; Enabled : Boolean); procedure Set_Compare_Function (Object : Sampler; Func : Compare_Function); function Border_Color (Object : Sampler) return Colors.Border_Color; function Compare_X_To_Texture_Enabled (Object : Sampler) return Boolean; -- Return whether to enable comparing (default is False) function Current_Compare_Function (Object : Sampler) return Compare_Function; -- Return the comparison function (default is LEqual) private type Sampler is new GL_Object with null record; end GL.Objects.Samplers;
{ "source": "starcoderdata", "programming_language": "ada" }
package body System.Storage_Pools.Subpools.Unbounded is type Unbounded_Subpool_Access is access all Unbounded_Subpool; -- implementation overriding function Create_Subpool ( Pool : in out Unbounded_Pool_With_Subpools) return not null Subpool_Handle is Subpool : constant not null Unbounded_Subpool_Access := new Unbounded_Subpool; begin Unbounded_Allocators.Initialize (Subpool.Allocator); declare Result : constant not null Subpool_Handle := Subpool_Handle (Subpool); begin Set_Pool_Of_Subpool (Result, Pool); return Result; end; end Create_Subpool; overriding procedure Allocate_From_Subpool ( Pool : in out Unbounded_Pool_With_Subpools; Storage_Address : out Address; Size_In_Storage_Elements : Storage_Elements.Storage_Count; Alignment : Storage_Elements.Storage_Count; Subpool : not null Subpool_Handle) is pragma Unreferenced (Pool); begin Unbounded_Allocators.Allocate ( Unbounded_Subpool_Access (Subpool).Allocator, Storage_Address => Storage_Address, Size_In_Storage_Elements => Size_In_Storage_Elements, Alignment => Alignment); end Allocate_From_Subpool; overriding procedure Deallocate_Subpool ( Pool : in out Unbounded_Pool_With_Subpools; Subpool : in out Subpool_Handle) is pragma Unreferenced (Pool); begin Unbounded_Allocators.Finalize ( Unbounded_Subpool_Access (Subpool).Allocator); end Deallocate_Subpool; overriding procedure Deallocate ( Pool : in out Unbounded_Pool_With_Subpools; Storage_Address : Address; Size_In_Storage_Elements : Storage_Elements.Storage_Count; Alignment : Storage_Elements.Storage_Count) is pragma Unreferenced (Pool); begin Unbounded_Allocators.Deallocate ( Unbounded_Allocators.Allocator_Of (Storage_Address), Storage_Address => Storage_Address, Size_In_Storage_Elements => Size_In_Storage_Elements, Alignment => Alignment); end Deallocate; end System.Storage_Pools.Subpools.Unbounded;
{ "source": "starcoderdata", "programming_language": "ada" }
with openGL.Primitive.indexed; package body openGL.Model.line.colored is --------- --- Forge -- function to_line_Model (Color : in openGL.Color; End_1, End_2 : in Vector_3 := Origin_3D) return Item is Self : Item; begin Self.Color := +Color; Self.Vertices (1).Site := End_1; Self.Vertices (2).Site := End_2; Self.set_Bounds; return Self; end to_line_Model; function new_line_Model (Color : in openGL.Color; End_1, End_2 : in Vector_3 := Origin_3D) return View is begin return new Item' (to_line_Model (Color, End_1, End_2)); end new_line_Model; -------------- --- Attributes -- overriding function to_GL_Geometries (Self : access Item; Textures : access Texture.name_Map_of_texture'Class; Fonts : in Font.font_id_Map_of_font) return Geometry.views is pragma unreferenced (Textures, Fonts); use Geometry.colored; indices_Count : constant long_Index_t := 2; the_Indices : aliased Indices := (1 .. indices_Count => <>); the_Primitive : Primitive.indexed.view; begin if Self.Geometry = null then Self.Geometry := Geometry.colored.new_Geometry; end if; set_Sites: begin Self.Vertices (1).Color := (Primary => Self.Color, Alpha => opaque_Value); Self.Vertices (2).Color := (Primary => Self.Color, Alpha => opaque_Value); end set_Sites; the_Indices := (1, 2); Self.Geometry.is_Transparent (False); Self.Geometry.Vertices_are (Self.Vertices); the_Primitive := Primitive.indexed.new_Primitive (Primitive.Lines, the_Indices); Self.Geometry.add (Primitive.view (the_Primitive)); return (1 => Self.Geometry); end to_GL_Geometries; function Site (Self : in Item; for_End : in end_Id) return Vector_3 is begin return Self.Vertices (for_End).Site; end Site; procedure Site_is (Self : in out Item; Now : in Vector_3; for_End : in end_Id) is use Geometry.colored; begin Self.Vertices (for_End).Site := Now; Self.Geometry.Vertices_are (Self.Vertices); Self.set_Bounds; end Site_is; end openGL.Model.line.colored;
{ "source": "starcoderdata", "programming_language": "ada" }
package body UxAS.Comms.Transport.Receiver is ------------------------------ -- Add_Subscription_Address -- ------------------------------ procedure Add_Subscription_Address (This : in out Transport_Receiver_Base; Address : String; Result : out Boolean) is Target : constant Subscription_Address := Instance (Subscription_Address_Max_Length, Address); use Subscription_Addresses; -- a hashed map C : Cursor; begin C := Find (This.Subscriptions, Target); if C = No_Element then -- didn't find it Insert (This.Subscriptions, Target); Add_Subscription_Address_To_Socket (Transport_Receiver_Base'Class (This), Address, Result); -- dispatching end if; end Add_Subscription_Address; --------------------------------- -- Remove_Subscription_Address -- --------------------------------- procedure Remove_Subscription_Address (This : in out Transport_Receiver_Base; Address : String; Result : out Boolean) is Target : constant Subscription_Address := Instance (Subscription_Address_Max_Length, Address); use Subscription_Addresses; -- a hashed map C : Cursor; begin C := Find (This.Subscriptions, Target); if C /= No_Element then -- found it Delete (This.Subscriptions, C); Remove_Subscription_Address_From_Socket (Transport_Receiver_Base'Class (This), Address, Result); -- dispatching end if; end Remove_Subscription_Address; --------------------------------------- -- Remove_All_Subscription_Addresses -- --------------------------------------- procedure Remove_All_Subscription_Addresses (This : in out Transport_Receiver_Base; Result : out Boolean) is begin for Target of This.Subscriptions loop Remove_Subscription_Address_From_Socket (Transport_Receiver_Base'Class (This), Value (Target), Result); -- dispatching end loop; Subscription_Addresses.Clear (This.Subscriptions); Result := Subscription_Addresses.Is_Empty (This.Subscriptions); end Remove_All_Subscription_Addresses; end UxAS.Comms.Transport.Receiver;
{ "source": "starcoderdata", "programming_language": "ada" }
-- The Village of Vampire by YT, このソースコードはNYSLです with Ada.Strings.Unbounded; procedure Vampire.R3.User_Page ( Output : not null access Ada.Streams.Root_Stream_Type'Class; Form : in Forms.Root_Form_Type'Class; Template : in String; Summaries : in Tabula.Villages.Lists.Summary_Maps.Map; User_Id : in String; User_Password : in String; User_Info : in Users.User_Info) is use type Ada.Strings.Unbounded.Unbounded_String; use type Tabula.Villages.Village_State; -- ユーザーの参加状況 Joined : aliased Ada.Strings.Unbounded.Unbounded_String; Created : aliased Ada.Strings.Unbounded.Unbounded_String; begin for I in Summaries.Iterate loop declare V : Tabula.Villages.Lists.Village_Summary renames Summaries.Constant_Reference (I); begin if V.State < Tabula.Villages.Epilogue then for J in V.People.Iterate loop if V.People.Constant_Reference (J) = User_Id then if not Joined.Is_Null then Ada.Strings.Unbounded.Append(Joined, "、"); end if; Ada.Strings.Unbounded.Append(Joined, V.Name); end if; end loop; if V.By = User_Id then Created := V.Name; end if; end if; end; end loop; declare procedure Handle ( Output : not null access Ada.Streams.Root_Stream_Type'Class; Tag : in String; Contents : in Web.Producers.Template) is begin if Tag = "action_page" then Forms.Write_Attribute_Name (Output, "action"); Forms.Write_Link ( Output, Form, Current_Directory => ".", Resource => Forms.Self, Parameters => Form.Parameters_To_User_Page ( User_Id => User_Id, User_Password => <PASSWORD>)); elsif Tag = "userpanel" then Handle_User_Panel ( Output, Contents, Form, User_Id => User_Id, User_Password => <PASSWORD>); elsif Tag = "id" then Forms.Write_In_HTML (Output, Form, User_Id); elsif Tag = "joined" then if not Joined.Is_Null then declare procedure Handle ( Output : not null access Ada.Streams.Root_Stream_Type'Class; Tag : in String; Contents : in Web.Producers.Template) is begin if Tag = "activevillage" then Forms.Write_In_HTML (Output, Form, Joined.Constant_Reference); else Raise_Unknown_Tag (Tag); end if; end Handle; begin Web.Producers.Produce(Output, Contents, Handler => Handle'Access); end; end if; elsif Tag = "nojoined" then if Joined.Is_Null then Web.Producers.Produce(Output, Contents); end if; elsif Tag = "created" then if not Created.Is_Null then declare procedure Handle ( Output : not null access Ada.Streams.Root_Stream_Type'Class; Tag : in String; Contents : in Web.Producers.Template) is begin if Tag = "createdvillage" then Forms.Write_In_HTML (Output, Form, Created.Constant_Reference); else Raise_Unknown_Tag (Tag); end if; end Handle; begin Web.Producers.Produce(Output, Contents, Handler => Handle'Access); end; end if; elsif Tag = "creatable" then if Joined.Is_Null and then Created.Is_Null then Web.Producers.Produce(Output, Contents, Handler => Handle'Access); -- rec end if; elsif Tag = "href_index" then Forms.Write_Attribute_Name (Output, "href"); Forms.Write_Link ( Output, Form, Current_Directory => ".", Resource => Forms.Self, Parameters => Form.Parameters_To_Index_Page ( User_Id => User_Id, User_Password => <PASSWORD>)); else Raise_Unknown_Tag (Tag); end if; end Handle; begin Web.Producers.Produce (Output, Read (Template), Handler => Handle'Access); end; end Vampire.R3.User_Page;
{ "source": "starcoderdata", "programming_language": "ada" }
-- COPYING. If not, write to the Free Software Foundation, 51 Franklin -- -- Street, Fifth Floor, Boston, MA 02110-1301, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by AdaCore -- -- (http://www.adacore.com). -- -- -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 14 package Asis.Iterator ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ package Asis.Iterator is ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Asis.Iterator encapsulates the generic procedure Traverse_Element which -- allows an ASIS application to perform an iterative traversal of a -- logical syntax tree. It requires the use of two generic procedures, -- Pre_Operation, which identifies processing for the traversal, and -- Post_Operation, which identifies processing after the traversal. -- The State_Information allows processing state to be passed during the -- iteration of Traverse_Element. -- -- Package Asis.Iterator is established as a child package to highlight the -- iteration capability and to facilitate the translation of ASIS to IDL. ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 14.1 procedure Traverse_Element ------------------------------------------------------------------------------ generic type State_Information is limited private; with procedure Pre_Operation (Element : Asis.Element; Control : in out Traverse_Control; State : in out State_Information) is <>; with procedure Post_Operation (Element : Asis.Element; Control : in out Traverse_Control; State : in out State_Information) is <>; procedure Traverse_Element (Element : Asis.Element; Control : in out Traverse_Control; State : in out State_Information); ------------------------------------------------------------------------------ -- Element - Specifies the initial element in the traversal -- Control - Specifies what next to do with the traversal -- State_Information - Specifies other information for the traversal -- -- Traverses the element and all its component elements, if any. -- Component elements are all elements that can be obtained by a combination -- of the ASIS structural queries appropriate for the given element. -- -- If an element has one or more component elements, each is called a child -- element. An element's parent element is its Enclosing_Element. Children -- with the same parent are sibling elements. The type Traverse_Control uses -- the terms children and siblings to control the traverse. -- -- For each element, the formal procedure Pre_Operation is called when first -- visiting the element. Each of that element's children are then visited -- and finally the formal procedure Post_Operation is called for the element. -- -- The order of Element traversal is in terms of the textual representation of -- the Elements. Elements are traversed in left-to-right and top-to-bottom -- order. -- -- Traversal of Implicit Elements: -- -- Implicit elements are not traversed by default. However, they may be -- explicitly queried and then passed to the traversal instance. Implicit -- elements include implicit predefined operator declarations, implicit -- inherited subprogram declarations, implicit expanded generic specifications -- and bodies, default expressions supplied to procedure, function, and entry -- calls, etc. -- -- Applications that wish to traverse these implicit Elements shall query for -- them at the appropriate places in a traversal and then recursively call -- their instantiation of the traversal generic. (Implicit elements provided -- by ASIS do not cover all possible Ada implicit constructs. For example, -- implicit initializations for variables of an access type are not provided -- by ASIS.) -- -- Traversal of Association lists: -- -- Argument and association lists for procedure calls, function calls, entry -- calls, generic instantiations, and aggregates are traversed in their -- unnormalized forms, as if the Normalized parameter was False for those -- queries. Implementations that always normalize certain associations may -- return Is_Normalized associations. See the Implementation Permissions -- for the queries Discriminant_Associations, Generic_Actual_Part, -- Call_Statement_Parameters, Record_Component_Associations, or -- Function_Call_Parameters. -- -- Applications that wish to explicitly traverse normalized associations can -- do so by querying the appropriate locations in order to obtain the -- normalized list. The list can then be traversed by recursively calling -- the traverse instance. Once that sub-traversal is finished, the Control -- parameter can be set to Abandon_Children to skip processing of the -- unnormalized argument list. -- -- Traversal can be controlled with the Control parameter. -- -- A call to an instance of Traverse_Element will not result in calls to -- Pre_Operation or Post_Operation unless Control is set to Continue. -- -- The subprograms matching Pre_Operation and Post_Operation can set -- their Control parameter to affect the traverse: -- -- Continue -- Continues the normal depth-first traversal. -- -- Abandon_Children -- Prevents traversal of the current element's -- -- children. -- -- If set in a Pre_Operation, traversal picks up -- -- with the next sibling element of the current -- -- element. -- -- If set in a Post_Operation, this is the -- -- same as Continue, all children will already -- -- have been traversed. Traversal picks up with -- -- the Post_Operation of the parent. -- -- Abandon_Siblings -- Prevents traversal of the current element's -- -- children and remaining siblings. -- -- If set in a Pre_Operation, this abandons the -- -- associated Post_Operation for the current -- -- element. Traversal picks up with the -- -- Post_Operation of the parent. -- -- If set in a Post_Operation, traversal picks -- -- up with the Post_Operation of the parent. -- -- Terminate_Immediately -- Does exactly that. -- -- Raises ASIS_Inappropriate_Element if the element is a Nil_Element ------------------------------------------------------------------------------ end Asis.Iterator;
{ "source": "starcoderdata", "programming_language": "ada" }
--------------------------------------------------------------------------- package body Chebychev_Quadrature is Pii : constant := 3.14159_26535_89793_23846_26433_83279_50288_41971_694; Gauss_Root : Gauss_Values := (others => 0.0); Gauss_Weight : Gauss_Values := (others => 0.0); -- Arrays initialized after the "begin" below. --------------------------- -- Construct_Gauss_Roots -- --------------------------- procedure Construct_Gauss_Roots is Factor : constant Real := Pii / Real (Gauss_Index'Last); begin for i in Gauss_Index loop Gauss_Root (i) := -Cos (Factor * (Real (i) - 0.5)); end loop; end Construct_Gauss_Roots; ----------------------------- -- Construct_Gauss_Weights -- ----------------------------- procedure Construct_Gauss_Weights is Factor : constant Real := Pii / Real (Gauss_Index'Last); begin for i in Gauss_Index loop Gauss_Weight (i) := 0.5 * Factor * Abs (Sin (Factor * (Real (i) - 0.5))); end loop; end Construct_Gauss_Weights; ---------------------- -- Find_Gauss_Nodes -- ---------------------- procedure Find_Gauss_Nodes (X_Starting : in Real; X_Final : in Real; X_gauss : out Gauss_Values) is Half_Delta_X : constant Real := (X_Final - X_Starting) * 0.5; X_Center : constant Real := X_Starting + Half_Delta_X; begin for i in Gauss_Index loop X_gauss(i) := X_Center + Gauss_Root(i) * Half_Delta_X; end loop; end Find_Gauss_Nodes; ------------------ -- Get_Integral -- ------------------ procedure Get_Integral (F_val : in Function_Values; X_Starting : in Real; X_Final : in Real; Area : out Real) is Sum : Real; Delta_X : constant Real := (X_Final - X_Starting); begin Area := 0.0; Sum := 0.0; for i in Gauss_Index loop Sum := Sum + Gauss_Weight (i) * F_val (i); end loop; Area := Sum * Delta_X; end Get_Integral; begin Construct_Gauss_Roots; Construct_Gauss_Weights; end Chebychev_Quadrature;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Float_Text_IO; with Ada.IO_Exceptions; package body SI_Units.Binary is function Prefix (S : in Prefixes) return String is (case S is when None => "", when kibi => "Ki", when mebi => "Mi", when gibi => "Gi", when tebi => "Ti", when pebi => "Pi", when exbi => "Ei", when zebi => "Zi", when yobi => "Yi") with Inline => True; function Image (Value : in Item; Aft : in Ada.Text_IO.Field := Default_Aft) return String is Result : String (1 .. 5 + Ada.Text_IO.Field'Max (1, Aft)); -- "1023.[...]"; Temp : Float := Float (Value); Scale : Prefixes := None; begin if Unit /= No_Unit then -- No prefix matching if no unit name is given. while Temp >= Magnitude loop Scale := Prefixes'Succ (Scale); Temp := Temp / Magnitude; end loop; end if; Try_Numeric_To_String_Conversion : begin Ada.Float_Text_IO.Put (To => Result, Item => Temp, Aft => Aft, Exp => 0); exception when Ada.IO_Exceptions.Layout_Error => -- Value was larger than 9999 Yi<units> and didn't fit into the -- string. -- Reset Scale and return "inf"inity instead. Result (1 .. 4) := "+inf"; Result (5 .. Result'Last) := (others => ' '); end Try_Numeric_To_String_Conversion; return Trim (Result & (if Unit = No_Unit then "" else No_Break_Space & Prefix (Scale) & Unit)); end Image; end SI_Units.Binary;
{ "source": "starcoderdata", "programming_language": "ada" }
-- with Ada.Finalization; generic type Element_Type is private; package Ahven.SList is type List is new Ada.Finalization.Controlled with private; type Cursor is private; subtype Count_Type is Natural; Invalid_Cursor : exception; List_Full : exception; -- Thrown when the size of the list exceeds Count_Type'Last. Empty_List : constant List; procedure Append (Target : in out List; Node_Data : Element_Type); -- Append an element at the end of the list. -- -- Raises List_Full if the list has already Count_Type'Last items. procedure Clear (Target : in out List); -- Remove all elements from the list. function First (Target : List) return Cursor; -- Return a cursor to the first element of the list. function Next (Position : Cursor) return Cursor; -- Move the cursor to point to the next element on the list. function Data (Position : Cursor) return Element_Type; -- Return element pointed by the cursor. function Is_Valid (Position : Cursor) return Boolean; -- Tell the validity of the cursor. The cursor -- will become invalid when you iterate it over -- the last item. function Length (Target : List) return Count_Type; -- Return the length of the list. generic with procedure Action (T : in out Element_Type) is <>; procedure For_Each (Target : List); -- A generic procedure for walk through every item -- in the list and call Action procedure for them. private type Node; type Node_Access is access Node; type Cursor is new Node_Access; procedure Remove (Ptr : Node_Access); -- A procedure to release memory pointed by Ptr. type Node is record Next : Node_Access := null; Data : Element_Type; end record; type List is new Ada.Finalization.Controlled with record First : Node_Access := null; Last : Node_Access := null; Size : Count_Type := 0; end record; procedure Initialize (Target : in out List); procedure Finalize (Target : in out List); procedure Adjust (Target : in out List); Empty_List : constant List := (Ada.Finalization.Controlled with First => null, Last => null, Size => 0); end Ahven.SList;
{ "source": "starcoderdata", "programming_language": "ada" }
with GESTE; with GESTE.Sprite; with GESTE.Tile_Bank; with Ada.Text_IO; with Console_Char_Screen; with Ada.Exceptions; procedure Layer_Priority is use type GESTE.Pix_Point; package Console_Screen is new Console_Char_Screen (Width => 9, Height => 9, Buffer_Size => 256, Init_Char => ' '); Palette : aliased constant GESTE.Palette_Type := ('1', '2', '3', '4'); Background : Character := '-'; Tiles : aliased constant GESTE.Tile_Array := (1 => ((1, 1, 1, 1, 1), (1, 1, 1, 1, 1), (1, 1, 1, 1, 1), (1, 1, 1, 1, 1), (1, 1, 1, 1, 1)), 2 => ((2, 2, 2, 2, 2), (2, 2, 2, 2, 2), (2, 2, 2, 2, 2), (2, 2, 2, 2, 2), (2, 2, 2, 2, 2)), 3 => ((3, 3, 3, 3, 3), (3, 3, 3, 3, 3), (3, 3, 3, 3, 3), (3, 3, 3, 3, 3), (3, 3, 3, 3, 3)), 4 => ((4, 4, 4, 4, 4), (4, 4, 4, 4, 4), (4, 4, 4, 4, 4), (4, 4, 4, 4, 4), (4, 4, 4, 4, 4)) ); Bank : aliased GESTE.Tile_Bank.Instance (Tiles'Unrestricted_Access, GESTE.No_Collisions, Palette'Unrestricted_Access); Sprite_1 : aliased GESTE.Sprite.Instance (Bank => Bank'Unrestricted_Access, Init_Frame => 1); Sprite_2 : aliased GESTE.Sprite.Instance (Bank => Bank'Unrestricted_Access, Init_Frame => 2); Sprite_3 : aliased GESTE.Sprite.Instance (Bank => Bank'Unrestricted_Access, Init_Frame => 3); Sprite_4 : aliased GESTE.Sprite.Instance (Bank => Bank'Unrestricted_Access, Init_Frame => 4); procedure Update is begin GESTE.Render_Window (Window => Console_Screen.Screen_Rect, Background => Background, Buffer => Console_Screen.Buffer, Push_Pixels => Console_Screen.Push_Pixels'Unrestricted_Access, Set_Drawing_Area => Console_Screen.Set_Drawing_Area'Unrestricted_Access); Console_Screen.Print; end Update; begin Console_Screen.Verbose; Sprite_3.Move ((3, 3)); GESTE.Add (Sprite_3'Unrestricted_Access, 3); -- Insert head on empty list Sprite_4.Move ((4, 4)); GESTE.Add (Sprite_4'Unrestricted_Access, 4); -- Insert head on non empty list Sprite_1.Move ((1, 1)); GESTE.Add (Sprite_1'Unrestricted_Access, 1); -- Insert tail Sprite_2.Move ((2, 2)); GESTE.Add (Sprite_2'Unrestricted_Access, 2); -- Insert mid Update; GESTE.Remove (Sprite_2'Unrestricted_Access); -- Remove mid Update; GESTE.Remove (Sprite_1'Unrestricted_Access); -- Remove tail Update; GESTE.Remove (Sprite_4'Unrestricted_Access); -- Remove head on non empty list Update; GESTE.Remove (Sprite_3'Unrestricted_Access); -- Remove head on empty list Update; declare begin -- Remove a layer not in the list GESTE.Remove (Sprite_3'Unrestricted_Access); exception when E : Program_Error => Ada.Text_IO.Put_Line ("Exception:" & Ada.Exceptions.Exception_Message (E)); end; end Layer_Priority;
{ "source": "starcoderdata", "programming_language": "ada" }
Gtk.About_Dialog.Set_Program_Name (V_Dialog, "BingAda"); Gtk.About_Dialog.Set_Version (V_Dialog, "0.9 Beta"); if Gtk.About_Dialog.Run (V_Dialog) /= Gtk.Dialog.Gtk_Response_Close then -- Dialog was destroyed by user, not closed through Close button null; end if; Gtk.About_Dialog.Destroy (V_Dialog); --GTK.ABOUT_DIALOG.ON_ACTIVATE_LINK (V_DIALOG,P_ON_ACTIVATE_LINK'Access); --GTK.ABOUT_DIALOG.DESTROY (V_DIALOG); end P_Show_Window; --================================================================== end Q_Bingo_Help;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Text_Io; use Ada.Text_Io; with Ada.Integer_Text_Io; use Ada.Integer_Text_Io; with Nt_Console; use Nt_console; with conecta4; use conecta4; procedure imprimir_tablero (Tablero: in T_Tablero) is -- Solo para poder imprimir package P_Celda_IO is new Enumeration_IO(T_Celda); use P_Celda_IO; begin Clear_Screen; new_line; Put_Line(" El estado del tablero es:"); New_Line; -- Imprimimos indicadores para identificar mejor las columnas Set_Foreground(Light_Green); put(" "); for Indicador in 1..Max_Columnas loop put(Indicador, width=>3); put(" "); end loop; Set_Foreground; new_line; -- Imprimimos el estado actual del tablero for Fila in 1..Max_Filas loop put(" "); for Columna in 1..Max_Columnas loop if (Tablero(Fila,Columna)=Azul) then Set_Foreground(Light_Blue); elsif (Tablero(Fila,Columna)=Rojo) then Set_Foreground(Light_Red); end if; Put(Tablero(Fila,Columna)); Put(" "); Set_Foreground; end loop; New_Line; end loop; end imprimir_tablero;
{ "source": "starcoderdata", "programming_language": "ada" }
----------------------------------------------------------------------- with Ada.Calendar; with AWA.Modules.Beans; with AWA.Modules.Get; with AWA.Permissions; with AWA.Comments.Models; with Util.Log.Loggers; with Jason.Tickets.Beans; with ADO.Sessions; with AWA.Services.Contexts; with ADO.Sessions.Entities; package body Jason.Tickets.Modules is use type ADO.Identifier; package ASC renames AWA.Services.Contexts; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Jason.Tickets.Module"); package Register is new AWA.Modules.Beans (Module => Ticket_Module, Module_Access => Ticket_Module_Access); -- ------------------------------ -- Initialize the tickets module. -- ------------------------------ overriding procedure Initialize (Plugin : in out Ticket_Module; App : in AWA.Modules.Application_Access; Props : in ASF.Applications.Config) is begin Log.Info ("Initializing the tickets module"); -- Register here any bean class, servlet, filter. Register.Register (Plugin => Plugin, Name => "Jason.Tickets.Beans.Ticket_Bean", Handler => Jason.Tickets.Beans.Create_Ticket_Bean'Access); Register.Register (Plugin => Plugin, Name => "Jason.Tickets.Beans.Ticket_List_Bean", Handler => Jason.Tickets.Beans.Create_Ticket_List_Bean'Access); Register.Register (Plugin => Plugin, Name => "Jason.Tickets.Beans.Ticket_Status_List_Bean", Handler => Jason.Tickets.Beans.Create_Status_List'Access); Register.Register (Plugin => Plugin, Name => "Jason.Tickets.Beans.Ticket_Type_List_Bean", Handler => Jason.Tickets.Beans.Create_Type_List'Access); Register.Register (Plugin => Plugin, Name => "Jason.Tickets.Beans.Ticket_Report_Bean", Handler => Jason.Tickets.Beans.Create_Ticket_Report_Bean'Access); AWA.Modules.Module (Plugin).Initialize (App, Props); -- Add here the creation of manager instances. end Initialize; -- ------------------------------ -- Get the tickets module. -- ------------------------------ function Get_Ticket_Module return Ticket_Module_Access is function Get is new AWA.Modules.Get (Ticket_Module, Ticket_Module_Access, NAME); begin return Get; end Get_Ticket_Module; -- ------------------------------ -- Load the ticket. -- ------------------------------ procedure Load_Ticket (Model : in Ticket_Module; Ticket : in out Jason.Tickets.Models.Ticket_Ref'Class; Project : in out Jason.Projects.Models.Project_Ref'Class; Tags : in out AWA.Tags.Beans.Tag_List_Bean; Id : in ADO.Identifier) is DB : ADO.Sessions.Session := Model.Get_Session; Found : Boolean; begin if Id /= ADO.NO_IDENTIFIER then Ticket.Load (DB, Id, Found); if Found then Project.Load (DB, Ticket.Get_Project.Get_Id, Found); end if; else Project.Load (DB, Project.Get_Id, Found); end if; -- Jason.Projects.Models.Project_Ref (Project) := ; -- Ticket.Get_Project.Copy (Projects.Models.Project_Ref (Project)); if Id /= ADO.NO_IDENTIFIER and Found then Tags.Load_Tags (DB, Id); end if; end Load_Ticket; -- ------------------------------ -- Create -- ------------------------------ procedure Create (Model : in Ticket_Module; Entity : in out Jason.Tickets.Models.Ticket_Ref'Class; Project_Id : in ADO.Identifier) is pragma Unreferenced (Model); Ctx : constant ASC.Service_Context_Access := ASC.Current; DB : ADO.Sessions.Master_Session := ASC.Get_Master_Session (Ctx); User : constant ADO.Identifier := Ctx.Get_User_Identifier; Project : Jason.Projects.Models.Project_Ref; begin -- Check that the user has the create ticket permission on the given project. AWA.Permissions.Check (Permission => ACL_Create_Tickets.Permission, Entity => Project_Id); Ctx.Start; Project.Load (DB, Project_Id); Project.Set_Last_Ticket (Project.Get_Last_Ticket + 1); Entity.Set_Create_Date (Ada.Calendar.Clock); Entity.Set_Status (Jason.Tickets.Models.OPEN); Entity.Set_Creator (Ctx.Get_User); Entity.Set_Project (Project); Entity.Set_Ident (Project.Get_Last_Ticket); Entity.Save (DB); Project.Save (DB); Ctx.Commit; Log.Info ("Ticket {0} created for user {1}", ADO.Identifier'Image (Entity.Get_Id), ADO.Identifier'Image (User)); end Create; -- ------------------------------ -- Save -- ------------------------------ procedure Save (Model : in Ticket_Module; Entity : in out Jason.Tickets.Models.Ticket_Ref'Class; Comment : in String) is pragma Unreferenced (Model); Ctx : constant ASC.Service_Context_Access := ASC.Current; DB : ADO.Sessions.Master_Session := ASC.Get_Master_Session (Ctx); Cmt : AWA.Comments.Models.Comment_Ref; Now : constant Ada.Calendar.Time := Ada.Calendar.Clock; begin -- Check that the user has the update ticket permission on the given ticket. AWA.Permissions.Check (Permission => ACL_Update_Tickets.Permission, Entity => Entity); Ctx.Start; Entity.Set_Update_Date (Now); if Comment'Length > 0 then Cmt.Set_Author (Ctx.Get_User); Cmt.Set_Create_Date (Now); Cmt.Set_Message (Comment); Cmt.Set_Entity_Id (Entity.Get_Id); Cmt.Set_Entity_Type (ADO.Sessions.Entities.Find_Entity_Type (DB, Models.TICKET_TABLE)); Cmt.Save (DB); end if; Entity.Save (DB); Ctx.Commit; end Save; end Jason.Tickets.Modules;
{ "source": "starcoderdata", "programming_language": "ada" }
with CSS.Parser.Parser_Goto; with CSS.Parser.Parser_Tokens; with CSS.Parser.Parser_Shift_Reduce; with CSS.Parser.Lexer_io; with CSS.Parser.Lexer; with CSS.Parser.Lexer_dfa; with CSS.Core.Selectors; with CSS.Core.Styles; with CSS.Core.Medias; with Ada.Text_IO; package body CSS.Parser.Parser is use Ada; use CSS.Parser.Lexer; use CSS.Core.Selectors; use CSS.Parser.Lexer_dfa; procedure YYParse; procedure yyerror (Message : in String := "syntax error"); Document : CSS.Core.Sheets.CSSStylesheet_Access; Current_Page : CSS.Core.Styles.CSSPageRule_Access; Current_Rule : CSS.Core.Styles.CSSStyleRule_Access; Current_Media : CSS.Core.Medias.CSSMediaRule_Access; procedure yyerror (Message : in String := "syntax error") is begin Error_Count := Error_Count + 1; Error (CSS.Parser.Lexer_Dfa.yylineno, CSS.Parser.Lexer_Dfa.yylinecol, Message); end yyerror; function Parse (Content : in String; Document : in CSS.Core.Sheets.CSSStylesheet_Access) return Integer is begin Error_Count := 0; CSS.Parser.Lexer_Dfa.yylineno := 1; CSS.Parser.Lexer_Dfa.yylinecol := 1; CSS.Parser.Lexer_IO.Open_Input (Content); CSS.Parser.Parser.Document := Document; Current_Rule := null; Current_Media := null; Current_Page := null; YYParse; Current_Rule := null; Current_Media := null; Current_Page := null; CSS.Parser.Parser.Document := null; CSS.Parser.Lexer_IO.Close_Input; Parser_Tokens.yylval := EMPTY; return Error_Count; exception when others => CSS.Parser.Parser.Document := null; CSS.Parser.Lexer_IO.Close_Input; Parser_Tokens.yylval := EMPTY; raise; end Parse; -- Warning: This file is automatically generated by AYACC. -- It is useless to modify it. Change the ".Y" & ".L" files instead. procedure YYParse is -- Rename User Defined Packages to Internal Names. package yy_goto_tables renames CSS.Parser.Parser_Goto; package yy_shift_reduce_tables renames CSS.Parser.Parser_Shift_Reduce; package yy_tokens renames CSS.Parser.Parser_Tokens; use yy_tokens, yy_goto_tables, yy_shift_reduce_tables; procedure yyerrok; procedure yyclearin; procedure handle_error; subtype goto_row is yy_goto_tables.Row; subtype reduce_row is yy_shift_reduce_tables.Row; package yy is -- the size of the value and state stacks -- Affects error 'Stack size exceeded on state_stack' stack_size : constant Natural := 256; -- subtype rule is Natural; subtype parse_state is Natural; -- subtype nonterminal is Integer; -- encryption constants default : constant := -1; first_shift_entry : constant := 0; accept_code : constant := -3001; error_code : constant := -3000; -- stack data used by the parser tos : Natural := 0; value_stack : array (0 .. stack_size) of yy_tokens.YYSType; state_stack : array (0 .. stack_size) of parse_state; -- current input symbol and action the parser is on action : Integer; rule_id : Rule; input_symbol : yy_tokens.Token := Error; -- error recovery flag error_flag : Natural := 0; -- indicates 3 - (number of valid shifts after an error occurs) look_ahead : Boolean := True; index : reduce_row; -- Is Debugging option on or off debug : constant Boolean := False; end yy; procedure shift_debug (state_id : yy.parse_state; lexeme : yy_tokens.Token); procedure reduce_debug (rule_id : Rule; state_id : yy.parse_state); function goto_state (state : yy.parse_state; sym : Nonterminal) return yy.parse_state; function parse_action (state : yy.parse_state; t : yy_tokens.Token) return Integer; pragma Inline (goto_state, parse_action); function goto_state (state : yy.parse_state; sym : Nonterminal) return yy.parse_state is index : goto_row; begin index := Goto_Offset (state); while Goto_Matrix (index).Nonterm /= sym loop index := index + 1; end loop; return Integer (Goto_Matrix (index).Newstate); end goto_state; function parse_action (state : yy.parse_state; t : yy_tokens.Token) return Integer is index : reduce_row; tok_pos : Integer; default : constant Integer := -1; begin tok_pos := yy_tokens.Token'Pos (t); index := Shift_Reduce_Offset (state); while Integer (Shift_Reduce_Matrix (index).T) /= tok_pos and then Integer (Shift_Reduce_Matrix (index).T) /= default loop index := index + 1; end loop; return Integer (Shift_Reduce_Matrix (index).Act); end parse_action; -- error recovery stuff procedure handle_error is temp_action : Integer; begin if yy.error_flag = 3 then -- no shift yet, clobber input. if yy.debug then Text_IO.Put_Line (" -- Ayacc.YYParse: Error Recovery Clobbers " & yy_tokens.Token'Image (yy.input_symbol)); end if; if yy.input_symbol = yy_tokens.End_Of_Input then -- don't discard, if yy.debug then Text_IO.Put_Line (" -- Ayacc.YYParse: Can't discard END_OF_INPUT, quiting..."); end if; raise yy_tokens.Syntax_Error; end if; yy.look_ahead := True; -- get next token return; -- and try again... end if; if yy.error_flag = 0 then -- brand new error yyerror ("Syntax Error"); end if; yy.error_flag := 3; -- find state on stack where error is a valid shift -- if yy.debug then Text_IO.Put_Line (" -- Ayacc.YYParse: Looking for state with error as valid shift"); end if; loop if yy.debug then Text_IO.Put_Line (" -- Ayacc.YYParse: Examining State " & yy.parse_state'Image (yy.state_stack (yy.tos))); end if; temp_action := parse_action (yy.state_stack (yy.tos), Error); if temp_action >= yy.first_shift_entry then if yy.tos = yy.stack_size then Text_IO.Put_Line (" -- Ayacc.YYParse: Stack size exceeded on state_stack"); raise yy_tokens.Syntax_Error; end if; yy.tos := yy.tos + 1; yy.state_stack (yy.tos) := temp_action; exit; end if; if yy.tos /= 0 then yy.tos := yy.tos - 1; end if; if yy.tos = 0 then if yy.debug then Text_IO.Put_Line (" -- Ayacc.YYParse: Error recovery popped entire stack, aborting..."); end if; raise yy_tokens.Syntax_Error; end if; end loop; if yy.debug then Text_IO.Put_Line (" -- Ayacc.YYParse: Shifted error token in state " & yy.parse_state'Image (yy.state_stack (yy.tos))); end if; end handle_error; -- print debugging information for a shift operation procedure shift_debug (state_id : yy.parse_state; lexeme : yy_tokens.Token) is begin Text_IO.Put_Line (" -- Ayacc.YYParse: Shift " & yy.parse_state'Image (state_id) & " on input symbol " & yy_tokens.Token'Image (lexeme)); end shift_debug; -- print debugging information for a reduce operation procedure reduce_debug (rule_id : Rule; state_id : yy.parse_state) is begin Text_IO.Put_Line (" -- Ayacc.YYParse: Reduce by rule " & Rule'Image (rule_id) & " goto state " & yy.parse_state'Image (state_id)); end reduce_debug; -- make the parser believe that 3 valid shifts have occured. -- used for error recovery. procedure yyerrok is begin yy.error_flag := 0; end yyerrok; -- called to clear input symbol that caused an error. procedure yyclearin is begin -- yy.input_symbol := YYLex; yy.look_ahead := True; end yyclearin; begin -- initialize by pushing state 0 and getting the first input symbol yy.state_stack (yy.tos) := 0; loop yy.index := Shift_Reduce_Offset (yy.state_stack (yy.tos)); if Integer (Shift_Reduce_Matrix (yy.index).T) = yy.default then yy.action := Integer (Shift_Reduce_Matrix (yy.index).Act); else if yy.look_ahead then yy.look_ahead := False; yy.input_symbol := YYLex; end if; yy.action := parse_action (yy.state_stack (yy.tos), yy.input_symbol); end if; if yy.action >= yy.first_shift_entry then -- SHIFT if yy.debug then shift_debug (yy.action, yy.input_symbol); end if; -- Enter new state if yy.tos = yy.stack_size then Text_IO.Put_Line (" Stack size exceeded on state_stack"); raise yy_tokens.Syntax_Error; end if; yy.tos := yy.tos + 1; yy.state_stack (yy.tos) := yy.action; yy.value_stack (yy.tos) := YYLVal; if yy.error_flag > 0 then -- indicate a valid shift yy.error_flag := yy.error_flag - 1; end if; -- Advance lookahead yy.look_ahead := True; elsif yy.action = yy.error_code then -- ERROR handle_error; elsif yy.action = yy.accept_code then if yy.debug then Text_IO.Put_Line (" -- Ayacc.YYParse: Accepting Grammar..."); end if; exit; else -- Reduce Action -- Convert action into a rule yy.rule_id := Rule (-1 * yy.action); -- Execute User Action -- user_action(yy.rule_id); case yy.rule_id is pragma Style_Checks (Off); when 4 => -- #line 78 Error (yy.value_stack (yy.tos).Line, yy.value_stack (yy.tos).Column, "Invalid CSS selector component"); when 32 => -- #line 158 Current_Media := null; when 33 => -- #line 161 Current_Media := null; when 38 => -- #line 176 Current_Rule := null; Error (yylval.Line, yylval.Column, "Media condition error"); when 39 => -- #line 181 Current_Rule := null; when 40 => -- #line 186 Current_Rule := null; when 41 => -- #line 189 Error (yy.value_stack (yy.tos-2).Line, yy.value_stack (yy.tos-2).Column, "Invalid media selection after " & To_String (yy.value_stack (yy.tos-2))); yyerrok; when 45 => -- #line 202 Current_Rule := null; when 46 => -- #line 207 Current_Rule := null; when 47 => -- #line 210 Current_Rule := null; when 48 => -- #line 215 Current_Rule := null; Error (yy.value_stack (yy.tos-1).line, yy.value_stack (yy.tos).line, "Found @<font-face> rule"); when 49 => -- #line 220 Append_Media (Current_Media, Document, yy.value_stack (yy.tos)); when 50 => -- #line 223 Append_Media (Current_Media, Document, yy.value_stack (yy.tos)); when 53 => -- #line 234 Append_String (YYVal, yy.value_stack (yy.tos-1), yy.value_stack (yy.tos)); when 54 => -- #line 239 Set_String (YYVal, "not ", yy.value_stack (yy.tos-2).Line, yy.value_stack (yy.tos-2).Column); Append_String (YYVal, yy.value_stack (yy.tos)); when 55 => -- #line 242 Set_String (YYVal, "not ", yy.value_stack (yy.tos-3).Line, yy.value_stack (yy.tos-3).Column); Append_String (YYVal, yy.value_stack (yy.tos-1)); when 56 => -- #line 245 Set_String (YYVal, "only ", yy.value_stack (yy.tos-3).Line, yy.value_stack (yy.tos-3).Column); Append_String (YYVal, yy.value_stack (yy.tos-1)); when 57 => -- #line 248 YYVal := yy.value_stack (yy.tos-2); Append_String (YYVal, yy.value_stack (yy.tos)); when 59 => -- #line 256 Set_String (YYVal, " and ", yy.value_stack (yy.tos-2).Line, yy.value_stack (yy.tos-2).Column); Append_String (YYVal, yy.value_stack (yy.tos)); when 60 => -- #line 259 Set_String (YYVal, "", yylval.Line, yylval.Column); when 63 => -- #line 270 YYVal := yy.value_stack (yy.tos-1); Append_String (YYVal, " "); Append_String (YYVal, yy.value_stack (yy.tos)); when 65 => -- #line 277 YYVal := yy.value_stack (yy.tos-1); Append_String (YYVal, " "); Append_String (YYVal, yy.value_stack (yy.tos)); when 67 => -- #line 284 Set_String (YYVal, "and ", yy.value_stack (yy.tos-2).Line, yy.value_stack (yy.tos-2).Column); Append_String (YYVal, yy.value_stack (yy.tos)); when 68 => -- #line 289 YYVal := yy.value_stack (yy.tos-1); Append_String (YYVal, " "); Append_String (YYVal, yy.value_stack (yy.tos)); when 70 => -- #line 296 Set_String (YYVal, "or ", yy.value_stack (yy.tos-1).Line, yy.value_stack (yy.tos-1).Column); Append_String (YYVal, yy.value_stack (yy.tos)); when 71 => -- #line 301 Set_String (YYVal, "(", yy.value_stack (yy.tos-3).Line, yy.value_stack (yy.tos-3).Column); Append_String (YYVal, yy.value_stack (yy.tos-3)); Append_String (YYVal, ")"); when 72 => -- #line 304 Set_String (YYVal, "(", yy.value_stack (yy.tos-3).Line, yy.value_stack (yy.tos-3).Column); Append_String (YYVal, yy.value_stack (yy.tos-3)); Append_String (YYVal, ")"); when 73 => -- #line 307 Set_String (YYVal, "(", yy.value_stack (yy.tos-3).Line, yy.value_stack (yy.tos-3).Column); Append_String (YYVal, yy.value_stack (yy.tos-3)); Append_String (YYVal, ")"); when 74 => -- #line 310 Error (yylval.Line, yylval.Column, "Invalid media in parens"); Set_String (YYVal, "", yylval.Line, yylval.Column); yyerrok; when 75 => -- #line 316 Set_String (YYVal, "<=", yylval.Line, yylval.Column); when 76 => -- #line 319 Set_String (YYVal, ">=", yylval.Line, yylval.Column); when 77 => -- #line 322 Set_String (YYVal, ">", yylval.Line, yylval.Column); when 78 => -- #line 325 Set_String (YYVal, "<", yylval.Line, yylval.Column); when 79 => -- #line 330 YYVal := yy.value_stack (yy.tos-4); Append_String (YYVal, yy.value_stack (yy.tos-2)); Append_String (YYVal, yy.value_stack (yy.tos)); when 80 => -- #line 333 YYVal := yy.value_stack (yy.tos-6); Append_String (YYVal, yy.value_stack (yy.tos-4)); Append_String (YYVal, yy.value_stack (yy.tos-2)); Append_String (YYVal, yy.value_stack (yy.tos)); when 81 => -- #line 336 YYVal := yy.value_stack (yy.tos-4); Append_String (YYVal, yy.value_stack (yy.tos-2)); Append_String (YYVal, yy.value_stack (yy.tos)); when 82 => -- #line 339 YYVal := yy.value_stack (yy.tos-4); Append_String (YYVal, ": "); Append_String (YYVal, yy.value_stack (yy.tos)); when 84 => -- #line 346 YYVal := yy.value_stack (yy.tos); when 85 => -- #line 349 YYVal := yy.value_stack (yy.tos); when 86 => -- #line 354 Current_Page := null; when 87 => -- #line 357 Current_Page := null; when 88 => -- #line 362 null; when 89 => -- #line 365 null; when 90 => -- #line 370 Current_Page := new CSS.Core.Styles.CSSPageRule; when 94 => -- #line 383 Set_Selector (YYVal, SEL_PSEUDO_ELEMENT, yy.value_stack (yy.tos)); when 95 => -- #line 388 Append_Property (Current_Page.Style, Document, yy.value_stack (yy.tos-1)); when 96 => -- #line 391 Append_Property (Current_Page.Style, Document, yy.value_stack (yy.tos-1)); when 97 => -- #line 396 YYVal := yy.value_stack (yy.tos-1); when 98 => -- #line 399 YYVal := yy.value_stack (yy.tos-1); when 99 => -- #line 404 Set_Selector_Type (YYVal, SEL_NEXT_SIBLING, yylineno, yylinecol); when 100 => -- #line 407 Set_Selector_Type (YYVal, SEL_CHILD, yylineno, yylinecol); when 101 => -- #line 410 Set_Selector_Type (YYVal, SEL_FOLLOWING_SIBLING, yylineno, yylinecol); when 104 => -- #line 421 Current_Rule := null; when 105 => -- #line 424 Current_Rule := null; Error (yy.value_stack (yy.tos-1).line, yy.value_stack (yy.tos-1).column, "Invalid CSS rule"); when 106 => -- #line 427 Current_Rule := null; when 107 => -- #line 430 Error (yy.value_stack (yy.tos-2).Line, yy.value_stack (yy.tos-2).Column, "Syntax error in CSS rule"); when 108 => -- #line 435 YYVal := yy.value_stack (yy.tos-1); when 109 => -- #line 438 YYVal := yy.value_stack (yy.tos); when 111 => -- #line 445 Error (yy.value_stack (yy.tos-1).Line, yy.value_stack (yy.tos-1).Column, "Invalid CSS selector component"); when 112 => -- #line 450 Add_Selector_List (Current_Rule, Current_Media, Document, yy.value_stack (yy.tos)); when 113 => -- #line 453 Add_Selector_List (Current_Rule, Current_Media, Document, yy.value_stack (yy.tos)); when 114 => -- #line 458 Add_Selector (yy.value_stack (yy.tos-3), yy.value_stack (yy.tos-2), yy.value_stack (yy.tos-1)); YYVal := yy.value_stack (yy.tos-3); when 115 => -- #line 461 Add_Selector (yy.value_stack (yy.tos-2), yy.value_stack (yy.tos-1)); YYVal := yy.value_stack (yy.tos-2); when 116 => -- #line 464 YYVal := yy.value_stack (yy.tos-1); when 117 => -- #line 469 Add_Selector_Filter (yy.value_stack (yy.tos-1), yy.value_stack (yy.tos)); YYVal := yy.value_stack (yy.tos-1); when 119 => -- #line 476 Set_Selector (YYVal, SEL_ELEMENT, yy.value_stack (yy.tos)); when 120 => -- #line 479 Set_Selector (YYVal, SEL_IDENT, yy.value_stack (yy.tos)); when 121 => -- #line 482 Set_Selector (YYVal, SEL_CLASS, yy.value_stack (yy.tos)); when 124 => -- #line 489 Set_Selector (YYVal, SEL_NOT, yy.value_stack (yy.tos-2)); when 129 => -- #line 504 YYVal := yy.value_stack (yy.tos); when 130 => -- #line 509 YYVal := yy.value_stack (yy.tos); when 137 => -- #line 528 Set_Selector (YYVal, SEL_HAS_ATTRIBUTE, yy.value_stack (yy.tos-2)); when 138 => -- #line 531 Set_Selector (YYVal, yy.value_stack (yy.tos-4).Sel, yy.value_stack (yy.tos-6), yy.value_stack (yy.tos-2)); when 139 => -- #line 534 Set_Selector (YYVal, yy.value_stack (yy.tos-4).Sel, yy.value_stack (yy.tos-6), yy.value_stack (yy.tos-2)); when 140 => -- #line 537 Error (yy.value_stack (yy.tos).Line, yy.value_stack (yy.tos).column, "Invalid attribute definition."); when 141 => -- #line 542 Set_Selector_Type (YYVal, SEL_EQ_ATTRIBUTE, yylineno, yylinecol); when 142 => -- #line 545 Set_Selector_Type (YYVal, SEL_CONTAIN_ATTRIBUTE, yylineno, yylinecol); when 143 => -- #line 548 Set_Selector_Type (YYVal, SEL_ORMATCH_ATTRIBUTE, yylineno, yylinecol); when 144 => -- #line 551 Set_Selector_Type (YYVal, SEL_STARTS_ATTRIBUTE, yylineno, yylinecol); when 145 => -- #line 554 Set_Selector_Type (YYVal, SEL_ENDS_ATTRIBUTE, yylineno, yylinecol); when 146 => -- #line 557 Set_Selector_Type (YYVal, SEL_MATCH_ATTRIBUTE, yylineno, yylinecol); when 147 => -- #line 562 Set_Selector (YYVal, SEL_PSEUDO_ELEMENT, yy.value_stack (yy.tos)); when 148 => -- #line 565 Set_Selector (YYVal, SEL_PSEUDO_CLASS, yy.value_stack (yy.tos)); when 149 => -- #line 568 Set_Selector (YYVal, SEL_FUNCTION, yy.value_stack (yy.tos-3)); when 152 => -- #line 579 YYVal := yy.value_stack (yy.tos); when 153 => -- #line 584 YYVal := yy.value_stack (yy.tos); when 154 => -- #line 587 YYVal := yy.value_stack (yy.tos-4); when 155 => -- #line 590 YYVal := yy.value_stack (yy.tos-1); when 156 => -- #line 595 Append_Property (Current_Rule, Current_Media, Document, yy.value_stack (yy.tos-1)); when 157 => -- #line 598 Append_Property (Current_Rule, Current_Media, Document, yy.value_stack (yy.tos)); Error (yy.value_stack (yy.tos-3).Line, yy.value_stack (yy.tos-3).Column, "Invalid property"); yyerrok; when 158 => -- #line 602 YYVal := yy.value_stack (yy.tos-2); Error (yy.value_stack (yy.tos-1).Line, yy.value_stack (yy.tos-1).Column, "Invalid property (2)"); yyerrok; when 159 => -- #line 605 Append_Property (Current_Rule, Current_Media, Document, yy.value_stack (yy.tos-1)); when 162 => -- #line 616 Set_Property (YYVal, yy.value_stack (yy.tos-4), yy.value_stack (yy.tos-1), True); when 163 => -- #line 619 Set_Property (YYVal, yy.value_stack (yy.tos-3), yy.value_stack (yy.tos), False); when 164 => -- #line 622 Error (yy.value_stack (yy.tos).Line, yy.value_stack (yy.tos).Column, "Missing ''' or '""' at end of string"); Set_Property (YYVal, yy.value_stack (yy.tos-3), EMPTY, False); yyclearin; when 165 => -- #line 628 Error (yy.value_stack (yy.tos).Line, yy.value_stack (yy.tos).Column, "Invalid property value: " & YYText); Set_Property (YYVal, yy.value_stack (yy.tos-2), yy.value_stack (yy.tos-2), False); yyclearin; when 166 => -- #line 634 Error (yy.value_stack (yy.tos-1).Line, yy.value_stack (yy.tos-1).Column, "Missing ':' after property name"); Set_Property (YYVal, yy.value_stack (yy.tos-1), EMPTY, False); yyclearin; when 167 => -- #line 640 Error (yylval.Line, yylval.Column, "Invalid property name"); YYVal := EMPTY; when 168 => -- #line 645 YYVal := yy.value_stack (yy.tos-1); when 169 => -- #line 648 Warning (yy.value_stack (yy.tos-1).Line, yy.value_stack (yy.tos-1).Column, "IE7 '*' symbol hack is used"); YYVal := yy.value_stack (yy.tos-1); when 171 => -- #line 657 CSS.Parser.Set_Function (YYVal, Document, yy.value_stack (yy.tos-4), yy.value_stack (yy.tos-2)); when 172 => -- #line 660 CSS.Parser.Set_Function (YYVal, Document, yy.value_stack (yy.tos-3), yy.value_stack (yy.tos-1)); when 173 => -- #line 663 Error (yy.value_stack (yy.tos-3).Line, yy.value_stack (yy.tos-3).Column, "Invalid function parameter"); when 174 => -- #line 668 CSS.Parser.Set_Expr (YYVal, yy.value_stack (yy.tos-3), yy.value_stack (yy.tos)); when 175 => -- #line 671 CSS.Parser.Set_Expr (YYVal, yy.value_stack (yy.tos-1), yy.value_stack (yy.tos)); when 176 => -- #line 674 YYVal := yy.value_stack (yy.tos); when 177 => -- #line 679 CSS.Parser.Set_Expr (YYVal, yy.value_stack (yy.tos-3), yy.value_stack (yy.tos)); when 178 => -- #line 682 CSS.Parser.Set_Expr (YYVal, yy.value_stack (yy.tos-3), yy.value_stack (yy.tos)); when 179 => -- #line 685 CSS.Parser.Set_Expr (YYVal, yy.value_stack (yy.tos-1), yy.value_stack (yy.tos)); when 180 => -- #line 688 YYVal := yy.value_stack (yy.tos); when 181 => -- #line 691 YYVal := yy.value_stack (yy.tos-1); -- CSS.Parser.Set_Parameter ($$, Document, $1, $5); when 182 => -- #line 697 CSS.Parser.Set_Expr (YYVal, yy.value_stack (yy.tos-2), yy.value_stack (yy.tos)); when 183 => -- #line 700 CSS.Parser.Set_Expr (YYVal, yy.value_stack (yy.tos-1), yy.value_stack (yy.tos)); when 185 => -- #line 707 CSS.Parser.Set_Value (YYVal, Document, yy.value_stack (yy.tos)); when 186 => -- #line 710 CSS.Parser.Set_Value (YYVal, Document, yy.value_stack (yy.tos)); when 187 => -- #line 713 CSS.Parser.Set_Value (YYVal, Document, yy.value_stack (yy.tos)); when 188 => -- #line 716 CSS.Parser.Set_Value (YYVal, Document, yy.value_stack (yy.tos-1)); when 189 => -- #line 719 CSS.Parser.Set_Value (YYVal, Document, yy.value_stack (yy.tos-1)); when 190 => -- #line 722 CSS.Parser.Set_Value (YYVal, Document, yy.value_stack (yy.tos-1)); when 191 => -- #line 725 CSS.Parser.Set_Value (YYVal, Document, yy.value_stack (yy.tos)); when 192 => -- #line 728 YYVal := yy.value_stack (yy.tos); when 193 => -- #line 731 Error (yy.value_stack (yy.tos).Line, yy.value_stack (yy.tos).Column, "Invalid url()"); YYVal := EMPTY; when 194 => -- #line 736 YYVal := yy.value_stack (yy.tos-1); when 195 => -- #line 739 YYVal := yy.value_stack (yy.tos-1); when 196 => -- #line 742 YYVal := yy.value_stack (yy.tos-1); when 197 => -- #line 745 YYVal := yy.value_stack (yy.tos-1); when 198 => -- #line 748 YYVal := yy.value_stack (yy.tos-1); when 199 => -- #line 751 YYVal := yy.value_stack (yy.tos-1); when 200 => -- #line 754 YYVal := yy.value_stack (yy.tos-1); when 201 => -- #line 757 YYVal := yy.value_stack (yy.tos-1); when 202 => -- #line 762 Set_Color (YYVal, yy.value_stack (yy.tos-1)); pragma Style_Checks (On); when others => null; end case; -- Pop RHS states and goto next state yy.tos := yy.tos - Rule_Length (yy.rule_id) + 1; if yy.tos > yy.stack_size then Text_IO.Put_Line (" Stack size exceeded on state_stack"); raise yy_tokens.Syntax_Error; end if; yy.state_stack (yy.tos) := goto_state (yy.state_stack (yy.tos - 1), Get_LHS_Rule (yy.rule_id)); yy.value_stack (yy.tos) := YYVal; if yy.debug then reduce_debug (yy.rule_id, goto_state (yy.state_stack (yy.tos - 1), Get_LHS_Rule (yy.rule_id))); end if; end if; end loop; end YYParse; end CSS.Parser.Parser;
{ "source": "starcoderdata", "programming_language": "ada" }
with System.Storage_Elements; with TLSF.Config; with TLSF.Bitmaps; with TLSF.Mem_Block_Size; use TLSF.Config; use TLSF.Bitmaps; use TLSF.Mem_Block_Size; package body TLSF.Mem_Blocks is subtype Free_Block_Header is Block_Header (Free); subtype Occupied_Block_Header is Block_Header (Occupied); Block_Header_Size : constant SSE.Storage_Count := Block_Header'Max_Size_In_Storage_Elements; Occupied_Block_Header_Size : constant SSE.Storage_Count := Occupied_Block_Header'Max_Size_In_Storage_Elements; Free_Block_Header_Size : constant SSE.Storage_Count := Free_Block_Header'Max_SizRound_Size_Up(e_In_Storage_Elements; Aligned_Block_Header_Size : constant SSE.Storage_Count := Align (Block_Header'Max_Size_In_Storage_Elements); Aligned_Occupied_Block_Header_Size : constant SSE.Storage_Count := Align (Occupied_Block_Header'Max_Size_In_Storage_Elements); Aligned_Free_Block_Header_Size : constant SSE.Storage_Count := Align (Free_Block_Header'Max_Size_In_Storage_Elements); Small_Block_Size : constant := 2 ** FL_Index_Shift; use type SSE.Storage_Offset; use type SSE.Storage_Count; pragma Assert (Small_Block_Size >= Block_Header_Size); -- should be >= Block_Header max size in storage elements function Adjust_And_Align_Size (S : SSE.Storage_Count) return Size is (Align (Aligned_Occupied_Block_Header_Size + S)); function Is_Free_Block_Too_Large (Free_Block : not null access Block_Header; Block_Size : Size) return Boolean is (Free_Block.Size >= Block_Size + Small_Block_Size); procedure Block_Make_Occupied (Block : not null access Block_Header) is Blk : Block_Header with Import, Address => Block.all'Address; begin Blk := Block_Header'(Status => Occupied, Prev_Block => Block.Prev_Block, Prev_Block_Status => Block.Prev_Block_Status, Next_Block_Status => Block.Next_Block_Status, Size => Block.Size); end Block_Make_Occupied; procedure Block_Make_Free (Block : not null access Block_Header) is BA : Block_Header with Import, Address => Block.all'Address; BH : Free_Block_Header := Free_Block_Header' (Status => Free, Prev_Block => Block.Prev_Block, Prev_Block_Status => Block.Prev_Block_Status, Next_Block_Status => Block.Next_Block_Status, Size => Block.Size, Free_List => Free_Blocks_List'(Prev => null, Next => null)); -- Blk : Block_Header with Import, Address => Block.all'Address; begin BA := BH; --Blk := end Block_Make_Free; function Address_To_Block_Header_Ptr (Addr : System.Address) return not null access Block_Header is use type SSE.Storage_Count; Block_Addr : System.Address := (Addr - Aligned_Occupied_Block_Header_Size); Block : aliased Block_Header with Import, Address => Block_Addr; begin return Block'Unchecked_Access; end Address_To_Block_Header_Ptr; function Block_Header_Ptr_To_Address (Block : not null access constant Block_Header) return System.Address is use type SSE.Storage_Count; begin return Block.all'Address + Aligned_Occupied_Block_Header_Size; end Block_Header_Ptr_To_Address; procedure Notify_Neighbors_Of_Block_Status (Block : access Block_Header) is Next_Block : access Block_Header := Get_Next_Block (Block); Prev_Block : access Block_Header := Get_Prev_Block (Block); begin if Next_Block /= null then Next_Block.Prev_Block_Status := Block.Status; end if; if Prev_Block /= null then Prev_Block.Next_Block_Status := Block.Status; end if; end Notify_Neighbors_Of_Block_Status; function Split_Free_Block (Free_Block : not null access Block_Header; New_Block_Size : Size) return not null access Block_Header is Remaining_Block_Size : Size := Free_Block.Size - New_Block_Size; Remaining_Block : aliased Block_Header with Import, Address => Free_Block.all'Address + New_Block_Size; begin Block_Make_Free ( Remaining_Block'Access ); Remaining_Block := Block_Header' (Status => Free, Prev_Block => Free_Block.all'Unchecked_Access, Prev_Block_Status => Occupied, Next_Block_Status => Free_Block.Next_Block_Status, Size => Remaining_Block_Size, Free_List => Free_Blocks_List'(Prev => null, Next => null)); Free_Block.Size := New_Block_Size; Free_Block.Next_Block_Status := Free; return Remaining_Block'Unchecked_Access; end Split_Free_Block; function Insert_To_Free_Blocks_List (Block_To_Insert : not null access Block_Header; Block_In_List : access Block_Header) return not null access Block_Header is begin if Block_In_List /= null then Block_To_Insert.Free_List.Next := Block_In_List; Block_To_Insert.Free_List.Prev := Block_In_List.Free_List.Prev; Block_In_List.Free_List.Prev := Block_To_Insert; return Block_In_List.all'Unchecked_Access; else Block_To_Insert.Free_List := Free_Blocks_List'(Prev => Block_To_Insert.all'Unchecked_Access, Next => Block_To_Insert.all'Unchecked_Access); return Block_To_Insert.all'Unchecked_Access; end if; end Insert_To_Free_Blocks_List; function Get_Next_Block ( Block : not null access Block_Header) return access Block_Header is Next_Block : aliased Block_Header with Import, Address => Block.all'Address + Block.Size; begin return (if Block.Next_Block_Status /= Absent then Next_Block'Unchecked_Access else null); end Get_Next_Block; function Get_Prev_Block ( Block : not null access Block_Header) return access Block_Header is begin return (if Block.Prev_Block_Status /= Absent then Block.Prev_Block else null); end Get_Prev_Block; function Init_First_Free_Block ( Addr : System.Address; Sz : SSE.Storage_Count) return not null access Block_Header is Free_Block_Hdr : aliased Block_Header with Import, Address => Addr; begin Free_Block_Hdr := Block_Header' (Status => Free, Prev_Block => null, Prev_Block_Status => Absent, Next_Block_Status => Absent, Size => Size(Sz), Free_List => Free_Blocks_List'(Prev => null, Next => null)); return Free_Block_Hdr'Unchecked_Access; end Init_First_Free_Block; function Block_Was_Last_In_Free_List (Block : not null access constant Block_Header) return Boolean is -- ERROR here -- since list is cyclic: -- /-------\ -- A B -- \--------/ -- when two last items remain A ->next = B and A->prev = B, so as B (Block.Free_List.Prev = Block.Free_List.Next); function Unlink_Block_From_Free_List (Block : not null access Block_Header) return access Block_Header is begin Block.Free_List.Prev.Free_List.Next := Block.Free_List.Next; Block.Free_List.Next.Free_List.Prev := Block.Free_List.Prev; return (if Block_Was_Last_In_Free_List (Block) then null else Block.Free_List.Next); end Unlink_Block_From_Free_List; procedure Merge_Two_Adjacent_Free_Blocks (Block : not null access Block_Header) is Next_Block : access Block_Header := Get_Next_Block (Block); begin Block.Next_Block_Status := Next_Block.Next_Block_Status; Block.Size := Block.Size + Next_Block.Size; end Merge_Two_Adjacent_Free_Blocks; function Is_Block_Free (Block : access Block_Header) return Boolean is (Block /= null and then Block.Status = Free); function Search_Suitable_Block (FL : First_Level_Index; SL : Second_Level_Index; Bmp : Levels_Bitmap; FB_List : Free_Lists) return not null access Block_Header is Block_Hdr : access Block_Header := null; SL_From : Second_Level_Index := SL; FL_From : First_Level_Index := FL; begin Search_Present (Bmp, FL_From, SL_From); Block_Hdr := FB_List (FL_From, SL_From); pragma Assert (Block_Hdr /= null); -- run-time exception will be raised if no block found return Block_Hdr; end Search_Suitable_Block; procedure Remove_Free_Block_From_Lists_And_Bitmap (Block : not null access Block_Header; FB_List : in out Free_Lists; Bmp : in out Levels_Bitmap) is FL : First_Level_Index; SL : Second_Level_Index; begin Mapping_Insert (Block.Size, FL, SL); FB_List (FL, SL) := Unlink_Block_From_Free_List (Block); if FB_List (FL, SL) = null then Set_Not_Present (Bmp, FL, SL); end if; end Remove_Free_Block_From_Lists_And_Bitmap; procedure Insert_Free_Block_To_Lists_And_Bitmap (Block : not null access Block_Header; FB_List : in out Free_Lists; Bmp : in out Levels_Bitmap) is FL : First_Level_Index; SL : Second_Level_Index; begin Mapping_Insert (Block.Size, FL, SL); FB_List (FL, SL) := Insert_To_Free_Blocks_List (Block_To_Insert => Block, Block_In_List => FB_List (FL, SL)); Set_Present (Bmp, FL, SL); end Insert_Free_Block_To_Lists_And_Bitmap; end TLSF.Mem_Blocks;
{ "source": "starcoderdata", "programming_language": "ada" }
with AVR.TIMERS; -- with AVR.INTERRUPTS; -- ============================================================================= -- Package AVR.TIMERS.CLOCK -- -- Implements the clock functions. This timer is used for handling the clock: -- - TIMER1_COMPA (16 bits timer) -- ============================================================================= package AVR.TIMERS.CLOCK is subtype Time_Hour_Type is Integer; subtype Time_Minute_Type is Integer range 0 .. 59; subtype Time_Second_Type is Integer range 0 .. 59; type Time_Type is record HH : Time_Hour_Type; MM : Time_Minute_Type; SS : Time_Second_Type; end record; -- Initialize Clock Timer procedure Initialize (Timer : TIMERS.Timer_Type); function Get_Current_Time_In_Nanoseconds return Unsigned_64; function Get_Current_Time_In_Seconds return Unsigned_64; function Get_Current_Time return Time_Type; -- Schedule tick update when Timer1_ChannelA overflows procedure Schedule_Update_Clock; -- pragma Machine_Attribute -- (Entity => Schedule_Update_Clock, -- Attribute_Name => "signal"); -- pragma Export -- (Convention => C, -- Entity => Schedule_Update_Clock, -- External_Name => AVR.INTERRUPTS.TIMER1_OVF); private Priv_Clock_Cycles : Unsigned_64 := 0; end AVR.TIMERS.CLOCK;
{ "source": "starcoderdata", "programming_language": "ada" }
with GNAT.OS_Lib; with Ada.Text_IO; with Parameters; with System; package body Unix is package OSL renames GNAT.OS_Lib; package TIO renames Ada.Text_IO; package PM renames Parameters; ---------------------- -- process_status -- ---------------------- function process_status (pid : pid_t) return process_exit is result : constant uInt8 := nohang_waitpid (pid); begin case result is when 0 => return still_running; when 1 => return exited_normally; when others => return exited_with_error; end case; end process_status; ----------------------- -- screen_attached -- ----------------------- function screen_attached return Boolean is begin return CSM.isatty (handle => CSM.fileno (CSM.stdin)) = 1; end screen_attached; ----------------------- -- cone_of_silence -- ----------------------- procedure cone_of_silence (deploy : Boolean) is result : uInt8; begin if not screen_attached then return; end if; if deploy then result := silent_control; if result > 0 then TIO.Put_Line ("Notice: tty echo+control OFF command failed"); end if; else result := chatty_control; if result > 0 then TIO.Put_Line ("Notice: tty echo+control ON command failed"); end if; end if; end cone_of_silence; ----------------------------- -- ignore_background_tty -- ----------------------------- procedure ignore_background_tty is result : uInt8; begin result := ignore_tty_write; if result > 0 then TIO.Put_Line ("Notice: ignoring background tty write signal failed"); end if; result := ignore_tty_read; if result > 0 then TIO.Put_Line ("Notice: ignoring background tty read signal failed"); end if; end ignore_background_tty; ------------------------- -- kill_process_tree -- ------------------------- procedure kill_process_tree (process_group : pid_t) is use type IC.int; result : constant IC.int := signal_runaway (process_group); begin if result /= 0 then TIO.Put_Line ("Notice: failed to signal pid " & process_group'Img); end if; end kill_process_tree; ------------------------ -- external_command -- ------------------------ function external_command (command : String) return Boolean is Args : OSL.Argument_List_Access; Exit_Status : Integer; begin Args := OSL.Argument_String_To_List (command); Exit_Status := OSL.Spawn (Program_Name => Args (Args'First).all, Args => Args (Args'First + 1 .. Args'Last)); OSL.Free (Args); return Exit_Status = 0; end external_command; ------------------- -- fork_failed -- ------------------- function fork_failed (pid : pid_t) return Boolean is begin if pid < 0 then return True; end if; return False; end fork_failed; ---------------------- -- launch_process -- ---------------------- function launch_process (command : String) return pid_t is procid : OSL.Process_Id; Args : OSL.Argument_List_Access; begin Args := OSL.Argument_String_To_List (command); procid := OSL.Non_Blocking_Spawn (Program_Name => Args (Args'First).all, Args => Args (Args'First + 1 .. Args'Last)); OSL.Free (Args); return pid_t (OSL.Pid_To_Integer (procid)); end launch_process; ---------------------------- -- env_variable_defined -- ---------------------------- function env_variable_defined (variable : String) return Boolean is test : String := OSL.Getenv (variable).all; begin return (test /= ""); end env_variable_defined; -------------------------- -- env_variable_value -- -------------------------- function env_variable_value (variable : String) return String is begin return OSL.Getenv (variable).all; end env_variable_value; ------------------ -- pipe_close -- ------------------ function pipe_close (OpenFile : CSM.FILEs) return Integer is res : constant CSM.int := pclose (FileStream => OpenFile); u16 : Interfaces.Unsigned_16; begin u16 := Interfaces.Shift_Right (Interfaces.Unsigned_16 (res), 8); if Integer (u16) > 0 then return Integer (u16); end if; return Integer (res); end pipe_close; --------------------- -- piped_command -- --------------------- function piped_command (command : String; status : out Integer) return JT.Text is redirect : constant String := " 2>&1"; filestream : CSM.FILEs; result : JT.Text; begin filestream := popen (IC.To_C (command & redirect), IC.To_C ("re")); result := pipe_read (OpenFile => filestream); status := pipe_close (OpenFile => filestream); return result; end piped_command; -------------------------- -- piped_mute_command -- -------------------------- function piped_mute_command (command : String; abnormal : out JT.Text) return Boolean is redirect : constant String := " 2>&1"; filestream : CSM.FILEs; status : Integer; begin filestream := popen (IC.To_C (command & redirect), IC.To_C ("re")); abnormal := pipe_read (OpenFile => filestream); status := pipe_close (OpenFile => filestream); return status = 0; end piped_mute_command; ----------------- -- pipe_read -- ----------------- function pipe_read (OpenFile : CSM.FILEs) return JT.Text is -- Allocate 2kb at a time buffer : String (1 .. 2048) := (others => ' '); result : JT.Text := JT.blank; charbuf : CSM.int; marker : Natural := 0; begin loop charbuf := CSM.fgetc (OpenFile); if charbuf = CSM.EOF then if marker >= buffer'First then JT.SU.Append (result, buffer (buffer'First .. marker)); end if; exit; end if; if marker = buffer'Last then JT.SU.Append (result, buffer); marker := buffer'First; else marker := marker + 1; end if; buffer (marker) := Character'Val (charbuf); end loop; return result; end pipe_read; ----------------- -- true_path -- ----------------- function true_path (provided_path : String) return String is use type ICS.chars_ptr; buffer : IC.char_array (0 .. 1024) := (others => IC.nul); result : ICS.chars_ptr; path : IC.char_array := IC.To_C (provided_path); begin result := realpath (pathname => path, resolved_path => buffer); if result = ICS.Null_Ptr then return ""; end if; return ICS.Value (result); exception when others => return ""; end true_path; end Unix;
{ "source": "starcoderdata", "programming_language": "ada" }
with STM32_SVD.RCC; use STM32_SVD.RCC; with STM32_SVD.USART; use STM32_SVD.USART; package body STM32GD.USART.Peripheral is type USART_Periph_Access is access all USART_Peripheral; function USART_Periph return USART_Periph_Access is begin return (if USART = USART_1 then STM32_SVD.USART.USART1_Periph'Access elsif USART = USART_2 then STM32_SVD.USART.USART2_Periph'Access else STM32_SVD.USART.USART3_Periph'Access); end USART_Periph; procedure Enable is begin case USART is when USART_1 => RCC_Periph.APB2ENR.USART1EN := 1; when USART_2 => RCC_Periph.APB1ENR.USART2EN := 1; when USART_3 => RCC_Periph.APB1ENR.USART3EN := 1; end case; end Enable; procedure Disable is begin case USART is when USART_1 => RCC_Periph.APB2ENR.USART1EN := 0; when USART_2 => RCC_Periph.APB1ENR.USART2EN := 0; when USART_3 => RCC_Periph.APB1ENR.USART3EN := 0; end case; end Disable; procedure Init is Int_Scale : constant UInt32 := 4; Int_Divider : constant UInt32 := (25 * UInt32 (Clock)) / (Int_Scale * Speed); Frac_Divider : constant UInt32 := Int_Divider rem 100; begin USART_Periph.BRR.DIV_Fraction := STM32_SVD.USART.BRR_DIV_Fraction_Field (((Frac_Divider * 16) + 50) / 100 mod 16); USART_Periph.BRR.DIV_Mantissa := STM32_SVD.USART.BRR_DIV_Mantissa_Field (Int_Divider / 100); USART_Periph.CR1.UE := 1; USART_Periph.CR1.TE := 1; USART_Periph.CR1.RE := 1; end Init; procedure Transmit (Data : in Byte) is begin while USART_Periph.SR.TXE = 0 loop null; end loop; USART_Periph.DR.DR := UInt9 (Data); end Transmit; function Data_Available return Boolean is begin return USART_Periph.SR.RXNE = 1; end Data_Available; function Receive return Byte is begin while USART_Periph.SR.RXNE = 0 loop null; end loop; return Byte (USART_Periph.DR.DR and 16#FF#); end Receive; end STM32GD.USART.Peripheral;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Text_IO; with BigInteger; use BigInteger; package body Problem_25 is package IO renames Ada.Text_IO; procedure Solve is term : Positive := 3; n : BigInt := BigInteger.Create(2); n_1 : BigInt := BigInteger.Create(1); n_2 : BigInt := BigInteger.Create(1); begin while Magnitude(n) < 1_000 loop term := term + 1; n_2 := n_1; n_1 := n; n := n_1 + n_2; end loop; IO.Put_Line(Positive'Image(term)); end Solve; end Problem_25;
{ "source": "starcoderdata", "programming_language": "ada" }
-- 40333139 -- Last Updated on 19th April 2019 -- main.adb with Trident; use Trident; with Ada.Text_IO; use Ada.Text_IO; procedure Main is begin Put_Line("--------------------------------------------------------"); Put_Line(" ___ _ _ "); Put_Line(" / __|_ _| |__ _ __ __ _ _ _(_)_ _ ___ "); Put_Line(" \__ \ || | '_ \ ' \/ _` | '_| | ' \/ -_) "); Put_Line(" |___/\_,_|_.__/_|_|_\__,_|_| |_|_||_\___| "); Put_Line(" ___ _ _ ___ _ "); Put_Line(" / __|___ _ _| |_ _ _ ___| | / __|_ _ __| |_ ___ _ __ "); Put_Line("| (__/ _ \ ' \ _| '_/ _ \ | \__ \ || (_-< _/ -_) ' \ "); Put_Line(" \___\___/_||_\__|_| \___/_| |___/\_, /__/\__\___|_|_|_|"); Put_Line(" |__/ "); Put_Line("--------------------------------------------------------"); Put_Line("Attempting to Start Submarine..."); OperateSubmarine; Put("Is Nuclear Submarine Operational?: "); Put_Line(TridentSubmarine.operating'Image); Put("Is Weapons System Available?: "); WeaponsSystemCheck; Put_Line(TridentSubmarine.WeaponsAvailablity'Image); Put_Line("---------------------------------------------------"); Put("Airlock Door One is: "); Put_Line(TridentSubmarine.CloseAirlockOne'Image); Put("Airlock Door Two is: "); Put_Line(TridentSubmarine.CloseAirlockTwo'Image); Put_Line("---------------------------------------------------"); Put_Line("Attempting to Open both Doors..."); OpenAirlockTwo; Put("Airlock Door One is: "); Put_Line(TridentSubmarine.CloseAirlockOne'Image); Put("Airlock Door Two is: "); Put_Line(TridentSubmarine.CloseAirlockTwo'Image); Put_Line("---------------------------------------------------"); Put_Line("Closing Airlock Door One..."); CloseAirlockOne; Put("Airlock Door One is: "); Put_Line(TridentSubmarine.CloseAirlockOne'Image); Put_Line("Closing Airlock Door Two..."); CloseAirlockTwo; Put("Airlock Door Two is: "); Put_Line(TridentSubmarine.CloseAirlockTwo'Image); Put_Line("---------------------------------------------------"); Put("Is Nuclear Submarine Operational?: "); OperateSubmarine; Put_Line(TridentSubmarine.operating'Image); Put("Is Weapons System Available?: "); WeaponsSystemCheck; Put_Line(TridentSubmarine.WeaponsAvailablity'Image); Put_Line("---------------------------------------------------"); Put("Airlock Door one lock is: "); Put_Line(TridentSubmarine.LockAirlockOne'Image); Put("Airlock Door two lock is: "); Put_Line(TridentSubmarine.LockAirlockTwo'Image); Put_Line("---------------------------------------------------"); Put_Line("Locking both Airlock Doors"); LockAirlockOne; LockAirlockTwo; Put("Airlock Door One is: "); Put_Line(TridentSubmarine.LockAirlockOne'Image); Put("Airlock Door Two is: "); Put_Line(TridentSubmarine.LockAirlockTwo'Image); Put_Line("---------------------------------------------------"); Put_Line("Attempting to Open Airlock Door One..."); OpenAirlockOne; Put("Status of Airlock Door one: "); Put(TridentSubmarine.CloseAirlockOne'Image); Put(" and "); Put_Line(TridentSubmarine.LockAirlockOne'Image); Put_Line("Attempting to Open Airlock Door Two..."); OpenAirlockTwo; Put("Status of Airlock Door Two: "); Put(TridentSubmarine.CloseAirlockTwo'Image); Put(" and "); Put_Line(TridentSubmarine.LockAirlockTwo'Image); Put_Line("---------------------------------------------------"); Put("Is Nuclear Submarine Operational?: "); OperateSubmarine; Put_Line(TridentSubmarine.operating'Image); Put("Is Weapons System Available?: "); WeaponsSystemCheck; Put_Line(TridentSubmarine.WeaponsAvailablity'Image); Put_Line("---------------------------------------------------"); Put("Is Weapons System Ready to Fire?: "); ReadyToFire; Put_Line(TridentSubmarine.loaded'Image); Put_Line("Attempting to Store Torpedoes..."); Store; Put(TridentSubmarine.storedTorpedoes'Image); Put(" Torpedo: "); Put_Line(TridentSubmarine.torpedoes'Image); Store; Put(TridentSubmarine.storedTorpedoes'Image); Put(" Torpedo: "); Put_Line(TridentSubmarine.torpedoes'Image); Store; Put(TridentSubmarine.storedTorpedoes'Image); Put(" Torpedo: "); Put_Line(TridentSubmarine.torpedoes'Image); Store; Put(TridentSubmarine.storedTorpedoes'Image); Put(" Torpedo: "); Put_Line(TridentSubmarine.torpedoes'Image); Store; Put(TridentSubmarine.storedTorpedoes'Image); Put(" Torpedo: "); Put_Line(TridentSubmarine.torpedoes'Image); Store; Put(TridentSubmarine.storedTorpedoes'Image); Put(" Torpedo: "); Put_Line(TridentSubmarine.torpedoes'Image); Put_Line("---------------------------------------------------"); Put("Is Weapons System Ready to Fire?: "); Put_Line(TridentSubmarine.loadedTorpedoes'Image); Put("Number of Torpedoes Stored: "); Put_Line(TridentSubmarine.torpedoes'Image); Put_Line("---------------------------------------------------"); -- One; Put_Line("Attempting to Load Torpedo..."); Load; Put("Loading Torpedo: "); Put_Line(TridentSubmarine.loaded'Image); Put_Line("Attempting to Fire Torpedo..."); Put("Is Weapons System Ready to Fire?: "); Put_Line(TridentSubmarine.loadedTorpedoes'Image); Fire; Put(TridentSubmarine.firingTorpedoes'Image); Put(" Torpedo! Remaining "); Put_Line(TridentSubmarine.torpedoes'Image); Put_Line("---------------------------------------------------"); -- Two; Put_Line("Attempting to Load Torpedo..."); Load; Put("Loading Torpedo: "); Put_Line(TridentSubmarine.loaded'Image); Put_Line("Attempting to Fire Torpedo..."); Put("Is Weapons System Ready to Fire?: "); Put_Line(TridentSubmarine.loadedTorpedoes'Image); Fire; Put(TridentSubmarine.firingTorpedoes'Image); Put(" Torpedo! Remaining "); Put_Line(TridentSubmarine.torpedoes'Image); Put_Line("---------------------------------------------------"); -- Three; Put_Line("Attempting to Load Torpedo..."); Load; Put("Loading Torpedo: "); Put_Line(TridentSubmarine.loaded'Image); Put_Line("Attempting to Fire Torpedo..."); Put("Is Weapons System Ready to Fire?: "); Put_Line(TridentSubmarine.loadedTorpedoes'Image); Fire; Put(TridentSubmarine.firingTorpedoes'Image); Put(" Torpedo! Remaining "); Put_Line(TridentSubmarine.torpedoes'Image); Put_Line("---------------------------------------------------"); -- Four; Put_Line("Attempting to Load Torpedo..."); Load; Put("Loading Torpedo: "); Put_Line(TridentSubmarine.loaded'Image); Put_Line("Attempting to Fire Torpedo..."); Put("Is Weapons System Ready to Fire?: "); Put_Line(TridentSubmarine.loadedTorpedoes'Image); Fire; Put(TridentSubmarine.firingTorpedoes'Image); Put(" Torpedo! Remaining "); Put_Line(TridentSubmarine.torpedoes'Image); Put_Line("---------------------------------------------------"); -- Five; Put_Line("Attempting to Load Torpedo..."); Load; Put("Loading Torpedo: "); Put_Line(TridentSubmarine.loaded'Image); Put_Line("Attempting to Fire Torpedo..."); Put("Is Weapons System Ready to Fire?: "); Put_Line(TridentSubmarine.loadedTorpedoes'Image); Fire; Put(TridentSubmarine.firingTorpedoes'Image); Put(" Torpedo! Remaining "); Put_Line(TridentSubmarine.torpedoes'Image); Put_Line("---------------------------------------------------"); -- Six; Put_Line("Attempting to Load Torpedo..."); Load; Put("Loading Torpedo: "); Put_Line(TridentSubmarine.loaded'Image); Put_Line("Attempting to Fire Torpedo..."); Put("Is Weapons System Ready to Fire?: "); Put_Line(TridentSubmarine.loadedTorpedoes'Image); Fire; Put(TridentSubmarine.firingTorpedoes'Image); Put(" Torpedo! Remaining "); Put_Line(TridentSubmarine.torpedoes'Image); Put_Line("---------------------------------------------------"); Put_Line("Attempting to Dive!"); Put("Depth Status: "); DepthPosition; Put_Line(TridentSubmarine.depthPositionCheck'Image); DepthTest; Put(TridentSubmarine.diveOperational'Image); Put(" at "); Put(TridentSubmarine.depthRange'Image); Put_Line(" metres..."); Put_Line("---------------------------------------------------"); DiveCheck; Put(TridentSubmarine.diveOperational'Image); Put(" from "); Put(TridentSubmarine.depthRange'Image); Put_Line(" metres..."); Put("Depth Status: "); DepthPosition; Put_Line(TridentSubmarine.depthPositionCheck'Image); DepthTest; Put(TridentSubmarine.diveOperational'Image); Put(" from "); Put(TridentSubmarine.depthRange'Image); Put_Line(" metres..."); Put("Depth Status: "); DepthPosition; Put_Line(TridentSubmarine.depthPositionCheck'Image); DepthTest; Put(TridentSubmarine.diveOperational'Image); Put(" from "); Put(TridentSubmarine.depthRange'Image); Put_Line(" metres..."); Put("Depth Status: "); DepthPosition; Put_Line(TridentSubmarine.depthPositionCheck'Image); DepthTest; Put(TridentSubmarine.diveOperational'Image); Put(" from "); Put(TridentSubmarine.depthRange'Image); Put_Line(" metres..."); Put("Depth Status: "); DepthPosition; Put_Line(TridentSubmarine.depthPositionCheck'Image); DepthTest; Put(TridentSubmarine.diveOperational'Image); Put(" from "); Put(TridentSubmarine.depthRange'Image); Put_Line(" metres..."); Put("Depth Status: "); DepthPosition; Put_Line(TridentSubmarine.depthPositionCheck'Image); Put_Line("---------------------------------------------------"); Put_Line("Resurfacing..."); EmergencySurface; Put("Depth Status: "); DepthPosition; Put_Line(TridentSubmarine.depthPositionCheck'Image); DepthTest; Put(TridentSubmarine.diveOperational'Image); Put(" at "); Put(TridentSubmarine.depthRange'Image); Put_Line(" metres..."); Put_Line("---------------------------------------------------"); Put_Line("Attempting Life Support Check!"); DiveCheck; Put("Life Support System: "); --100 LifeSupportCheck; Put(TridentSubmarine.lifeSupportStatus'Image); Put(" - Oxygen Percentage: "); Put_Line(TridentSubmarine.oxygenRange'Image); Put("Life Support System: "); LifeSupportCheck; Put(TridentSubmarine.lifeSupportStatus'Image); OxygenTest; Put(" - Oxygen Percentage: "); Put_Line(TridentSubmarine.oxygenRange'Image); Put("Life Support System: "); --90 LifeSupportCheck; Put(TridentSubmarine.lifeSupportStatus'Image); OxygenTest; Put(" - Oxygen Percentage: "); Put_Line(TridentSubmarine.oxygenRange'Image); Put("Life Support System: "); --80 LifeSupportCheck; Put(TridentSubmarine.lifeSupportStatus'Image); OxygenTest; Put(" - Oxygen Percentage: "); Put_Line(TridentSubmarine.oxygenRange'Image); Put("Life Support System: "); --70 LifeSupportCheck; Put(TridentSubmarine.lifeSupportStatus'Image); OxygenTest; Put(" - Oxygen Percentage: "); Put_Line(TridentSubmarine.oxygenRange'Image); Put("Life Support System: "); --60 LifeSupportCheck; Put(TridentSubmarine.lifeSupportStatus'Image); OxygenTest; Put(" - Oxygen Percentage: "); Put_Line(TridentSubmarine.oxygenRange'Image); Put("Life Support System: "); --50 LifeSupportCheck; Put(TridentSubmarine.lifeSupportStatus'Image); OxygenTest; Put(" - Oxygen Percentage: "); Put_Line(TridentSubmarine.oxygenRange'Image); Put("Life Support System: "); --40 LifeSupportCheck; Put(TridentSubmarine.lifeSupportStatus'Image); OxygenTest; Put(" - Oxygen Percentage: "); Put_Line(TridentSubmarine.oxygenRange'Image); Put("Life Support System: "); --30 LifeSupportCheck; Put(TridentSubmarine.lifeSupportStatus'Image); OxygenTest; Put(" - Oxygen Percentage: "); Put_Line(TridentSubmarine.oxygenRange'Image); Put("Life Support System: "); --20 LifeSupportCheck; Put(TridentSubmarine.lifeSupportStatus'Image); OxygenTest; Put(" - Oxygen Percentage: "); Put_Line(TridentSubmarine.oxygenRange'Image); Put("Life Support System: "); --10 LifeSupportCheck; Put(TridentSubmarine.lifeSupportStatus'Image); OxygenTest; Put(" - Oxygen Percentage: "); Put_Line(TridentSubmarine.oxygenRange'Image); Put("Life Support System: "); --0 LifeSupportCheck; Put(TridentSubmarine.lifeSupportStatus'Image); OxygenTest; Put(" - Oxygen Percentage: "); Put_Line(TridentSubmarine.oxygenRange'Image); LifeSupportCheck; Put_Line(TridentSubmarine.lifeSupportStatus'Image); Put_Line("---------------------------------------------------"); Put_Line("Attempting Reactor Temperature Check!"); DiveCheck; ReactorCheck; Put_Line("---------------------------------------------------"); end Main;
{ "source": "starcoderdata", "programming_language": "ada" }
-- { dg-do compile } -- { dg-options "-gnatws -O3" } with Discr21_Pkg; use Discr21_Pkg; package body Discr21 is type Index is new Natural range 0 .. 100; type Arr is array (Index range <> ) of Position; type Rec(Size : Index := 1) is record A : Arr(1 .. Size); end record; Data : Rec; function To_V(pos : Position) return VPosition is begin return To_Position(pos.x, pos.y, pos.z); end; procedure Read(Data : Rec) is pos : VPosition := To_V (Data.A(1)); begin null; end; procedure Test is begin Read (Data); end; end Discr21;
{ "source": "starcoderdata", "programming_language": "ada" }
-- with HAL; package Edc_Client.Matrix.Word is -------------------------------------------------------------------------- -- Shows the least significant byte on the matrix -- This is equivalent of the right byte on the matrix -------------------------------------------------------------------------- procedure Show_LSB (Value : HAL.UInt8) with Pre => Initialized; -------------------------------------------------------------------------- -- Shows the most significant byte on the matrix -- This is equivalent of the left byte on the matrix -------------------------------------------------------------------------- procedure Show_MSB (Value : HAL.UInt8) with Pre => Initialized; -------------------------------------------------------------------------- -- Shows the full word on the matrix -------------------------------------------------------------------------- procedure Show_Word (Value : HAL.UInt16) with Pre => Initialized; end Edc_Client.Matrix.Word;
{ "source": "starcoderdata", "programming_language": "ada" }
----------------------------------------------------------------------- with Wiki.Strings; private with Ada.Containers.Vectors; private with Ada.Finalization; private with Util.Refs; -- == Attributes == -- The `Attributes` package defines a simple management of attributes for -- the wiki document parser. Attribute lists are described by the `Attribute_List` -- with some operations to append or query for an attribute. Attributes are used for -- the Wiki document representation to describe the HTML attributes that were parsed and -- several parameters that describe Wiki content (links, ...). -- -- The Wiki filters and Wiki plugins have access to the attributes before they are added -- to the Wiki document. They can check them or modify them according to their needs. -- -- The Wiki renderers use the attributes to render the final HTML content. package Wiki.Attributes is pragma Preelaborate; type Cursor is private; -- Get the attribute name. function Get_Name (Position : in Cursor) return String; -- Get the attribute value. function Get_Value (Position : in Cursor) return String; -- Get the attribute wide value. function Get_Wide_Value (Position : in Cursor) return Wiki.Strings.WString; -- Returns True if the cursor has a valid attribute. function Has_Element (Position : in Cursor) return Boolean; -- Move the cursor to the next attribute. procedure Next (Position : in out Cursor); -- A list of attributes. type Attribute_List is private; -- Find the attribute with the given name. function Find (List : in Attribute_List; Name : in String) return Cursor; -- Find the attribute with the given name and return its value. function Get_Attribute (List : in Attribute_List; Name : in String) return Wiki.Strings.WString; -- Append the attribute to the attribute list. procedure Append (List : in out Attribute_List; Name : in Wiki.Strings.WString; Value : in Wiki.Strings.WString); -- Append the attribute to the attribute list. procedure Append (List : in out Attribute_List; Name : in String; Value : in Wiki.Strings.WString); -- Append the attribute to the attribute list. procedure Append (List : in out Attribute_List; Name : in String; Value : in Wiki.Strings.UString); -- Get the cursor to get access to the first attribute. function First (List : in Attribute_List) return Cursor; -- Get the number of attributes in the list. function Length (List : in Attribute_List) return Natural; -- Clear the list and remove all existing attributes. procedure Clear (List : in out Attribute_List); -- Iterate over the list attributes and call the <tt>Process</tt> procedure. procedure Iterate (List : in Attribute_List; Process : not null access procedure (Name : in String; Value : in Wiki.Strings.WString)); private type Attribute (Name_Length, Value_Length : Natural) is limited new Util.Refs.Ref_Entity with record Name : String (1 .. Name_Length); Value : Wiki.Strings.WString (1 .. Value_Length); end record; type Attribute_Access is access all Attribute; package Attribute_Refs is new Util.Refs.Indefinite_References (Attribute, Attribute_Access); use Attribute_Refs; subtype Attribute_Ref is Attribute_Refs.Ref; package Attribute_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Attribute_Ref); subtype Attribute_Vector is Attribute_Vectors.Vector; type Cursor is record Pos : Attribute_Vectors.Cursor; end record; type Attribute_List is new Ada.Finalization.Controlled with record List : Attribute_Vector; end record; -- Finalize the attribute list releasing any storage. overriding procedure Finalize (List : in out Attribute_List); end Wiki.Attributes;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Strings.UTF_Encoding; with Ada.Strings.Unbounded; package CommonText is package SU renames Ada.Strings.Unbounded; subtype Text is SU.Unbounded_String; subtype UTF8 is Ada.Strings.UTF_Encoding.UTF_8_String; blank : constant Text := SU.Null_Unbounded_String; -- converters : Text <==> String function USS (US : Text) return String; function SUS (S : String) return Text; -- converters : UTF8 <==> String function UTF8S (S8 : UTF8) return String; function SUTF8 (S : String) return UTF8; -- True if the string is zero length function IsBlank (US : Text) return Boolean; function IsBlank (S : String) return Boolean; -- True if strings are identical function equivalent (A, B : Text) return Boolean; function equivalent (A : Text; B : String) return Boolean; -- Trim both sides function trim (US : Text) return Text; function trim (S : String) return String; -- unpadded numeric image function int2str (A : Integer) return String; function int2text (A : Integer) return Text; -- convert boolean to lowercase string function bool2str (A : Boolean) return String; function bool2text (A : Boolean) return Text; -- shorthand for index function pinpoint (S : String; fragment : String) return Natural; function contains (S : String; fragment : String) return Boolean; function contains (US : Text; fragment : String) return Boolean; -- Return half of a string split by separator function part_1 (S : String; separator : String := "/") return String; function part_2 (S : String; separator : String := "/") return String; -- Replace a single character with another single character (first found) function replace (S : String; reject, shiny : Character) return String; -- Numeric image with left-padded zeros function zeropad (N : Natural; places : Positive) return String; -- Returns length of string function len (US : Text) return Natural; function len (S : String) return Natural; -- Returns number of instances of a given character in a given string function count_char (S : String; focus : Character) return Natural; -- Provides a mask of the given sql string, all quoted text set to '#' -- including the quote marks themselves. function redact_quotes (sql : String) return String; -- Removes leading and trailing whitespace, and any trailing semicolon function trim_sql (sql : String) return String; -- After masking, return number of queries separated by semicolons function count_queries (trimmed_sql : String) return Natural; -- Returns a single query given a multiquery and an index starting from 1 function subquery (trimmed_sql : String; index : Positive) return String; -- With "set" imput of comma-separated values, return number of items function num_set_items (nv : String) return Natural; end CommonText;
{ "source": "starcoderdata", "programming_language": "ada" }
-- -- pragma Ada_2012; with Skill.Types.Pools; package Skill.Iterators.Type_Hierarchy_Iterator is use type Skill.Types.Pools.Pool; type Iterator is tagged record Current : Skill.Types.Pools.Pool; End_Height : Natural; end record; procedure Init (This : access Iterator'Class; First : Skill.Types.Pools.Pool := null); function Element (This : access Iterator'Class) return Skill.Types.Pools.Pool is (This.Current); function Has_Next (This : access Iterator'Class) return Boolean is (null /= This.Current); procedure Next (This : access Iterator'Class); function Next (This : access Iterator'Class) return Skill.Types.Pools.Pool; end Skill.Iterators.Type_Hierarchy_Iterator;
{ "source": "starcoderdata", "programming_language": "ada" }
-- -- This package provides handlers for enumerative types. Since the -- type is not fixed in advance, the package needs to be generic. -- generic type Value_Type is (<>); package Line_Parsers.Receivers.Enumeration_Receivers is type Receiver_Type is new Abstract_Parameter_Handler with private; function Is_Set (Handler : Receiver_Type) return Boolean; overriding procedure Receive (Handler : in out Receiver_Type; Name : String; Value : String; Position : Natural); function Get (Handler : Receiver_Type) return Value_Type with Pre => Handler.Is_Set; overriding function Reusable (Handler : Receiver_Type) return Boolean; private type Receiver_Type is new Abstract_Parameter_Handler with record Value : Value_Type; Set : Boolean := False; end record; function Is_Set (Handler : Receiver_Type) return Boolean is (Handler.Set); function Reusable (Handler : Receiver_Type) return Boolean is (False); function Get (Handler : Receiver_Type) return Value_Type is (Handler.Value); end Line_Parsers.Receivers.Enumeration_Receivers;
{ "source": "starcoderdata", "programming_language": "ada" }
-------------------------------------------------------------------------------- with CL.API; with CL.Enumerations; with CL.Helpers; package body CL.Events is procedure Adjust (Object : in out Event) is use type System.Address; begin if Object.Location /= System.Null_Address then Helpers.Error_Handler (API.Retain_Event (Object.Location)); end if; end Adjust; procedure Finalize (Object : in out Event) is use type System.Address; begin if Object.Location /= System.Null_Address then Helpers.Error_Handler (API.Release_Event (Object.Location)); end if; end Finalize; procedure Wait_For (Subject : Event) is List : constant Event_List (1..1) := (1 => Subject'Unchecked_Access); begin Wait_For (List); end Wait_For; procedure Wait_For (Subjects : Event_List) is Raw_List : Address_List (Subjects'Range); begin for Index in Subjects'Range loop Raw_List (Index) := Subjects (Index).Location; end loop; Helpers.Error_Handler (API.Wait_For_Events (Subjects'Length, Raw_List (1)'Address)); end Wait_For; function Command_Queue (Source : Event) return Command_Queues.Queue is function Getter is new Helpers.Get_Parameter (Return_T => System.Address, Parameter_T => Enumerations.Event_Info, C_Getter => API.Get_Event_Info); function New_CQ_Reference is new Helpers.New_Reference (Object_T => Command_Queues.Queue); begin return New_CQ_Reference (Getter (Source, Enumerations.Command_Queue)); end Command_Queue; function Kind (Source : Event) return Command_Type is function Getter is new Helpers.Get_Parameter (Return_T => Command_Type, Parameter_T => Enumerations.Event_Info, C_Getter => API.Get_Event_Info); begin return Getter (Source, Enumerations.Command_T); end Kind; function Reference_Count (Source : Event) return UInt is function Getter is new Helpers.Get_Parameter (Return_T => UInt, Parameter_T => Enumerations.Event_Info, C_Getter => API.Get_Event_Info); begin return Getter (Source, Enumerations.Reference_Count); end Reference_Count; function Status (Source : Event) return Execution_Status is function Getter is new Helpers.Get_Parameter (Return_T => Execution_Status, Parameter_T => Enumerations.Event_Info, C_Getter => API.Get_Event_Info); begin return Getter (Source, Enumerations.Command_Execution_Status); end Status; function Profiling_Info_ULong is new Helpers.Get_Parameter (Return_T => ULong, Parameter_T => Enumerations.Profiling_Info, C_Getter => API.Get_Event_Profiling_Info); function Queued_At (Source : Event) return ULong is begin return Profiling_Info_ULong (Source, Enumerations.Command_Queued); end Queued_At; function Submitted_At (Source : Event) return ULong is begin return Profiling_Info_ULong (Source, Enumerations.Submit); end Submitted_At; function Started_At (Source : Event) return ULong is begin return Profiling_Info_ULong (Source, Enumerations.Start); end Started_At; function Ended_At (Source : Event) return ULong is begin return Profiling_Info_ULong (Source, Enumerations.P_End); end Ended_At; end CL.Events;
{ "source": "starcoderdata", "programming_language": "ada" }
with Agar.Core.Thin; package Agar.Core.DSO is subtype DSO_Access_t is Thin.DSO.DSO_Access_t; subtype DSO_Not_Null_Access_t is Thin.DSO.DSO_Not_Null_Access_t; function Load (Name : in String; Path : in String) return DSO_Access_t; function Unload (DSO : DSO_Not_Null_Access_t) return Boolean; function Lookup (Name : in String) return DSO_Access_t; procedure Lock renames Thin.DSO.Lock; procedure Unlock renames Thin.DSO.Unlock; generic type Subprogram_Access_Type is private; function Generic_Symbol_Lookup (DSO : in DSO_Not_Null_Access_t; Name : in String) return Subprogram_Access_Type; end Agar.Core.DSO;
{ "source": "starcoderdata", "programming_language": "ada" }
----------------------------------------------------------------------- with System; with Ada.Finalization; private with Interfaces.C.Strings; -- == Secret Service API == -- The Secret Service API is a service developped for the Gnome keyring and the KDE KWallet. -- It allows application to access and manage stored passwords and secrets in the two -- desktop environments. The libsecret is the C library that gives access to the secret -- service. The <tt>Secret</tt> package provides an Ada binding for this secret service API. -- -- @include secret-values.ads -- @include secret-attributes.ads -- @include secret-services.ads package Secret is type Object_Type is tagged private; -- Check if the value is empty. function Is_Null (Value : in Object_Type'Class) return Boolean; private use type System.Address; subtype Opaque_Type is System.Address; type Object_Type is new Ada.Finalization.Controlled with record Opaque : Opaque_Type := System.Null_Address; end record; -- Internal operation to set the libsecret internal pointer. procedure Set_Opaque (Into : in out Object_Type'Class; Data : in Opaque_Type); -- Internal operation to get the libsecret internal pointer. function Get_Opaque (From : in Object_Type'Class) return Opaque_Type; subtype Chars_Ptr is Interfaces.C.Strings.chars_ptr; procedure Free (P : in out Chars_Ptr) renames Interfaces.C.Strings.Free; function To_String (P : Chars_Ptr) return String renames Interfaces.C.Strings.Value; function New_String (V : in String) return Chars_Ptr renames Interfaces.C.Strings.New_String; type GError_Type is record Domain : Interfaces.Unsigned_32 := 0; Code : Interfaces.C.int := 0; Message : Chars_Ptr; end record with Convention => C; type GError is access all GError_Type with Convention => C; pragma Linker_Options ("-lsecret-1"); pragma Linker_Options ("-lglib-2.0"); pragma Linker_Options ("-lgio-2.0"); -- pragma Linker_Options ("-liconv"); end Secret;
{ "source": "starcoderdata", "programming_language": "ada" }
with Interfaces; use Interfaces; package GBA.Numerics is pragma Preelaborate; Pi : constant := 3.14159_26535_89793_23846_26433_83279_50288_41971_69399_37511; e : constant := 2.71828_18284_59045_23536_02874_71352_66249_77572_47093_69996; type Fixed_2_14 is delta 2.0**(-14) range -2.0 .. 2.0 - 2.0**(-14) with Size => 16; type Fixed_20_8 is delta 2.0**(-8) range -2.0**19 .. 2.0**19 with Size => 32; type Fixed_8_8 is delta 2.0**(-8) range -2.0**7 .. 2.0**7 - 2.0**(-8) with Size => 16; type Fixed_2_30 is delta 2.0**(-30) range -2.0 .. 2.0 - 2.0**(-30) with Size => 32; type Fixed_Unorm_8 is delta 2.0**(-8) range 0.0 .. 1.0 - 2.0**(-8) with Size => 8; type Fixed_Unorm_16 is delta 2.0**(-16) range 0.0 .. 1.0 - 2.0**(-16) with Size => 16; type Fixed_Unorm_32 is delta 2.0**(-32) range 0.0 .. 1.0 - 2.0**(-32) with Size => 32; subtype Fixed_Snorm_16 is Fixed_2_14 range -1.0 .. 1.0; subtype Fixed_Snorm_32 is Fixed_2_30 range -1.0 .. 1.0; -- Consider this to have an implicit unit of 2*Pi. -- Additive operators are defined to be cyclic. type Radians_16 is new Fixed_Unorm_16; overriding function "+" (X, Y : Radians_16) return Radians_16 with Pure_Function, Inline_Always; overriding function "-" (X, Y : Radians_16) return Radians_16 with Pure_Function, Inline_Always; overriding function "-" (X : Radians_16) return Radians_16 with Pure_Function, Inline_Always; -- Consider this to have an implicit unit of 2*Pi. -- Additive operators are defined to be cyclic. type Radians_32 is new Fixed_Unorm_32; overriding function "+" (X, Y : Radians_32) return Radians_32 with Pure_Function, Inline_Always; overriding function "-" (X, Y : Radians_32) return Radians_32 with Pure_Function, Inline_Always; overriding function "-" (X : Radians_32) return Radians_32 with Pure_Function, Inline_Always; subtype Affine_Transform_Parameter is Fixed_8_8; type Affine_Transform_Matrix is record DX, DMX, DY, DMY : Affine_Transform_Parameter; end record with Size => 64; for Affine_Transform_Matrix use record DX at 0 range 0 .. 15; DMX at 2 range 0 .. 15; DY at 4 range 0 .. 15; DMY at 6 range 0 .. 15; end record; function Sqrt (N : Unsigned_32) return Unsigned_16 with Pure_Function, Import, External_Name => "usqrt"; generic type Fixed is delta <>; with function Sqrt (N : Unsigned_32) return Unsigned_16; function Fixed_Sqrt (F : Fixed) return Fixed with Inline_Always; function Sin (Theta : Radians_32) return Fixed_Snorm_32 with Pure_Function, Inline_Always; function Cos (Theta : Radians_32) return Fixed_Snorm_32 with Pure_Function, Inline_Always; procedure Sin_Cos (Theta : Radians_32; Sin, Cos : out Fixed_Snorm_32) with Linker_Section => ".iwram.sin_cos"; pragma Machine_Attribute (Sin_Cos, "target", "arm"); function Sin_LUT (Theta : Radians_16) return Fixed_Snorm_16 with Pure_Function, Linker_Section => ".iwram.sin_lut"; function Cos_LUT (Theta : Radians_16) return Fixed_Snorm_16 with Pure_Function, Inline_Always; procedure Sin_Cos_LUT (Theta : Radians_16; Sin, Cos : out Fixed_Snorm_16) with Inline_Always; pragma Machine_Attribute (Sin_LUT, "target", "arm"); function Count_Trailing_Zeros (I : Long_Long_Integer) return Natural with Pure_Function, Inline_Always; function Count_Trailing_Zeros (I : Unsigned_64) return Natural with Pure_Function, Linker_Section => ".iwram.ctz64"; pragma Machine_Attribute (Count_Trailing_Zeros, "target", "arm"); function Count_Trailing_Zeros (I : Integer) return Natural with Pure_Function, Inline_Always; function Count_Trailing_Zeros (I : Unsigned_32) return Natural with Pure_Function, Linker_Section => ".iwram.ctz"; pragma Machine_Attribute (Count_Trailing_Zeros, "target", "arm"); function Count_Trailing_Zeros (I : Integer_16) return Natural with Pure_Function, Inline_Always; function Count_Trailing_Zeros (I : Unsigned_16) return Natural with Pure_Function, Linker_Section => ".iwram.ctz16"; pragma Machine_Attribute (Count_Trailing_Zeros, "target", "arm"); function Count_Leading_Zeros (I : Long_Long_Integer) return Natural with Pure_Function, Inline_Always; function Count_Leading_Zeros (I : Unsigned_64) return Natural with Pure_Function, Linker_Section => ".iwram.clz64"; pragma Machine_Attribute (Count_Leading_Zeros, "target", "arm"); function Count_Leading_Zeros (I : Integer) return Natural with Pure_Function, Inline_Always; function Count_Leading_Zeros (I : Unsigned_32) return Natural with Pure_Function, Linker_Section => ".iwram.clz"; pragma Machine_Attribute (Count_Leading_Zeros, "target", "arm"); function Count_Leading_Zeros (I : Integer_16) return Natural with Pure_Function, Inline_Always; function Count_Leading_Zeros (I : Unsigned_16) return Natural with Pure_Function, Linker_Section => ".iwram.clz16"; pragma Machine_Attribute (Count_Leading_Zeros, "target", "arm"); end GBA.Numerics;
{ "source": "starcoderdata", "programming_language": "ada" }
separate(Formatter.Get) procedure Format_string (Data : in Contents; In_The_String : in out String; Location : in out Natural; Width : in Natural := 0; Precision : in Natural := 0; Left_Justify : in Boolean := False) is -- ++ -- -- FUNCTIONAL DESCRIPTION: -- -- Formats data string according to input parameters. -- -- FORMAL PARAMETERS: -- -- Data: -- Input data string contained in variant record. -- -- In_The_String: -- Formatted Output String -- -- Location: -- Position in output string to place formatted input data string. -- -- Width: -- Field width of formatted output. -- -- Precision: -- Number of characters of input string to place in formatted output -- field. -- -- Left_Justify: -- Logical (Boolean) switch which specifies to left-justify output -- formatted string. -- -- DESIGN: -- -- If input string is greater than specified output field width then place -- justified sub-string in output field. Otherwise, place justified string -- in output field. -- -- -- -- Local variables Blanks : String(1..255) := (others => ' '); Data_Width : integer; begin -- Check data type if Data.Class = String_type then -- Is correct type to convert if Width = 0 then -- Put entire string into output buffer In_the_string(Location..Location + Data.String_value.The_Length - 1) := Data.String_value.The_String.All; Location := Location + Data.String_value.The_Length; else -- Non-zero field Width specified Data_Width := Data.String_value.The_Length; if Data_width > Width then -- Data string too long if Precision > 0 then -- Sub-string specified if Left_justify then In_The_String(Location..Location + Width - 1) := Data.String_value.The_String(1..Precision) & Blanks(1..Width - Precision); Location := Location + Width; else -- Right-justify In_The_String(Location..Location + WIDTH - 1) := Blanks(1..Width - Precision) & Data.String_value.The_String(1..Precision); Location := Location + WIDTH; end if; else -- Truncate string to fit in width of field if Left_Justify then -- Take left-most "width" characters In_the_string (Location..Location + Width - 1) := Data.String_value.The_String(1..Width); else -- Take right-most "width" characters In_the_string (Location..Location + Width - 1) := Data.String_value.The_String(Data_Width - Width + 1..Data_Width); end if; Location := Location + Width; end if; -- Long String else -- String < specified field Width If Precision > 0 Then -- Sub-String Specified If Left_justify Then In_the_string(Location..Location + Width - 1) := Data.String_value.The_String(1..Precision) & Blanks(1..Width - Precision); Location := Location + Width; Else -- Right-Justify In_the_string(Location..Location + Width - 1) := Blanks(1..Width - Precision) & Data.String_value.The_String(1..Precision); Location := Location + Width; end if; else -- No substring specified If Left_justify Then In_the_string(Location..Location + Width - 1) := Data.String_value.The_String.All & Blanks(1..Width - Data_width); Location := Location + Width; else -- Right justify In_the_string(Location..Location + Width - 1) := Blanks(1..Width - Data_width) & Data.String_value.The_String.All; Location := Location + Width; end if; -- Justify test end if; -- Substring specified end if; -- Field width test end if; else -- Wrong class type for format specifier -- Uses Global Default_Width constant Format_Error(In_The_String, Location, Default_Width); end if; -- Class test exception When others => -- Uses Global Default_Width constant Format_Error(In_The_String, Location, Default_Width); end Format_string;
{ "source": "starcoderdata", "programming_language": "ada" }
--* -- OBJECTIVE: -- CHECK THAT IF A COLLECTION SIZE SPECIFICATION IS GIVEN FOR AN -- ACCESS TYPE WHOSE DESIGNATED TYPE IS A DISCRIMINATED RECORD, THEN -- OPERATIONS ON VALUES OF THE ACCESS TYPE ARE NOT AFFECTED. -- HISTORY: -- BCB 09/29/87 CREATED ORIGINAL TEST. -- PWB 05/11/89 CHANGED EXTENSION FROM '.DEP' TO '.ADA'. WITH REPORT; USE REPORT; PROCEDURE CD2B11F IS BASIC_SIZE : CONSTANT := 1024; TYPE RECORD_TYPE(DISC : INTEGER := 100) IS RECORD COMP1 : INTEGER; COMP2 : INTEGER; COMP3 : INTEGER; END RECORD; TYPE ACC_RECORD IS ACCESS RECORD_TYPE; FOR ACC_RECORD'STORAGE_SIZE USE BASIC_SIZE; CHECK_RECORD1 : ACC_RECORD; CHECK_RECORD2 : ACC_RECORD; BEGIN TEST ("CD2B11F", "CHECK THAT IF A COLLECTION SIZE SPECIFICATION " & "IS GIVEN FOR AN ACCESS TYPE WHOSE " & "DESIGNATED TYPE IS A DISCRIMINATED RECORD, " & "THEN OPERATIONS ON VALUES OF THE ACCESS TYPE " & "ARE NOT AFFECTED"); CHECK_RECORD1 := NEW RECORD_TYPE; CHECK_RECORD1.COMP1 := 25; CHECK_RECORD1.COMP2 := 25; CHECK_RECORD1.COMP3 := 150; IF ACC_RECORD'STORAGE_SIZE < BASIC_SIZE THEN FAILED ("INCORRECT VALUE FOR RECORD TYPE ACCESS " & "STORAGE_SIZE"); END IF; IF CHECK_RECORD1.DISC /= IDENT_INT (100) THEN FAILED ("INCORRECT VALUE FOR RECORD DISCRIMINANT"); END IF; IF ((CHECK_RECORD1.COMP1 /= CHECK_RECORD1.COMP2) OR (CHECK_RECORD1.COMP1 = CHECK_RECORD1.COMP3)) THEN FAILED ("INCORRECT VALUE FOR RECORD COMPONENT"); END IF; IF EQUAL (3,3) THEN CHECK_RECORD2 := CHECK_RECORD1; END IF; IF CHECK_RECORD2 /= CHECK_RECORD1 THEN FAILED ("INCORRECT RESULTS FOR RELATIONAL OPERATOR"); END IF; RESULT; END CD2B11F;
{ "source": "starcoderdata", "programming_language": "ada" }
-- pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with x86_64_linux_gnu_bits_types_h; with Interfaces.C.Strings; with stddef_h; with xlocale_h; with unistd_h; with System; package time_h is -- unsupported macro: TIME_UTC 1 subtype clock_t is x86_64_linux_gnu_bits_types_h.uu_clock_t; -- /usr/include/time.h:59 subtype time_t is x86_64_linux_gnu_bits_types_h.uu_time_t; -- /usr/include/time.h:75 subtype clockid_t is x86_64_linux_gnu_bits_types_h.uu_clockid_t; -- /usr/include/time.h:91 subtype timer_t is x86_64_linux_gnu_bits_types_h.uu_timer_t; -- /usr/include/time.h:103 type timespec is record tv_sec : aliased x86_64_linux_gnu_bits_types_h.uu_time_t; -- /usr/include/time.h:122 tv_nsec : aliased x86_64_linux_gnu_bits_types_h.uu_syscall_slong_t; -- /usr/include/time.h:123 end record; pragma Convention (C_Pass_By_Copy, timespec); -- /usr/include/time.h:120 type tm is record tm_sec : aliased int; -- /usr/include/time.h:135 tm_min : aliased int; -- /usr/include/time.h:136 tm_hour : aliased int; -- /usr/include/time.h:137 tm_mday : aliased int; -- /usr/include/time.h:138 tm_mon : aliased int; -- /usr/include/time.h:139 tm_year : aliased int; -- /usr/include/time.h:140 tm_wday : aliased int; -- /usr/include/time.h:141 tm_yday : aliased int; -- /usr/include/time.h:142 tm_isdst : aliased int; -- /usr/include/time.h:143 tm_gmtoff : aliased long; -- /usr/include/time.h:146 tm_zone : Interfaces.C.Strings.chars_ptr; -- /usr/include/time.h:147 end record; pragma Convention (C_Pass_By_Copy, tm); -- /usr/include/time.h:133 type itimerspec is record it_interval : aliased timespec; -- /usr/include/time.h:163 it_value : aliased timespec; -- /usr/include/time.h:164 end record; pragma Convention (C_Pass_By_Copy, itimerspec); -- /usr/include/time.h:161 -- skipped empty struct sigevent function clock return clock_t; -- /usr/include/time.h:189 pragma Import (C, clock, "clock"); function time (uu_timer : access time_t) return time_t; -- /usr/include/time.h:192 pragma Import (C, time, "time"); function difftime (uu_time1 : time_t; uu_time0 : time_t) return double; -- /usr/include/time.h:195 pragma Import (C, difftime, "difftime"); function mktime (uu_tp : access tm) return time_t; -- /usr/include/time.h:199 pragma Import (C, mktime, "mktime"); function strftime (uu_s : Interfaces.C.Strings.chars_ptr; uu_maxsize : stddef_h.size_t; uu_format : Interfaces.C.Strings.chars_ptr; uu_tp : access constant tm) return stddef_h.size_t; -- /usr/include/time.h:205 pragma Import (C, strftime, "strftime"); function strptime (uu_s : Interfaces.C.Strings.chars_ptr; uu_fmt : Interfaces.C.Strings.chars_ptr; uu_tp : access tm) return Interfaces.C.Strings.chars_ptr; -- /usr/include/time.h:213 pragma Import (C, strptime, "strptime"); function strftime_l (uu_s : Interfaces.C.Strings.chars_ptr; uu_maxsize : stddef_h.size_t; uu_format : Interfaces.C.Strings.chars_ptr; uu_tp : access constant tm; uu_loc : xlocale_h.uu_locale_t) return stddef_h.size_t; -- /usr/include/time.h:223 pragma Import (C, strftime_l, "strftime_l"); function strptime_l (uu_s : Interfaces.C.Strings.chars_ptr; uu_fmt : Interfaces.C.Strings.chars_ptr; uu_tp : access tm; uu_loc : xlocale_h.uu_locale_t) return Interfaces.C.Strings.chars_ptr; -- /usr/include/time.h:230 pragma Import (C, strptime_l, "strptime_l"); function gmtime (uu_timer : access time_t) return access tm; -- /usr/include/time.h:239 pragma Import (C, gmtime, "gmtime"); function localtime (uu_timer : access time_t) return access tm; -- /usr/include/time.h:243 pragma Import (C, localtime, "localtime"); function gmtime_r (uu_timer : access time_t; uu_tp : access tm) return access tm; -- /usr/include/time.h:249 pragma Import (C, gmtime_r, "gmtime_r"); function localtime_r (uu_timer : access time_t; uu_tp : access tm) return access tm; -- /usr/include/time.h:254 pragma Import (C, localtime_r, "localtime_r"); function asctime (uu_tp : access constant tm) return Interfaces.C.Strings.chars_ptr; -- /usr/include/time.h:261 pragma Import (C, asctime, "asctime"); function ctime (uu_timer : access time_t) return Interfaces.C.Strings.chars_ptr; -- /usr/include/time.h:264 pragma Import (C, ctime, "ctime"); function asctime_r (uu_tp : access constant tm; uu_buf : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr; -- /usr/include/time.h:272 pragma Import (C, asctime_r, "asctime_r"); function ctime_r (uu_timer : access time_t; uu_buf : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr; -- /usr/include/time.h:276 pragma Import (C, ctime_r, "ctime_r"); tzname : aliased array (0 .. 1) of Interfaces.C.Strings.chars_ptr; -- /usr/include/time.h:289 pragma Import (C, tzname, "tzname"); procedure tzset; -- /usr/include/time.h:293 pragma Import (C, tzset, "tzset"); daylight : aliased int; -- /usr/include/time.h:297 pragma Import (C, daylight, "daylight"); timezone : aliased long; -- /usr/include/time.h:298 pragma Import (C, timezone, "timezone"); function stime (uu_when : access time_t) return int; -- /usr/include/time.h:304 pragma Import (C, stime, "stime"); function timegm (uu_tp : access tm) return time_t; -- /usr/include/time.h:319 pragma Import (C, timegm, "timegm"); function timelocal (uu_tp : access tm) return time_t; -- /usr/include/time.h:322 pragma Import (C, timelocal, "timelocal"); function dysize (uu_year : int) return int; -- /usr/include/time.h:325 pragma Import (C, dysize, "dysize"); function nanosleep (uu_requested_time : access constant timespec; uu_remaining : access timespec) return int; -- /usr/include/time.h:334 pragma Import (C, nanosleep, "nanosleep"); function clock_getres (uu_clock_id : clockid_t; uu_res : access timespec) return int; -- /usr/include/time.h:339 pragma Import (C, clock_getres, "clock_getres"); function clock_gettime (uu_clock_id : clockid_t; uu_tp : access timespec) return int; -- /usr/include/time.h:342 pragma Import (C, clock_gettime, "clock_gettime"); function clock_settime (uu_clock_id : clockid_t; uu_tp : access constant timespec) return int; -- /usr/include/time.h:345 pragma Import (C, clock_settime, "clock_settime"); function clock_nanosleep (uu_clock_id : clockid_t; uu_flags : int; uu_req : access constant timespec; uu_rem : access timespec) return int; -- /usr/include/time.h:353 pragma Import (C, clock_nanosleep, "clock_nanosleep"); function clock_getcpuclockid (uu_pid : unistd_h.pid_t; uu_clock_id : access clockid_t) return int; -- /usr/include/time.h:358 pragma Import (C, clock_getcpuclockid, "clock_getcpuclockid"); function timer_create (uu_clock_id : clockid_t; uu_evp : System.Address; uu_timerid : System.Address) return int; -- /usr/include/time.h:363 pragma Import (C, timer_create, "timer_create"); function timer_delete (uu_timerid : timer_t) return int; -- /usr/include/time.h:368 pragma Import (C, timer_delete, "timer_delete"); function timer_settime (uu_timerid : timer_t; uu_flags : int; uu_value : access constant itimerspec; uu_ovalue : access itimerspec) return int; -- /usr/include/time.h:371 pragma Import (C, timer_settime, "timer_settime"); function timer_gettime (uu_timerid : timer_t; uu_value : access itimerspec) return int; -- /usr/include/time.h:376 pragma Import (C, timer_gettime, "timer_gettime"); function timer_getoverrun (uu_timerid : timer_t) return int; -- /usr/include/time.h:380 pragma Import (C, timer_getoverrun, "timer_getoverrun"); function timespec_get (uu_ts : access timespec; uu_base : int) return int; -- /usr/include/time.h:386 pragma Import (C, timespec_get, "timespec_get"); getdate_err : aliased int; -- /usr/include/time.h:403 pragma Import (C, getdate_err, "getdate_err"); function getdate (uu_string : Interfaces.C.Strings.chars_ptr) return access tm; -- /usr/include/time.h:412 pragma Import (C, getdate, "getdate"); function getdate_r (uu_string : Interfaces.C.Strings.chars_ptr; uu_resbufp : access tm) return int; -- /usr/include/time.h:426 pragma Import (C, getdate_r, "getdate_r"); end time_h;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Text_IO; use Ada.Text_IO; procedure Test_LCS is function LCS (A, B : String) return String is L : array (A'First..A'Last + 1, B'First..B'Last + 1) of Natural; begin for I in L'Range (1) loop L (I, B'First) := 0; end loop; for J in L'Range (2) loop L (A'First, J) := 0; end loop; for I in A'Range loop for J in B'Range loop if A (I) = B (J) then L (I + 1, J + 1) := L (I, J) + 1; else L (I + 1, J + 1) := Natural'Max (L (I + 1, J), L (I, J + 1)); end if; end loop; end loop; declare I : Integer := L'Last (1); J : Integer := L'Last (2); R : String (1..Integer'Max (A'Length, B'Length)); K : Integer := R'Last; begin while I > L'First (1) and then J > L'First (2) loop if L (I, J) = L (I - 1, J) then I := I - 1; elsif L (I, J) = L (I, J - 1) then J := J - 1; else I := I - 1; J := J - 1; R (K) := A (I); K := K - 1; end if; end loop; return R (K + 1..R'Last); end; end LCS; begin Put_Line (LCS ("thisisatest", "testing123testing")); end Test_LCS;
{ "source": "starcoderdata", "programming_language": "ada" }
------------------------------------------------------------- with Incr.Nodes.Tokens; package body Incr.Nodes is To_Diff : constant array (Boolean) of Integer := (False => -1, True => 1); ------------------ -- Constructors -- ------------------ package body Constructors is ---------------- -- Initialize -- ---------------- procedure Initialize (Self : aliased in out Node_With_Parent'Class) is begin Versioned_Booleans.Initialize (Self.Exist, False); Versioned_Booleans.Initialize (Self.LC, False); Versioned_Booleans.Initialize (Self.LE, False); Versioned_Nodes.Initialize (Self.Parent, null); end Initialize; ------------------------ -- Initialize_Ancient -- ------------------------ procedure Initialize_Ancient (Self : aliased in out Node_With_Parent'Class; Parent : Node_Access) is begin Versioned_Booleans.Initialize (Self.Exist, True); Versioned_Booleans.Initialize (Self.LC, False); Versioned_Booleans.Initialize (Self.LE, False); Versioned_Nodes.Initialize (Self.Parent, Parent); end Initialize_Ancient; end Constructors; ------------ -- Exists -- ------------ overriding function Exists (Self : Node_With_Exist; Time : Version_Trees.Version) return Boolean is begin return Versioned_Booleans.Get (Self.Exist, Time); end Exists; ----------------- -- Child_Index -- ----------------- function Child_Index (Self : Node'Class; Child : Constant_Node_Access; Time : Version_Trees.Version) return Natural is begin for J in 1 .. Self.Arity loop if Constant_Node_Access (Self.Child (J, Time)) = Child then return J; end if; end loop; return 0; end Child_Index; -------------------- -- Discard_Parent -- -------------------- overriding procedure Discard_Parent (Self : in out Node_With_Parent) is Changed : Boolean; Ignore : Integer := 0; Now : constant Version_Trees.Version := Self.Document.History.Changing; begin Changed := Self.Local_Changes > 0 or Self.Nested_Changes > 0; if Changed then Self.Propagate_Nested_Changes (-1); end if; Versioned_Nodes.Discard (Self.Parent, Now, Ignore); if Changed then Self.Propagate_Nested_Changes (1); end if; end Discard_Parent; ----------------- -- First_Token -- ----------------- function First_Token (Self : aliased in out Node'Class; Time : Version_Trees.Version) return Tokens.Token_Access is Child : Node_Access; begin if Self.Arity > 0 then Child := Self.Child (1, Time); if Child.Is_Token then return Tokens.Token_Access (Child); else return Child.First_Token (Time); end if; elsif Self.Is_Token then return Tokens.Token'Class (Self)'Access; else return null; end if; end First_Token; -------------- -- Get_Flag -- -------------- overriding function Get_Flag (Self : Node_With_Exist; Flag : Transient_Flags) return Boolean is begin return Self.Flag (Flag); end Get_Flag; ---------------- -- Last_Token -- ---------------- function Last_Token (Self : aliased in out Node'Class; Time : Version_Trees.Version) return Tokens.Token_Access is Child : Node_Access; begin if Self.Arity > 0 then Child := Self.Child (Self.Arity, Time); if Child.Is_Token then return Tokens.Token_Access (Child); else return Child.Last_Token (Time); end if; elsif Self.Is_Token then return Tokens.Token'Class (Self)'Access; else return null; end if; end Last_Token; ------------------- -- Local_Changes -- ------------------- overriding function Local_Changes (Self : Node_With_Exist; From : Version_Trees.Version; To : Version_Trees.Version) return Boolean is use type Version_Trees.Version; Time : Version_Trees.Version := To; begin if Self.Document.History.Is_Changing (To) then -- Self.LC doesn't contain Local_Changes for Is_Changing version yet -- Take it from Self.Nested_Changes if Self.Local_Changes > 0 then return True; elsif Time = From then return False; end if; Time := Self.Document.History.Parent (Time); end if; while Time /= From loop if Versioned_Booleans.Get (Self.LC, Time) then return True; end if; Time := Self.Document.History.Parent (Time); end loop; return False; end Local_Changes; --------------------------- -- Mark_Deleted_Children -- --------------------------- procedure Mark_Deleted_Children (Self : in out Node'Class) is function Find_Root (Node : Node_Access) return Node_Access; -- Find top root accessible from the Node procedure Delete_Tree (Node : not null Node_Access; Parent : Node_Access; Index : Positive); -- Check Node if it's disjointed from ultra-root. -- Delete a subtree rooted from Node if so. -- If Parent /= null also set Parent.Child(Index) to null. Now : constant Version_Trees.Version := Self.Document.History.Changing; ----------------- -- In_The_Tree -- ----------------- function Find_Root (Node : Node_Access) return Node_Access is Child : not null Nodes.Node_Access := Node; begin loop declare Parent : constant Nodes.Node_Access := Child.Parent (Now); begin if Parent = null then return Child; else Child := Parent; end if; end; end loop; end Find_Root; ----------------- -- Delete_Tree -- ----------------- procedure Delete_Tree (Node : not null Node_Access; Parent : Node_Access; Index : Positive) is Changes : Integer := 0; begin if not Node.Exists (Now) then return; elsif Node.Parent (Now) /= Parent then declare Root : constant Node_Access := Find_Root (Node); begin if Root = Self.Document.Ultra_Root then return; end if; end; end if; for J in 1 .. Node.Arity loop declare Child : constant Node_Access := Node.Child (J, Now); begin Delete_Tree (Child, Node, J); end; end loop; Versioned_Booleans.Set (Node_With_Exist (Node.all).Exist, False, Now, Changes => Changes); if Parent /= null then Parent.Set_Child (Index, null); end if; end Delete_Tree; Prev : constant Version_Trees.Version := Self.Document.History.Parent (Now); Child : Node_Access; begin for J in 1 .. Self.Arity loop Child := Self.Child (J, Prev); if Child /= null and then Child.Exists (Now) and then Child.Parent (Now) /= Self'Unchecked_Access then Child := Find_Root (Child); if Child /= Self.Document.Ultra_Root then Delete_Tree (Child, null, J); end if; end if; end loop; end Mark_Deleted_Children; ------------------ -- Local_Errors -- ------------------ overriding function Local_Errors (Self : Node_With_Exist; Time : Version_Trees.Version) return Boolean is begin return Versioned_Booleans.Get (Self.LE, Time); end Local_Errors; ------------------ -- Next_Subtree -- ------------------ function Next_Subtree (Self : Node'Class; Time : Version_Trees.Version) return Node_Access is Node : Constant_Node_Access := Self'Unchecked_Access; Parent : Node_Access := Node.Parent (Time); Child : Node_Access; begin while Parent /= null loop declare J : constant Natural := Parent.Child_Index (Node, Time); begin if J in 1 .. Parent.Arity - 1 then for K in J + 1 .. Parent.Arity loop Child := Parent.Child (K, Time); if Child /= null then return Child; end if; end loop; end if; end; Node := Constant_Node_Access (Parent); Parent := Node.Parent (Time); end loop; return null; end Next_Subtree; --------------- -- On_Commit -- --------------- overriding procedure On_Commit (Self : in out Node_With_Exist; Parent : Node_Access) is Now : constant Version_Trees.Version := Self.Document.History.Changing; This : constant Node_Access := Self'Unchecked_Access; Child : Node_Access; Diff : Integer := 0; -- Ignore this diff begin pragma Assert (Node'Class (Self).Parent (Now) = Parent); Versioned_Booleans.Set (Self.LC, Self.Local_Changes > 0, Now, Diff); Self.Nested_Changes := 0; Self.Local_Changes := 0; Self.Flag := (others => False); for J in 1 .. This.Arity loop Child := This.Child (J, Now); if Child /= null then Child.On_Commit (Self'Unchecked_Access); end if; end loop; end On_Commit; ------------ -- Parent -- ------------ overriding function Parent (Self : Node_With_Parent; Time : Version_Trees.Version) return Node_Access is begin return Versioned_Nodes.Get (Self.Parent, Time); end Parent; ---------------------- -- Previous_Subtree -- ---------------------- function Previous_Subtree (Self : Node'Class; Time : Version_Trees.Version) return Node_Access is Node : Constant_Node_Access := Self'Unchecked_Access; Parent : Node_Access := Node.Parent (Time); Child : Node_Access; begin while Parent /= null loop declare J : constant Natural := Parent.Child_Index (Node, Time); begin if J in 2 .. Parent.Arity then for K in reverse 1 .. J - 1 loop Child := Parent.Child (K, Time); if Child /= null then return Child; end if; end loop; end if; end; Node := Constant_Node_Access (Parent); Parent := Node.Parent (Time); end loop; return null; end Previous_Subtree; ------------------------------ -- Propagate_Nested_Changes -- ------------------------------ procedure Propagate_Nested_Changes (Self : in out Node'Class; Diff : Integer) is Parent : constant Node_Access := Self.Parent (Self.Document.History.Changing); begin if Parent /= null then Parent.On_Nested_Changes (Diff); end if; end Propagate_Nested_Changes; ------------------------------ -- Propagate_Nested_Changes -- ------------------------------ overriding procedure On_Nested_Changes (Self : in out Node_With_Exist; Diff : Integer) is Before : Boolean; After : Boolean; begin Before := Self.Local_Changes > 0 or Self.Nested_Changes > 0; Self.Nested_Changes := Self.Nested_Changes + Diff; After := Self.Local_Changes > 0 or Self.Nested_Changes > 0; if Before /= After then Self.Propagate_Nested_Changes (To_Diff (After)); end if; end On_Nested_Changes; -------------- -- Set_Flag -- -------------- overriding procedure Set_Flag (Self : in out Node_With_Exist; Flag : Transient_Flags; Value : Boolean := True) is Before : Boolean; After : Boolean; begin Before := (Self.Flag and Local_Changes_Mask) /= No_Flags; Self.Flag (Flag) := Value; After := (Self.Flag and Local_Changes_Mask) /= No_Flags; if Before /= After then Self.Update_Local_Changes (To_Diff (After)); end if; end Set_Flag; ---------------------- -- Set_Local_Errors -- ---------------------- overriding procedure Set_Local_Errors (Self : in out Node_With_Exist; Value : Boolean := True) is Now : constant Version_Trees.Version := Self.Document.History.Changing; Diff : Integer := 0; begin Versioned_Booleans.Set (Self.LE, Value, Now, Diff); Self.Update_Local_Changes (Diff); end Set_Local_Errors; ---------------- -- Set_Parent -- ---------------- overriding procedure Set_Parent (Self : in out Node_With_Parent; Value : Node_Access) is Changed : Boolean; Ignore : Integer := 0; Now : constant Version_Trees.Version := Self.Document.History.Changing; begin Changed := Self.Local_Changes > 0 or Self.Nested_Changes > 0; if Changed then Self.Propagate_Nested_Changes (-1); end if; Versioned_Nodes.Set (Self.Parent, Value, Now, Ignore); if Changed then Self.Propagate_Nested_Changes (1); end if; end Set_Parent; -------------------------- -- Update_Local_Changes -- -------------------------- not overriding procedure Update_Local_Changes (Self : in out Node_With_Exist; Diff : Integer) is Before : Boolean; After : Boolean; begin Before := Self.Local_Changes > 0 or Self.Nested_Changes > 0; Self.Local_Changes := Self.Local_Changes + Diff; After := Self.Local_Changes > 0 or Self.Nested_Changes > 0; if Before /= After then Self.Propagate_Nested_Changes (To_Diff (After)); end if; end Update_Local_Changes; end Incr.Nodes;
{ "source": "starcoderdata", "programming_language": "ada" }
package scanner.DFA is Aflex_Debug : Boolean := False; YYText_Ptr : Integer; -- points to start of yytext in buffer -- yy_ch_buf has to be 2 characters longer than YY_BUF_SIZE because we -- need to put in 2 end-of-buffer characters (this is explained where -- it is done) at the end of yy_ch_buf YY_READ_BUF_SIZE : constant Integer := 8192; YY_BUF_SIZE : constant Integer := YY_READ_BUF_SIZE * 2; -- Size of input buffer type Unbounded_Character_Array is array (Integer range <>) of Wide_Wide_Character; type Ch_Buf_Type is record Data : Unbounded_Character_Array (0 .. YY_BUF_SIZE + 1); end record; function Previous (Data : Ch_Buf_Type; Index : Integer) return Wide_Wide_Character; procedure Next (Data : Ch_Buf_Type; Index : in out Integer; Code : out Wide_Wide_Character); YY_Ch_Buf : Ch_Buf_Type; YY_CP : Integer; YY_BP : Integer; YY_C_Buf_P : Integer; -- Points to current character in buffer function YYText return Wide_Wide_String; function YYLength return Integer; procedure YY_DO_BEFORE_ACTION; -- These variables are needed between calls to YYLex. YY_Init : Boolean := True; -- do we need to initialize YYLex? YY_Start : Integer := 0; -- current start state number subtype YY_State_Type is Integer; YY_Last_Accepting_State : YY_State_Type; YY_Last_Accepting_Cpos : Integer; end scanner.DFA;
{ "source": "starcoderdata", "programming_language": "ada" }
package body Ordered_Maps_G is function Binary_Search (M: Map; Key: Key_Type; Left: Integer; Right: Integer) return Integer is Middle: Integer; begin if Right < Left then return Left; else Middle := (Left + Right)/2; if Left = Right then return Left; elsif M.P_Array(Middle).Key < Key then return Binary_Search (M,Key,Middle + 1,Right); elsif Key < M.P_Array(Middle).Key then return Binary_Search (M,Key,Left,Middle); else return Middle; end if; end if; end Binary_Search; procedure Put (M: in out Map; Key: Key_Type; Value: Value_Type) is Position: Integer := 0; Left: Integer := 0; begin if M.P_Array = null or M.Length = 0 then M.P_Array := new Cell_Array; M.P_Array(0) := (Key, Value, True); M.Length := 1; else Position := Binary_Search (M,Key,Left,M.Length); if Position > Max - 1 then raise Full_Map; end if; if M.P_Array(Position).Full and M.P_Array(Position).Key = Key then M.P_Array(Position).Value := Value; elsif M.P_Array(Position).Full then for I in reverse Position..M.Length-1 loop if M.Length = Max then raise Full_Map; end if; M.P_Array(I + 1) := M.P_Array(I); end loop; M.Length := M.Length + 1; M.P_Array(Position) := (Key, Value, True); else M.P_Array(Position) := (Key, Value, True); M.Length := M.Length + 1; end if; end if; end Put; procedure Get (M: Map; Key: in Key_Type; Value: out Value_Type; Success: out Boolean) is Left: Integer := 0; Right: Integer := Max-1; Position: Integer := 0; begin Success := False; if M.P_Array /= null then Position := Binary_Search (M,Key,Left,Right); if Position <= Max - 1 then if M.P_Array(0).Key = Key then Success := True; Value := M.P_Array(Binary_Search (M,Key,Left,Right)).Value; end if; end if; end if; end Get; procedure Delete (M: in out Map; Key: in Key_Type; Success: out Boolean) is Left: Integer := 0; Right: Integer := M.Length; Position: Integer; begin Success := False; Position := Binary_Search (M,Key,Left,Right); if Position <= Max - 1 then if M.P_Array(Position).Key = Key then Success := True; M.Length := M.Length - 1; for I in Position..M.Length - 1 loop M.P_Array(I) := M.P_Array(I + 1); end loop; end if; end if; end Delete; function Map_Length (M: Map) return Natural is begin return M.Length; end Map_Length; function First (M: Map) return Cursor is C: Cursor; begin C.M := M; C.Position := 0; return C; end First; procedure Next (C: in out Cursor) is End_Of_Map: Boolean; begin End_Of_Map := False; if C.Position <= Max then C.Position := C.Position + 1; end if; end Next; function Has_Element (C: Cursor) return Boolean is begin if C.Position >= C.M.Length then return False; end if; return C.M.P_Array(C.Position).Full; end Has_Element; function Element (C: Cursor) return Element_Type is Element: Element_Type; begin if Has_Element (C) then Element.Key := C.M.P_Array(C.Position).Key; Element.Value := C.M.P_Array(C.Position).Value; else raise No_Element; end if; return Element; end Element; end Ordered_Maps_G;
{ "source": "starcoderdata", "programming_language": "ada" }
-- SOFTWARE. -- TODO Error Handling with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; package body Simh_Tapes is function Reverse_Dword_Bytes (In_Dw : in Dword_T) return Dword_T is begin return Shift_Left (In_Dw and 16#0000_00ff#, 24) or Shift_Left (In_Dw and 16#0000_ff00#, 8) or Shift_Right (In_Dw and 16#00ff_0000#, 8) or Shift_Right (In_Dw and 16#ff00_0000#, 24); end Reverse_Dword_Bytes; -- Read_Meta_Data reads a four byte (one doubleword) header, trailer, or other metadata record -- from the supplied tape image file procedure Read_Meta_Data (Img_Stream : in out Stream_Access; Meta_Data : out Dword_T) is Tmp_Dw : Dword_T; begin Dword_T'Read (Img_Stream, Tmp_Dw); -- Meta_Data := Reverse_Dword_Bytes (Tmp_Dw); Meta_Data := Tmp_Dw; end Read_Meta_Data; -- Write_Meta_Data writes a 4-byte header/trailer or other metadata procedure Write_Meta_Data (Img_Stream : in out Stream_Access; Meta_Data : in Dword_T) is -- Tmp_Dw : Dword_T; begin -- Tmp_Dw := Reverse_Dword_Bytes (Meta_Data); -- Dword_T'Write (Img_Stream, Tmp_Dw); Dword_T'Write (Img_Stream, Meta_Data); end Write_Meta_Data; -- Read_Record_Data attempts to read a data record from SimH tape image, fails if wrong number of bytes read -- N.B. does not read the header and trailer procedure Read_Record_Data (Img_Stream : in out Stream_Access; Num_Bytes : in Natural; Rec : out Mt_Rec) is Tmp_Rec : Mt_Rec (1..Num_Bytes); Out_Rec_Ix : Integer := Rec'First; begin for C in 1 .. Num_Bytes loop Byte_T'Read (Img_Stream, Tmp_Rec(C)); Rec(Out_Rec_Ix) := Tmp_Rec(C); Out_Rec_Ix := Out_Rec_Ix + 1; end loop; end Read_Record_Data; -- Write_Record_Data writes the actual data - not the header/trailer procedure Write_Record_Data (Img_Stream : in out Stream_Access; Rec : in Mt_Rec) is begin for C in Rec'Range loop Byte_T'Write( Img_Stream, Rec(C)); end loop; end Write_Record_Data; procedure Rewind (Img_File : in out File_Type) is begin Set_Index (Img_File, 1); end Rewind; -- internal function function Space_Forward_1_Rec (Img_Stream : in out Stream_Access) return Mt_Stat is Hdr, Trailer : Dword_T; begin Read_Meta_Data (Img_Stream , Hdr); if Hdr = Mtr_Tmk then return Tmk; end if; -- read and discard 1 record declare Rec : Mt_Rec(1..Natural(Hdr)); begin Read_Record_Data (Img_Stream , Natural(Hdr), Rec); end; -- check trailer Read_Meta_Data (Img_Stream , Trailer); if Hdr /= Trailer then return InvRec; end if; return OK; end Space_Forward_1_Rec; -- SpaceFwd advances the virtual tape by the specified amount (N.B. 0 means 1 whole file) function Space_Forward (Img_Stream : in out Stream_Access; Num_Recs : in Integer) return Mt_Stat is Simh_Stat : Mt_Stat := IOerr; Done : Boolean := false; Hdr, Trailer : Dword_T; Rec_Cnt : Integer := Num_Recs; begin if Num_Recs = 0 then -- one whole file while not Done loop Read_Meta_Data (Img_Stream , Hdr); if Hdr = Mtr_Tmk then Simh_Stat := OK; Done := true; else -- read and discard 1 record declare Rec : Mt_Rec(1..Natural(Hdr)); begin Read_Record_Data (Img_Stream , Natural(Hdr), Rec); end; -- check trailer Read_Meta_Data (Img_Stream , Trailer); if Hdr /= Trailer then return InvRec; end if; end if; end loop; else -- otherwise word count is a negative number and we space fwd that many records while Rec_Cnt /= 0 loop Rec_Cnt := Rec_Cnt + 1; Simh_Stat := Space_Forward_1_Rec (Img_Stream); if Simh_Stat /= OK then return Simh_Stat; end if; end loop; end if; return Simh_Stat; end Space_Forward; -- Scan_Image - attempt to read a whole tape image ensuring headers, record sizes, and trailers match -- TODO if csv is true then output is in CSV format function Scan_Image (Img_Filename : in String) return String is Result : Unbounded_String; Img_File : File_Type; Img_Stream : Stream_Access; Hdr, Trailer : Dword_T; File_Count : Integer := -1; File_Size, Mark_Count, Record_Num : Integer := 0; Dummy_Rec : Mt_Rec(1..32768); begin Open (File => Img_File, Mode => In_File, Name => Img_Filename); Img_Stream := stream(Img_File); Record_Loop : loop Read_Meta_Data (Img_Stream , Hdr); case Hdr is when Mtr_Tmk => if File_Size > 0 then File_Count := File_Count + 1; Result := Result & Dasher_NL & "File " & Integer'Image(File_Count) & " : " & Integer'Image(File_Size) & " bytes in " & Integer'Image(Record_Num) & " blocks"; File_Size := 0; Record_Num := 0; end if; Mark_Count := Mark_Count + 1; if Mark_Count = 3 then Result := Result & Dasher_NL & "Triple Mark (old End-of-Tape indicator)"; exit Record_Loop; end if; when Mtr_EOM => Result := Result & Dasher_NL & "End of Medium"; exit Record_Loop; when Mtr_Gap => Result := Result & Dasher_NL & "Erase Gap"; Mark_Count := 0; when others => Record_Num := Record_Num + 1; Mark_Count := 0; Read_Record_Data (Img_Stream, Natural(Hdr), Dummy_Rec); Read_Meta_Data (Img_Stream , Trailer); if Hdr = Trailer then File_Size := File_Size + Integer(Hdr); else Result := Result & Dasher_NL & "Non-matching trailer found."; end if; end case; end loop Record_Loop; Close (Img_File); return To_String(Result); end Scan_Image; end Simh_Tapes;
{ "source": "starcoderdata", "programming_language": "ada" }
with Definitions; use Definitions; with HelperText; private with Utilities; package Parameters is package HT renames HelperText; no_ccache : constant String := "none"; no_unkindness : constant String := "none"; raven_confdir : constant String := host_localbase & "/etc/ravenadm"; type configuration_record is record profile : HT.Text; dir_sysroot : HT.Text; dir_toolchain : HT.Text; dir_localbase : HT.Text; dir_conspiracy : HT.Text; dir_unkindness : HT.Text; dir_distfiles : HT.Text; dir_packages : HT.Text; dir_ccache : HT.Text; dir_buildbase : HT.Text; dir_profile : HT.Text; dir_logs : HT.Text; dir_options : HT.Text; num_builders : builders; jobs_limit : builders; avoid_tmpfs : Boolean; defer_prebuilt : Boolean; avec_ncurses : Boolean; record_options : Boolean; batch_mode : Boolean; -- defaults def_firebird : HT.Text; def_lua : HT.Text; def_mysql_group : HT.Text; def_perl : HT.Text; def_php : HT.Text; def_postgresql : HT.Text; def_python3 : HT.Text; def_ruby : HT.Text; def_ssl : HT.Text; def_tcl_tk : HT.Text; -- Computed, not saved number_cores : cpu_range; dir_repository : HT.Text; sysroot_pkg8 : HT.Text; end record; configuration : configuration_record; active_profile : HT.Text; -- Gentoo linux puts chroot in /usr/bin when ever other system has the program or -- a symlink at /usr/sbin. Precreate the longest string for the command. chroot_cmd : String := "/usr/sbin/chroot "; -- Return true if configuration file exists. -- Reason: if it doesn't, we need to check privileges because root is needed -- to pre-create the first version function configuration_exists return Boolean; -- This procedure will create a default configuration file if one -- does not already exist, otherwise it will it load it. In every case, -- the "configuration" record will be populated after this is run. -- returns "True" on success function load_configuration return Boolean; -- Maybe a previously valid directory path has been removed. This -- function returns true when all the paths still work. -- The configuration must be loaded before it's run, of course. function all_paths_valid (skip_mk_check : Boolean) return Boolean; -- Return true if the localbase is set to someplace it really shouldn't be function forbidden_localbase (candidate : String) return Boolean; -- Return a profile record filled with dynamic defaults. function default_profile (new_profile : String) return configuration_record; -- Delete any existing profile data and create a new profile. -- Typically a save operation follows. procedure insert_profile (confrec : configuration_record); -- Create or overwrite a complete ravenadm.ini file using internal data at IFM procedure rewrite_configuration; -- Return True if 3 or more sections exist (1 is global, the rest must be profiles) function alternative_profiles_exist return Boolean; -- Return a LF-delimited list of profiles contained in ravenadm.ini function list_profiles return String; -- Remove an entire profile from the configuration and save it. procedure delete_profile (profile : String); -- Updates master section with new profile name and initiates a transfer procedure switch_profile (to_profile : String); -- Returns SSL selection (converts "floating" to default) function ssl_selection (confrec : in configuration_record) return String; private package UTL renames Utilities; memory_probe : exception; profile_DNE : exception; memory_megs : Natural := 0; -- Default Sizing by number of CPUS -- 1 CPU :: 1 Builder, 1 job per builder -- 2/3 CPU :: 2 builders, 2 jobs per builder -- 4/5 CPU :: 3 builders, 3 jobs per builder -- 6/7 CPU :: 4 builders, 3 jobs per builder -- 8/9 CPU :: 6 builders, 4 jobs per builder -- 10/11 CPU :: 8 builders, 4 jobs per builder -- 12+ CPU :: floor (75% * CPU), 5 jobs per builder Field_01 : constant String := "directory_sysroot"; Field_16 : constant String := "directory_toolchain"; Field_02 : constant String := "directory_localbase"; Field_03 : constant String := "directory_conspiracy"; Field_04 : constant String := "directory_unkindness"; Field_05 : constant String := "directory_distfiles"; Field_06 : constant String := "directory_profile"; Field_07 : constant String := "directory_packages"; Field_08 : constant String := "directory_ccache"; Field_09 : constant String := "directory_buildbase"; Field_10 : constant String := "number_of_builders"; Field_11 : constant String := "max_jobs_per_builder"; Field_12 : constant String := "avoid_tmpfs"; Field_13 : constant String := "leverage_prebuilt"; Field_14 : constant String := "display_with_ncurses"; Field_15 : constant String := "record_default_options"; Field_27 : constant String := "assume_default_options"; Field_17 : constant String := "default_firebird"; Field_18 : constant String := "default_lua"; Field_19 : constant String := "default_mysql_group"; Field_20 : constant String := "default_perl"; Field_21 : constant String := "default_php"; Field_22 : constant String := "default_postgresql"; Field_23 : constant String := "default_python3"; Field_24 : constant String := "default_ruby"; Field_25 : constant String := "default_ssl"; Field_26 : constant String := "default_tcl_tk"; global_01 : constant String := "profile_selected"; global_02 : constant String := "url_conspiracy"; first_profile : constant String := "primary"; master_section : constant String := "Global Configuration"; pri_packages : constant String := raven_var & "/[X]/packages"; pri_profile : constant String := raven_var & "/[X]"; pri_buildbase : constant String := raven_var & "/builders"; ravenadm_ini : constant String := "ravenadm.ini"; conf_location : constant String := raven_confdir & "/" & ravenadm_ini; std_localbase : constant String := "/raven"; std_distfiles : constant String := raven_var & "/distfiles"; std_conspiracy : constant String := raven_var & "/conspiracy"; std_sysroot : constant String := std_localbase & "/share/raven/sysroot/" & UTL.mixed_opsys (platform_type); std_toolchain : constant String := std_localbase & "/share/raven/toolchain"; procedure query_physical_memory; procedure query_physical_memory_linux; procedure query_physical_memory_sunos; function enough_memory (num_builders : builders) return Boolean; procedure default_parallelism (num_cores : cpu_range; num_builders : out Integer; jobs_per_builder : out Integer); -- Copy from IFM to configuration record, updating type as necessary. -- If values are missing, use default values. -- If profile in global does not exist, throw exception procedure transfer_configuration; -- Determine and store number of cores. It's needed for dynamic configuration and -- the value is used in the build cycle as well. procedure set_cores; -- Platform-specific routines to determine ncpu function get_number_cpus return Positive; -- Updates the global section to indicate active profile procedure change_active_profile (new_active_profile : String); -- Set chroot to /usr/bin/chroot if program is found -- If not, chroot remains set to /usr/sbin/chroot procedure set_chroot; end Parameters;
{ "source": "starcoderdata", "programming_language": "ada" }
with openGL.Renderer.lean, mmi.World, mmi.Sprite, ada.Containers.Vectors, ada.Containers.Hashed_Sets, ada.Unchecked_Conversion; package gasp.World is type Item is limited new mmi.World.item with private; type View is access all item'Class; package Forge is function new_World (Name : in String; Renderer : in openGL.Renderer.lean.view) return View; end Forge; overriding procedure destroy (Self : in out Item); procedure free (Self : in out View); procedure store (Self : in out Item); procedure restore (Self : in out Item); overriding procedure evolve (Self : in out Item; By : in Duration); function Pod (Self : in Item) return mmi.Sprite.view; private use type mmi.sprite_Id; package sprite_id_Vectors is new ada.containers.Vectors (Positive, mmi.sprite_Id); function Hash is new ada.Unchecked_Conversion (mmi.sprite_Id, ada.Containers.Hash_Type); package organ_Sets is new ada.Containers.hashed_Sets (mmi.sprite_Id, Hash, "="); type Item is limited new mmi.World.item with record Counter : Natural := 0; pod_Sprite : mmi.Sprite.view; end record; end gasp.World;
{ "source": "starcoderdata", "programming_language": "ada" }
task Buffer is entry Put (X : in Integer); entry Get (X : out Integer); end; task body Buffer is V: Integer; begin loop accept Put (X : in Integer) do Put_Line ("Requested put: " & Integer'Image (X)); V := X; end Put; if V = 0 then exit; end if; delay 5.0; -- give time to other tasks accept Get (X : out Integer) do X := V; Put_Line ("Requested get: " & Integer'Image (X)); end Get; end loop; end; task E1; task E2; task body E1 is P : Integer; begin Put_Line ("E1 puts 11..."); Buffer.Put (11); delay 10.0; Put_Line ("E1 getting..."); Buffer.Get (P); Put_Line ("...E1 got " & Integer'Image (P)); end; task body E2 is P : Integer; begin delay 3.0; -- a Put here would freeze because Buffer is executing the delay -- and then expecting a Get. Hence, just get! Buffer.Get (P); Put_Line ("E2 gets " & Integer'Image (P)); Put_Line ("E2 puts 12..."); Buffer.Put (12); Put_Line ("...E2 done"); end; begin Put_Line ("All set"); delay 16.0; Buffer.Put (0); Put_Line ("Stuck?"); end;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Containers.Indefinite_Ordered_Maps; with Ada.Containers.Ordered_Maps; with Ada.Finalization; generic type Symbol_Type is private; with function "<" (Left, Right : Symbol_Type) return Boolean is <>; with procedure Put (Item : Symbol_Type); type Symbol_Sequence is array (Positive range <>) of Symbol_Type; type Frequency_Type is private; with function "+" (Left, Right : Frequency_Type) return Frequency_Type is <>; with function "<" (Left, Right : Frequency_Type) return Boolean is <>; package Huffman is -- bits = booleans (true/false = 1/0) type Bit_Sequence is array (Positive range <>) of Boolean; Zero_Sequence : constant Bit_Sequence (1 .. 0) := (others => False); -- output the sequence procedure Put (Code : Bit_Sequence); -- type for freqency map package Frequency_Maps is new Ada.Containers.Ordered_Maps (Element_Type => Frequency_Type, Key_Type => Symbol_Type); type Huffman_Tree is private; -- create a huffman tree from frequency map procedure Create_Tree (Tree : out Huffman_Tree; Frequencies : Frequency_Maps.Map); -- encode a single symbol function Encode (Tree : Huffman_Tree; Symbol : Symbol_Type) return Bit_Sequence; -- encode a symbol sequence function Encode (Tree : Huffman_Tree; Symbols : Symbol_Sequence) return Bit_Sequence; -- decode a bit sequence function Decode (Tree : Huffman_Tree; Code : Bit_Sequence) return Symbol_Sequence; -- dump the encoding table procedure Dump_Encoding (Tree : Huffman_Tree); private -- type for encoding map package Encoding_Maps is new Ada.Containers.Indefinite_Ordered_Maps (Element_Type => Bit_Sequence, Key_Type => Symbol_Type); type Huffman_Node; type Node_Access is access Huffman_Node; -- a node is either internal (left_child/right_child used) -- or a leaf (left_child/right_child are null) type Huffman_Node is record Frequency : Frequency_Type; Left_Child : Node_Access := null; Right_Child : Node_Access := null; Symbol : Symbol_Type; end record; -- create a leaf node function Create_Node (Symbol : Symbol_Type; Frequency : Frequency_Type) return Node_Access; -- create an internal node function Create_Node (Left, Right : Node_Access) return Node_Access; -- fill the encoding map procedure Fill (The_Node : Node_Access; Map : in out Encoding_Maps.Map; Prefix : Bit_Sequence); -- huffman tree has a tree and an encoding map type Huffman_Tree is new Ada.Finalization.Controlled with record Tree : Node_Access := null; Map : Encoding_Maps.Map := Encoding_Maps.Empty_Map; end record; -- free memory after finalization overriding procedure Finalize (Object : in out Huffman_Tree); end Huffman;
{ "source": "starcoderdata", "programming_language": "ada" }
private with openGL.Buffer.short_indices; package openGL.Primitive.short_indexed -- -- Provides a class for short indexed openGL primitives. -- is type Item is limited new Primitive.item with private; subtype Class is Item'Class; type View is access all Item'Class; type Views is array (Index_t range <>) of View; --------- -- Forge -- function new_Primitive (Kind : in facet_Kind; Indices : in openGL.short_Indices) return Primitive.short_indexed.view; function new_Primitive (Kind : in facet_Kind; Indices : in openGL.Indices) return Primitive.short_indexed.view; function new_Primitive (Kind : in facet_Kind; Indices : in openGL.long_Indices) return Primitive.short_indexed.view; procedure define (Self : in out Item; Kind : in facet_Kind; Indices : in openGL.short_Indices); procedure define (Self : in out Item; Kind : in facet_Kind; Indices : in openGL.Indices); procedure define (Self : in out Item; Kind : in facet_Kind; Indices : in openGL.long_Indices); overriding procedure destroy (Self : in out Item); -------------- -- Attributes -- procedure Indices_are (Self : in out Item; Now : in short_Indices); procedure Indices_are (Self : in out Item; Now : in Indices); procedure Indices_are (Self : in out Item; Now : in long_Indices); -------------- -- Operations -- overriding procedure render (Self : in out Item); private type Item is limited new Primitive.item with record Indices : Buffer.short_indices.view; end record; end openGL.Primitive.short_indexed;
{ "source": "starcoderdata", "programming_language": "ada" }
-- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ with Ada.Numerics.Short_Complex_Types; with Ada.Numerics.Generic_Complex_Elementary_Functions; package Ada.Numerics.Short_Complex_Elementary_Functions is new Ada.Numerics.Generic_Complex_Elementary_Functions (Ada.Numerics.Short_Complex_Types);
{ "source": "starcoderdata", "programming_language": "ada" }
----------------------------------------------------------------------- with Ada.Strings.Wide_Wide_Maps; with Ada.Strings.Wide_Wide_Unbounded; with Wiki.Documents; with Wiki.Attributes; with Wiki.Streams; with Wiki.Strings; -- === Wiki Renderer === -- The `Wiki_Renderer</tt> allows to render a wiki document into another wiki content. -- The formatting rules are ignored except for the paragraphs and sections. package Wiki.Render.Wiki is use Standard.Wiki.Attributes; -- ------------------------------ -- Wiki to HTML writer -- ------------------------------ type Wiki_Renderer is new Renderer with private; -- Set the output stream. procedure Set_Output_Stream (Engine : in out Wiki_Renderer; Stream : in Streams.Output_Stream_Access; Format : in Wiki_Syntax); -- Render the node instance from the document. overriding procedure Render (Engine : in out Wiki_Renderer; Doc : in Documents.Document; Node : in Nodes.Node_Type); -- Add a section header in the document. procedure Render_Header (Engine : in out Wiki_Renderer; Header : in Wide_Wide_String; Level : in Positive); -- Add a paragraph (<p>). Close the previous paragraph if any. -- The paragraph must be closed at the next paragraph or next header. procedure Add_Paragraph (Engine : in out Wiki_Renderer); -- Add a blockquote (<blockquote>). The level indicates the blockquote nested level. -- The blockquote must be closed at the next header. procedure Add_Blockquote (Engine : in out Wiki_Renderer; Level : in Natural); -- Add a list item (<li>). Close the previous paragraph and list item if any. -- The list item will be closed at the next list item, next paragraph or next header. procedure Add_List_Item (Engine : in out Wiki_Renderer; Level : in Positive; Ordered : in Boolean); -- Render a link. procedure Render_Link (Engine : in out Wiki_Renderer; Name : in Strings.WString; Attrs : in Attributes.Attribute_List); -- Render an image. procedure Render_Image (Engine : in out Wiki_Renderer; Title : in Strings.WString; Attrs : in Attributes.Attribute_List); -- Render a quote. procedure Render_Quote (Engine : in out Wiki_Renderer; Title : in Strings.WString; Attrs : in Attributes.Attribute_List); -- Add a text block with the given format. procedure Render_Text (Engine : in out Wiki_Renderer; Text : in Wide_Wide_String; Format : in Format_Map); -- Render a text block that is pre-formatted. procedure Render_Preformatted (Engine : in out Wiki_Renderer; Text : in Strings.WString; Format : in Strings.WString); procedure Render_Tag (Engine : in out Wiki_Renderer; Doc : in Documents.Document; Node : in Nodes.Node_Type); -- Finish the document after complete wiki text has been parsed. procedure Finish (Engine : in out Wiki_Renderer; Doc : in Documents.Document); -- Set the text style format. procedure Set_Format (Engine : in out Wiki_Renderer; Format : in Format_Map); private use Ada.Strings.Wide_Wide_Unbounded; type Wide_String_Access is access constant Wide_Wide_String; type Wiki_Tag_Type is (Header_Start, Header_End, Img_Start, Img_End, Link_Start, Link_End, Link_Separator, Quote_Start, Quote_End, Quote_Separator, Preformat_Start, Preformat_End, List_Start, List_Item, List_Ordered_Item, Line_Break, Escape_Rule, Horizontal_Rule, Blockquote_Start, Blockquote_End); type Wiki_Tag_Array is array (Wiki_Tag_Type) of Wide_String_Access; type Wiki_Format_Array is array (Format_Type) of Wide_String_Access; procedure Write_Optional_Space (Engine : in out Wiki_Renderer); -- Emit a new line. procedure New_Line (Engine : in out Wiki_Renderer; Optional : in Boolean := False); procedure Need_Separator_Line (Engine : in out Wiki_Renderer); procedure Close_Paragraph (Engine : in out Wiki_Renderer); procedure Start_Keep_Content (Engine : in out Wiki_Renderer); type List_Style_Array is array (1 .. 32) of Boolean; EMPTY_TAG : aliased constant Wide_Wide_String := ""; type Wiki_Renderer is new Renderer with record Output : Streams.Output_Stream_Access := null; Syntax : Wiki_Syntax := SYNTAX_CREOLE; Format : Format_Map := (others => False); Tags : Wiki_Tag_Array := (others => EMPTY_TAG'Access); Style_Start_Tags : Wiki_Format_Array := (others => EMPTY_TAG'Access); Style_End_Tags : Wiki_Format_Array := (others => EMPTY_TAG'Access); Escape_Set : Ada.Strings.Wide_Wide_Maps.Wide_Wide_Character_Set; Has_Paragraph : Boolean := False; Has_Item : Boolean := False; Need_Paragraph : Boolean := False; Need_Newline : Boolean := False; Need_Space : Boolean := False; Empty_Line : Boolean := True; Empty_Previous_Line : Boolean := True; Keep_Content : Natural := 0; In_List : Boolean := False; Invert_Header_Level : Boolean := False; Allow_Link_Language : Boolean := False; Link_First : Boolean := False; Html_Blockquote : Boolean := False; Line_Count : Natural := 0; Current_Level : Natural := 0; Quote_Level : Natural := 0; UL_List_Level : Natural := 0; OL_List_Level : Natural := 0; Current_Style : Format_Map := (others => False); Content : Unbounded_Wide_Wide_String; Link_Href : Unbounded_Wide_Wide_String; Link_Title : Unbounded_Wide_Wide_String; Link_Lang : Unbounded_Wide_Wide_String; end record; end Wiki.Render.Wiki;
{ "source": "starcoderdata", "programming_language": "ada" }
----------------------------------------------------------------------- with AWA.Events.Action_Method; package body AWA.Jobs.Beans is package Execute_Binding is new AWA.Events.Action_Method.Bind (Bean => Process_Bean, Method => Execute, Name => "execute"); Process_Binding : aliased constant Util.Beans.Methods.Method_Binding_Array := (1 => Execute_Binding.Proxy'Access); -- ------------------------------ -- Get the value identified by the name. -- ------------------------------ overriding function Get_Value (From : in Process_Bean; Name : in String) return Util.Beans.Objects.Object is begin return AWA.Jobs.Services.Get_Parameter (From.Job, Name); end Get_Value; -- ------------------------------ -- Set the value identified by the name. -- ------------------------------ overriding procedure Set_Value (From : in out Process_Bean; Name : in String; Value : in Util.Beans.Objects.Object) is begin null; end Set_Value; -- ------------------------------ -- This bean provides some methods that can be used in a Method_Expression -- ------------------------------ overriding function Get_Method_Bindings (From : in Process_Bean) return Util.Beans.Methods.Method_Binding_Array_Access is pragma Unreferenced (From); begin return Process_Binding'Access; end Get_Method_Bindings; -- ------------------------------ -- Execute the job described by the event. -- ------------------------------ procedure Execute (Bean : in out Process_Bean; Event : in AWA.Events.Module_Event'Class) is begin AWA.Jobs.Services.Execute (Event, Bean.Job); end Execute; -- ------------------------------ -- Create the job process bean instance. -- ------------------------------ function Create_Process_Bean (Module : in AWA.Jobs.Modules.Job_Module_Access) return Util.Beans.Basic.Readonly_Bean_Access is Result : constant Process_Bean_Access := new Process_Bean; begin Result.Module := Module; return Result.all'Access; end Create_Process_Bean; end AWA.Jobs.Beans;
{ "source": "starcoderdata", "programming_language": "ada" }
-- with GNAT.Source_Info; with HW.Time; with HW.Debug; with HW.GFX.GMA.Config; with HW.GFX.GMA.Registers; package body HW.GFX.GMA.Power_And_Clocks_Haswell is PWR_WELL_CTL_ENABLE_REQUEST : constant := 1 * 2 ** 31; PWR_WELL_CTL_DISABLE_REQUEST : constant := 0 * 2 ** 31; PWR_WELL_CTL_STATE_ENABLED : constant := 1 * 2 ** 30; ---------------------------------------------------------------------------- SRD_CTL_ENABLE : constant := 1 * 2 ** 31; SRD_STATUS_STATE_MASK : constant := 7 * 2 ** 29; type Pipe is (EDP, A, B, C); type SRD_Regs is record CTL : Registers.Registers_Index; STATUS : Registers.Registers_Index; end record; type SRD_Per_Pipe_Regs is array (Pipe) of SRD_Regs; SRD : constant SRD_Per_Pipe_Regs := SRD_Per_Pipe_Regs' (A => SRD_Regs' (CTL => Registers.SRD_CTL_A, STATUS => Registers.SRD_STATUS_A), B => SRD_Regs' (CTL => Registers.SRD_CTL_B, STATUS => Registers.SRD_STATUS_B), C => SRD_Regs' (CTL => Registers.SRD_CTL_C, STATUS => Registers.SRD_STATUS_C), EDP => SRD_Regs' (CTL => Registers.SRD_CTL_EDP, STATUS => Registers.SRD_STATUS_EDP)); ---------------------------------------------------------------------------- IPS_CTL_ENABLE : constant := 1 * 2 ** 31; DISPLAY_IPS_CONTROL : constant := 16#19#; GT_MAILBOX_READY : constant := 1 * 2 ** 31; ---------------------------------------------------------------------------- procedure PSR_Off is Enabled : Boolean; begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); if Config.Has_Per_Pipe_SRD then for P in Pipe loop Registers.Is_Set_Mask (SRD (P).CTL, SRD_CTL_ENABLE, Enabled); if Enabled then Registers.Unset_Mask (SRD (P).CTL, SRD_CTL_ENABLE); Registers.Wait_Unset_Mask (SRD (P).STATUS, SRD_STATUS_STATE_MASK); pragma Debug (Debug.Put_Line ("Disabled PSR.")); end if; end loop; else Registers.Is_Set_Mask (Registers.SRD_CTL, SRD_CTL_ENABLE, Enabled); if Enabled then Registers.Unset_Mask (Registers.SRD_CTL, SRD_CTL_ENABLE); Registers.Wait_Unset_Mask (Registers.SRD_STATUS, SRD_STATUS_STATE_MASK); pragma Debug (Debug.Put_Line ("Disabled PSR.")); end if; end if; end PSR_Off; ---------------------------------------------------------------------------- procedure GT_Mailbox_Write (MBox : Word32; Value : Word32) is begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); Registers.Wait_Unset_Mask (Registers.GT_MAILBOX, GT_MAILBOX_READY); Registers.Write (Registers.GT_MAILBOX_DATA, Value); Registers.Write (Registers.GT_MAILBOX, GT_MAILBOX_READY or MBox); Registers.Wait_Unset_Mask (Registers.GT_MAILBOX, GT_MAILBOX_READY); Registers.Write (Registers.GT_MAILBOX_DATA, 0); end GT_Mailbox_Write; procedure IPS_Off is Enabled : Boolean; begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); if Config.Has_IPS then Registers.Is_Set_Mask (Registers.IPS_CTL, IPS_CTL_ENABLE, Enabled); if Enabled then if Config.Has_IPS_CTL_Mailbox then GT_Mailbox_Write (DISPLAY_IPS_CONTROL, 0); Registers.Wait_Unset_Mask (Register => Registers.IPS_CTL, Mask => IPS_CTL_ENABLE, TOut_MS => 42); else Registers.Unset_Mask (Registers.IPS_CTL, IPS_CTL_ENABLE); end if; pragma Debug (Debug.Put_Line ("Disabled IPS.")); -- We have to wait until the next vblank here. -- 20ms should be enough. Time.M_Delay (20); end if; end if; end IPS_Off; ---------------------------------------------------------------------------- procedure PDW_Off is Ctl1, Ctl2, Ctl3, Ctl4 : Word32; begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); Registers.Read (Registers.PWR_WELL_CTL_BIOS, Ctl1); Registers.Read (Registers.PWR_WELL_CTL_DRIVER, Ctl2); Registers.Read (Registers.PWR_WELL_CTL_KVMR, Ctl3); Registers.Read (Registers.PWR_WELL_CTL_DEBUG, Ctl4); pragma Debug (Registers.Posting_Read (Registers.PWR_WELL_CTL5)); -- Result for debugging only pragma Debug (Registers.Posting_Read (Registers.PWR_WELL_CTL6)); -- Result for debugging only if ((Ctl1 or Ctl2 or Ctl3 or Ctl4) and PWR_WELL_CTL_ENABLE_REQUEST) /= 0 then Registers.Wait_Set_Mask (Registers.PWR_WELL_CTL_DRIVER, PWR_WELL_CTL_STATE_ENABLED); end if; if (Ctl1 and PWR_WELL_CTL_ENABLE_REQUEST) /= 0 then Registers.Write (Registers.PWR_WELL_CTL_BIOS, PWR_WELL_CTL_DISABLE_REQUEST); end if; if (Ctl2 and PWR_WELL_CTL_ENABLE_REQUEST) /= 0 then Registers.Write (Registers.PWR_WELL_CTL_DRIVER, PWR_WELL_CTL_DISABLE_REQUEST); end if; end PDW_Off; procedure PDW_On is Ctl1, Ctl2, Ctl3, Ctl4 : Word32; begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); Registers.Read (Registers.PWR_WELL_CTL_BIOS, Ctl1); Registers.Read (Registers.PWR_WELL_CTL_DRIVER, Ctl2); Registers.Read (Registers.PWR_WELL_CTL_KVMR, Ctl3); Registers.Read (Registers.PWR_WELL_CTL_DEBUG, Ctl4); pragma Debug (Registers.Posting_Read (Registers.PWR_WELL_CTL5)); -- Result for debugging only pragma Debug (Registers.Posting_Read (Registers.PWR_WELL_CTL6)); -- Result for debugging only if ((Ctl1 or Ctl2 or Ctl3 or Ctl4) and PWR_WELL_CTL_ENABLE_REQUEST) = 0 then Registers.Wait_Unset_Mask (Registers.PWR_WELL_CTL_DRIVER, PWR_WELL_CTL_STATE_ENABLED); end if; if (Ctl2 and PWR_WELL_CTL_ENABLE_REQUEST) = 0 then Registers.Write (Registers.PWR_WELL_CTL_DRIVER, PWR_WELL_CTL_ENABLE_REQUEST); Registers.Wait_Set_Mask (Registers.PWR_WELL_CTL_DRIVER, PWR_WELL_CTL_STATE_ENABLED); end if; end PDW_On; function Need_PDW (Checked_Configs : Pipe_Configs) return Boolean is Primary : Pipe_Config renames Checked_Configs (GMA.Primary); begin return (Config.Use_PDW_For_EDP_Scaling and then (Primary.Port = Internal and Requires_Scaling (Primary))) or (Primary.Port /= Disabled and Primary.Port /= Internal) or Checked_Configs (Secondary).Port /= Disabled or Checked_Configs (Tertiary).Port /= Disabled; end Need_PDW; ---------------------------------------------------------------------------- procedure Pre_All_Off is begin -- HSW: disable panel self refresh (PSR) on eDP if enabled -- wait for PSR idling PSR_Off; IPS_Off; end Pre_All_Off; procedure Initialize is begin -- HSW: disable power down well PDW_Off; Config.Raw_Clock := Config.Default_RawClk_Freq; end Initialize; procedure Power_Set_To (Configs : Pipe_Configs) is begin if Need_PDW (Configs) then PDW_On; else PDW_Off; end if; end Power_Set_To; procedure Power_Up (Old_Configs, New_Configs : Pipe_Configs) is begin if not Need_PDW (Old_Configs) and Need_PDW (New_Configs) then PDW_On; end if; end Power_Up; procedure Power_Down (Old_Configs, Tmp_Configs, New_Configs : Pipe_Configs) is begin if (Need_PDW (Old_Configs) or Need_PDW (Tmp_Configs)) and not Need_PDW (New_Configs) then PDW_Off; end if; end Power_Down; end HW.GFX.GMA.Power_And_Clocks_Haswell;
{ "source": "starcoderdata", "programming_language": "ada" }
----------------------------------------------------------------------- with Interfaces; with Util.Log.Loggers; with Keystore.Logs; with Keystore.Repository.Workers; -- === Data Block === -- -- Data block start is encrypted with wallet data key, data fragments are -- encrypted with their own key. Loading and saving data blocks occurs exclusively -- from the workers package. The data block can be stored in a separate file so that -- the wallet repository and its keys are separate from the data blocks. -- -- ``` -- +------------------+ -- | 03 03 | 2b -- | Encrypt size | 2b = DATA_ENTRY_SIZE * Nb data fragment -- | Wallet id | 4b -- | PAD 0 | 4b -- | PAD 0 | 4b -- +------------------+----- -- | Entry ID | 4b Encrypted with wallet id -- | Slot size | 2b -- | 0 0 | 2b -- | Data offset | 8b -- | Content HMAC-256 | 32b => 48b = DATA_ENTRY_SIZE -- +------------------+ -- | ... | -- +------------------+----- -- | ... | -- +------------------+ -- | Data content | Encrypted with data entry key -- +------------------+----- -- | Block HMAC-256 | 32b -- +------------------+ -- ``` -- package body Keystore.Repository.Data is use type Interfaces.Unsigned_64; use type Keystore.Repository.Workers.Data_Work_Access; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Keystore.Repository.Data"); -- ------------------------------ -- Find the data block to hold a new data entry that occupies the given space. -- The first data block that has enough space is used otherwise a new block -- is allocated and initialized. -- ------------------------------ procedure Allocate_Data_Block (Manager : in out Wallet_Repository; Space : in IO.Block_Index; Work : in Workers.Data_Work_Access) is pragma Unreferenced (Space); begin Manager.Stream.Allocate (IO.DATA_BLOCK, Work.Data_Block); Work.Data_Need_Setup := True; Logs.Debug (Log, "Allocated data block{0}", Work.Data_Block); end Allocate_Data_Block; -- ------------------------------ -- Write the data in one or several blocks. -- ------------------------------ procedure Add_Data (Manager : in out Wallet_Repository; Iterator : in out Keys.Data_Key_Iterator; Content : in Ada.Streams.Stream_Element_Array; Offset : in out Interfaces.Unsigned_64) is Size : IO.Buffer_Size; Input_Pos : Stream_Element_Offset := Content'First; Data_Offset : Stream_Element_Offset := Stream_Element_Offset (Offset); Work : Workers.Data_Work_Access; begin Workers.Initialize_Queue (Manager); while Input_Pos <= Content'Last loop -- Get a data work instance or flush pending works to make one available. Workers.Allocate_Work (Manager, Workers.DATA_ENCRYPT, null, Iterator, Work); Workers.Fill (Work.all, Content, Input_Pos, Size); if Size = 0 then Workers.Put_Work (Manager.Workers.all, Work); Work := null; exit; end if; Allocate_Data_Block (Manager, Size, Work); Keys.Allocate_Key_Slot (Manager, Iterator, Work.Data_Block, Size, Work.Key_Pos, Work.Key_Block.Buffer.Block); Work.Key_Block.Buffer := Iterator.Current.Buffer; Workers.Queue_Cipher_Work (Manager, Work); Work := null; -- Move on to what remains. Data_Offset := Data_Offset + Size; Input_Pos := Input_Pos + Size; end loop; Offset := Interfaces.Unsigned_64 (Data_Offset); Workers.Flush_Queue (Manager, null); exception when E : others => Log.Error ("Exception while encrypting data: ", E); if Work /= null then Workers.Put_Work (Manager.Workers.all, Work); end if; Workers.Flush_Queue (Manager, null); raise; end Add_Data; -- ------------------------------ -- Write the data in one or several blocks. -- ------------------------------ procedure Add_Data (Manager : in out Wallet_Repository; Iterator : in out Keys.Data_Key_Iterator; Content : in out Util.Streams.Input_Stream'Class; Offset : in out Interfaces.Unsigned_64) is Size : IO.Buffer_Size; Data_Offset : Stream_Element_Offset := Stream_Element_Offset (Offset); Work : Workers.Data_Work_Access; begin Workers.Initialize_Queue (Manager); loop -- Get a data work instance or flush pending works to make one available. Workers.Allocate_Work (Manager, Workers.DATA_ENCRYPT, null, Iterator, Work); -- Fill the work buffer by reading the stream. Workers.Fill (Work.all, Content, DATA_MAX_SIZE, Size); if Size = 0 then Workers.Put_Work (Manager.Workers.all, Work); exit; end if; Allocate_Data_Block (Manager, DATA_MAX_SIZE, Work); Keys.Allocate_Key_Slot (Manager, Iterator, Work.Data_Block, Size, Work.Key_Pos, Work.Key_Block.Buffer.Block); Work.Key_Block.Buffer := Iterator.Current.Buffer; Workers.Queue_Cipher_Work (Manager, Work); -- Move on to what remains. Data_Offset := Data_Offset + Size; end loop; Offset := Interfaces.Unsigned_64 (Data_Offset); Workers.Flush_Queue (Manager, null); exception when E : others => Log.Error ("Exception while encrypting data: ", E); Workers.Flush_Queue (Manager, null); raise; end Add_Data; procedure Update_Data (Manager : in out Wallet_Repository; Iterator : in out Keys.Data_Key_Iterator; Content : in Ada.Streams.Stream_Element_Array; Last_Pos : out Ada.Streams.Stream_Element_Offset; Offset : in out Interfaces.Unsigned_64) is Size : Stream_Element_Offset; Input_Pos : Stream_Element_Offset := Content'First; Work : Workers.Data_Work_Access; Data_Offset : Stream_Element_Offset := Stream_Element_Offset (Offset); begin Workers.Initialize_Queue (Manager); Keys.Next_Data_Key (Manager, Iterator); while Input_Pos <= Content'Last and Keys.Has_Data_Key (Iterator) loop Workers.Allocate_Work (Manager, Workers.DATA_ENCRYPT, null, Iterator, Work); Size := Content'Last - Input_Pos + 1; if Size > DATA_MAX_SIZE then Size := DATA_MAX_SIZE; end if; if Size > AES_Align (Iterator.Data_Size) then Size := AES_Align (Iterator.Data_Size); end if; Work.Buffer_Pos := 1; Work.Last_Pos := Size; Work.Data (1 .. Size) := Content (Input_Pos .. Input_Pos + Size - 1); Keys.Update_Key_Slot (Manager, Iterator, Size); Work.Key_Block.Buffer := Iterator.Current.Buffer; -- Run the encrypt data work either through work manager or through current task. Workers.Queue_Cipher_Work (Manager, Work); Input_Pos := Input_Pos + Size; Data_Offset := Data_Offset + Size; exit when Input_Pos > Content'Last; Keys.Next_Data_Key (Manager, Iterator); end loop; Workers.Flush_Queue (Manager, null); Offset := Interfaces.Unsigned_64 (Data_Offset); Last_Pos := Input_Pos; if Input_Pos <= Content'Last then Keys.Prepare_Append (Iterator); end if; exception when E : others => Log.Error ("Exception while encrypting data: ", E); Workers.Flush_Queue (Manager, null); raise; end Update_Data; procedure Update_Data (Manager : in out Wallet_Repository; Iterator : in out Keys.Data_Key_Iterator; Content : in out Util.Streams.Input_Stream'Class; End_Of_Stream : out Boolean; Offset : in out Interfaces.Unsigned_64) is Work : Workers.Data_Work_Access; Size : IO.Buffer_Size := 0; Data_Offset : Stream_Element_Offset := Stream_Element_Offset (Offset); Mark : Keys.Data_Key_Marker; begin Workers.Initialize_Queue (Manager); Keys.Mark_Data_Key (Iterator, Mark); Keys.Next_Data_Key (Manager, Iterator); while Keys.Has_Data_Key (Iterator) loop Workers.Allocate_Work (Manager, Workers.DATA_ENCRYPT, null, Iterator, Work); -- Fill the work buffer by reading the stream. Workers.Fill (Work.all, Content, AES_Align (Iterator.Data_Size), Size); if Size = 0 then Workers.Put_Work (Manager.Workers.all, Work); Delete_Data (Manager, Iterator, Mark); exit; end if; Keys.Update_Key_Slot (Manager, Iterator, Size); Work.Key_Block.Buffer := Iterator.Current.Buffer; -- Run the encrypt data work either through work manager or through current task. Workers.Queue_Cipher_Work (Manager, Work); Data_Offset := Data_Offset + Size; Keys.Mark_Data_Key (Iterator, Mark); Keys.Next_Data_Key (Manager, Iterator); end loop; Workers.Flush_Queue (Manager, null); Offset := Interfaces.Unsigned_64 (Data_Offset); End_Of_Stream := Size = 0; if not End_Of_Stream then Keys.Prepare_Append (Iterator); end if; exception when E : others => Log.Error ("Exception while encrypting data: ", E); Workers.Flush_Queue (Manager, null); raise; end Update_Data; -- ------------------------------ -- Erase the data fragments starting at the key iterator current position. -- ------------------------------ procedure Delete_Data (Manager : in out Wallet_Repository; Iterator : in out Keys.Data_Key_Iterator; Mark : in out Keys.Data_Key_Marker) is Work : Workers.Data_Work_Access; begin while Keys.Has_Data_Key (Iterator) loop Workers.Allocate_Work (Manager, Workers.DATA_RELEASE, null, Iterator, Work); -- Run the delete data work either through work manager or through current task. Workers.Queue_Delete_Work (Manager, Work); -- When the last data block was processed, erase the data key. if Keys.Is_Last_Key (Iterator) then Keys.Delete_Key (Manager, Iterator, Mark); end if; Keys.Next_Data_Key (Manager, Iterator); end loop; end Delete_Data; -- ------------------------------ -- Erase the data fragments starting at the key iterator current position. -- ------------------------------ procedure Delete_Data (Manager : in out Wallet_Repository; Iterator : in out Keys.Data_Key_Iterator) is Work : Workers.Data_Work_Access; Mark : Keys.Data_Key_Marker; begin Keys.Mark_Data_Key (Iterator, Mark); Workers.Initialize_Queue (Manager); loop Keys.Next_Data_Key (Manager, Iterator); exit when not Keys.Has_Data_Key (Iterator); Workers.Allocate_Work (Manager, Workers.DATA_RELEASE, null, Iterator, Work); -- Run the delete data work either through work manager or through current task. Workers.Queue_Delete_Work (Manager, Work); -- When the last data block was processed, erase the data key. if Keys.Is_Last_Key (Iterator) then Keys.Delete_Key (Manager, Iterator, Mark); end if; end loop; Workers.Flush_Queue (Manager, null); exception when E : others => Log.Error ("Exception while deleting data: ", E); Workers.Flush_Queue (Manager, null); raise; end Delete_Data; -- ------------------------------ -- Get the data associated with the named entry. -- ------------------------------ procedure Get_Data (Manager : in out Wallet_Repository; Iterator : in out Keys.Data_Key_Iterator; Output : out Ada.Streams.Stream_Element_Array) is procedure Process (Work : in Workers.Data_Work_Access); Data_Offset : Stream_Element_Offset := Output'First; procedure Process (Work : in Workers.Data_Work_Access) is Data_Size : constant Stream_Element_Offset := Work.End_Data - Work.Start_Data + 1; begin Output (Data_Offset .. Data_Offset + Data_Size - 1) := Work.Data (Work.Buffer_Pos .. Work.Buffer_Pos + Data_Size - 1); Data_Offset := Data_Offset + Data_Size; end Process; Work : Workers.Data_Work_Access; Enqueued : Boolean; begin Workers.Initialize_Queue (Manager); loop Keys.Next_Data_Key (Manager, Iterator); exit when not Keys.Has_Data_Key (Iterator); Workers.Allocate_Work (Manager, Workers.DATA_DECRYPT, Process'Access, Iterator, Work); -- Run the decipher work either through work manager or through current task. Workers.Queue_Decipher_Work (Manager, Work, Enqueued); if not Enqueued then Process (Work); end if; end loop; Workers.Flush_Queue (Manager, Process'Access); exception when E : others => Log.Error ("Exception while decrypting data: ", E); Workers.Flush_Queue (Manager, null); raise; end Get_Data; procedure Get_Data (Manager : in out Wallet_Repository; Iterator : in out Keys.Data_Key_Iterator; Output : in out Util.Streams.Output_Stream'Class) is procedure Process (Work : in Workers.Data_Work_Access); procedure Process (Work : in Workers.Data_Work_Access) is begin Output.Write (Work.Data (Work.Buffer_Pos .. Work.Last_Pos)); end Process; Work : Workers.Data_Work_Access; Enqueued : Boolean; begin Workers.Initialize_Queue (Manager); loop Keys.Next_Data_Key (Manager, Iterator); exit when not Keys.Has_Data_Key (Iterator); Workers.Allocate_Work (Manager, Workers.DATA_DECRYPT, Process'Access, Iterator, Work); -- Run the decipher work either through work manager or through current task. Workers.Queue_Decipher_Work (Manager, Work, Enqueued); if not Enqueued then Process (Work); end if; end loop; Workers.Flush_Queue (Manager, Process'Access); exception when E : others => Log.Error ("Exception while decrypting data: ", E); Workers.Flush_Queue (Manager, null); raise; end Get_Data; -- ------------------------------ -- Get the data associated with the named entry. -- ------------------------------ procedure Read (Manager : in out Wallet_Repository; Iterator : in out Keys.Data_Key_Iterator; Offset : in Ada.Streams.Stream_Element_Offset; Output : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset) is procedure Process (Work : in Workers.Data_Work_Access); Seek_Offset : Stream_Element_Offset := Offset; Data_Offset : Stream_Element_Offset := Output'First; procedure Process (Work : in Workers.Data_Work_Access) is Data_Size : Stream_Element_Offset := Work.End_Data - Work.Start_Data + 1 - Work.Seek_Offset; begin Work.Buffer_Pos := Work.Buffer_Pos + Work.Seek_Offset; if Data_Offset + Data_Size - 1 >= Output'Last then Data_Size := Output'Last - Data_Offset + 1; end if; Output (Data_Offset .. Data_Offset + Data_Size - 1) := Work.Data (Work.Buffer_Pos .. Work.Buffer_Pos + Data_Size - 1); Data_Offset := Data_Offset + Data_Size; end Process; Work : Workers.Data_Work_Access; Enqueued : Boolean; Length : Stream_Element_Offset := Output'Length; begin Workers.Initialize_Queue (Manager); Keys.Seek (Manager, Seek_Offset, Iterator); Length := Length + Seek_Offset; while Keys.Has_Data_Key (Iterator) and Length > 0 loop Workers.Allocate_Work (Manager, Workers.DATA_DECRYPT, Process'Access, Iterator, Work); Work.Seek_Offset := Seek_Offset; -- Run the decipher work either through work manager or through current task. Workers.Queue_Decipher_Work (Manager, Work, Enqueued); if not Enqueued then Process (Work); end if; exit when Length < Iterator.Data_Size; Length := Length - Iterator.Data_Size; Seek_Offset := 0; Keys.Next_Data_Key (Manager, Iterator); end loop; Workers.Flush_Queue (Manager, Process'Access); Last := Data_Offset - 1; exception when E : others => Log.Error ("Exception while decrypting data: ", E); Workers.Flush_Queue (Manager, null); raise; end Read; -- ------------------------------ -- Get the data associated with the named entry. -- ------------------------------ procedure Write (Manager : in out Wallet_Repository; Iterator : in out Keys.Data_Key_Iterator; Offset : in Ada.Streams.Stream_Element_Offset; Content : in Ada.Streams.Stream_Element_Array; Result : in out Interfaces.Unsigned_64) is use type Workers.Status_Type; Seek_Offset : Stream_Element_Offset := Offset; Input_Pos : Stream_Element_Offset := Content'First; Work : Workers.Data_Work_Access; Length : Stream_Element_Offset := Content'Length; Status : Workers.Status_Type; begin Workers.Initialize_Queue (Manager); Keys.Seek (Manager, Seek_Offset, Iterator); -- First part that overlaps an existing data block: -- read the current block, update the content. if Keys.Has_Data_Key (Iterator) and Length > 0 then Workers.Allocate_Work (Manager, Workers.DATA_DECRYPT, null, Iterator, Work); -- Run the decipher work ourselves. Work.Do_Decipher_Data; Status := Work.Status; if Status = Workers.SUCCESS then declare Data_Size : Stream_Element_Offset := Work.End_Data - Work.Start_Data + 1 - Seek_Offset; Pos : constant Stream_Element_Offset := Work.Buffer_Pos + Seek_Offset; begin if Input_Pos + Data_Size - 1 >= Content'Last then Data_Size := Content'Last - Input_Pos + 1; end if; Work.Data (Pos .. Pos + Data_Size - 1) := Content (Input_Pos .. Input_Pos + Data_Size - 1); Input_Pos := Input_Pos + Data_Size; Work.Kind := Workers.DATA_ENCRYPT; Work.Status := Workers.PENDING; Work.Entry_Id := Iterator.Entry_Id; Work.Key_Pos := Iterator.Key_Pos; Work.Key_Block.Buffer := Iterator.Current.Buffer; Work.Data_Block := Iterator.Data_Block; Work.Data_Need_Setup := False; Work.Data_Offset := Iterator.Current_Offset; Length := Length - Data_Size; Keys.Update_Key_Slot (Manager, Iterator, Work.End_Data - Work.Start_Data + 1); end; -- Run the encrypt data work either through work manager or through current task. Workers.Queue_Cipher_Work (Manager, Work); else Workers.Put_Work (Manager.Workers.all, Work); -- Check_Raise_Error (Status); end if; Keys.Next_Data_Key (Manager, Iterator); end if; while Keys.Has_Data_Key (Iterator) and Length >= DATA_MAX_SIZE loop Workers.Allocate_Work (Manager, Workers.DATA_ENCRYPT, null, Iterator, Work); Work.Buffer_Pos := 1; Work.Last_Pos := DATA_MAX_SIZE; Work.Data (1 .. DATA_MAX_SIZE) := Content (Input_Pos .. Input_Pos + DATA_MAX_SIZE - 1); Keys.Update_Key_Slot (Manager, Iterator, DATA_MAX_SIZE); Work.Key_Block.Buffer := Iterator.Current.Buffer; -- Run the encrypt data work either through work manager or through current task. Workers.Queue_Cipher_Work (Manager, Work); Input_Pos := Input_Pos + DATA_MAX_SIZE; -- Data_Offset := Data_Offset + DATA_MAX_SIZE; Length := Length - DATA_MAX_SIZE; exit when Input_Pos > Content'Last; Keys.Next_Data_Key (Manager, Iterator); end loop; -- Last part that overlaps an existing data block: -- read the current block, update the content. if Keys.Has_Data_Key (Iterator) and Length > 0 then Workers.Allocate_Work (Manager, Workers.DATA_DECRYPT, null, Iterator, Work); -- Run the decipher work ourselves. Work.Do_Decipher_Data; Status := Work.Status; if Status = Workers.SUCCESS then declare Last : constant Stream_Element_Offset := Content'Last - Input_Pos + 1; begin Work.Data (1 .. Last) := Content (Input_Pos .. Content'Last); Input_Pos := Content'Last + 1; if Last > Work.End_Data then Work.End_Data := Last; end if; Work.Kind := Workers.DATA_ENCRYPT; Work.Status := Workers.PENDING; Work.Entry_Id := Iterator.Entry_Id; Work.Key_Pos := Iterator.Key_Pos; Work.Key_Block.Buffer := Iterator.Current.Buffer; Work.Data_Block := Iterator.Data_Block; Work.Data_Need_Setup := False; Work.Data_Offset := Iterator.Current_Offset; Keys.Update_Key_Slot (Manager, Iterator, Work.End_Data - Work.Start_Data + 1); end; -- Run the encrypt data work either through work manager or through current task. Workers.Queue_Cipher_Work (Manager, Work); else Workers.Put_Work (Manager.Workers.all, Work); -- Check_Raise_Error (Status); end if; Keys.Next_Data_Key (Manager, Iterator); end if; Workers.Flush_Queue (Manager, null); Result := Iterator.Current_Offset; if Input_Pos <= Content'Last then Keys.Prepare_Append (Iterator); Add_Data (Manager, Iterator, Content (Input_Pos .. Content'Last), Result); end if; exception when E : others => Log.Error ("Exception while decrypting data: ", E); Workers.Flush_Queue (Manager, null); raise; end Write; end Keystore.Repository.Data;
{ "source": "starcoderdata", "programming_language": "ada" }
-- with Rule_Table, Symbol_Table, Set_Pack; use Rule_Table, Symbol_Table; package LR0_Machine is type Parse_State is range -1..5_000; Null_Parse_State : constant Parse_State := -1; type Item is record Rule_ID : Rule; Dot_Position : Natural; end record; type Transition is record Symbol : Grammar_Symbol; State_ID : Parse_State; end record; function "<" (Item_1, Item_2 : Item) return Boolean; function "<" (Trans_1, Trans_2 : Transition) return Boolean; package Parse_State_Set_Pack is new Set_Pack(Parse_State, "<"); package Item_Set_Pack is new Set_Pack(Item, "<"); package Transition_Set_Pack is new Set_Pack(Transition, "<"); package Grammar_Symbol_Set_Pack is new Set_Pack(Grammar_Symbol, "<"); subtype Parse_State_Set is Parse_State_Set_Pack.Set; subtype Item_Set is Item_Set_Pack.Set; subtype Transition_Set is Transition_Set_Pack.Set; subtype Grammar_Symbol_Set is Grammar_Symbol_Set_Pack.Set; subtype Parse_State_Iterator is Parse_State_Set_Pack.Set_Iterator; subtype Item_Iterator is Item_Set_Pack.Set_Iterator; subtype Transition_Iterator is Transition_Set_Pack.Set_Iterator; subtype Grammar_Symbol_Iterator is Grammar_Symbol_Set_Pack.Set_Iterator; procedure LR0_Initialize; -- must be called first. function First_Parse_State return Parse_State; function Last_Parse_State return Parse_State; function Get_Goto (State_ID : Parse_State; Sym : Grammar_Symbol) return Parse_State; -- Returns the predecessor states of STATE_ID and the item I. -- Must be called with PRED_SET empty! procedure Get_Pred_Set (State_ID : in Parse_State; I : in Item; Pred_Set : in out Parse_State_Set); type Transition_Type is (Terminals, Nonterminals, Grammar_Symbols); procedure Get_Transitions (State_ID : in Parse_State; Kind : in Transition_Type; Set_1 : in out Transition_Set); procedure Get_Transition_Symbols (State_ID : in Parse_State; Kind : in Transition_Type; Set_1 : in out Grammar_Symbol_Set); procedure Get_Kernel (State_ID : in Parse_State; Set_1 : in out Item_Set); procedure Closure (Set_1 : in out Item_Set); -- -- The following routines allow the user to iterate over the -- items in the kernel of a particular state. -- type Kernel_Iterator is limited private; procedure Initialize (Iterator : in out Kernel_Iterator; State_ID : in Parse_State); function More(Iterator : Kernel_Iterator) return Boolean; procedure Next(Iterator : in out Kernel_Iterator; I : out Item); -- -- The following routines allow the user to iterate over the -- nonterminal transitions of a particular state -- type Nt_Transition_Iterator is limited private; procedure Initialize (Iterator : in out Nt_Transition_Iterator; State_ID : in Parse_State); function More (Iterator : Nt_Transition_Iterator) return Boolean; procedure Next (Iterator : in out Nt_Transition_Iterator; Trans : out Transition); -- The following routines allow iteration over the Terminal transitions -- of a particular state. type T_Transition_Iterator is limited private; -- For Terminals procedure Initialize (Iterator : in out T_Transition_Iterator; State_ID : in Parse_State); function More (Iterator : T_Transition_Iterator) return Boolean; procedure Next (Iterator : in out T_Transition_Iterator; Trans : out Transition); To_Many_States : exception; No_More_Iterations : exception; State_Out_of_Bounds : exception; --RJS pragma inline(more); --DEC Ada Bug: , next); private type Item_Array_Index is range 0..5_000; -- An arbitrarily big number ----- type Item_Array; type Item_Array is array (Item_Array_Index range <>) of Item; type Item_Array_Pointer is access Item_Array; type Kernel_Iterator is record Kernel : Item_Array_Pointer; Curser : Item_Array_Index; end record; ----- type Transition_Array; -- The type declarations for storing the nonterminal transitions of -- the DFA in the states. type Transition_Array is array(Integer range <>) of Transition; type Transition_Array_Pointer is access Transition_Array; type Nt_Transition_Iterator is record Nonterm_Trans : Transition_Array_Pointer; Curser : Integer; -- Use a derived type instead ??? end record; type T_Transition_Iterator is record Term_Trans : Transition_Array_Pointer; Curser : Integer; end record; end LR0_Machine;
{ "source": "starcoderdata", "programming_language": "ada" }
------------------------------------------------------------- with Program.Elements.Expressions; with Program.Lexical_Elements; with Program.Elements.Defining_Identifiers; with Program.Elements.Defining_Expanded_Names; with Program.Element_Visitors; package Program.Nodes.Defining_Expanded_Names is pragma Preelaborate; type Defining_Expanded_Name is new Program.Nodes.Node and Program.Elements.Defining_Expanded_Names.Defining_Expanded_Name and Program.Elements.Defining_Expanded_Names .Defining_Expanded_Name_Text with private; function Create (Prefix : not null Program.Elements.Expressions.Expression_Access; Dot_Token : not null Program.Lexical_Elements.Lexical_Element_Access; Selector : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access) return Defining_Expanded_Name; type Implicit_Defining_Expanded_Name is new Program.Nodes.Node and Program.Elements.Defining_Expanded_Names.Defining_Expanded_Name with private; function Create (Prefix : not null Program.Elements.Expressions .Expression_Access; Selector : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Defining_Expanded_Name with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Defining_Expanded_Name is abstract new Program.Nodes.Node and Program.Elements.Defining_Expanded_Names.Defining_Expanded_Name with record Prefix : not null Program.Elements.Expressions.Expression_Access; Selector : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; end record; procedure Initialize (Self : in out Base_Defining_Expanded_Name'Class); overriding procedure Visit (Self : not null access Base_Defining_Expanded_Name; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Prefix (Self : Base_Defining_Expanded_Name) return not null Program.Elements.Expressions.Expression_Access; overriding function Selector (Self : Base_Defining_Expanded_Name) return not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; overriding function Is_Defining_Expanded_Name (Self : Base_Defining_Expanded_Name) return Boolean; overriding function Is_Defining_Name (Self : Base_Defining_Expanded_Name) return Boolean; type Defining_Expanded_Name is new Base_Defining_Expanded_Name and Program.Elements.Defining_Expanded_Names.Defining_Expanded_Name_Text with record Dot_Token : not null Program.Lexical_Elements.Lexical_Element_Access; end record; overriding function To_Defining_Expanded_Name_Text (Self : in out Defining_Expanded_Name) return Program.Elements.Defining_Expanded_Names .Defining_Expanded_Name_Text_Access; overriding function Dot_Token (Self : Defining_Expanded_Name) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Image (Self : Defining_Expanded_Name) return Text; type Implicit_Defining_Expanded_Name is new Base_Defining_Expanded_Name with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; end record; overriding function To_Defining_Expanded_Name_Text (Self : in out Implicit_Defining_Expanded_Name) return Program.Elements.Defining_Expanded_Names .Defining_Expanded_Name_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Defining_Expanded_Name) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Defining_Expanded_Name) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Defining_Expanded_Name) return Boolean; overriding function Image (Self : Implicit_Defining_Expanded_Name) return Text; end Program.Nodes.Defining_Expanded_Names;
{ "source": "starcoderdata", "programming_language": "ada" }
package openGL.Palette -- -- Provides a pallete of named colors. -- -- Color values are sourced from WikiPaedia: -- -- - http://en.wikipedia.org/wiki/Primary_color -- - http://en.wikipedia.org/wiki/Secondary_color -- - http://en.wikipedia.org/wiki/Tertiary_color -- - http://en.wikipedia.org/wiki/List_of_colors -- is -------------------- -- Color Primitives -- -- Shades -- type Shade_Level is digits 7 range 0.0 .. 1.0; function Shade_of (Self : in Color; Level : in Shade_Level) return Color; -- -- Darkens a color by the given shade level factor. -- Color Mixing -- type mix_Factor is digits 7 range 0.0 .. 1.0; -- 0.0 returns 'Self', 1.0 returns 'Other'. function mixed (Self : in Color; Other : in Color; Mix : in mix_Factor := 0.5) return Color; -- -- Combines two colors. -- Similarity -- default_Similarity : constant Primary; function is_similar (Self : in Color; To : in Color; Similarity : in Primary := default_Similarity) return Boolean; -- -- Returns true if the none of the red, green, blue components of 'Self' -- differ from 'to' by more than 'Similarity'. -- Random Colors -- function random_Color return Color; ---------------- -- Named Colors -- -- Achromatic -- White : constant Color; Black : constant Color; Grey : constant Color; -- Primary -- Red : constant Color; Green : constant Color; Blue : constant Color; -- Secondary -- Yellow : constant Color; Cyan : constant Color; Magenta : constant Color; -- Tertiary -- Azure : constant Color; Violet : constant Color; Rose : constant Color; Orange : constant Color; Chartreuse : constant Color; spring_Green : constant Color; -- Named (TODO: sort named colors into primary, secondary and tertiary categories). -- Air_Force_blue : constant Color; Alice_blue : constant Color; Alizarin : constant Color; Amaranth : constant Color; Amaranth_cerise : constant Color; Amaranth_deep_purple : constant Color; Amaranth_magenta : constant Color; Amaranth_pink : constant Color; Amaranth_purple : constant Color; Amber : constant Color; Amber_SAE_ECE : constant Color; American_rose : constant Color; Amethyst : constant Color; Android_Green : constant Color; Anti_flash_white : constant Color; Antique_fuchsia : constant Color; Antique_white : constant Color; Apple_green : constant Color; Apricot : constant Color; Aqua : constant Color; Aquamarine : constant Color; Army_green : constant Color; Arsenic : constant Color; Ash_grey : constant Color; Asparagus : constant Color; Atomic_tangerine : constant Color; Auburn : constant Color; Aureolin : constant Color; Azure_mist : constant Color; Baby_blue : constant Color; Baby_pink : constant Color; Battleship_grey : constant Color; Beige : constant Color; Bistre : constant Color; Bittersweet : constant Color; Blue_pigment : constant Color; Blue_RYB : constant Color; Blue_green : constant Color; Blue_violet : constant Color; Bole : constant Color; Bondi_blue : constant Color; Boston_University_Red : constant Color; Brandeis_Blue : constant Color; Brass : constant Color; Brick_red : constant Color; Bright_cerulean : constant Color; Bright_green : constant Color; Bright_lavender : constant Color; Bright_maroon : constant Color; Bright_pink : constant Color; Bright_turquoise : constant Color; Bright_ube : constant Color; Brilliant_lavender : constant Color; Brilliant_rose : constant Color; Brink_Pink : constant Color; British_racing_green : constant Color; Bronze : constant Color; Brown : constant Color; Brown_web : constant Color; Buff : constant Color; Bulgarian_rose : constant Color; Burgundy : constant Color; Burnt_orange : constant Color; Burnt_sienna : constant Color; Burnt_umber : constant Color; Byzantine : constant Color; Byzantium : constant Color; Cadet_blue : constant Color; Cadmium_Green : constant Color; Cadmium_Orange : constant Color; Cadmium_Red : constant Color; Cadmium_Yellow : constant Color; Cambridge_Blue : constant Color; Camel : constant Color; Camouflage_green : constant Color; Canary_yellow : constant Color; Candy_apple_red : constant Color; Candy_pink : constant Color; Caput_mortuum : constant Color; Cardinal : constant Color; Carmine : constant Color; Carmine_pink : constant Color; Carmine_red : constant Color; Carnation_pink : constant Color; Carnelian : constant Color; Carolina_blue : constant Color; Caribbean_green : constant Color; Carrot_orange : constant Color; Ceil : constant Color; Celadon : constant Color; Celestial_blue : constant Color; Cerise : constant Color; Cerise_pink : constant Color; Cerulean : constant Color; Cerulean_blue : constant Color; Chamoisee : constant Color; Champagne : constant Color; Charcoal : constant Color; Chartreuse_web : constant Color; Cherry_blossom_pink : constant Color; Chestnut : constant Color; Chocolate : constant Color; Chrome_yellow : constant Color; Cinereous : constant Color; Cinnabar : constant Color; Cinnamon : constant Color; Citrine : constant Color; Classic_rose : constant Color; Cobalt : constant Color; Columbia_blue : constant Color; Cool_black : constant Color; Cool_grey : constant Color; Copper : constant Color; Copper_rose : constant Color; Coquelicot : constant Color; Coral : constant Color; Coral_pink : constant Color; Coral_red : constant Color; Cordovan : constant Color; Corn : constant Color; Cornsilk : constant Color; Cornflower_blue : constant Color; Cosmic_latte : constant Color; Cotton_candy : constant Color; Cream : constant Color; Crimson : constant Color; Crimson_glory : constant Color; Cyan_process : constant Color; Dandelion : constant Color; Dark_blue : constant Color; Dark_brown : constant Color; Dark_byzantium : constant Color; Dark_candy_apple_red : constant Color; Dark_cerulean : constant Color; Dark_champagne : constant Color; Dark_chestnut : constant Color; Dark_coral : constant Color; Dark_cyan : constant Color; Dark_electric_blue : constant Color; Dark_goldenrod : constant Color; Dark_green : constant Color; Dark_jungle_green : constant Color; Dark_khaki : constant Color; Dark_lava : constant Color; Dark_lavender : constant Color; Dark_magenta : constant Color; Dark_midnight_blue : constant Color; Dark_orange : constant Color; Dark_pastel_green : constant Color; Dark_pink : constant Color; Dark_powder_blue : constant Color; Dark_raspberry : constant Color; Dark_red : constant Color; Dark_salmon : constant Color; Dark_scarlet : constant Color; Dark_sienna : constant Color; Dark_slate_gray : constant Color; Dark_spring_green : constant Color; Dark_tan : constant Color; Dark_tangerine : constant Color; Dark_taupe : constant Color; Dark_terra_cotta : constant Color; Dark_turquoise : constant Color; Dark_violet : constant Color; Dartmouth_green : constant Color; Davys_grey : constant Color; Deep_carmine : constant Color; Deep_carmine_pink : constant Color; Deep_carrot_orange : constant Color; Deep_cerise : constant Color; Deep_champagne : constant Color; Deep_chestnut : constant Color; Deep_fuchsia : constant Color; Deep_jungle_green : constant Color; Deep_lilac : constant Color; Deep_magenta : constant Color; Deep_peach : constant Color; Deep_pink : constant Color; Deep_saffron : constant Color; Deep_sky_blue : constant Color; Denim : constant Color; Desert : constant Color; Desert_sand : constant Color; Dim_gray : constant Color; Dodger_blue : constant Color; Dogwood_Rose : constant Color; Drab : constant Color; Duke_blue : constant Color; Earth_yellow : constant Color; Ecru : constant Color; Eggplant : constant Color; Eggshell : constant Color; Egyptian_blue : constant Color; Electric_blue : constant Color; Electric_cyan : constant Color; Electric_green : constant Color; Electric_indigo : constant Color; Electric_lavender : constant Color; Electric_lime : constant Color; Electric_purple : constant Color; Electric_ultramarine : constant Color; Electric_violet : constant Color; Emerald : constant Color; Eton_blue : constant Color; Fallow : constant Color; Falu_red : constant Color; Fandango : constant Color; Fashion_fuchsia : constant Color; Fawn : constant Color; Feldgrau : constant Color; Fern_green : constant Color; Field_drab : constant Color; Firebrick : constant Color; Fire_engine_red : constant Color; Flame : constant Color; Flamingo_pink : constant Color; Flavescent : constant Color; Flax : constant Color; Forest_green : constant Color; Forest_green_web : constant Color; French_Beige : constant Color; French_Rose : constant Color; Fuchsia : constant Color; Fuchsia_Pink : constant Color; Fulvous : constant Color; Gamboge : constant Color; Ghost_white : constant Color; Glaucous : constant Color; Gold_metallic : constant Color; Gold_web : constant Color; Golden_brown : constant Color; Golden_poppy : constant Color; Golden_yellow : constant Color; Goldenrod : constant Color; Gray : constant Color; Gray_asparagus : constant Color; Green_web : constant Color; Green_pigment : constant Color; Green_RYB : constant Color; Green_yellow : constant Color; Grullo : constant Color; Halaya_ube : constant Color; Han_Blue : constant Color; Han_Purple : constant Color; Harlequin : constant Color; Heliotrope : constant Color; Hollywood_cerise : constant Color; Honeydew : constant Color; Hot_magenta : constant Color; Hot_pink : constant Color; Hunter_green : constant Color; Iceberg : constant Color; Icterine : constant Color; India_green : constant Color; Indian_yellow : constant Color; Indigo : constant Color; Indigo_web : constant Color; International_Klein_Blue : constant Color; International_orange : constant Color; Iris : constant Color; Isabelline : constant Color; Islamic_green : constant Color; Ivory : constant Color; Jade : constant Color; Jazzberry_jam : constant Color; Jonquil : constant Color; June_bud : constant Color; Jungle_green : constant Color; Kelly_green : constant Color; Khaki_web : constant Color; Khaki : constant Color; Languid_lavender : constant Color; Lava : constant Color; Lavender_floral : constant Color; Lavender_web : constant Color; Lavender_blue : constant Color; Lavender_blush : constant Color; Lavender_gray : constant Color; Lavender_indigo : constant Color; Lavender_magenta : constant Color; Lavender_mist : constant Color; Lavender_pink : constant Color; Lavender_purple : constant Color; Lavender_rose : constant Color; Lawn_green : constant Color; Lemon : constant Color; Lemon_chiffon : constant Color; Light_apricot : constant Color; Light_blue : constant Color; Light_carmine_pink : constant Color; Light_coral : constant Color; Light_cornflower_blue : constant Color; Light_fuchsia_pink : constant Color; Light_khaki : constant Color; Light_mauve : constant Color; Light_pink : constant Color; Light_sea_green : constant Color; Light_salmon : constant Color; Light_salmon_pink : constant Color; Light_sky_blue : constant Color; Light_slate_gray : constant Color; Light_Thulian_pink : constant Color; Lilac : constant Color; Lime : constant Color; Lime_web : constant Color; Lime_green : constant Color; Linen : constant Color; Liver : constant Color; Lust : constant Color; Magenta_dye : constant Color; Magenta_process : constant Color; Magic_mint : constant Color; Magnolia : constant Color; Mahogany : constant Color; Maize : constant Color; Majorelle_Blue : constant Color; Malachite : constant Color; Maroon_web : constant Color; Maroon : constant Color; Mauve : constant Color; Mauve_taupe : constant Color; Maya_blue : constant Color; Medium_aquamarine : constant Color; Medium_blue : constant Color; Medium_candy_apple_red : constant Color; Medium_carmine : constant Color; Medium_champagne : constant Color; Medium_electric_blue : constant Color; Medium_jungle_green : constant Color; Medium_lavender_magenta : constant Color; Medium_Persian_blue : constant Color; Medium_purple : constant Color; Medium_red_violet : constant Color; Medium_sea_green : constant Color; Medium_spring_bud : constant Color; Medium_spring_green : constant Color; Medium_taupe : constant Color; Medium_teal_blue : constant Color; Medium_turquoise : constant Color; Midnight_blue : constant Color; Midnight_green : constant Color; Eagle_green : constant Color; Mikado_yellow : constant Color; Mint_green : constant Color; Misty_rose : constant Color; Moccasin : constant Color; Mode_Beige : constant Color; Mordant_red : constant Color; Moss_green : constant Color; Mountbatten_pink : constant Color; Mulberry : constant Color; Mustard : constant Color; Myrtle : constant Color; MSU_Green : constant Color; Nadeshiko_pink : constant Color; Napier_Green : constant Color; Naples_Yellow : constant Color; Navajo_white : constant Color; Navy_Blue : constant Color; Ochre : constant Color; Office_green : constant Color; Old_Gold : constant Color; Old_Lace : constant Color; Old_lavender : constant Color; Old_Rose : constant Color; Olive : constant Color; Olive_Drab_web : constant Color; Olive_Drab : constant Color; Olivine : constant Color; Onyx : constant Color; Opera_mauve : constant Color; Orange_color_wheel : constant Color; Orange_RYB : constant Color; Orange_web : constant Color; Orange_peel : constant Color; Orange_red : constant Color; Orchid : constant Color; Oxford_Blue : constant Color; OU_Crimson_Red : constant Color; Pale_Amaranth_Pink : constant Color; Pale_blue : constant Color; Pale_brown : constant Color; Pale_carmine : constant Color; Pale_cerulean : constant Color; Pale_chestnut : constant Color; Pale_copper : constant Color; Pale_cornflower_blue : constant Color; Pale_gold : constant Color; Pale_magenta : constant Color; Pale_pink : constant Color; Pale_red_violet : constant Color; Pale_robin_egg_blue : constant Color; Pale_silver : constant Color; Pale_spring_bud : constant Color; Pale_taupe : constant Color; Palatinate_blue : constant Color; Palatinate_purple : constant Color; Pansy_purple : constant Color; Papaya_whip : constant Color; Pastel_green : constant Color; Pastel_pink : constant Color; Paynes_grey : constant Color; Peach : constant Color; Peach_orange : constant Color; Peach_puff : constant Color; Peach_yellow : constant Color; Pear : constant Color; Pearl : constant Color; Periwinkle : constant Color; Persian_blue : constant Color; Persian_green : constant Color; Persian_indigo : constant Color; Persian_orange : constant Color; Persian_red : constant Color; Persian_pink : constant Color; Persian_rose : constant Color; Persimmon : constant Color; Phthalo_blue : constant Color; Phthalo_green : constant Color; Piggy_pink : constant Color; Pine_green : constant Color; Pink : constant Color; Pink_orange : constant Color; Pistachio : constant Color; Platinum : constant Color; Plum : constant Color; Portland_Orange : constant Color; Powder_blue : constant Color; Princeton_Orange : constant Color; Prussian_blue : constant Color; Psychedelic_purple : constant Color; Puce : constant Color; Pumpkin : constant Color; Purple_web : constant Color; Purple : constant Color; Purple_Heart : constant Color; Purple_mountain_majesty : constant Color; Purple_taupe : constant Color; Radical_Red : constant Color; Raspberry : constant Color; Raspberry_glace : constant Color; Raspberry_pink : constant Color; Raspberry_rose : constant Color; Raw_umber : constant Color; Razzle_dazzle_rose : constant Color; Razzmatazz : constant Color; Red_pigment : constant Color; Red_RYB : constant Color; Red_violet : constant Color; Rich_black : constant Color; Rich_brilliant_lavender : constant Color; Rich_carmine : constant Color; Rich_electric_blue : constant Color; Rich_lavender : constant Color; Rich_maroon : constant Color; Rifle_green : constant Color; Robin_egg_blue : constant Color; Rose_Ebony : constant Color; Rose_Gold : constant Color; Rose_Madder : constant Color; Rose_pink : constant Color; Rose_quartz : constant Color; Rose_taupe : constant Color; Rose_vale : constant Color; Rosewood : constant Color; Rosso_corsa : constant Color; Rosy_brown : constant Color; Royal_azure : constant Color; Royal_blue : constant Color; Royal_blue_web : constant Color; Royal_fuchsia : constant Color; Royal_purple : constant Color; Ruby : constant Color; Rufous : constant Color; Russet : constant Color; Rust : constant Color; Sacramento_State_green : constant Color; Saddle_brown : constant Color; Safety_orange : constant Color; blaze_orange : constant Color; Saffron : constant Color; St_Patricks_blue : constant Color; Salmon : constant Color; Salmon_pink : constant Color; Sand : constant Color; Sand_dune : constant Color; Sandy_brown : constant Color; Sandy_taupe : constant Color; Sangria : constant Color; Sap_green : constant Color; Sapphire : constant Color; Satin_sheen_gold : constant Color; Scarlet : constant Color; School_bus_yellow : constant Color; Sea_green : constant Color; Seal_brown : constant Color; Seashell : constant Color; Selective_yellow : constant Color; Sepia : constant Color; Shamrock_green : constant Color; Shocking_pink : constant Color; Sienna : constant Color; Silver : constant Color; Skobeloff : constant Color; Sky_blue : constant Color; Sky_magenta : constant Color; Slate_gray : constant Color; Smalt : constant Color; Smoky_black : constant Color; Snow : constant Color; Splashed_white : constant Color; Spring_bud : constant Color; Steel_blue : constant Color; Straw : constant Color; Sunglow : constant Color; Sunset : constant Color; Tan : constant Color; Tangelo : constant Color; Tangerine : constant Color; Tangerine_yellow : constant Color; Taupe : constant Color; Taupe_gray : constant Color; Tea_green : constant Color; Tea_rose_orange : constant Color; Tea_rose : constant Color; Teal : constant Color; Teal_blue : constant Color; Tenne : constant Color; Tawny : constant Color; Terra_cotta : constant Color; Thistle : constant Color; Thulian_pink : constant Color; Tiffany_Blue : constant Color; Tomato : constant Color; Torch_red : constant Color; Tropical_rain_forest : constant Color; Turkish_Rose : constant Color; Turquoise : constant Color; Turquoise_blue : constant Color; Tuscan_red : constant Color; Twilight_lavender : constant Color; Tyrian_purple : constant Color; Ube : constant Color; Ultramarine : constant Color; Ultramarine_blue : constant Color; Ultra_pink : constant Color; Umber : constant Color; United_Nations_blue : constant Color; Upsdell_red : constant Color; UP_Forest_green : constant Color; UP_Maroon : constant Color; Vegas_Gold : constant Color; Venetian_red : constant Color; Vermilion : constant Color; Violet_web : constant Color; Violet_RYB : constant Color; Viridian : constant Color; Vivid_auburn : constant Color; Vivid_burgundy : constant Color; Vivid_violet : constant Color; Warm_black : constant Color; Wenge : constant Color; Wheat : constant Color; White_smoke : constant Color; Wild_blue_yonder : constant Color; Wisteria : constant Color; Xanadu : constant Color; Yale_Blue : constant Color; Yellow_process : constant Color; Yellow_RYB : constant Color; Yellow_green : constant Color; private default_Similarity : constant Primary := to_Primary (3); White : constant Color := (1.0, 1.0, 1.0); Black : constant Color := (0.0, 0.0, 0.0); Grey : constant Color := (0.5, 0.5, 0.5); Red : constant Color := (1.0, 0.0, 0.0); Green : constant Color := (0.0, 1.0, 0.0); Blue : constant Color := (0.0, 0.0, 1.0); Yellow : constant Color := (1.0, 1.0, 0.0); Cyan : constant Color := (0.0, 1.0, 1.0); Magenta : constant Color := (1.0, 0.0, 1.0); Azure : constant Color := +( 0, 127, 255); Violet : constant Color := +(139, 0, 255); Rose : constant Color := +(255, 0, 127); Orange : constant Color := +(255, 127, 0); Chartreuse : constant Color := +(223, 255, 0); spring_Green : constant Color := +( 0, 255, 127); Air_Force_blue : constant Color := +(93, 138, 168); Alice_blue : constant Color := +(240, 248, 255); Alizarin : constant Color := +(227, 38, 54); Amaranth : constant Color := +(229, 43, 80); Amaranth_cerise : constant Color := +(205, 38, 130); Amaranth_deep_purple : constant Color := +(159, 43, 104); Amaranth_magenta : constant Color := +(237, 60, 202); Amaranth_pink : constant Color := +(241, 156, 187); Amaranth_purple : constant Color := +(171, 39, 79); Amber : constant Color := +(255, 191, 0); Amber_SAE_ECE : constant Color := +(255, 126, 0); American_rose : constant Color := +(255, 3, 62); Amethyst : constant Color := +(153, 102, 204); Android_Green : constant Color := +(164, 198, 57); Anti_flash_white : constant Color := +(242, 243, 244); Antique_fuchsia : constant Color := +(145, 92, 131); Antique_white : constant Color := +(250, 235, 215); Apple_green : constant Color := +(141, 182, 0); Apricot : constant Color := +(251, 206, 177); Aqua : constant Color := +(0, 255, 255); Aquamarine : constant Color := +(127, 255, 212); Army_green : constant Color := +(75, 83, 32); Arsenic : constant Color := +(59, 68, 75); Ash_grey : constant Color := +(178, 190, 181); Asparagus : constant Color := +(135, 169, 107); Atomic_tangerine : constant Color := +(255, 153, 102); Auburn : constant Color := +(109, 53, 26); Aureolin : constant Color := +(253, 238, 0); Azure_mist : constant Color := +(240, 255, 255); Baby_blue : constant Color := +(224, 255, 255); Baby_pink : constant Color := +(244, 194, 194); Battleship_grey : constant Color := +(132, 132, 130); Beige : constant Color := +(245, 245, 220); Bistre : constant Color := +(61, 43, 31); Bittersweet : constant Color := +(254, 111, 94); Blue_pigment : constant Color := +(51, 51, 153); Blue_RYB : constant Color := +(2, 71, 254); Blue_green : constant Color := +(0, 221, 221); Blue_violet : constant Color := +(138, 43, 226); Bole : constant Color := +(121, 68, 59); Bondi_blue : constant Color := +(0, 149, 182); Boston_University_Red : constant Color := +(204, 0, 0); Brandeis_Blue : constant Color := +(0, 112, 255); Brass : constant Color := +(181, 166, 66); Brick_red : constant Color := +(203, 65, 84); Bright_cerulean : constant Color := +(29, 172, 214); Bright_green : constant Color := +(102, 255, 0); Bright_lavender : constant Color := +(191, 148, 228); Bright_maroon : constant Color := +(195, 33, 72); Bright_pink : constant Color := +(255, 0, 127); Bright_turquoise : constant Color := +(8, 232, 222); Bright_ube : constant Color := +(209, 159, 232); Brilliant_lavender : constant Color := +(244, 187, 255); Brilliant_rose : constant Color := +(255, 85, 163); Brink_Pink : constant Color := +(251, 96, 127); British_racing_green : constant Color := +(0, 66, 37); Bronze : constant Color := +(205, 127, 50); Brown : constant Color := +(150, 75, 0); Brown_web : constant Color := +(165, 42, 42); Buff : constant Color := +(240, 220, 130); Bulgarian_rose : constant Color := +(72, 6, 7); Burgundy : constant Color := +(128, 0, 32); Burnt_orange : constant Color := +(204, 85, 0); Burnt_sienna : constant Color := +(233, 116, 81); Burnt_umber : constant Color := +(138, 51, 36); Byzantine : constant Color := +(189, 51, 164); Byzantium : constant Color := +(112, 41, 99); Cadet_blue : constant Color := +(95, 158, 160); Cadmium_Green : constant Color := +(0, 107, 60); Cadmium_Orange : constant Color := +(237, 135, 45); Cadmium_Red : constant Color := +(227, 0, 34); Cadmium_Yellow : constant Color := +(255, 246, 0); Cambridge_Blue : constant Color := +(153, 204, 204); Camel : constant Color := +(193, 154, 107); Camouflage_green : constant Color := +(120, 134, 107); Canary_yellow : constant Color := +(255, 239, 0); Candy_apple_red : constant Color := +(255, 8, 0); Candy_pink : constant Color := +(228, 113, 122); Caput_mortuum : constant Color := +(89, 39, 32); Cardinal : constant Color := +(196, 30, 58); Carmine : constant Color := +(150, 0, 24); Carmine_pink : constant Color := +(235, 76, 66); Carmine_red : constant Color := +(255, 0, 51); Carnation_pink : constant Color := +(255, 166, 201); Carnelian : constant Color := +(179, 27, 27); Carolina_blue : constant Color := +(153, 186, 227); Caribbean_green : constant Color := +(0, 204, 153); Carrot_orange : constant Color := +(237, 145, 33); Ceil : constant Color := +(147, 162, 208); Celadon : constant Color := +(172, 225, 175); Celestial_blue : constant Color := +(73, 151, 208); Cerise : constant Color := +(222, 49, 99); Cerise_pink : constant Color := +(236, 59, 131); Cerulean : constant Color := +(0, 123, 167); Cerulean_blue : constant Color := +(42, 82, 190); Chamoisee : constant Color := +(160, 120, 90); Champagne : constant Color := +(247, 231, 206); Charcoal : constant Color := +(54, 69, 79); Chartreuse_web : constant Color := +(127, 255, 0); Cherry_blossom_pink : constant Color := +(255, 183, 197); Chestnut : constant Color := +(205, 92, 92); Chocolate : constant Color := +(123, 63, 0); Chrome_yellow : constant Color := +(255, 167, 0); Cinereous : constant Color := +(152, 129, 123); Cinnabar : constant Color := +(227, 66, 52); Cinnamon : constant Color := +(210, 105, 30); Citrine : constant Color := +(228, 208, 10); Classic_rose : constant Color := +(251, 204, 231); Cobalt : constant Color := +(0, 71, 171); Columbia_blue : constant Color := +(155, 221, 255); Cool_black : constant Color := +(0, 46, 99); Cool_grey : constant Color := +(140, 146, 172); Copper : constant Color := +(184, 115, 51); Copper_rose : constant Color := +(153, 102, 102); Coquelicot : constant Color := +(255, 56, 0); Coral : constant Color := +(255, 127, 80); Coral_pink : constant Color := +(248, 131, 121); Coral_red : constant Color := +(255, 64, 64); Cordovan : constant Color := +(137, 63, 69); Corn : constant Color := +(251, 236, 93); Cornsilk : constant Color := +(255, 248, 220); Cornflower_blue : constant Color := +(100, 149, 237); Cosmic_latte : constant Color := +(255, 248, 231); Cotton_candy : constant Color := +(255, 188, 217); Cream : constant Color := +(255, 253, 208); Crimson : constant Color := +(220, 20, 60); Crimson_glory : constant Color := +(190, 0, 50); Cyan_process : constant Color := +(0, 183, 235); Dandelion : constant Color := +(240, 225, 48); Dark_blue : constant Color := +(0, 0, 139); Dark_brown : constant Color := +(101, 67, 33); Dark_byzantium : constant Color := +(93, 57, 84); Dark_candy_apple_red : constant Color := +(164, 0, 0); Dark_cerulean : constant Color := +(8, 69, 126); Dark_champagne : constant Color := +(194, 178, 128); Dark_chestnut : constant Color := +(152, 105, 96); Dark_coral : constant Color := +(205, 91, 69); Dark_cyan : constant Color := +(0, 139, 139); Dark_electric_blue : constant Color := +(83, 104, 120); Dark_goldenrod : constant Color := +(184, 134, 11); Dark_green : constant Color := +(1, 50, 32); Dark_jungle_green : constant Color := +(26, 36, 33); Dark_khaki : constant Color := +(189, 183, 107); Dark_lava : constant Color := +(72, 60, 50); Dark_lavender : constant Color := +(115, 79, 150); Dark_magenta : constant Color := +(139, 0, 139); Dark_midnight_blue : constant Color := +(0, 51, 102); Dark_orange : constant Color := +(255, 140, 0); Dark_pastel_green : constant Color := +(3, 192, 60); Dark_pink : constant Color := +(231, 84, 128); Dark_powder_blue : constant Color := +(0, 51, 153); Dark_raspberry : constant Color := +(135, 38, 87); Dark_red : constant Color := +(139, 0, 0); Dark_salmon : constant Color := +(233, 150, 122); Dark_scarlet : constant Color := +(86, 3, 25); Dark_sienna : constant Color := +(60, 20, 20); Dark_slate_gray : constant Color := +(47, 79, 79); Dark_spring_green : constant Color := +(23, 114, 69); Dark_tan : constant Color := +(145, 129, 81); Dark_tangerine : constant Color := +(255, 168, 18); Dark_taupe : constant Color := +(72, 60, 50); Dark_terra_cotta : constant Color := +(204, 78, 92); Dark_turquoise : constant Color := +(0, 206, 209); Dark_violet : constant Color := +(148, 0, 211); Dartmouth_green : constant Color := +(13, 128, 15); Davys_grey : constant Color := +(85, 85, 85); Deep_carmine : constant Color := +(169, 32, 62); Deep_carmine_pink : constant Color := +(239, 48, 56); Deep_carrot_orange : constant Color := +(233, 105, 44); Deep_cerise : constant Color := +(218, 50, 135); Deep_champagne : constant Color := +(250, 214, 165); Deep_chestnut : constant Color := +(185, 78, 72); Deep_fuchsia : constant Color := +(193, 84, 193); Deep_jungle_green : constant Color := +(0, 75, 73); Deep_lilac : constant Color := +(153, 85, 187); Deep_magenta : constant Color := +(205, 0, 204); Deep_peach : constant Color := +(255, 203, 164); Deep_pink : constant Color := +(255, 20, 147); Deep_saffron : constant Color := +(255, 153, 51); Deep_sky_blue : constant Color := +(0, 191, 255); Denim : constant Color := +(21, 96, 189); Desert : constant Color := +(193, 154, 107); Desert_sand : constant Color := +(237, 201, 175); Dim_gray : constant Color := +(105, 105, 105); Dodger_blue : constant Color := +(30, 144, 255); Dogwood_Rose : constant Color := +(215, 24, 104); Drab : constant Color := +(150, 113, 23); Duke_blue : constant Color := +(0, 0, 156); Earth_yellow : constant Color := +(225, 169, 95); Ecru : constant Color := +(194, 178, 128); Eggplant : constant Color := +(97, 64, 81); Eggshell : constant Color := +(240, 234, 214); Egyptian_blue : constant Color := +(16, 52, 166); Electric_blue : constant Color := +(125, 249, 255); Electric_cyan : constant Color := +(0, 255, 255); Electric_green : constant Color := +(0, 255, 0); Electric_indigo : constant Color := +(111, 0, 255); Electric_lavender : constant Color := +(244, 187, 255); Electric_lime : constant Color := +(204, 255, 0); Electric_purple : constant Color := +(191, 0, 255); Electric_ultramarine : constant Color := +(63, 0, 255); Electric_violet : constant Color := +(139, 0, 255); Emerald : constant Color := +(80, 200, 120); Eton_blue : constant Color := +(150, 200, 162); Fallow : constant Color := +(193, 154, 107); Falu_red : constant Color := +(128, 24, 24); Fandango : constant Color := +(184, 84, 137); Fashion_fuchsia : constant Color := +(244, 0, 161); Fawn : constant Color := +(229, 170, 112); Feldgrau : constant Color := +(77, 93, 83); Fern_green : constant Color := +(79, 121, 66); Field_drab : constant Color := +(108, 84, 30); Firebrick : constant Color := +(178, 34, 34); Fire_engine_red : constant Color := +(206, 22, 32); Flame : constant Color := +(226, 88, 34); Flamingo_pink : constant Color := +(252, 142, 172); Flavescent : constant Color := +(247, 233, 142); Flax : constant Color := +(238, 220, 130); Forest_green : constant Color := +(1, 68, 33); Forest_green_web : constant Color := +(34, 139, 34); French_Beige : constant Color := +(166, 123, 91); French_Rose : constant Color := +(246, 74, 138); Fuchsia : constant Color := +(255, 0, 255); Fuchsia_Pink : constant Color := +(255, 119, 255); Fulvous : constant Color := +(220, 132, 0); Gamboge : constant Color := +(228, 155, 15); Ghost_white : constant Color := +(248, 248, 255); Glaucous : constant Color := +(96, 130, 182); Gold_metallic : constant Color := +(212, 175, 55); Gold_web : constant Color := +(255, 215, 0); Golden_brown : constant Color := +(153, 101, 21); Golden_poppy : constant Color := +(252, 194, 0); Golden_yellow : constant Color := +(255, 223, 0); Goldenrod : constant Color := +(218, 165, 32); Gray : constant Color := +(128, 128, 128); Gray_asparagus : constant Color := +(70, 89, 69); Green_web : constant Color := +(0, 128, 0); Green_pigment : constant Color := +(0, 165, 80); Green_RYB : constant Color := +(102, 176, 50); Green_yellow : constant Color := +(173, 255, 47); Grullo : constant Color := +(169, 154, 134); Halaya_ube : constant Color := +(102, 56, 84); Han_Blue : constant Color := +(82, 24, 250); Han_Purple : constant Color := +(82, 24, 250); Harlequin : constant Color := +(63, 255, 0); Heliotrope : constant Color := +(223, 115, 255); Hollywood_cerise : constant Color := +(244, 0, 161); Honeydew : constant Color := +(240, 255, 240); Hot_magenta : constant Color := +(255, 0, 204); Hot_pink : constant Color := +(255, 105, 180); Hunter_green : constant Color := +(53, 94, 59); Iceberg : constant Color := +(113, 166, 210); Icterine : constant Color := +(252, 247, 94); India_green : constant Color := +(19, 136, 8); Indian_yellow : constant Color := +(227, 168, 87); Indigo : constant Color := +(0, 65, 106); Indigo_web : constant Color := +(75, 0, 130); International_Klein_Blue : constant Color := +(0, 47, 167); International_orange : constant Color := +(255, 79, 0); Iris : constant Color := +(90, 79, 207); Isabelline : constant Color := +(244, 240, 236); Islamic_green : constant Color := +(0, 144, 0); Ivory : constant Color := +(255, 255, 240); Jade : constant Color := +(0, 168, 107); Jazzberry_jam : constant Color := +(165, 11, 94); Jonquil : constant Color := +(250, 218, 94); June_bud : constant Color := +(189, 218, 87); Jungle_green : constant Color := +(41, 171, 135); Kelly_green : constant Color := +(76, 187, 23); Khaki_web : constant Color := +(195, 176, 145); Khaki : constant Color := +(240, 230, 140); Languid_lavender : constant Color := +(214, 202, 221); Lava : constant Color := +(207, 16, 32); Lavender_floral : constant Color := +(181, 126, 220); Lavender_web : constant Color := +(230, 230, 250); Lavender_blue : constant Color := +(204, 204, 255); Lavender_blush : constant Color := +(255, 240, 245); Lavender_gray : constant Color := +(196, 195, 208); Lavender_indigo : constant Color := +(148, 87, 235); Lavender_magenta : constant Color := +(238, 130, 238); Lavender_mist : constant Color := +(230, 230, 250); Lavender_pink : constant Color := +(251, 174, 210); Lavender_purple : constant Color := +(150, 123, 182); Lavender_rose : constant Color := +(251, 160, 227); Lawn_green : constant Color := +(124, 252, 0); Lemon : constant Color := +(255, 247, 0); Lemon_chiffon : constant Color := +(255, 250, 205); Light_apricot : constant Color := +(253, 213, 177); Light_blue : constant Color := +(173, 216, 230); Light_carmine_pink : constant Color := +(230, 103, 97); Light_coral : constant Color := +(240, 128, 128); Light_cornflower_blue : constant Color := +(173, 216, 230); Light_fuchsia_pink : constant Color := +(249, 132, 229); Light_khaki : constant Color := +(240, 230, 140); Light_mauve : constant Color := +(220, 208, 255); Light_pink : constant Color := +(255, 182, 193); Light_sea_green : constant Color := +(32, 178, 170); Light_salmon : constant Color := +(255, 160, 122); Light_salmon_pink : constant Color := +(255, 153, 153); Light_sky_blue : constant Color := +(135, 206, 250); Light_slate_gray : constant Color := +(119, 136, 153); Light_Thulian_pink : constant Color := +(230, 143, 172); Lilac : constant Color := +(200, 162, 200); Lime : constant Color := +(191, 255, 0); Lime_web : constant Color := +(0, 255, 0); Lime_green : constant Color := +(50, 205, 50); Linen : constant Color := +(250, 240, 230); Liver : constant Color := +(83, 75, 79); Lust : constant Color := +(230, 32, 32); Magenta_dye : constant Color := +(202, 21, 123); Magenta_process : constant Color := +(255, 0, 144); Magic_mint : constant Color := +(170, 240, 209); Magnolia : constant Color := +(248, 244, 255); Mahogany : constant Color := +(192, 64, 0); Maize : constant Color := +(251, 236, 94); Majorelle_Blue : constant Color := +(96, 80, 220); Malachite : constant Color := +(11, 218, 81); Maroon_web : constant Color := +(128, 0, 0); Maroon : constant Color := +(176, 48, 96); Mauve : constant Color := +(224, 176, 255); Mauve_taupe : constant Color := +(145, 95, 109); Maya_blue : constant Color := +(115, 194, 251); Medium_aquamarine : constant Color := +(0, 84, 180); Medium_blue : constant Color := +(0, 0, 205); Medium_candy_apple_red : constant Color := +(226, 6, 44); Medium_carmine : constant Color := +(175, 64, 53); Medium_champagne : constant Color := +(243, 229, 171); Medium_electric_blue : constant Color := +(3, 80, 150); Medium_jungle_green : constant Color := +(28, 53, 45); Medium_lavender_magenta : constant Color := +(204, 153, 204); Medium_Persian_blue : constant Color := +(0, 103, 165); Medium_purple : constant Color := +(147, 112, 219); Medium_red_violet : constant Color := +(187, 51, 133); Medium_sea_green : constant Color := +(60, 179, 113); Medium_spring_bud : constant Color := +(201, 220, 137); Medium_spring_green : constant Color := +(0, 250, 154); Medium_taupe : constant Color := +(103, 76, 71); Medium_teal_blue : constant Color := +(0, 84, 180); Medium_turquoise : constant Color := +(72, 209, 204); Midnight_blue : constant Color := +(25, 25, 112); Midnight_green : constant Color := +(0, 73, 83); Eagle_green : constant Color := +(0, 73, 83); Mikado_yellow : constant Color := +(255, 196, 12); Mint_green : constant Color := +(152, 255, 152); Misty_rose : constant Color := +(255, 228, 225); Moccasin : constant Color := +(250, 235, 215); Mode_Beige : constant Color := +(150, 113, 23); Mordant_red : constant Color := +(174, 12, 0); Moss_green : constant Color := +(173, 223, 173); Mountbatten_pink : constant Color := +(153, 122, 141); Mulberry : constant Color := +(197, 75, 140); Mustard : constant Color := +(255, 219, 88); Myrtle : constant Color := +(33, 66, 30); MSU_Green : constant Color := +(0, 102, 51); Nadeshiko_pink : constant Color := +(246, 173, 198); Napier_Green : constant Color := +(42, 128, 0); Naples_Yellow : constant Color := +(250, 218, 94); Navajo_white : constant Color := +(255, 222, 173); Navy_Blue : constant Color := +(0, 0, 128); Ochre : constant Color := +(204, 119, 34); Office_green : constant Color := +(0, 128, 0); Old_Gold : constant Color := +(207, 181, 59); Old_Lace : constant Color := +(253, 245, 230); Old_lavender : constant Color := +(121, 104, 120); Old_Rose : constant Color := +(192, 128, 129); Olive : constant Color := +(128, 128, 0); Olive_Drab_web : constant Color := +(107, 142, 35); Olive_Drab : constant Color := +(60, 52, 31); Olivine : constant Color := +(154, 185, 115); Onyx : constant Color := +(15, 15, 15); Opera_mauve : constant Color := +(183, 132, 167); Orange_color_wheel : constant Color := +(255, 127, 0); Orange_RYB : constant Color := +(251, 153, 2); Orange_web : constant Color := +(255, 165, 0); Orange_peel : constant Color := +(255, 159, 0); Orange_red : constant Color := +(255, 69, 0); Orchid : constant Color := +(218, 112, 214); Oxford_Blue : constant Color := +(0, 33, 71); OU_Crimson_Red : constant Color := +(153, 0, 0); Pale_Amaranth_Pink : constant Color := +(221, 190, 195); Pale_blue : constant Color := +(175, 238, 238); Pale_brown : constant Color := +(152, 118, 84); Pale_carmine : constant Color := +(175, 64, 53); Pale_cerulean : constant Color := +(155, 196, 226); Pale_chestnut : constant Color := +(221, 173, 175); Pale_copper : constant Color := +(218, 138, 103); Pale_cornflower_blue : constant Color := +(171, 205, 239); Pale_gold : constant Color := +(230, 190, 138); Pale_magenta : constant Color := +(249, 132, 229); Pale_pink : constant Color := +(250, 218, 221); Pale_red_violet : constant Color := +(219, 112, 147); Pale_robin_egg_blue : constant Color := +(150, 222, 209); Pale_silver : constant Color := +(201, 192, 187); Pale_spring_bud : constant Color := +(236, 235, 189); Pale_taupe : constant Color := +(188, 152, 126); Palatinate_blue : constant Color := +(39, 59, 226); Palatinate_purple : constant Color := +(104, 40, 96); Pansy_purple : constant Color := +(120, 24, 74); Papaya_whip : constant Color := +(255, 239, 213); Pastel_green : constant Color := +(119, 221, 119); Pastel_pink : constant Color := +(255, 209, 220); Paynes_grey : constant Color := +(64, 64, 72); Peach : constant Color := +(255, 229, 180); Peach_orange : constant Color := +(255, 204, 153); Peach_puff : constant Color := +(255, 218, 185); Peach_yellow : constant Color := +(250, 223, 173); Pear : constant Color := +(209, 226, 49); Pearl : constant Color := +(240, 234, 214); Periwinkle : constant Color := +(204, 204, 255); Persian_blue : constant Color := +(28, 57, 187); Persian_green : constant Color := +(0, 166, 147); Persian_indigo : constant Color := +(50, 18, 122); Persian_orange : constant Color := +(217, 144, 88); Persian_red : constant Color := +(204, 51, 51); Persian_pink : constant Color := +(247, 127, 190); Persian_rose : constant Color := +(254, 40, 162); Persimmon : constant Color := +(236, 88, 0); Phthalo_blue : constant Color := +(0, 15, 137); Phthalo_green : constant Color := +(18, 53, 36); Piggy_pink : constant Color := +(253, 221, 230); Pine_green : constant Color := +(1, 121, 111); Pink : constant Color := +(255, 192, 203); Pink_orange : constant Color := +(255, 153, 102); Pistachio : constant Color := +(147, 197, 114); Platinum : constant Color := +(229, 228, 226); Plum : constant Color := +(204, 153, 204); Portland_Orange : constant Color := +(255, 90, 54); Powder_blue : constant Color := +(176, 224, 230); Princeton_Orange : constant Color := +(215, 71, 33); Prussian_blue : constant Color := +(0, 49, 83); Psychedelic_purple : constant Color := +(221, 0, 255); Puce : constant Color := +(204, 136, 153); Pumpkin : constant Color := +(255, 117, 24); Purple_web : constant Color := +(127, 0, 127); Purple : constant Color := +(160, 92, 240); Purple_Heart : constant Color := +(105, 53, 156); Purple_mountain_majesty : constant Color := +(150, 120, 182); Purple_taupe : constant Color := +(80, 64, 77); Radical_Red : constant Color := +(255, 53, 94); Raspberry : constant Color := +(227, 11, 92); Raspberry_glace : constant Color := +(145, 95, 109); Raspberry_pink : constant Color := +(226, 80, 155); Raspberry_rose : constant Color := +(179, 68, 108); Raw_umber : constant Color := +(130, 102, 68); Razzle_dazzle_rose : constant Color := +(255, 51, 204); Razzmatazz : constant Color := +(227, 37, 107); Red_pigment : constant Color := +(237, 28, 36); Red_RYB : constant Color := +(254, 39, 18); Red_violet : constant Color := +(199, 21, 133); Rich_black : constant Color := +(0, 64, 64); Rich_brilliant_lavender : constant Color := +(241, 167, 254); Rich_carmine : constant Color := +(215, 0, 64); Rich_electric_blue : constant Color := +(8, 146, 208); Rich_lavender : constant Color := +(170, 97, 204); Rich_maroon : constant Color := +(176, 48, 96); Rifle_green : constant Color := +(65, 72, 51); Robin_egg_blue : constant Color := +(0, 204, 204); Rose_Ebony : constant Color := +(103, 76, 71); Rose_Gold : constant Color := +(183, 110, 121); Rose_Madder : constant Color := +(227, 38, 54); Rose_pink : constant Color := +(255, 102, 204); Rose_quartz : constant Color := +(170, 152, 169); Rose_taupe : constant Color := +(144, 93, 93); Rose_vale : constant Color := +(171, 78, 82); Rosewood : constant Color := +(101, 0, 11); Rosso_corsa : constant Color := +(212, 0, 0); Rosy_brown : constant Color := +(188, 143, 143); Royal_azure : constant Color := +(0, 56, 168); Royal_blue : constant Color := +(0, 35, 102); Royal_blue_web : constant Color := +(65, 105, 225); Royal_fuchsia : constant Color := +(202, 44, 146); Royal_purple : constant Color := +(107, 63, 160); Ruby : constant Color := +(224, 17, 95); Rufous : constant Color := +(168, 28, 7); Russet : constant Color := +(128, 70, 27); Rust : constant Color := +(183, 65, 14); Sacramento_State_green : constant Color := +(0, 86, 63); Saddle_brown : constant Color := +(139, 69, 19); Safety_orange : constant Color := +(255, 102, 0); blaze_orange : constant Color := +(255, 102, 0); Saffron : constant Color := +(244, 196, 48); St_Patricks_blue : constant Color := +(35, 41, 122); Salmon : constant Color := +(255, 140, 105); Salmon_pink : constant Color := +(255, 145, 164); Sand : constant Color := +(194, 178, 128); Sand_dune : constant Color := +(150, 113, 23); Sandy_brown : constant Color := +(244, 164, 96); Sandy_taupe : constant Color := +(150, 113, 23); Sangria : constant Color := +(146, 0, 10); Sap_green : constant Color := +(80, 125, 42); Sapphire : constant Color := +(8, 37, 103); Satin_sheen_gold : constant Color := +(203, 161, 53); Scarlet : constant Color := +(255, 32, 0); School_bus_yellow : constant Color := +(255, 216, 0); Sea_green : constant Color := +(46, 139, 87); Seal_brown : constant Color := +(50, 20, 20); Seashell : constant Color := +(255, 245, 238); Selective_yellow : constant Color := +(255, 186, 0); Sepia : constant Color := +(112, 66, 20); Shamrock_green : constant Color := +(0, 158, 96); Shocking_pink : constant Color := +(252, 15, 192); Sienna : constant Color := +(136, 45, 23); Silver : constant Color := +(192, 192, 192); Skobeloff : constant Color := +(0, 122, 116); Sky_blue : constant Color := +(135, 206, 235); Sky_magenta : constant Color := +(207, 113, 175); Slate_gray : constant Color := +(112, 128, 144); Smalt : constant Color := +(0, 51, 153); Smoky_black : constant Color := +(16, 12, 8); Snow : constant Color := +(255, 250, 250); Splashed_white : constant Color := +(254, 253, 255); Spring_bud : constant Color := +(167, 252, 0); Steel_blue : constant Color := +(70, 130, 180); Straw : constant Color := +(228, 117, 111); Sunglow : constant Color := +(255, 204, 51); Sunset : constant Color := +(250, 214, 165); Tan : constant Color := +(210, 180, 140); Tangelo : constant Color := +(249, 77, 0); Tangerine : constant Color := +(242, 133, 0); Tangerine_yellow : constant Color := +(255, 204, 0); Taupe : constant Color := +(72, 60, 50); Taupe_gray : constant Color := +(139, 133, 137); Tea_green : constant Color := +(208, 240, 192); Tea_rose_orange : constant Color := +(248, 131, 121); Tea_rose : constant Color := +(244, 194, 194); Teal : constant Color := +(0, 128, 128); Teal_blue : constant Color := +(54, 117, 136); Tenne : constant Color := +(205, 87, 0); Tawny : constant Color := +(205, 87, 0); Terra_cotta : constant Color := +(226, 114, 91); Thistle : constant Color := +(216, 191, 216); Thulian_pink : constant Color := +(222, 111, 161); Tiffany_Blue : constant Color := +(10, 186, 181); Tomato : constant Color := +(255, 99, 71); Torch_red : constant Color := +(253, 14, 53); Tropical_rain_forest : constant Color := +(0, 117, 94); Turkish_Rose : constant Color := +(181, 114, 129); Turquoise : constant Color := +(48, 213, 200); Turquoise_blue : constant Color := +(0, 191, 255); Tuscan_red : constant Color := +(123, 54, 54); Twilight_lavender : constant Color := +(138, 73, 107); Tyrian_purple : constant Color := +(102, 2, 60); Ube : constant Color := +(136, 120, 195); Ultramarine : constant Color := +(18, 10, 143); Ultramarine_blue : constant Color := +(65, 102, 245); Ultra_pink : constant Color := +(255, 111, 255); Umber : constant Color := +(99, 81, 71); United_Nations_blue : constant Color := +(91, 146, 229); Upsdell_red : constant Color := +(174, 22, 32); UP_Forest_green : constant Color := +(1, 68, 33); UP_Maroon : constant Color := +(123, 17, 19); Vegas_Gold : constant Color := +(197, 179, 88); Venetian_red : constant Color := +(200, 8, 21); Vermilion : constant Color := +(227, 66, 51); Violet_wheel : constant Color := +(128, 0, 255); Violet_web : constant Color := +(238, 130, 238); Violet_RYB : constant Color := +(134, 1, 175); Viridian : constant Color := +(64, 130, 109); Vivid_auburn : constant Color := +(147, 39, 36); Vivid_burgundy : constant Color := +(159, 29, 53); Vivid_violet : constant Color := +(153, 0, 255); Warm_black : constant Color := +(0, 66, 66); Wenge : constant Color := +(100, 84, 82); Wheat : constant Color := +(245, 222, 179); White_smoke : constant Color := +(245, 245, 245); Wild_blue_yonder : constant Color := +(162, 173, 208); Wisteria : constant Color := +(201, 160, 220); Xanadu : constant Color := +(115, 134, 120); Yale_Blue : constant Color := +(15, 77, 146); Yellow_process : constant Color := +(255, 239, 0); Yellow_RYB : constant Color := +(254, 254, 51); Yellow_green : constant Color := +(154, 205, 50); end openGL.Palette;
{ "source": "starcoderdata", "programming_language": "ada" }
with GNAT.String_Split; with UxAS.Comms.Data.Addressed; use UxAS.Comms.Data.Addressed; package body UxAS.Comms.Data is -------------------- -- Set_Attributes -- -------------------- procedure Set_Attributes (This : in out Message_Attributes; Content_Type : String; Descriptor : String; Source_Group : String; Source_Entity_Id : String; Source_Service_Id : String; Result : out Boolean) is begin Result := False; This.Is_Valid := False; if Content_Type'Length = 0 then return; end if; if Descriptor'Length = 0 then return; end if; if Source_Entity_Id'Length = 0 then return; end if; if Source_Service_Id'Length = 0 then return; end if; Copy (Content_Type, To => This.Content_Type); Copy (Descriptor, To => This.Descriptor); Copy (Source_Group, To => This.Source_Group); Copy (Source_Entity_Id, To => This.Source_Entity_Id); Copy (Source_Service_Id, To => This.Source_Service_Id); Copy (This.Content_Type & Addressed.Field_Delimiter & This.Descriptor & Addressed.Field_Delimiter & This.Source_Group & Addressed.Field_Delimiter & This.Source_Entity_Id & Addressed.Field_Delimiter & This.Source_Service_Id, To => This.Content_String); This.Is_Valid := True; -- already determined by preconditions... Result := True; end Set_Attributes; ------------------------------ -- Update_Source_Attributes -- ------------------------------ procedure Update_Source_Attributes (This : in out Message_Attributes; Source_Group : String; Source_Entity_Id : String; Source_Service_Id : String; Result : out Boolean) is begin Copy (Source_Group, To => This.Source_Group); Copy (Source_Entity_Id, To => This.Source_Entity_Id); Copy (Source_Service_Id, To => This.Source_Service_Id); Copy (This.Content_Type & Addressed.Field_Delimiter & This.Descriptor & Addressed.Field_Delimiter & This.Source_Group & Addressed.Field_Delimiter & This.Source_Entity_Id & Addressed.Field_Delimiter & This.Source_Service_Id & Addressed.Field_Delimiter, To => This.Content_String); This.Is_Valid := True; -- already determined by preconditions... Result := True; end Update_Source_Attributes; ------------------------------------------ -- Set_Attributes_From_Delimited_String -- ------------------------------------------ procedure Set_Attributes_From_Delimited_String (This : in out Message_Attributes; Delimited_String : String; Result : out Boolean) is begin Parse_Message_Attributes_String_And_Set_Fields (This, Delimited_String, Result); end Set_Attributes_From_Delimited_String; -------------- -- Is_Valid -- -------------- function Is_Valid (This : Message_Attributes) return Boolean is (This.Is_Valid); -------------------------- -- Payload_Content_Type -- -------------------------- function Payload_Content_Type (This : Message_Attributes) return String is (Value (This.Content_Type)); ------------------------ -- Payload_Descriptor -- ------------------------ function Payload_Descriptor (This : Message_Attributes) return String is (Value (This.Descriptor)); ------------------ -- Source_Group -- ------------------ function Source_Group (This : Message_Attributes) return String is (Value (This.Source_Group)); ---------------------- -- Source_Entity_Id -- ---------------------- function Source_Entity_Id (This : Message_Attributes) return String is (Value (This.Source_Entity_Id)); ----------------------- -- Source_Service_Id -- ----------------------- function Source_Service_Id (This : Message_Attributes) return String is (Value (This.Source_Service_Id)); -------------------- -- Content_String -- -------------------- function Content_String (This : Message_Attributes) return String is (Value (This.Content_String)); ---------------------------------------------------- -- Parse_Message_Attributes_String_And_Set_Fields -- ---------------------------------------------------- procedure Parse_Message_Attributes_String_And_Set_Fields (This : in out Message_Attributes; Delimited_String : String; Result : out Boolean) is use GNAT.String_Split; Tokens : Slice_Set; begin Create (Tokens, From => Delimited_String, Separators => Field_Delimiter, Mode => Single); -- contiguous delimiters are NOT treated as a single delimiter if Slice_Count (Tokens) = Attribute_Count then This.Set_Attributes (Content_Type => Slice (Tokens, 1), Descriptor => Slice (Tokens, 2), Source_Group => Slice (Tokens, 3), Source_Entity_Id => Slice (Tokens, 4), Source_Service_Id => Slice (Tokens, 5), Result => Result); else Result := False; This.Is_Valid := False; end if; end Parse_Message_Attributes_String_And_Set_Fields; end UxAS.Comms.Data;
{ "source": "starcoderdata", "programming_language": "ada" }
----------------------------------------------------------------------- with Gen.Model.List; package Gen.Model.Operations is type Operation_Type is (UNKNOWN, ASF_ACTION, ASF_UPLOAD, AWA_EVENT); -- ------------------------------ -- Parameter Definition -- ------------------------------ type Parameter_Definition is new Definition with private; type Parameter_Definition_Access is access all Parameter_Definition'Class; -- ------------------------------ -- Operation Definition -- ------------------------------ type Operation_Definition is new Definition with private; type Operation_Definition_Access is access all Operation_Definition'Class; -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. overriding function Get_Value (From : in Operation_Definition; Name : in String) return UBO.Object; -- Prepare the generation of the model. overriding procedure Prepare (O : in out Operation_Definition); -- Initialize the operation definition instance. overriding procedure Initialize (O : in out Operation_Definition); -- Add an operation parameter with the given name and type. procedure Add_Parameter (Into : in out Operation_Definition; Name : in UString; Of_Type : in UString; Parameter : out Parameter_Definition_Access); -- Get the operation type. function Get_Type (From : in Operation_Definition) return Operation_Type; -- Create an operation with the given name. function Create_Operation (Name : in UString) return Operation_Definition_Access; private type Parameter_Definition is new Definition with record -- The parameter type name. Type_Name : UString; end record; package Parameter_List is new Gen.Model.List (T => Parameter_Definition, T_Access => Parameter_Definition_Access); type Operation_Definition is new Definition with record Parameters : aliased Parameter_List.List_Definition; Parameters_Bean : UBO.Object; Return_Type : UString; Kind : Operation_Type := UNKNOWN; end record; end Gen.Model.Operations;
{ "source": "starcoderdata", "programming_language": "ada" }
with Ada.Text_IO; use Ada.Text_IO; generic N, H : in Natural; package Data is type Vector is array(Integer range <>) of Integer; Subtype VectorN is Vector(1..N); Subtype Vector4H is Vector(1..4 * H); Subtype Vector3H is Vector(1..3 * H); Subtype Vector2H is Vector(1..2 * H); Subtype VectorH is Vector(1..H); type Matrix is array(Integer range <>) of VectorN; Subtype MatrixN is Matrix(1..N); Subtype Matrix4H is Matrix(1..4 * H); Subtype Matrix3H is Matrix(1..3 * H); Subtype Matrix2H is Matrix(1..2 * H); Subtype MatrixH is Matrix(1..H); procedure Input ( V : out Vector; Value : in Integer); procedure Input ( MA : out Matrix; Value : in Integer); procedure Output (V : in VectorN); procedure Output (MA : in Matrix); procedure FindMinZ (V : in VectorH; minZi : out Integer); function Min (A, B: Integer) return Integer; function Calculation (X : in VectorN; MA : in MatrixN; MS : in MatrixH; q : in Integer; R : in VectorN; MF: in MatrixH) return VectorH; end Data;
{ "source": "starcoderdata", "programming_language": "ada" }
with AdaBase.Connection.Base.SQLite; with AdaBase.Bindings.SQLite; with Ada.Containers.Vectors; package AdaBase.Statement.Base.SQLite is package ACS renames AdaBase.Connection.Base.SQLite; package BND renames AdaBase.Bindings.SQLite; package AC renames Ada.Containers; type SQLite_statement (type_of_statement : Stmt_Type; log_handler : ALF.LogFacility_access; sqlite_conn : ACS.SQLite_Connection_Access; initial_sql : SQL_Access; con_error_mode : Error_Modes; con_case_mode : Case_Modes; con_max_blob : BLOB_Maximum) is new Base_Statement and AIS.iStatement with private; type SQLite_statement_access is access all SQLite_statement; overriding function column_count (Stmt : SQLite_statement) return Natural; overriding function last_insert_id (Stmt : SQLite_statement) return Trax_ID; overriding function last_sql_state (Stmt : SQLite_statement) return SQL_State; overriding function last_driver_code (Stmt : SQLite_statement) return Driver_Codes; overriding function last_driver_message (Stmt : SQLite_statement) return String; overriding procedure discard_rest (Stmt : out SQLite_statement); overriding function execute (Stmt : out SQLite_statement) return Boolean; overriding function execute (Stmt : out SQLite_statement; parameters : String; delimiter : Character := '|') return Boolean; overriding function rows_returned (Stmt : SQLite_statement) return Affected_Rows; overriding function column_name (Stmt : SQLite_statement; index : Positive) return String; overriding function column_table (Stmt : SQLite_statement; index : Positive) return String; overriding function column_native_type (Stmt : SQLite_statement; index : Positive) return field_types; overriding function fetch_next (Stmt : out SQLite_statement) return ARS.Datarow; overriding function fetch_all (Stmt : out SQLite_statement) return ARS.Datarow_Set; overriding function fetch_bound (Stmt : out SQLite_statement) return Boolean; overriding procedure fetch_next_set (Stmt : out SQLite_statement; data_present : out Boolean; data_fetched : out Boolean); private type column_info is record table : CT.Text; field_name : CT.Text; field_type : field_types; null_possible : Boolean; sqlite_type : BND.enum_field_types; end record; type sqlite_canvas is record buffer_binary : BND.ICS.char_array_access := null; buffer_text : BND.ICS.chars_ptr := BND.ICS.Null_Ptr; end record; type step_result_type is (unset, data_pulled, progam_complete, error_seen); package VColumns is new AC.Vectors (Index_Type => Positive, Element_Type => column_info); package VCanvas is new AC.Vectors (Index_Type => Positive, Element_Type => sqlite_canvas); type SQLite_statement (type_of_statement : Stmt_Type; log_handler : ALF.LogFacility_access; sqlite_conn : ACS.SQLite_Connection_Access; initial_sql : SQL_Access; con_error_mode : Error_Modes; con_case_mode : Case_Modes; con_max_blob : BLOB_Maximum) is new Base_Statement and AIS.iStatement with record stmt_handle : aliased BND.sqlite3_stmt_Access := null; step_result : step_result_type := unset; assign_counter : Natural := 0; num_columns : Natural := 0; column_info : VColumns.Vector; bind_canvas : VCanvas.Vector; sql_final : SQL_Access; end record; procedure log_problem (statement : SQLite_statement; category : Log_Category; message : String; pull_codes : Boolean := False; break : Boolean := False); procedure initialize (Object : in out SQLite_statement); procedure Adjust (Object : in out SQLite_statement); procedure finalize (Object : in out SQLite_statement); procedure scan_column_information (Stmt : out SQLite_statement); procedure reclaim_canvas (Stmt : out SQLite_statement); function seems_like_bit_string (candidate : CT.Text) return Boolean; function private_execute (Stmt : out SQLite_statement) return Boolean; function construct_bind_slot (Stmt : SQLite_statement; marker : Positive) return sqlite_canvas; procedure free_binary is new Ada.Unchecked_Deallocation (BND.IC.char_array, BND.ICS.char_array_access); end AdaBase.Statement.Base.SQLite;
{ "source": "starcoderdata", "programming_language": "ada" }
-- file COPYING.LIB. If not, write to the Free Software Foundation, 675 -- -- Mass Ave, Cambridge, MA 02139, USA. -- -- -- ----------------------------------------------------------------------------- package Interfaces.C.System_Constants is pthread_t_size : constant Integer := 1; pthread_attr_t_size : constant Integer := 13; pthread_mutexattr_t_size : constant Integer := 3; pthread_mutex_t_size : constant Integer := 8; pthread_condattr_t_size : constant Integer := 1; pthread_cond_t_size : constant Integer := 5; pthread_key_t_size : constant Integer := 1; jmp_buf_size : constant Integer := 12; sigjmp_buf_size : constant Integer := 19; sigset_t_size : constant Integer := 4; SIG_BLOCK : constant := 1; SIG_UNBLOCK : constant := 2; SIG_SETMASK : constant := 3; SA_NOCLDSTOP : constant := 131072; SA_SIGINFO : constant := 8; SIG_ERR : constant := -1; SIG_DFL : constant := 0; SIG_IGN : constant := 1; SIGNULL : constant := 0; SIGHUP : constant := 1; SIGINT : constant := 2; SIGQUIT : constant := 3; SIGILL : constant := 4; SIGABRT : constant := 6; SIGFPE : constant := 8; SIGKILL : constant := 9; SIGSEGV : constant := 11; SIGPIPE : constant := 13; SIGALRM : constant := 14; SIGTERM : constant := 15; SIGSTOP : constant := 23; SIGTSTP : constant := 24; SIGCONT : constant := 25; SIGCHLD : constant := 18; SIGTTIN : constant := 26; SIGTTOU : constant := 27; SIGUSR1 : constant := 16; SIGUSR2 : constant := 17; NSIG : constant := 44; -- OS specific signals represented as an array type Sig_Array is array (positive range <>) of integer; OS_Specific_Sync_Sigs : Sig_Array := (NSIG, 5, 7, 10); OS_Specific_Async_Sigs : Sig_Array := (NSIG, 12, 21, 22, 30, 31, 28, 29, 20); -- End of OS specific signals representation EPERM : constant := 1; ENOENT : constant := 2; ESRCH : constant := 3; EINTR : constant := 4; EIO : constant := 5; ENXIO : constant := 6; E2BIG : constant := 7; ENOEXEC : constant := 8; EBADF : constant := 9; ECHILD : constant := 10; EAGAIN : constant := 11; ENOMEM : constant := 12; EACCES : constant := 13; EFAULT : constant := 14; ENOTBLK : constant := 15; EBUSY : constant := 16; EEXIST : constant := 17; EXDEV : constant := 18; ENODEV : constant := 19; ENOTDIR : constant := 20; EISDIR : constant := 21; EINVAL : constant := 22; ENFILE : constant := 23; EMFILE : constant := 24; ENOTTY : constant := 25; ETXTBSY : constant := 26; EFBIG : constant := 27; ENOSPC : constant := 28; ESPIPE : constant := 29; EROFS : constant := 30; EMLINK : constant := 31; EPIPE : constant := 32; ENAMETOOLONG : constant := 78; ENOTEMPTY : constant := 93; EDEADLK : constant := 45; ENOLCK : constant := 46; ENOSYS : constant := 89; ENOTSUP : constant := 48; NO_PRIO_INHERIT : constant := 0; PRIO_INHERIT : constant := 1; PRIO_PROTECT : constant := 2; Add_Prio : constant Integer := 2; end Interfaces.C.System_Constants;
{ "source": "starcoderdata", "programming_language": "ada" }
package Pck is type Rec_Type (C : Character := 'd') is record case C is when Character'First => X_First : Integer; when Character'Val (127) => X_127 : Integer; when Character'Val (128) => X_128 : Integer; when Character'Last => X_Last : Integer; when others => null; end case; end record; type Second_Type (I : Integer) is record One: Integer; case I is when -5 .. 5 => X : Integer; when others => Y : Integer; end case; end record; type Nested_And_Variable (One, Two: Integer) is record Str : String (1 .. One); case One is when 0 => null; when others => OneValue : Integer; Str2 : String (1 .. Two); case Two is when 0 => null; when others => TwoValue : Integer; end case; end case; end record; end Pck;
{ "source": "starcoderdata", "programming_language": "ada" }
----------------------------------------------------------------------- with Ada.Finalization; with Util.Strings.Sets; private with GNAT.Sockets; package UPnP.SSDP is type Scanner_Type is limited new Ada.Finalization.Limited_Controlled with private; -- Find the IPv4 addresses of the network interfaces. procedure Find_IPv4_Addresses (Scanner : in out Scanner_Type; IPs : out Util.Strings.Sets.Set); -- Initialize the SSDP scanner by opening the UDP socket. procedure Initialize (Scanner : in out Scanner_Type); -- Send the SSDP discovery UDP packet on the UPnP multicast group 192.168.127.12. -- Set the "ST" header to the given target. The UDP packet is sent on each interface -- whose IP address is defined in the set <tt>IPs</tt>. procedure Send_Discovery (Scanner : in out Scanner_Type; Target : in String; IPs : in Util.Strings.Sets.Set); -- Receive the UPnP SSDP discovery messages for the given target. -- Call the <tt>Process</tt> procedure for each of them. The <tt>Desc</tt> parameter -- represents the UPnP location header which gives the UPnP XML root descriptor. -- Wait at most the given time. procedure Discover (Scanner : in out Scanner_Type; Target : in String; Process : not null access procedure (Desc : in String); Wait : in Duration); -- Release the socket. overriding procedure Finalize (Scanner : in out Scanner_Type); private type Scanner_Type is limited new Ada.Finalization.Limited_Controlled with record Socket : GNAT.Sockets.Socket_Type := GNAT.Sockets.No_Socket; end record; end UPnP.SSDP;
{ "source": "starcoderdata", "programming_language": "ada" }
-- { dg-do run } -- { dg-options "-fstack-check" } -- This test requires architecture- and OS-specific support code for unwinding -- through signal frames (typically located in *-unwind.h) to pass. Feel free -- to disable it if this code hasn't been implemented yet. procedure Stack_Check2 is function UB return Integer is begin return 2048; end; type A is Array (Positive range <>) of Integer; procedure Consume_Stack (N : Integer) is My_A : A (1..UB); -- 8 KB dynamic begin My_A (1) := 0; if N <= 0 then return; end if; Consume_Stack (N-1); end; Task T; Task body T is begin begin Consume_Stack (Integer'Last); raise Program_Error; exception when Storage_Error => null; end; Consume_Stack (128); end; begin null; end;
{ "source": "starcoderdata", "programming_language": "ada" }
-- (c). Permission is hereby freely given for any and all use of program -- and data. You can sell it as your own, but at least tell me. -- -- This version is distributed without obligation, but the developer -- would appreciate comments and suggestions. -- -- All parts of the WORDS system, source code and data files, are made freely -- available to anyone who wishes to use them, for whatever purpose. with Text_IO; with Latin_Utils.Strings_Package; use Latin_Utils.Strings_Package; -- with Latin_Utils.Latin_File_Names; use Latin_Utils.Latin_File_Names; with Latin_Utils.Inflections_Package; use Latin_Utils.Inflections_Package; with Latin_Utils.Dictionary_Package; use Latin_Utils.Dictionary_Package; -- with line_stuff; use line_stuff; -- with dictionary_form; procedure Uniqpage is -- package Integer_IO is new Text_IO.Integer_IO (Integer); use Text_IO; use Dictionary_Entry_IO; use Part_Entry_IO; use Kind_Entry_IO; use Translation_Record_IO; use Age_Type_IO; use Area_Type_IO; use Geo_Type_IO; use Frequency_Type_IO; use Source_Type_IO; Uniques_File, Uniqpage : Text_IO.File_Type; S : constant String (1 .. 400) := (others => ' '); Line : String (1 .. 400) := (others => ' '); Blanks : constant String (1 .. 400) := (others => ' '); L, Last : Integer := 0; Stem : Stem_Type := Null_Stem_Type; Qual : Quality_Record; Kind : Kind_Entry; Tran : Translation_Record; Mean : Meaning_Type; procedure Get_Line_Unique (Input : in Text_IO.File_Type; S : out String; Last : out Natural) is begin Last := 0; Text_IO.Get_Line (Input, S, Last); -- FIXME: this if statement was commented out, because it triggered -- warning "if statement has no effect". I didn't delete it because quite -- possibly author wanted it to do something. Question is what? --if Trim (s (s'First .. last)) /= "" then -- Rejecting blank lines -- null; --end if; end Get_Line_Unique; begin Put_Line ("UNIQUES.LAT -> UNIQPAGE.PG"); Put_Line ("Takes UNIQUES form, single lines it, puts # at beginning,"); Put_Line ("producing a .PG file for sorting to produce paper dictionary"); Create (Uniqpage, Out_File, "UNIQPAGE.PG"); Open (Uniques_File, In_File, "UNIQUES.LAT"); Over_Lines : while not End_Of_File (Uniques_File) loop Line := Blanks; Get_Line_Unique (Uniques_File, Line, Last); -- STEM Stem := Head (Trim (Line (1 .. Last)), Max_Stem_Size); Line := Blanks; Get_Line_Unique (Uniques_File, Line, Last); -- QUAL, KIND, TRAN Quality_Record_IO.Get (Line (1 .. Last), Qual, L); Get (Line (L + 1 .. Last), Qual.Pofs, Kind, L); Age_Type_IO.Get (Line (L + 1 .. Last), Tran.Age, L); Area_Type_IO.Get (Line (L + 1 .. Last), Tran.Area, L); Geo_Type_IO.Get (Line (L + 1 .. Last), Tran.Geo, L); Frequency_Type_IO.Get (Line (L + 1 .. Last), Tran.Freq, L); Source_Type_IO.Get (Line (L + 1 .. Last), Tran.Source, L); Line := Blanks; Get_Line_Unique (Uniques_File, Line, L); -- MEAN Mean := Head (Trim (Line (1 .. L)), Max_Meaning_Size); -- while not END_OF_FILE (UNIQUES_FILE) loop -- S := BLANK_LINE; -- GET_LINE (INPUT, S, LAST); -- if TRIM (S (1 .. LAST)) /= "" then -- Rejecting blank lines -- -- Text_IO.Put (Uniqpage, "#" & Stem); Quality_Record_IO.Put (Uniqpage, Qual); -- PART := (V, (QUAL.V.CON, KIND.V_KIND)); if (Qual.Pofs = V) and then (Kind.V_Kind in Gen .. Perfdef) then Text_IO.Put (Uniqpage, " " & Verb_Kind_Type'Image (Kind.V_Kind) & " "); end if; Text_IO.Put (Uniqpage, " ["); Age_Type_IO.Put (Uniqpage, Tran.Age); Area_Type_IO.Put (Uniqpage, Tran.Area); Geo_Type_IO.Put (Uniqpage, Tran.Geo); Frequency_Type_IO.Put (Uniqpage, Tran.Freq); Source_Type_IO.Put (Uniqpage, Tran.Source); Text_IO.Put (Uniqpage, "]"); Put (Uniqpage, " :: "); Put_Line (Uniqpage, Mean); --end if; -- Rejecting blank lines end loop Over_Lines; Close (Uniqpage); exception when Text_IO.Data_Error => null; when others => Put_Line (S (1 .. Last)); Close (Uniqpage); end Uniqpage;
{ "source": "starcoderdata", "programming_language": "ada" }
------------------------------------------------------------------------------- package body ZMQ.Pollsets is ------------ -- append -- ------------ procedure Append (This : in out Pollset; Item : Pollitem'Class) is pragma Unreferenced (This, Item); begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "append unimplemented"); raise Program_Error with "Unimplemented procedure append"; end Append; ------------ -- remove -- ------------ procedure Remove (This : in out Pollset; Item : Pollitem'Class) is pragma Unreferenced (This, Item); begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "remove unimplemented"); raise Program_Error with "Unimplemented procedure remove"; end Remove; ---------- -- poll -- ---------- procedure Poll (This : in out Pollset; Timeout : Duration) is pragma Unreferenced (This, Timeout); begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "poll unimplemented"); raise Program_Error with "Unimplemented procedure poll"; end Poll; end ZMQ.Pollsets;
{ "source": "starcoderdata", "programming_language": "ada" }
end if; if not spec.post_parse_usergroup_check_passes then return "The USERGROUP_SPKG definition is required when USERS or GROUPS is set"; end if; if not spec.post_parse_opt_desc_check_passes then return "Check above errors to determine which options have no descriptions"; end if; if not spec.post_parse_option_group_size_passes then return "check above errors to determine which option groups are too small"; end if; return ""; end late_validity_check_error; -------------------------------------------------------------------------------------------- -- determine_target -------------------------------------------------------------------------------------------- function determine_target (spec : PSP.Portspecs; line : String; last_seen : type_category) return spec_target is function active_prefix return String; function extract_option (prefix, line : String) return String; lead_pre : Boolean := False; lead_do : Boolean := False; lead_post : Boolean := False; fetch : constant String := "fetch"; extract : constant String := "extract"; patch : constant String := "patch"; configure : constant String := "configure"; build : constant String := "build"; install : constant String := "install"; stage : constant String := "stage"; test : constant String := "test"; opt_on : constant String := "-ON:"; opt_off : constant String := "-OFF:"; pre_pre : constant String := "pre-"; pre_do : constant String := "do-"; pre_post : constant String := "post-"; function active_prefix return String is begin if lead_pre then return pre_pre; elsif lead_do then return pre_do; else return pre_post; end if; end active_prefix; function extract_option (prefix, line : String) return String is function first_set_successful (substring : String) return Boolean; -- Given: Line terminates in "-ON:" or "-OFF:" last : Natural; first : Natural := 0; function first_set_successful (substring : String) return Boolean is begin if HT.leads (line, substring) then first := line'First + substring'Length; return True; else return False; end if; end first_set_successful; begin if HT.trails (line, opt_on) then last := line'Last - opt_on'Length; else last := line'Last - opt_off'Length; end if; if first_set_successful (prefix & fetch & LAT.Hyphen) or else first_set_successful (prefix & extract & LAT.Hyphen) or else first_set_successful (prefix & patch & LAT.Hyphen) or else first_set_successful (prefix & configure & LAT.Hyphen) or else first_set_successful (prefix & build & LAT.Hyphen) or else first_set_successful (prefix & install & LAT.Hyphen) or else first_set_successful (prefix & stage & LAT.Hyphen) or else first_set_successful (prefix & test & LAT.Hyphen) then return line (first .. last); else return ""; end if; end extract_option; begin if last_seen = cat_target then -- If the line starts with a period or if it has a single tab, then mark it as -- as a target body and leave. We don't need to check more. if line (line'First) = LAT.Full_Stop or else line (line'First) = LAT.HT then return target_body; end if; end if; -- Check if line has format of a target (ends in a colon) if not HT.trails (line, ":") then return not_target; end if; -- From this point forward, we're either a target_title or bad_target lead_pre := HT.leads (line, pre_pre); if not lead_pre then lead_do := HT.leads (line, pre_do); if not lead_do then lead_post := HT.leads (line, pre_post); if not lead_post then return bad_target; end if; end if; end if; declare prefix : constant String := active_prefix; begin -- Handle pre-, do-, post- target overrides if line = prefix & fetch & LAT.Colon or else line = prefix & fetch & LAT.Colon or else line = prefix & extract & LAT.Colon or else line = prefix & patch & LAT.Colon or else line = prefix & configure & LAT.Colon or else line = prefix & build & LAT.Colon or else line = prefix & install & LAT.Colon or else line = prefix & stage & LAT.Colon or else line = prefix & test & LAT.Colon then return target_title; end if; -- Opsys also applies to pre-, do-, and post- for opsys in supported_opsys'Range loop declare lowsys : String := '-' & UTL.lower_opsys (opsys) & LAT.Colon; begin if line = prefix & fetch & lowsys or else line = prefix & extract & lowsys or else line = prefix & patch & lowsys or else line = prefix & configure & lowsys or else line = prefix & build & lowsys or else line = prefix & install & lowsys or else line = prefix & install & lowsys or else line = prefix & test & lowsys then return target_title; end if; end; end loop; -- The only targets left to check are options which end in "-ON:" and "-OFF:". -- If these suffices aren't found, it's a bad target. if not HT.trails (line, opt_on) and then not HT.trails (line, opt_off) then return bad_target; end if; declare option_name : String := extract_option (prefix, line); begin if spec.option_exists (option_name) then return target_title; else return bad_target; end if; end; end; end determine_target; -------------------------------------------------------------------------------------------- -- extract_option_name -------------------------------------------------------------------------------------------- function extract_option_name (spec : PSP.Portspecs; line : String; last_name : HT.Text) return String is -- Already known: first character = "]" and there's "]." present candidate : String := HT.partial_search (fullstr => line, offset => 1, end_marker => "]."); tabs5 : String (1 .. 5) := (others => LAT.HT); begin if candidate = "" and then line'Length > 5 and then line (line'First .. line'First + 4) = tabs5 then return HT.USS (last_name); end if; if spec.option_exists (candidate) then return candidate; else return ""; end if; end extract_option_name; -------------------------------------------------------------------------------------------- -- build_list -------------------------------------------------------------------------------------------- procedure build_list (spec : in out PSP.Portspecs; field : PSP.spec_option; option : String; line : String) is procedure insert_item (data : String); arrow : Natural; word_start : Natural; strvalue : constant String := retrieve_single_option_value (spec, line); -- let any exceptions cascade procedure insert_item (data : String) is begin spec.build_option_helper (field => field, option => option, value => data); end insert_item; use type PSP.spec_option; begin if field = PSP.broken_on or else field = PSP.description then spec.build_option_helper (field => field, option => option, value => strvalue); return; end if; -- Handle single item case if not HT.contains (S => strvalue, fragment => " ") then insert_item (strvalue); return; end if; declare mask : constant String := UTL.mask_quoted_string (strvalue); begin if HT.contains (S => mask, fragment => " ") or else mask (mask'First) = LAT.Space then raise extra_spaces; end if; -- Now we have multiple list items separated by single spaces -- We know the original line has no trailing spaces too, btw. word_start := strvalue'First; arrow := word_start; loop exit when arrow > strvalue'Last; if mask (arrow) = LAT.Space then insert_item (strvalue (word_start .. arrow - 1)); word_start := arrow + 1; end if; arrow := arrow + 1; end loop; end; insert_item (strvalue (word_start .. strvalue'Last)); end build_list; -------------------------------------------------------------------------------------------- -- retrieve_single_option_value -------------------------------------------------------------------------------------------- function retrieve_single_option_value (spec : PSP.Portspecs; line : String) return String is wrkstr : String (1 .. line'Length) := line; equals : Natural := AS.Fixed.Index (wrkstr, LAT.Equals_Sign & LAT.HT); c81624 : Natural := ((equals / 8) + 1) * 8; tabs5 : String (1 .. 5) := (others => LAT.HT); -- f(4) = 8 ( 2 .. 7) -- f(8) = 16; ( 8 .. 15) -- f(18) = 24; (16 .. 23) -- We are looking for an exact number of tabs starting at equals + 2: -- if c81624 = 8, then we need 2 tabs. IF it's 16 then we need 1 tab, -- if it's 24 then there can be no tabs, and if it's higher, that's a problem. begin if equals = 0 then -- Support quintuple-tab line too. if wrkstr'Length > 5 and then wrkstr (wrkstr'First .. wrkstr'First + 4) = tabs5 then equals := wrkstr'First + 3; c81624 := 40; else raise missing_definition with "No quintuple-tab or equals+tab detected."; end if; end if; if c81624 > 40 then raise mistabbed_40; end if; declare rest : constant String := wrkstr (equals + 2 .. wrkstr'Last); contig_tabs : Natural := 0; arrow : Natural := rest'First; begin loop exit when arrow > rest'Last; exit when rest (arrow) /= LAT.HT; contig_tabs := contig_tabs + 1; arrow := arrow + 1; end loop; if ((c81624 = 8) and then (contig_tabs /= 4)) or else ((c81624 = 16) and then (contig_tabs /= 3)) or else ((c81624 = 24) and then (contig_tabs /= 2)) or else ((c81624 = 32) and then (contig_tabs /= 1)) or else ((c81624 = 40) and then (contig_tabs /= 0)) then raise mistabbed_40; end if; return expand_value (spec, rest (rest'First + contig_tabs .. rest'Last)); end; end retrieve_single_option_value; -------------------------------------------------------------------------------------------- -- is_file_capsule -------------------------------------------------------------------------------------------- function is_file_capsule (line : String) return Boolean is -- format: [FILE:XXXX:filename] dummy : Integer; begin if line (line'Last) /= LAT.Right_Square_Bracket then return False; end if; if not HT.leads (line, "[FILE:") then return False; end if; if HT.count_char (line, LAT.Colon) /= 2 then return False; end if; dummy := Integer'Value (HT.partial_search (line, 6, ":")); return True; exception when others => return False; end is_file_capsule; -------------------------------------------------------------------------------------------- -- retrieve_file_size -------------------------------------------------------------------------------------------- function retrieve_file_size (capsule_label : String) return Natural is result : Natural; begin result := Integer'Value (HT.partial_search (capsule_label, 6, ":")); if result > 0 then return result; else return 0; end if; exception when others => return 0; end retrieve_file_size; -------------------------------------------------------------------------------------------- -- retrieve_file_name -------------------------------------------------------------------------------------------- function retrieve_file_name (capsule_label : String) return String is begin return HT.part_2 (HT.partial_search (capsule_label, 6, "]"), ":"); end retrieve_file_name; -------------------------------------------------------------------------------------------- -- tranform_filenames -------------------------------------------------------------------------------------------- function tranform_filename (filename : String; match_opsys : String; match_arch : String) return String is pm : constant String := "pkg-message-"; sys : constant String := "opsys"; arc : constant String := "arch"; files : constant String := "files/"; pmlen : constant Natural := pm'Length; justfile : constant String := HT.part_2 (filename, "/"); begin if justfile'Length < pmlen + 4 or else justfile (justfile'First .. justfile'First + pmlen - 1) /= pm then return ""; end if; return HT.USS (HT.replace_substring (US => HT.replace_substring (HT.SUS (filename), match_opsys, sys), old_string => match_arch, new_string => arc)); end tranform_filename; -------------------------------------------------------------------------------------------- -- valid_conditional_variable -------------------------------------------------------------------------------------------- function valid_conditional_variable (candidate : String) return Boolean is is_namepair : constant Boolean := HT.contains (candidate, "="); part_name : constant String := HT.part_1 (candidate, "="); begin if not is_namepair then return False; end if; declare possible_singlet : String := part_name & LAT.Equals_Sign & LAT.HT & 'x'; this_singlet : spec_singlet := determine_singlet (possible_singlet); begin case this_singlet is when cflags | cppflags | cxxflags | ldflags | plist_sub | config_args | config_env | make_args | make_env | cmake_args | qmake_args => null; when not_singlet => if not (part_name = "VAR1" or else part_name = "VAR2" or else part_name = "VAR3" or else part_name = "VAR4" or else part_name = "MAKEFILE_LINE") then return False; end if; when others => return False; end case; declare payload : String := HT.part_2 (candidate, "="); mask : String := UTL.mask_quoted_string (payload); found_spaces : Boolean := HT.contains (payload, " "); begin if found_spaces then return not HT.contains (mask, " "); else return True; end if; end; end; end valid_conditional_variable; -------------------------------------------------------------------------------------------- -- transform_target_line -------------------------------------------------------------------------------------------- function transform_target_line (spec : PSP.Portspecs; line : String; skip_transform : Boolean) return String is arrow1 : Natural := 0; arrow2 : Natural := 0; back_marker : Natural := 0; canvas : HT.Text := HT.blank; begin if skip_transform or else spec.no_definitions or else line = "" then return line; end if; back_marker := line'First; loop arrow1 := AS.Fixed.Index (Source => line, Pattern => "${", From => back_marker); if arrow1 = 0 then HT.SU.Append (canvas, line (back_marker .. line'Last)); exit; end if; arrow2 := AS.Fixed.Index (Source => line, Pattern => "}", From => arrow1 + 2); if arrow2 = 0 then HT.SU.Append (canvas, line (back_marker .. line'Last)); exit; end if; -- We've found a candidate. Save the leader and attempt to replace. if arrow1 > back_marker then HT.SU.Append (canvas, line (back_marker .. arrow1 - 1)); end if; back_marker := arrow2 + 1; if arrow2 - 1 > arrow1 + 2 then begin declare newval : HT.Text := HT.SUS (expand_value (spec, line (arrow1 .. arrow2))); begin UTL.apply_cbc_string (newval); HT.SU.Append (canvas, newval); end; exception when others => -- It didn't expand, so keep it. HT.SU.Append (canvas, line (arrow1 .. arrow2)); end; else -- This is "${}", just keep it. HT.SU.Append (canvas, line (arrow1 .. arrow2)); end if; exit when back_marker > line'Last; end loop; return HT.USS (canvas); end transform_target_line; -------------------------------------------------------------------------------------------- -- extract_version -------------------------------------------------------------------------------------------- function extract_version (varname : String) return String is consdir : String := HT.USS (Parameters.configuration.dir_conspiracy); extmake : String := HT.USS (Parameters.configuration.dir_sysroot) & "/usr/bin/make -m " & consdir & "/Mk"; command : String := extmake & " -f " & consdir & "/Mk/raven.versions.mk -V " & varname; status : Integer; result : HT.Text := Unix.piped_command (command, status); begin return HT.first_line (HT.USS (result)); end extract_version; -------------------------------------------------------------------------------------------- -- extract_information -------------------------------------------------------------------------------------------- function extract_information (varname : String) return String is consdir : String := HT.USS (Parameters.configuration.dir_conspiracy); extmake : String := HT.USS (Parameters.configuration.dir_sysroot) & "/usr/bin/make -m " & consdir & "/Mk"; command : String := extmake & " -f " & consdir & "/Mk/raven.information.mk -V " & varname; status : Integer; result : HT.Text := Unix.piped_command (command, status); begin return HT.first_line (HT.USS (result)); end extract_information; -------------------------------------------------------------------------------------------- -- verify_extra_file_exists -------------------------------------------------------------------------------------------- procedure verify_extra_file_exists (spec : PSP.Portspecs; specfile : String; line : String; is_option : Boolean; sub_file : Boolean) is function get_payload return String; function get_full_filename (basename : String) return String; procedure perform_check (filename : String); arrow : Natural; word_start : Natural; filesdir : String := DIR.Containing_Directory (specfile) & "/files"; function get_payload return String is begin if is_option then return retrieve_single_option_value (spec, line); else return retrieve_single_value (spec, line); end if; end get_payload; function get_full_filename (basename : String) return String is begin if sub_file then return basename & ".in"; else return basename; end if; end get_full_filename; procedure perform_check (filename : String) is adjusted_filename : String := get_full_filename (filename); begin if not DIR.Exists (filesdir & "/" & adjusted_filename) then raise missing_file with "'" & adjusted_filename & "' is missing from files directory"; end if; end perform_check; strvalue : String := get_payload; begin -- Handle single item case if not HT.contains (S => strvalue, fragment => " ") then perform_check (strvalue); return; end if; declare mask : constant String := UTL.mask_quoted_string (strvalue); begin if HT.contains (S => mask, fragment => " ") or else mask (mask'First) = LAT.Space then raise extra_spaces; end if; -- Now we have multiple list items separated by single spaces -- We know the original line has no trailing spaces too, btw. word_start := strvalue'First; arrow := word_start; loop exit when arrow > strvalue'Last; if mask (arrow) = LAT.Space then perform_check (strvalue (word_start .. arrow - 1)); word_start := arrow + 1; end if; arrow := arrow + 1; end loop; end; perform_check (strvalue (word_start .. strvalue'Last)); end verify_extra_file_exists; -------------------------------------------------------------------------------------------- -- transform_download_sites -------------------------------------------------------------------------------------------- procedure transform_download_sites (site : in out HT.Text) is begin -- special case, GITHUB_PRIVATE (aka GHPRIV). -- If found, append with site with ":<token>" where <token> is the contents of -- confdir/tokens/account-project (or ":missing-security-token" if not found) -- With this case, there is always 4 colons / 5 fields. The 4th (extraction directory) -- is often blank if HT.leads (site, "GITHUB_PRIVATE/") or else HT.leads (site, "GHPRIV/") then declare notoken : constant String := ":missing-security-token"; triplet : constant String := HT.part_2 (HT.USS (site), "/"); ncolons : constant Natural := HT.count_char (triplet, ':'); begin if ncolons < 3 then HT.SU.Append (site, ':'); end if; if ncolons >= 2 then declare account : constant String := HT.specific_field (triplet, 1, ":"); project : constant String := HT.specific_field (triplet, 2, ":"); tfile : constant String := Parameters.raven_confdir & "/tokens/" & account & '-' & project; token : constant String := FOP.get_file_contents (tfile); begin HT.SU.Append (site, ':' & token); end; end if; exception when others => HT.SU.Append (site, notoken); end; end if; end transform_download_sites; end Specification_Parser;
{ "source": "starcoderdata", "programming_language": "ada" }
--* -- OBJECTIVE: -- CHECK THAT FLOAT I/O GET CAN READ A VALUE FROM A STRING. -- CHECK THAT END_ERROR IS RAISED WHEN CALLED WITH A NULL STRING -- OR A STRING CONTAINING SPACES AND/OR HORIZONTAL TABULATION -- CHARACTERS. CHECK THAT LAST CONTAINS THE INDEX OF THE LAST -- CHARACTER READ FROM THE STRING. -- HISTORY: -- SPS 10/07/82 -- SPS 12/14/82 -- JBG 12/21/82 -- DWC 09/15/87 ADDED CASE TO INCLUDE ONLY TABS IN STRING AND -- CHECKED THAT END_ERROR IS RAISED. WITH REPORT; USE REPORT; WITH TEXT_IO; USE TEXT_IO; PROCEDURE CE3809A IS BEGIN TEST ("CE3809A", "CHECK THAT FLOAT_IO GET " & "OPERATES CORRECTLY ON STRINGS"); DECLARE TYPE FL IS DIGITS 4; PACKAGE FLIO IS NEW FLOAT_IO (FL); USE FLIO; X : FL; STR : STRING (1..10) := " 10.25 "; L : POSITIVE; BEGIN -- LEFT-JUSTIFIED IN STRING, POSITIVE, NO EXPONENT BEGIN GET ("896.5 ", X, L); IF X /= 896.5 THEN FAILED ("FLOAT VALUE FROM STRING INCORRECT"); END IF; EXCEPTION WHEN DATA_ERROR => FAILED ("DATA_ERROR RAISED - FLOAT - 1"); WHEN OTHERS => FAILED ("UNEXPECTED EXCEPTION RAISED - FLOAT - 1"); END; IF L /= IDENT_INT (5) THEN FAILED ("VALUE OF LAST INCORRECT - FLOAT - 1. LAST IS" & INTEGER'IMAGE(L)); END IF; -- STRING LITERAL WITH BLANKS BEGIN GET (" ", X, L); FAILED ("END_ERROR NOT RAISED - FLOAT - 2"); EXCEPTION WHEN END_ERROR => IF L /= 5 THEN FAILED ("AFTER END_ERROR, VALUE OF LAST " & "INCORRECT - 2. LAST IS" & INTEGER'IMAGE(L)); END IF; WHEN DATA_ERROR => FAILED ("DATA_ERROR RAISED - FLOAT - 2"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - FLOAT - 2"); END; -- NULL STRING LITERAL BEGIN GET ("", X, L); FAILED ("END_ERROR NOT RAISED - FLOAT - 3"); EXCEPTION WHEN END_ERROR => IF L /= 5 THEN FAILED ("AFTER END_ERROR, VALUE OF LAST " & "INCORRECT - 3. LAST IS" & INTEGER'IMAGE(L)); END IF; WHEN DATA_ERROR => FAILED ("DATA_ERROR RAISED - FLOAT - 3"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - FLOAT - 3"); END; -- NULL SLICE BEGIN GET (STR(5..IDENT_INT(2)), X, L); FAILED ("END_ERROR NOT RAISED - FLOAT - 4"); EXCEPTION WHEN END_ERROR => IF L /= 5 THEN FAILED ("AFTER END_ERROR, VALUE OF LAST " & "INCORRECT - 4. LAST IS" & INTEGER'IMAGE(L)); END IF; WHEN DATA_ERROR => FAILED ("DATA_ERROR RAISED - FLOAT - 4"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - FLOAT - 4"); END; -- SLICE WITH BLANKS BEGIN GET (STR(IDENT_INT(9)..10), X, L); FAILED ("END_ERROR NOT RAISED - FLOAT - 5"); EXCEPTION WHEN END_ERROR => IF L /= IDENT_INT(5) THEN FAILED ("AFTER END_ERROR, VALUE OF LAST " & "INCORRECT - 5. LAST IS" & INTEGER'IMAGE(L)); END IF; WHEN DATA_ERROR => FAILED ("DATA_ERROR RAISED - FLOAT - 5"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - FLOAT - 5"); END; -- NON-NULL SLICE BEGIN GET (STR(2..IDENT_INT(8)), X, L); IF X /= 10.25 THEN FAILED ("FLOAT VALUE INCORRECT - 6"); END IF; IF L /= 8 THEN FAILED ("LAST INCORRECT FOR SLICE - 6. LAST IS" & INTEGER'IMAGE(L)); END IF; EXCEPTION WHEN OTHERS => FAILED ("EXCEPTION RAISED - 6"); END; -- LEFT-JUSTIFIED, POSITIVE EXPONENT BEGIN GET ("1.34E+02", X, L); IF X /= 134.0 THEN FAILED ("FLOAT WITH EXP FROM STRING INCORRECT - 7"); END IF; IF L /= 8 THEN FAILED ("VALUE OF LAST INCORRECT - FLOAT - 7. " & "LAST IS" & INTEGER'IMAGE(L)); END IF; EXCEPTION WHEN DATA_ERROR => FAILED ("DATA_EROR RAISED - FLOAT - 7"); WHEN OTHERS => FAILED ("UNEXPECTED EXCEPTION RAISED - FLOAT - 7"); END; -- RIGHT-JUSTIFIED, NEGATIVE EXPONENT BEGIN GET (" 25.0E-2", X, L); IF X /= 0.25 THEN FAILED ("NEG EXPONENT INCORRECT - 8"); END IF; IF L /= 8 THEN FAILED ("LAST INCORRECT - 8. LAST IS" & INTEGER'IMAGE(L)); END IF; EXCEPTION WHEN OTHERS => FAILED ("EXCEPTION RAISED - 8"); END; -- RIGHT-JUSTIFIED, NEGATIVE GET (" -1.50", X, L); IF X /= -1.5 THEN FAILED ("FLOAT IN RIGHT JUSTIFIED STRING INCORRECT - 9"); END IF; IF L /= 7 THEN FAILED ("LAST INCORRECT - 9. LAST IS" & INTEGER'IMAGE(L)); END IF; -- HORIZONTAL TAB WITH BLANKS BEGIN GET (" " & ASCII.HT & "2.3E+2", X, L); IF X /= 230.0 THEN FAILED ("FLOAT WITH TAB IN STRING INCORRECT - 10"); END IF; IF L /= 8 THEN FAILED ("LAST INCORRECT FOR TAB - 10. LAST IS" & INTEGER'IMAGE(L)); END IF; EXCEPTION WHEN DATA_ERROR => FAILED ("DATA_ERROR FOR STRING WITH TAB - 10"); WHEN OTHERS => FAILED ("SOME EXCEPTION RAISED FOR STRING WITH " & "TAB - 10"); END; -- HORIZONTAL TABS ONLY BEGIN GET (ASCII.HT & ASCII.HT, X, L); FAILED ("END_ERROR NOT RAISED - FLOAT - 11"); EXCEPTION WHEN END_ERROR => IF L /= IDENT_INT(8) THEN FAILED ("AFTER END_ERROR, VALUE OF LAST " & "INCORRECT - 11. LAST IS" & INTEGER'IMAGE(L)); END IF; WHEN DATA_ERROR => FAILED ("DATA_ERROR RAISED - FLOAT - 11"); WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - FLOAT - 11"); END; END; RESULT; END CE3809A;
{ "source": "starcoderdata", "programming_language": "ada" }
with NXP.Device; use NXP.Device; with System; use System; with NXP_SVD; use NXP_SVD; with NXP_SVD.GPIO; use NXP_SVD.GPIO; with NXP_SVD.IOCON; use NXP_SVD.IOCON; with NXP_SVD.INPUTMUX; use NXP_SVD.INPUTMUX; with NXP_SVD.PINT; use NXP_SVD.PINT; package body NXP.GPIO is IOCON : aliased IOCON_Peripheral with Import, Address => S_NS_Periph (IOCON_Base); ------------- -- Any_Set -- ------------- function Any_Set (Pins : GPIO_Points) return Boolean is begin for Pin of Pins loop if Pin.Set then return True; end if; end loop; return False; end Any_Set; ---------- -- Mode -- ---------- overriding function Mode (This : GPIO_Point) return HAL.GPIO.GPIO_Mode is Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin); begin return HAL.GPIO.Output; end Mode; -------------- -- Set_Mode -- -------------- overriding function Set_Mode (This : in out GPIO_Point; Mode : HAL.GPIO.GPIO_Config_Mode) return Boolean is Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin); begin return True; end Set_Mode; ------------------- -- Pull_Resistor -- ------------------- overriding function Pull_Resistor (This : GPIO_Point) return HAL.GPIO.GPIO_Pull_Resistor is Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin); begin return HAL.GPIO.Floating; end Pull_Resistor; ----------------------- -- Set_Pull_Resistor -- ----------------------- overriding function Set_Pull_Resistor (This : in out GPIO_Point; Pull : HAL.GPIO.GPIO_Pull_Resistor) return Boolean is Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin); begin return True; end Set_Pull_Resistor; --------- -- Set -- --------- overriding function Set (This : GPIO_Point) return Boolean is Port_Idx : Integer := This.Port'Enum_Rep; Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin); begin return This.Periph.B (Port_Idx).B (Index).PBYTE; end Set; ------------- -- All_Set -- ------------- function All_Set (Pins : GPIO_Points) return Boolean is begin for Pin of Pins loop if not Pin.Set then return False; end if; end loop; return True; end All_Set; --------- -- Set -- --------- overriding procedure Set (This : in out GPIO_Point) is Port_Idx : Integer := This.Port'Enum_Rep; Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin); begin This.Periph.B (Port_Idx).B (Index).PBYTE := True; end Set; --------- -- Set -- --------- procedure Set (Pins : in out GPIO_Points) is begin for Pin of Pins loop Pin.Set; end loop; end Set; ----------- -- Clear -- ----------- overriding procedure Clear (This : in out GPIO_Point) is Port_Idx : Integer := This.Port'Enum_Rep; Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin); begin This.Periph.B (Port_Idx).B (Index).PBYTE := False; end Clear; ----------- -- Clear -- ----------- procedure Clear (Pins : in out GPIO_Points) is begin for Pin of Pins loop Pin.Clear; end loop; end Clear; ------------ -- Toggle -- ------------ overriding procedure Toggle (This : in out GPIO_Point) is Port_Idx : Integer := This.Port'Enum_Rep; Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin); Mask : UInt32 := 2 ** Index; begin This.Periph.NOT_k (Port_Idx) := Mask; end Toggle; ------------ -- Toggle -- ------------ procedure Toggle (Points : in out GPIO_Points) is begin for Point of Points loop Point.Toggle; end loop; end Toggle; ------------------ -- Configure_IO -- ------------------ procedure Configure_IO (This : GPIO_Point; Config : GPIO_Port_Configuration) is Port_Idx : Integer := This.Port'Enum_Rep; Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin); Mask : UInt32 := 2 ** Index; begin case Config.Mode is when Mode_Out => This.Periph.DIR (Port_Idx) := This.Periph.DIR (Port_Idx) or Mask; IOCON.P (Port_Idx).PIO (Index).CTL.SLEW := CTL_SLEW_Field'Enum_Val (Config.Speed'Enum_Rep); IOCON.P (Port_Idx).PIO (Index).CTL.OD := CTL_OD_Field'Enum_Val (Config.Output_Type'Enum_Rep); when Mode_In => This.Periph.DIR (Port_Idx) := This.Periph.DIR (Port_Idx) and not Mask; IOCON.P (Port_Idx).PIO (Index).CTL.MODE := CTL_MODE_Field'Enum_Val (Config.Resistors'Enum_Rep); IOCON.P (Port_Idx).PIO (Index).CTL.DIGIMODE := Digital; IOCON.P (Port_Idx).PIO (Index).CTL.INVERT := (if Config.Invert then Enabled else Disabled); when Mode_AF => IOCON.P (Port_Idx).PIO (Index).CTL.MODE := CTL_MODE_Field'Enum_Val (Config.Resistors'Enum_Rep); IOCON.P (Port_Idx).PIO (Index).CTL.DIGIMODE := Digital; IOCON.P (Port_Idx).PIO (Index).CTL.INVERT := (if Config.Invert then Enabled else Disabled); when others => null; end case; end Configure_IO; ------------------ -- Configure_IO -- ------------------ procedure Configure_IO (Points : GPIO_Points; Config : GPIO_Port_Configuration) is begin for Point of Points loop Point.Configure_IO (Config); end loop; end Configure_IO; ---------------------------------- -- Configure_Alternate_Function -- ---------------------------------- procedure Configure_Alternate_Function (This : GPIO_Point; AF : GPIO_Alternate_Function) is Port_Idx : Integer := This.Port'Enum_Rep; Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin); begin IOCON.P (Port_Idx).PIO (Index).CTL.FUNC := UInt4 (AF); end Configure_Alternate_Function; ---------------------------------- -- Configure_Alternate_Function -- ---------------------------------- procedure Configure_Alternate_Function (Points : GPIO_Points; AF : GPIO_Alternate_Function) is begin for Point of Points loop Point.Configure_Alternate_Function (AF); end loop; end Configure_Alternate_Function; procedure Enable_GPIO_Interrupt (Pin : GPIO_Point; Config : Pint_Configuration) is Port_Idx : Integer := Pin.Port'Enum_Rep; Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (Pin.Pin); INPUTMUX : aliased INPUTMUX_Peripheral with Import, Address => S_NS_Periph (INPUTMUX_Base); PINT : aliased PINT_Peripheral with Import, Address => S_NS_Periph (PINT_Base); Slot : Integer := Config.Slot'Enum_Rep; Mask : UInt8 := (2 ** Slot); begin INPUTMUX.PINTSEL (Slot'Enum_Rep).INTPIN := UInt7 ((Port_Idx * 32) + Index); if Config.Mode = Pint_Edge then PINT.ISEL.PMODE := PINT.ISEL.PMODE and not Mask; if Config.Edge = Pint_Rising then PINT.SIENR.SETENRL := Mask; else PINT.SIENF.SETENAF := Mask; end if; else -- handle level PINT.ISEL.PMODE := PINT.ISEL.PMODE or Mask; if Config.Level = Pint_High then PINT.SIENR.SETENRL := Mask; else PINT.SIENF.SETENAF := Mask; end if; end if; end Enable_GPIO_Interrupt; end NXP.GPIO;
{ "source": "starcoderdata", "programming_language": "ada" }